diff --git a/src/AiFactory.cpp b/src/AiFactory.cpp index 3ecfb10d..87251a64 100644 --- a/src/AiFactory.cpp +++ b/src/AiFactory.cpp @@ -1,28 +1,30 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AiFactory.h" + #include "BattlegroundMgr.h" +#include "DKAiObjectContext.h" +#include "DruidAiObjectContext.h" +#include "Engine.h" +#include "Group.h" +#include "HunterAiObjectContext.h" #include "Item.h" +#include "MageAiObjectContext.h" +#include "PaladinAiObjectContext.h" #include "PlayerbotAI.h" #include "PlayerbotAIConfig.h" #include "Playerbots.h" -#include "Engine.h" -#include "Group.h" -#include "DKAiObjectContext.h" #include "PriestAiObjectContext.h" -#include "MageAiObjectContext.h" +#include "RogueAiObjectContext.h" +#include "ShamanAiObjectContext.h" #include "SharedDefines.h" #include "SpellInfo.h" #include "SpellMgr.h" #include "WarlockAiObjectContext.h" #include "WarriorAiObjectContext.h" -#include "ShamanAiObjectContext.h" -#include "PaladinAiObjectContext.h" -#include "DruidAiObjectContext.h" -#include "HunterAiObjectContext.h" -#include "RogueAiObjectContext.h" AiObjectContext* AiFactory::createAiObjectContext(Player* player, PlayerbotAI* botAI) { @@ -100,11 +102,12 @@ std::map AiFactory::GetPlayerSpecTabs(Player* bot) for (PlayerTalentMap::const_iterator i = talentMap.begin(); i != talentMap.end(); ++i) { uint32 spellId = i->first; - if ((bot->GetActiveSpecMask() & i->second->specMask) == 0) { + if ((bot->GetActiveSpecMask() & i->second->specMask) == 0) + { continue; } TalentSpellPos const* talentPos = GetTalentSpellPos(spellId); - if(!talentPos) + if (!talentPos) continue; TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentPos->talent_id); if (!talentInfo) @@ -186,7 +189,8 @@ std::string AiFactory::GetPlayerSpecName(Player* player) specName = "holy"; else specName = "disc"; - ; break; + ; + break; case CLASS_SHAMAN: if (tab == 2) specName = "resto"; @@ -274,7 +278,7 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa { engine->addStrategies("racials", "chat", "default", "cast time", "duel", "boost", "emote", nullptr); } - if (sPlayerbotAIConfig->autoSaveMana) + if (sPlayerbotAIConfig->autoSaveMana) { engine->addStrategy("auto save mana"); } @@ -286,11 +290,16 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa switch (player->getClass()) { case CLASS_PRIEST: - if (tab == 2) { + if (tab == 2) + { engine->addStrategies("dps", "shadow debuff", "shadow aoe", nullptr); - } else if (tab == PRIEST_TAB_DISIPLINE) { + } + else if (tab == PRIEST_TAB_DISIPLINE) + { engine->addStrategies("heal", nullptr); - } else { + } + else + { engine->addStrategies("holy heal", nullptr); } @@ -310,13 +319,13 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa if (tab == 2) engine->addStrategies("tank", "tank assist", "aoe", "mark rti", nullptr); else if (player->GetLevel() < 36 || tab == 0) - engine->addStrategies("arms", "aoe", "dps assist",/*"behind",*/ nullptr); + engine->addStrategies("arms", "aoe", "dps assist", /*"behind",*/ nullptr); else - engine->addStrategies("fury", "aoe", "dps assist",/*"behind",*/ nullptr); + engine->addStrategies("fury", "aoe", "dps assist", /*"behind",*/ nullptr); break; case CLASS_SHAMAN: if (tab == 0) - engine->addStrategies("caster", "caster aoe", "bmana",nullptr); + engine->addStrategies("caster", "caster aoe", "bmana", nullptr); else if (tab == 2) engine->addStrategies("heal", "bmana", nullptr); else @@ -343,9 +352,12 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa engine->addStrategies("heal", "cure", "dps assist", nullptr); else { - if (player->GetLevel() >= 20 && !player->HasAura(16931)/*thick hide*/) { + if (player->GetLevel() >= 20 && !player->HasAura(16931) /*thick hide*/) + { engine->addStrategies("cat", "dps assist", nullptr); - } else { + } + else + { engine->addStrategies("bear", "tank assist", nullptr); } } @@ -355,9 +367,12 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa engine->addStrategy("dps debuff"); break; case CLASS_ROGUE: - if (tab == ROGUE_TAB_ASSASSINATION) { + if (tab == ROGUE_TAB_ASSASSINATION) + { engine->addStrategies("melee", "dps assist", "aoe", /*"behind",*/ nullptr); - } else { + } + else + { engine->addStrategies("dps", "dps assist", "aoe", /*"behind",*/ nullptr); } break; @@ -384,28 +399,37 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa engine->addStrategy("dps assist"); engine->removeStrategy("threat"); // engine- - switch (player->getClass()) { - case CLASS_PRIEST: { - if (tab != PRIEST_TAB_SHADOW) { + switch (player->getClass()) + { + case CLASS_PRIEST: + { + if (tab != PRIEST_TAB_SHADOW) + { engine->addStrategies("holy dps", "shadow debuff", "shadow aoe", nullptr); } break; } - case CLASS_DRUID: { - if (tab == DRUID_TAB_RESTORATION) { + case CLASS_DRUID: + { + if (tab == DRUID_TAB_RESTORATION) + { engine->addStrategies("caster", "caster aoe", nullptr); engine->addStrategy("caster debuff"); } break; } - case CLASS_SHAMAN: { - if (tab == SHAMAN_TAB_RESTORATION) { + case CLASS_SHAMAN: + { + if (tab == SHAMAN_TAB_RESTORATION) + { engine->addStrategies("caster", "caster aoe", "bmana", nullptr); } break; } - case CLASS_PALADIN: { - if (tab == PALADIN_TAB_HOLY) { + case CLASS_PALADIN: + { + if (tab == PALADIN_TAB_HOLY) + { engine->addStrategies("dps", "dps assist", "baoe", nullptr); } break; @@ -447,7 +471,8 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa engine->addStrategy("arena"); } - engine->addStrategies("boost", "racials", "chat", "default", "aoe", "potions", "cast time", "dps assist", nullptr); + engine->addStrategies("boost", "racials", "chat", "default", "aoe", "potions", "cast time", "dps assist", + nullptr); engine->removeStrategy("custom::say"); engine->removeStrategy("flee"); engine->removeStrategy("threat"); @@ -466,7 +491,7 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa Engine* AiFactory::createCombatEngine(Player* player, PlayerbotAI* const facade, AiObjectContext* aiObjectContext) { - Engine* engine = new Engine(facade, aiObjectContext); + Engine* engine = new Engine(facade, aiObjectContext); AddDefaultCombatStrategies(player, facade, engine); return engine; } @@ -481,18 +506,22 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const nonCombatEngine->addStrategies("dps assist", "cure", nullptr); break; case CLASS_PALADIN: - if (tab == 1) { + if (tab == 1) + { nonCombatEngine->addStrategies("bthreat", "tank assist", "barmor", nullptr); - if (player->GetLevel() >= 20) { + if (player->GetLevel() >= 20) + { nonCombatEngine->addStrategy("bstats"); - } else { + } + else + { nonCombatEngine->addStrategy("bdps"); } } else if (tab == 0) nonCombatEngine->addStrategies("dps assist", "bmana", "bcast", nullptr); else - nonCombatEngine->addStrategies("dps assist", "bdps", "baoe",nullptr); + nonCombatEngine->addStrategies("dps assist", "bdps", "baoe", nullptr); nonCombatEngine->addStrategies("cure", nullptr); break; @@ -516,10 +545,14 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const nonCombatEngine->addStrategies("dps assist", "cure", nullptr); break; case CLASS_DRUID: - if (tab == 1) { - if (player->GetLevel() >= 20 && !player->HasAura(16931)/*thick hide*/) { + if (tab == 1) + { + if (player->GetLevel() >= 20 && !player->HasAura(16931) /*thick hide*/) + { nonCombatEngine->addStrategy("dps assist"); - } else { + } + else + { nonCombatEngine->addStrategy("tank assist"); } } @@ -533,11 +566,16 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const nonCombatEngine->addStrategy("dps assist"); break; case CLASS_WARLOCK: - if (tab == WARLOCK_TAB_AFFLICATION) { + if (tab == WARLOCK_TAB_AFFLICATION) + { nonCombatEngine->addStrategies("bmana", nullptr); - } else if (tab == WARLOCK_TAB_DEMONOLOGY) { + } + else if (tab == WARLOCK_TAB_DEMONOLOGY) + { nonCombatEngine->addStrategies("bdps", nullptr); - } else if (tab == WARLOCK_TAB_DESTRUCTION) { + } + else if (tab == WARLOCK_TAB_DESTRUCTION) + { nonCombatEngine->addStrategies("bhealth", nullptr); } nonCombatEngine->addStrategies("dps assist", nullptr); @@ -555,17 +593,18 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const if (!player->InBattleground()) { - nonCombatEngine->addStrategies("nc", "food", "chat", "follow", - "default", "quest", "loot", "gather", "duel", "buff", "mount", "emote", nullptr); + nonCombatEngine->addStrategies("nc", "food", "chat", "follow", "default", "quest", "loot", "gather", "duel", + "buff", "mount", "emote", nullptr); } - if (sPlayerbotAIConfig->autoSaveMana) { + if (sPlayerbotAIConfig->autoSaveMana) + { nonCombatEngine->addStrategy("auto save mana"); } if ((sRandomPlayerbotMgr->IsRandomBot(player)) && !player->InBattleground()) { Player* master = facade->GetMaster(); - // let 25% of free bots start duels. + // let 25% of free bots start duels. if (!urand(0, 3)) nonCombatEngine->addStrategy("start duel"); @@ -588,7 +627,9 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const { // nonCombatEngine->addStrategy("travel"); nonCombatEngine->addStrategy("rpg"); - } else { + } + else + { nonCombatEngine->addStrategy("move random"); } @@ -627,7 +668,8 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig->randomBotNonCombatStrategies); } - else { + else + { nonCombatEngine->addStrategy("pvp"); nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig->nonCombatStrategies); } @@ -644,7 +686,8 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const // Battleground switch if (player->InBattleground() && player->GetBattleground()) { - nonCombatEngine->addStrategies("nc", "chat", "default", "buff", "food", "mount", "pvp", "dps assist", "attack tagged", "emote", nullptr); + nonCombatEngine->addStrategies("nc", "chat", "default", "buff", "food", "mount", "pvp", "dps assist", + "attack tagged", "emote", nullptr); nonCombatEngine->removeStrategy("custom::say"); nonCombatEngine->removeStrategy("travel"); nonCombatEngine->removeStrategy("rpg"); @@ -654,7 +697,8 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const if (bgType == BATTLEGROUND_RB) bgType = player->GetBattleground()->GetBgTypeID(true); - if ((bgType <= BATTLEGROUND_EY || bgType == BATTLEGROUND_IC) && !player->InArena()) // do not add for not supported bg or arena + if ((bgType <= BATTLEGROUND_EY || bgType == BATTLEGROUND_IC) && + !player->InArena()) // do not add for not supported bg or arena nonCombatEngine->addStrategy("battleground"); if (bgType == BATTLEGROUND_WS) @@ -682,15 +726,15 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const Engine* AiFactory::createNonCombatEngine(Player* player, PlayerbotAI* const facade, AiObjectContext* aiObjectContext) { - Engine* nonCombatEngine = new Engine(facade, aiObjectContext); + Engine* nonCombatEngine = new Engine(facade, aiObjectContext); AddDefaultNonCombatStrategies(player, facade, nonCombatEngine); - return nonCombatEngine; + return nonCombatEngine; } void AiFactory::AddDefaultDeadStrategies(Player* player, PlayerbotAI* const facade, Engine* deadEngine) { - (void)facade; // unused and remove warning + (void)facade; // unused and remove warning deadEngine->addStrategies("dead", "stay", "chat", "default", "follow", nullptr); if (sRandomPlayerbotMgr->IsRandomBot(player) && !player->GetGroup()) diff --git a/src/AiFactory.h b/src/AiFactory.h index 37a2004e..2c3fafe5 100644 --- a/src/AiFactory.h +++ b/src/AiFactory.h @@ -1,14 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_AIFACTORY_H #define _PLAYERBOT_AIFACTORY_H -#include "Common.h" - #include +#include "Common.h" + class AiObjectContext; class Engine; class Player; @@ -18,19 +19,19 @@ enum BotRoles : uint8; class AiFactory { - public: - static AiObjectContext* createAiObjectContext(Player* player, PlayerbotAI* botAI); - static Engine* createCombatEngine(Player* player, PlayerbotAI* const facade, AiObjectContext* aiObjectContext); - static Engine* createNonCombatEngine(Player* player, PlayerbotAI* const facade, AiObjectContext* aiObjectContext); - static Engine* createDeadEngine(Player* player, PlayerbotAI* const facade, AiObjectContext* aibjectContext); - static void AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const facade, Engine* nonCombatEngine); - static void AddDefaultDeadStrategies(Player* player, PlayerbotAI* const facade, Engine* deadEngine); - static void AddDefaultCombatStrategies(Player* player, PlayerbotAI* const facade, Engine* engine); +public: + static AiObjectContext* createAiObjectContext(Player* player, PlayerbotAI* botAI); + static Engine* createCombatEngine(Player* player, PlayerbotAI* const facade, AiObjectContext* aiObjectContext); + static Engine* createNonCombatEngine(Player* player, PlayerbotAI* const facade, AiObjectContext* aiObjectContext); + static Engine* createDeadEngine(Player* player, PlayerbotAI* const facade, AiObjectContext* aibjectContext); + static void AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const facade, Engine* nonCombatEngine); + static void AddDefaultDeadStrategies(Player* player, PlayerbotAI* const facade, Engine* deadEngine); + static void AddDefaultCombatStrategies(Player* player, PlayerbotAI* const facade, Engine* engine); - static uint8 GetPlayerSpecTab(Player* player); - static std::map GetPlayerSpecTabs(Player* player); - static BotRoles GetPlayerRoles(Player* player); - static std::string GetPlayerSpecName(Player* player); + static uint8 GetPlayerSpecTab(Player* player); + static std::map GetPlayerSpecTabs(Player* player); + static BotRoles GetPlayerRoles(Player* player); + static std::string GetPlayerSpecName(Player* player); }; #endif diff --git a/src/ChatFilter.cpp b/src/ChatFilter.cpp index 18f6ce84..0cc6720b 100644 --- a/src/ChatFilter.cpp +++ b/src/ChatFilter.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ChatFilter.h" + #include "Group.h" #include "Playerbots.h" #include "RtiTargetValue.h" @@ -17,252 +19,252 @@ std::string const ChatFilter::Filter(std::string& message) class StrategyChatFilter : public ChatFilter { - public: - StrategyChatFilter(PlayerbotAI* botAI) : ChatFilter(botAI) { } +public: + StrategyChatFilter(PlayerbotAI* botAI) : ChatFilter(botAI) {} - std::string const Filter(std::string& message) override - { - Player* bot = botAI->GetBot(); + std::string const Filter(std::string& message) override + { + Player* bot = botAI->GetBot(); - bool tank = message.find("@tank") == 0; - if (tank && !botAI->IsTank(bot)) - return ""; + bool tank = message.find("@tank") == 0; + if (tank && !botAI->IsTank(bot)) + return ""; - bool dps = message.find("@dps") == 0; - if (dps && (botAI->IsTank(bot) || botAI->IsHeal(bot))) - return ""; + bool dps = message.find("@dps") == 0; + if (dps && (botAI->IsTank(bot) || botAI->IsHeal(bot))) + return ""; - bool heal = message.find("@heal") == 0; - if (heal && !botAI->IsHeal(bot)) - return ""; + bool heal = message.find("@heal") == 0; + if (heal && !botAI->IsHeal(bot)) + return ""; - bool ranged = message.find("@ranged") == 0; - if (ranged && !botAI->IsRanged(bot)) - return ""; + bool ranged = message.find("@ranged") == 0; + if (ranged && !botAI->IsRanged(bot)) + return ""; - bool melee = message.find("@melee") == 0; - if (melee && botAI->IsRanged(bot)) - return ""; + bool melee = message.find("@melee") == 0; + if (melee && botAI->IsRanged(bot)) + return ""; - if (tank || dps || heal || ranged || melee) - return ChatFilter::Filter(message); + if (tank || dps || heal || ranged || melee) + return ChatFilter::Filter(message); - return message; - } + return message; + } }; class LevelChatFilter : public ChatFilter { - public: - LevelChatFilter(PlayerbotAI* botAI) : ChatFilter(botAI) { } +public: + LevelChatFilter(PlayerbotAI* botAI) : ChatFilter(botAI) {} - std::string const Filter(std::string& message) override + std::string const Filter(std::string& message) override + { + Player* bot = botAI->GetBot(); + + if (message[0] != '@') + return message; + + if (message.find("-") != std::string::npos) { - Player* bot = botAI->GetBot(); + uint32 fromLevel = atoi(message.substr(message.find("@") + 1, message.find("-")).c_str()); + uint32 toLevel = atoi(message.substr(message.find("-") + 1, message.find(" ")).c_str()); - if (message[0] != '@') - return message; - - if (message.find("-") != std::string::npos) - { - uint32 fromLevel = atoi(message.substr(message.find("@") + 1, message.find("-")).c_str()); - uint32 toLevel = atoi(message.substr(message.find("-") + 1, message.find(" ")).c_str()); - - if (bot->GetLevel() >= fromLevel && bot->GetLevel() <= toLevel) - return ChatFilter::Filter(message); - - return message; - } - - uint32 level = atoi(message.substr(message.find("@") + 1, message.find(" ")).c_str()); - if (bot->GetLevel() == level) + if (bot->GetLevel() >= fromLevel && bot->GetLevel() <= toLevel) return ChatFilter::Filter(message); return message; } + + uint32 level = atoi(message.substr(message.find("@") + 1, message.find(" ")).c_str()); + if (bot->GetLevel() == level) + return ChatFilter::Filter(message); + + return message; + } }; class CombatTypeChatFilter : public ChatFilter { - public: - CombatTypeChatFilter(PlayerbotAI* botAI) : ChatFilter(botAI) { } +public: + CombatTypeChatFilter(PlayerbotAI* botAI) : ChatFilter(botAI) {} - std::string const Filter(std::string& message) override + std::string const Filter(std::string& message) override + { + Player* bot = botAI->GetBot(); + + bool melee = message.find("@melee") == 0; + bool ranged = message.find("@ranged") == 0; + + if (!melee && !ranged) + return message; + + switch (bot->getClass()) { - Player* bot = botAI->GetBot(); - - bool melee = message.find("@melee") == 0; - bool ranged = message.find("@ranged") == 0; - - if (!melee && !ranged) - return message; - - switch (bot->getClass()) - { - case CLASS_WARRIOR: - case CLASS_PALADIN: - case CLASS_ROGUE: - case CLASS_DEATH_KNIGHT: - if (ranged) - return ""; - break; - case CLASS_HUNTER: - case CLASS_PRIEST: - case CLASS_MAGE: - case CLASS_WARLOCK: - if (melee) - return ""; - break; - case CLASS_DRUID: - if (ranged && botAI->IsTank(bot)) - return ""; - if (melee && !botAI->IsTank(bot)) - return ""; - break; - case CLASS_SHAMAN: - if (melee && botAI->IsHeal(bot)) - return ""; - if (ranged && !botAI->IsHeal(bot)) - return ""; - break; - } - - return ChatFilter::Filter(message); + case CLASS_WARRIOR: + case CLASS_PALADIN: + case CLASS_ROGUE: + case CLASS_DEATH_KNIGHT: + if (ranged) + return ""; + break; + case CLASS_HUNTER: + case CLASS_PRIEST: + case CLASS_MAGE: + case CLASS_WARLOCK: + if (melee) + return ""; + break; + case CLASS_DRUID: + if (ranged && botAI->IsTank(bot)) + return ""; + if (melee && !botAI->IsTank(bot)) + return ""; + break; + case CLASS_SHAMAN: + if (melee && botAI->IsHeal(bot)) + return ""; + if (ranged && !botAI->IsHeal(bot)) + return ""; + break; } + + return ChatFilter::Filter(message); + } }; class RtiChatFilter : public ChatFilter { - public: - RtiChatFilter(PlayerbotAI* botAI) : ChatFilter(botAI) +public: + RtiChatFilter(PlayerbotAI* botAI) : ChatFilter(botAI) + { + rtis.push_back("@star"); + rtis.push_back("@circle"); + rtis.push_back("@diamond"); + rtis.push_back("@triangle"); + rtis.push_back("@moon"); + rtis.push_back("@square"); + rtis.push_back("@cross"); + rtis.push_back("@skull"); + } + + std::string const Filter(std::string& message) override + { + Player* bot = botAI->GetBot(); + Group* group = bot->GetGroup(); + if (!group) + return message; + + bool found = false; + bool isRti = false; + for (std::vector::iterator i = rtis.begin(); i != rtis.end(); i++) { - rtis.push_back("@star"); - rtis.push_back("@circle"); - rtis.push_back("@diamond"); - rtis.push_back("@triangle"); - rtis.push_back("@moon"); - rtis.push_back("@square"); - rtis.push_back("@cross"); - rtis.push_back("@skull"); - } + std::string const rti = *i; - std::string const Filter(std::string& message) override - { - Player* bot = botAI->GetBot(); - Group* group = bot->GetGroup(); - if (!group) - return message; + bool isRti = message.find(rti) == 0; + if (!isRti) + continue; - bool found = false; - bool isRti = false; - for (std::vector::iterator i = rtis.begin(); i != rtis.end(); i++) - { - std::string const rti = *i; - - bool isRti = message.find(rti) == 0; - if (!isRti) - continue; - - ObjectGuid rtiTarget = group->GetTargetIcon(RtiTargetValue::GetRtiIndex(rti.substr(1))); - if (bot->GetGUID() == rtiTarget) - return ChatFilter::Filter(message); - - Unit* target = *botAI->GetAiObjectContext()->GetValue("current target"); - if (!target) - return ""; - - if (target->GetGUID() != rtiTarget) - return ""; - - found |= isRti; - if (found) - break; - } - - if (found) + ObjectGuid rtiTarget = group->GetTargetIcon(RtiTargetValue::GetRtiIndex(rti.substr(1))); + if (bot->GetGUID() == rtiTarget) return ChatFilter::Filter(message); - return message; + Unit* target = *botAI->GetAiObjectContext()->GetValue("current target"); + if (!target) + return ""; + + if (target->GetGUID() != rtiTarget) + return ""; + + found |= isRti; + if (found) + break; } - private: - std::vector rtis; + if (found) + return ChatFilter::Filter(message); + + return message; + } + +private: + std::vector rtis; }; class ClassChatFilter : public ChatFilter { - public: - ClassChatFilter(PlayerbotAI* botAI) : ChatFilter(botAI) +public: + ClassChatFilter(PlayerbotAI* botAI) : ChatFilter(botAI) + { + classNames["@death_knight"] = CLASS_DEATH_KNIGHT; + classNames["@druid"] = CLASS_DRUID; + classNames["@hunter"] = CLASS_HUNTER; + classNames["@mage"] = CLASS_MAGE; + classNames["@paladin"] = CLASS_PALADIN; + classNames["@priest"] = CLASS_PRIEST; + classNames["@rogue"] = CLASS_ROGUE; + classNames["@shaman"] = CLASS_SHAMAN; + classNames["@warlock"] = CLASS_WARLOCK; + classNames["@warrior"] = CLASS_WARRIOR; + } + + std::string const Filter(std::string& message) override + { + Player* bot = botAI->GetBot(); + + bool found = false; + bool isClass = false; + for (std::map::iterator i = classNames.begin(); i != classNames.end(); i++) { - classNames["@death_knight"] = CLASS_DEATH_KNIGHT; - classNames["@druid"] = CLASS_DRUID; - classNames["@hunter"] = CLASS_HUNTER; - classNames["@mage"] = CLASS_MAGE; - classNames["@paladin"] = CLASS_PALADIN; - classNames["@priest"] = CLASS_PRIEST; - classNames["@rogue"] = CLASS_ROGUE; - classNames["@shaman"] = CLASS_SHAMAN; - classNames["@warlock"] = CLASS_WARLOCK; - classNames["@warrior"] = CLASS_WARRIOR; - } - - std::string const Filter(std::string& message) override - { - Player* bot = botAI->GetBot(); - - bool found = false; - bool isClass = false; - for (std::map::iterator i = classNames.begin(); i != classNames.end(); i++) - { - bool isClass = message.find(i->first) == 0; - if (isClass && bot->getClass() != i->second) - return ""; - - found |= isClass; - if (found) - break; - } + bool isClass = message.find(i->first) == 0; + if (isClass && bot->getClass() != i->second) + return ""; + found |= isClass; if (found) - return ChatFilter::Filter(message); - - return message; + break; } - private: - std::map classNames; + if (found) + return ChatFilter::Filter(message); + + return message; + } + +private: + std::map classNames; }; class SubGroupChatFilter : public ChatFilter { - public: - SubGroupChatFilter(PlayerbotAI* botAI) : ChatFilter(botAI) { } +public: + SubGroupChatFilter(PlayerbotAI* botAI) : ChatFilter(botAI) {} - std::string const Filter(std::string& message) override + std::string const Filter(std::string& message) override + { + Player* bot = botAI->GetBot(); + + if (message.find("@group") == 0) { - Player* bot = botAI->GetBot(); - - if (message.find("@group") == 0) + std::string const pnum = message.substr(6, message.find(" ")); + uint32 from = atoi(pnum.c_str()); + uint32 to = from; + if (pnum.find("-") != std::string::npos) { - std::string const pnum = message.substr(6, message.find(" ")); - uint32 from = atoi(pnum.c_str()); - uint32 to = from; - if (pnum.find("-") != std::string::npos) - { - from = atoi(pnum.substr(pnum.find("@") + 1, pnum.find("-")).c_str()); - to = atoi(pnum.substr(pnum.find("-") + 1, pnum.find(" ")).c_str()); - } - - if (!bot->GetGroup()) - return message; - - uint32 sg = bot->GetSubGroup() + 1; - if (sg >= from && sg <= to) - return ChatFilter::Filter(message); + from = atoi(pnum.substr(pnum.find("@") + 1, pnum.find("-")).c_str()); + to = atoi(pnum.substr(pnum.find("-") + 1, pnum.find(" ")).c_str()); } - return message; + if (!bot->GetGroup()) + return message; + + uint32 sg = bot->GetSubGroup() + 1; + if (sg >= from && sg <= to) + return ChatFilter::Filter(message); } + + return message; + } }; CompositeChatFilter::CompositeChatFilter(PlayerbotAI* botAI) : ChatFilter(botAI) @@ -295,4 +297,3 @@ std::string const CompositeChatFilter::Filter(std::string& message) return message; } - diff --git a/src/ChatFilter.h b/src/ChatFilter.h index a19aa719..e823cbf5 100644 --- a/src/ChatFilter.h +++ b/src/ChatFilter.h @@ -1,36 +1,37 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHATFILTER_H #define _PLAYERBOT_CHATFILTER_H +#include + #include "Common.h" #include "PlayerbotAIAware.h" -#include - class PlayerbotAI; class ChatFilter : public PlayerbotAIAware { - public: - ChatFilter(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) { } - virtual ~ChatFilter() { } +public: + ChatFilter(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) {} + virtual ~ChatFilter() {} - virtual std::string const Filter(std::string& message); + virtual std::string const Filter(std::string& message); }; class CompositeChatFilter : public ChatFilter { - public: - CompositeChatFilter(PlayerbotAI* botAI); +public: + CompositeChatFilter(PlayerbotAI* botAI); - virtual ~CompositeChatFilter(); - std::string const Filter(std::string& message) override; + virtual ~CompositeChatFilter(); + std::string const Filter(std::string& message) override; - private: - std::vector filters; +private: + std::vector filters; }; #endif diff --git a/src/ChatHelper.cpp b/src/ChatHelper.cpp index 92daa117..6f3339b2 100644 --- a/src/ChatHelper.cpp +++ b/src/ChatHelper.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ChatHelper.h" + #include "AiFactory.h" #include "Playerbots.h" #include "SpellInfo.h" @@ -18,13 +20,13 @@ std::map ChatHelper::classes; std::map ChatHelper::races; std::map > ChatHelper::specs; -template +template static bool substrContainsInMap(std::string const searchTerm, std::map searchIn) { for (typename std::map::iterator i = searchIn.begin(); i != searchIn.end(); ++i) { std::string const term = i->first; - if (term.size() > 1 && searchTerm.find(term) != std::string::npos) + if (term.size() > 1 && searchTerm.find(term) != std::string::npos) return true; } @@ -57,19 +59,19 @@ ChatHelper::ChatHelper(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) projectileSubClasses["arrows"] = ITEM_SUBCLASS_ARROW; projectileSubClasses["bullets"] = ITEM_SUBCLASS_BULLET; - //tradeSubClasses["cloth"] = ITEM_SUBCLASS_CLOTH; - //tradeSubClasses["leather"] = ITEM_SUBCLASS_LEATHER; - //tradeSubClasses["metal"] = ITEM_SUBCLASS_METAL_STONE; - //tradeSubClasses["stone"] = ITEM_SUBCLASS_METAL_STONE; - //tradeSubClasses["ore"] = ITEM_SUBCLASS_METAL_STONE; - //tradeSubClasses["meat"] = ITEM_SUBCLASS_MEAT; - //tradeSubClasses["herb"] = ITEM_SUBCLASS_HERB; - //tradeSubClasses["elemental"] = ITEM_SUBCLASS_ELEMENTAL; - //tradeSubClasses["disenchants"] = ITEM_SUBCLASS_ENCHANTING; - //tradeSubClasses["enchanting"] = ITEM_SUBCLASS_ENCHANTING; - //tradeSubClasses["gems"] = ITEM_SUBCLASS_JEWELCRAFTING; - //tradeSubClasses["jewels"] = ITEM_SUBCLASS_JEWELCRAFTING; - //tradeSubClasses["jewelcrafting"] = ITEM_SUBCLASS_JEWELCRAFTING; + // tradeSubClasses["cloth"] = ITEM_SUBCLASS_CLOTH; + // tradeSubClasses["leather"] = ITEM_SUBCLASS_LEATHER; + // tradeSubClasses["metal"] = ITEM_SUBCLASS_METAL_STONE; + // tradeSubClasses["stone"] = ITEM_SUBCLASS_METAL_STONE; + // tradeSubClasses["ore"] = ITEM_SUBCLASS_METAL_STONE; + // tradeSubClasses["meat"] = ITEM_SUBCLASS_MEAT; + // tradeSubClasses["herb"] = ITEM_SUBCLASS_HERB; + // tradeSubClasses["elemental"] = ITEM_SUBCLASS_ELEMENTAL; + // tradeSubClasses["disenchants"] = ITEM_SUBCLASS_ENCHANTING; + // tradeSubClasses["enchanting"] = ITEM_SUBCLASS_ENCHANTING; + // tradeSubClasses["gems"] = ITEM_SUBCLASS_JEWELCRAFTING; + // tradeSubClasses["jewels"] = ITEM_SUBCLASS_JEWELCRAFTING; + // tradeSubClasses["jewelcrafting"] = ITEM_SUBCLASS_JEWELCRAFTING; slots["head"] = EQUIPMENT_SLOT_HEAD; slots["neck"] = EQUIPMENT_SLOT_NECK; @@ -179,11 +181,11 @@ ChatHelper::ChatHelper(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) std::string const ChatHelper::formatMoney(uint32 copper) { std::ostringstream out; - if (!copper) - { - out << "0"; - return out.str(); - } + if (!copper) + { + out << "0"; + return out.str(); + } uint32 gold = uint32(copper / 10000); copper -= (gold * 10000); @@ -193,7 +195,7 @@ std::string const ChatHelper::formatMoney(uint32 copper) bool space = false; if (gold > 0) { - out << gold << "g"; + out << gold << "g"; space = true; } @@ -202,17 +204,17 @@ std::string const ChatHelper::formatMoney(uint32 copper) if (space) out << " "; - out << silver << "s"; + out << silver << "s"; space = true; } - if (copper > 0 && gold < 10) - { + if (copper > 0 && gold < 10) + { if (space) out << " "; - out << copper << "c"; - } + out << copper << "c"; + } return out.str(); } @@ -281,22 +283,27 @@ ItemIds ChatHelper::parseItems(std::string const text) std::string const ChatHelper::FormatQuest(Quest const* quest) { std::ostringstream out; - out << "|cFFFFFF00|Hquest:" << quest->GetQuestId() << ':' << quest->GetQuestLevel() << "|h[" << quest->GetTitle() << "]|h|r"; + out << "|cFFFFFF00|Hquest:" << quest->GetQuestId() << ':' << quest->GetQuestLevel() << "|h[" << quest->GetTitle() + << "]|h|r"; return out.str(); } std::string const ChatHelper::FormatGameobject(GameObject* go) { std::ostringstream out; - out << "|cFFFFFF00|Hfound:" << go->GetGUID().GetRawValue() << ":" << go->GetEntry() << ":" << "|h[" << go->GetNameForLocaleIdx(LOCALE_enUS) << "]|h|r"; + out << "|cFFFFFF00|Hfound:" << go->GetGUID().GetRawValue() << ":" << go->GetEntry() << ":" + << "|h[" << go->GetNameForLocaleIdx(LOCALE_enUS) << "]|h|r"; return out.str(); } std::string const ChatHelper::FormatWorldobject(WorldObject* wo) { std::ostringstream out; - out << "|cFFFFFF00|Hfound:" << wo->GetGUID().GetRawValue() << ":" << wo->GetEntry() << ":" << "|h["; - out << (wo->ToGameObject() ? ((GameObject*)wo)->GetNameForLocaleIdx(LOCALE_enUS) : wo->GetNameForLocaleIdx(LOCALE_enUS)) << "]|h|r"; + out << "|cFFFFFF00|Hfound:" << wo->GetGUID().GetRawValue() << ":" << wo->GetEntry() << ":" + << "|h["; + out << (wo->ToGameObject() ? ((GameObject*)wo)->GetNameForLocaleIdx(LOCALE_enUS) + : wo->GetNameForLocaleIdx(LOCALE_enUS)) + << "]|h|r"; return out.str(); } @@ -311,7 +318,8 @@ std::string const ChatHelper::FormatWorldEntry(int32 entry) gInfo = sObjectMgr->GetGameObjectTemplate(entry * -1); std::ostringstream out; - out << "|cFFFFFF00|Hentry:" << abs(entry) << ":" << "|h["; + out << "|cFFFFFF00|Hentry:" << abs(entry) << ":" + << "|h["; if (entry < 0 && gInfo) out << gInfo->name; @@ -339,9 +347,8 @@ std::string const ChatHelper::FormatItem(ItemTemplate const* proto, uint32 count // const std::string &name = sObjectMgr->GetItemLocale(proto->ItemId)->Name[LOCALE_enUS]; std::ostringstream out; - out << "|c" << color << "|Hitem:" << proto->ItemId - << ":0:0:0:0:0:0:0" << "|h[" << proto->Name1 - << "]|h|r"; + out << "|c" << color << "|Hitem:" << proto->ItemId << ":0:0:0:0:0:0:0" + << "|h[" << proto->Name1 << "]|h|r"; if (count > 1) out << "x" << count; @@ -392,7 +399,6 @@ std::string const ChatHelper::FormatChat(ChatMsg chat) return "unknown"; } - uint32 ChatHelper::parseSpell(std::string const text) { PlayerbotChatHandler handler(botAI->GetBot()); @@ -410,13 +416,13 @@ GuidVector ChatHelper::parseGameobjects(std::string const text) while (true) { // extract GO guid - auto i = text.find("Hfound:", pos); // base H = 11 - if (i == std::string::npos) // break if error + auto i = text.find("Hfound:", pos); // base H = 11 + if (i == std::string::npos) // break if error break; - pos = i + 7; //start of window in text 11 + 7 = 18 - auto endPos = text.find(':', pos); // end of window in text 22 - if (endPos == std::string::npos) //break if error + pos = i + 7; // start of window in text 11 + 7 = 18 + auto endPos = text.find(':', pos); // end of window in text 22 + if (endPos == std::string::npos) // break if error break; std::istringstream stream(text.substr(pos, endPos - pos)); @@ -426,11 +432,11 @@ GuidVector ChatHelper::parseGameobjects(std::string const text) // extract GO entry pos = endPos + 1; endPos = text.find(':', pos); // end of window in text - if (endPos == std::string::npos) //break if error + if (endPos == std::string::npos) // break if error break; - std::string const entryC = text.substr(pos, endPos - pos); // get std::string const within window i.e entry - uint32 entry = atol(entryC.c_str()); // convert ascii to float + std::string const entryC = text.substr(pos, endPos - pos); // get std::string const within window i.e entry + uint32 entry = atol(entryC.c_str()); // convert ascii to float ObjectGuid lootCurrent = ObjectGuid(guid); @@ -444,8 +450,8 @@ GuidVector ChatHelper::parseGameobjects(std::string const text) std::string const ChatHelper::FormatQuestObjective(std::string const name, uint32 available, uint32 required) { std::ostringstream out; - out << "|cFFFFFFFF" << name << (available >= required ? "|c0000FF00: " : "|c00FF0000: ") - << available << "/" << required << "|r"; + out << "|cFFFFFFFF" << name << (available >= required ? "|c0000FF00: " : "|c00FF0000: ") << available << "/" + << required << "|r"; return out.str(); } @@ -501,9 +507,11 @@ uint32 ChatHelper::parseSlot(std::string const text) bool ChatHelper::parseable(std::string const text) { - return text.find("|H") != std::string::npos || text == "questitem" || text == "ammo" || substrContainsInMap(text, consumableSubClasses) || - substrContainsInMap(text, tradeSubClasses) || substrContainsInMap(text, itemQualities) || substrContainsInMap(text, slots) || - substrContainsInMap(text, chats) || substrContainsInMap(text, skills) || parseMoney(text) > 0; + return text.find("|H") != std::string::npos || text == "questitem" || text == "ammo" || + substrContainsInMap(text, consumableSubClasses) || + substrContainsInMap(text, tradeSubClasses) || substrContainsInMap(text, itemQualities) || + substrContainsInMap(text, slots) || substrContainsInMap(text, chats) || + substrContainsInMap(text, skills) || parseMoney(text) > 0; } std::string const ChatHelper::FormatClass(Player* player, int8 spec) @@ -526,15 +534,9 @@ std::string const ChatHelper::FormatClass(Player* player, int8 spec) return out.str(); } -std::string const ChatHelper::FormatClass(uint8 cls) -{ - return classes[cls]; -} +std::string const ChatHelper::FormatClass(uint8 cls) { return classes[cls]; } -std::string const ChatHelper::FormatRace(uint8 race) -{ - return races[race]; -} +std::string const ChatHelper::FormatRace(uint8 race) { return races[race]; } uint32 ChatHelper::parseSkill(std::string const text) { @@ -555,10 +557,7 @@ std::string const ChatHelper::FormatSkill(uint32 skill) return ""; } -std::string const ChatHelper::FormatBoolean(bool flag) -{ - return flag ? "|cff00ff00ON|r" : "|cffffff00OFF|r"; -} +std::string const ChatHelper::FormatBoolean(bool flag) { return flag ? "|cff00ff00ON|r" : "|cffffff00OFF|r"; } void ChatHelper::eraseAllSubStr(std::string& mainStr, std::string const toErase) { diff --git a/src/ChatHelper.h b/src/ChatHelper.h index 2b88afdd..a23f8460 100644 --- a/src/ChatHelper.h +++ b/src/ChatHelper.h @@ -1,17 +1,18 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHATHELPER_H #define _PLAYERBOT_CHATHELPER_H +#include + #include "Common.h" #include "ObjectGuid.h" #include "PlayerbotAIAware.h" #include "SharedDefines.h" -#include - class GameObject; class Quest; class Player; @@ -26,52 +27,52 @@ typedef std::set SpellIds; class ChatHelper : public PlayerbotAIAware { - public: - ChatHelper(PlayerbotAI* botAI); +public: + ChatHelper(PlayerbotAI* botAI); - static std::string const formatMoney(uint32 copper); - static uint32 parseMoney(std::string const text); - static ItemIds parseItems(std::string const text); - uint32 parseSpell(std::string const text); - static std::string const FormatQuest(Quest const* quest); - static std::string const FormatItem(ItemTemplate const* proto, uint32 count = 0, uint32 total = 0); - static std::string const FormatQItem(uint32 itemId); - static std::string const FormatSpell(SpellInfo const* spellInfo); - static std::string const FormatGameobject(GameObject* go); - static std::string const FormatWorldobject(WorldObject* wo); - static std::string const FormatWorldEntry(int32 entry); - static std::string const FormatQuestObjective(std::string const name, uint32 available, uint32 required); - static GuidVector parseGameobjects(std::string const text); + static std::string const formatMoney(uint32 copper); + static uint32 parseMoney(std::string const text); + static ItemIds parseItems(std::string const text); + uint32 parseSpell(std::string const text); + static std::string const FormatQuest(Quest const* quest); + static std::string const FormatItem(ItemTemplate const* proto, uint32 count = 0, uint32 total = 0); + static std::string const FormatQItem(uint32 itemId); + static std::string const FormatSpell(SpellInfo const* spellInfo); + static std::string const FormatGameobject(GameObject* go); + static std::string const FormatWorldobject(WorldObject* wo); + static std::string const FormatWorldEntry(int32 entry); + static std::string const FormatQuestObjective(std::string const name, uint32 available, uint32 required); + static GuidVector parseGameobjects(std::string const text); - static ChatMsg parseChat(std::string const text); - static std::string const FormatChat(ChatMsg chat); + static ChatMsg parseChat(std::string const text); + static std::string const FormatChat(ChatMsg chat); - static std::string const FormatClass(Player* player, int8 spec); - static std::string const FormatClass(uint8 cls); - static std::string const FormatRace(uint8 race); - static std::string const FormatSkill(uint32 skill); - static std::string const FormatBoolean(bool flag); + static std::string const FormatClass(Player* player, int8 spec); + static std::string const FormatClass(uint8 cls); + static std::string const FormatRace(uint8 race); + static std::string const FormatSkill(uint32 skill); + static std::string const FormatBoolean(bool flag); - static uint32 parseItemQuality(std::string const text); - static bool parseItemClass(std::string const text, uint32* itemClass, uint32* itemSubClass); - static uint32 parseSlot(std::string const text); - uint32 parseSkill(std::string const text); + static uint32 parseItemQuality(std::string const text); + static bool parseItemClass(std::string const text, uint32* itemClass, uint32* itemSubClass); + static uint32 parseSlot(std::string const text); + uint32 parseSkill(std::string const text); - static bool parseable(std::string const text); + static bool parseable(std::string const text); - void eraseAllSubStr(std::string& mainStr, std::string const toErase); + void eraseAllSubStr(std::string& mainStr, std::string const toErase); - private: - static std::map consumableSubClasses; - static std::map tradeSubClasses; - static std::map itemQualities; - static std::map projectileSubClasses; - static std::map slots; - static std::map skills; - static std::map chats; - static std::map classes; - static std::map races; - static std::map> specs; +private: + static std::map consumableSubClasses; + static std::map tradeSubClasses; + static std::map itemQualities; + static std::map projectileSubClasses; + static std::map slots; + static std::map skills; + static std::map chats; + static std::map classes; + static std::map races; + static std::map> specs; }; #endif diff --git a/src/FleeManager.cpp b/src/FleeManager.cpp index 8ca6ac6b..edbfcbaa 100644 --- a/src/FleeManager.cpp +++ b/src/FleeManager.cpp @@ -1,36 +1,44 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "FleeManager.h" + #include "Playerbots.h" #include "ServerFacade.h" -FleeManager::FleeManager(Player* bot, float maxAllowedDistance, float followAngle, bool forceMaxDistance, WorldPosition startPosition) : - bot(bot), maxAllowedDistance(maxAllowedDistance), followAngle(followAngle), forceMaxDistance(forceMaxDistance), startPosition(startPosition ? startPosition : WorldPosition(bot)) +FleeManager::FleeManager(Player* bot, float maxAllowedDistance, float followAngle, bool forceMaxDistance, + WorldPosition startPosition) + : bot(bot), + maxAllowedDistance(maxAllowedDistance), + followAngle(followAngle), + forceMaxDistance(forceMaxDistance), + startPosition(startPosition ? startPosition : WorldPosition(bot)) { } -void FleeManager::calculateDistanceToCreatures(FleePoint *point) +void FleeManager::calculateDistanceToCreatures(FleePoint* point) { point->minDistance = -1.0f; point->sumDistance = 0.0f; PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - if (!botAI) { + if (!botAI) + { return; } - GuidVector units = *botAI->GetAiObjectContext()->GetValue("possible targets no los"); - for (GuidVector::iterator i = units.begin(); i != units.end(); ++i) + GuidVector units = *botAI->GetAiObjectContext()->GetValue("possible targets no los"); + for (GuidVector::iterator i = units.begin(); i != units.end(); ++i) { - Unit* unit = botAI->GetUnit(*i); - if (!unit) - continue; + Unit* unit = botAI->GetUnit(*i); + if (!unit) + continue; - float d = sServerFacade->GetDistance2d(unit, point->x, point->y); - point->sumDistance += d; - if (point->minDistance < 0 || point->minDistance > d) + float d = sServerFacade->GetDistance2d(unit, point->x, point->y); + point->sumDistance += d; + if (point->minDistance < 0 || point->minDistance > d) point->minDistance = d; - } + } } bool intersectsOri(float angle, std::vector& angles, float angleIncrement) @@ -45,20 +53,21 @@ bool intersectsOri(float angle, std::vector& angles, float angleIncrement return false; } -void FleeManager::calculatePossibleDestinations(std::vector &points) +void FleeManager::calculatePossibleDestinations(std::vector& points) { PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - if (!botAI) { + if (!botAI) + { return; } Unit* target = *botAI->GetAiObjectContext()->GetValue("current target"); - float botPosX = startPosition.getX(); + float botPosX = startPosition.getX(); float botPosY = startPosition.getY(); float botPosZ = startPosition.getZ(); - FleePoint start(botAI, botPosX, botPosY, botPosZ); - calculateDistanceToCreatures(&start); + FleePoint start(botAI, botPosX, botPosY, botPosZ); + calculateDistanceToCreatures(&start); std::vector enemyOri; GuidVector units = *botAI->GetAiObjectContext()->GetValue("possible targets no los"); @@ -72,19 +81,24 @@ void FleeManager::calculatePossibleDestinations(std::vector &points) enemyOri.push_back(ori); } - float distIncrement = std::max(sPlayerbotAIConfig->followDistance, (maxAllowedDistance - sPlayerbotAIConfig->tooCloseDistance) / 10.0f); - for (float dist = maxAllowedDistance; dist >= sPlayerbotAIConfig->tooCloseDistance ; dist -= distIncrement) + float distIncrement = std::max(sPlayerbotAIConfig->followDistance, + (maxAllowedDistance - sPlayerbotAIConfig->tooCloseDistance) / 10.0f); + for (float dist = maxAllowedDistance; dist >= sPlayerbotAIConfig->tooCloseDistance; dist -= distIncrement) { float angleIncrement = std::max(M_PI / 20, M_PI / 4 / (1.0 + dist - sPlayerbotAIConfig->tooCloseDistance)); for (float add = 0.0f; add < M_PI / 4 + angleIncrement; add += angleIncrement) { - for (float angle = add; angle < add + 2 * static_cast(M_PI) + angleIncrement; angle += static_cast(M_PI) / 4) + for (float angle = add; angle < add + 2 * static_cast(M_PI) + angleIncrement; + angle += static_cast(M_PI) / 4) { if (intersectsOri(angle, enemyOri, angleIncrement)) continue; - float x = botPosX + cos(angle) * maxAllowedDistance, y = botPosY + sin(angle) * maxAllowedDistance, z = botPosZ + CONTACT_DISTANCE; - if (forceMaxDistance && sServerFacade->IsDistanceLessThan(sServerFacade->GetDistance2d(bot, x, y), maxAllowedDistance - sPlayerbotAIConfig->tooCloseDistance)) + float x = botPosX + cos(angle) * maxAllowedDistance, y = botPosY + sin(angle) * maxAllowedDistance, + z = botPosZ + CONTACT_DISTANCE; + if (forceMaxDistance && + sServerFacade->IsDistanceLessThan(sServerFacade->GetDistance2d(bot, x, y), + maxAllowedDistance - sPlayerbotAIConfig->tooCloseDistance)) continue; bot->UpdateAllowedPositionZ(x, y, z); @@ -99,7 +113,8 @@ void FleeManager::calculatePossibleDestinations(std::vector &points) FleePoint* point = new FleePoint(botAI, x, y, z); calculateDistanceToCreatures(point); - if (sServerFacade->IsDistanceGreaterOrEqualThan(point->minDistance - start.minDistance, sPlayerbotAIConfig->followDistance)) + if (sServerFacade->IsDistanceGreaterOrEqualThan(point->minDistance - start.minDistance, + sPlayerbotAIConfig->followDistance)) points.push_back(point); else delete point; @@ -108,14 +123,14 @@ void FleeManager::calculatePossibleDestinations(std::vector &points) } } -void FleeManager::cleanup(std::vector &points) +void FleeManager::cleanup(std::vector& points) { - for (std::vector::iterator i = points.begin(); i != points.end(); i++) + for (std::vector::iterator i = points.begin(); i != points.end(); i++) { - delete *i; - } + delete *i; + } - points.clear(); + points.clear(); } bool FleeManager::isBetterThan(FleePoint* point, FleePoint* other) @@ -123,23 +138,23 @@ bool FleeManager::isBetterThan(FleePoint* point, FleePoint* other) return point->sumDistance - other->sumDistance > 0; } -FleePoint* FleeManager::selectOptimalDestination(std::vector &points) +FleePoint* FleeManager::selectOptimalDestination(std::vector& points) { - FleePoint* best = nullptr; - for (std::vector::iterator i = points.begin(); i != points.end(); i++) + FleePoint* best = nullptr; + for (std::vector::iterator i = points.begin(); i != points.end(); i++) { - FleePoint* point = *i; - if (!best || isBetterThan(point, best)) + FleePoint* point = *i; + if (!best || isBetterThan(point, best)) best = point; - } + } - return best; + return best; } bool FleeManager::CalculateDestination(float* rx, float* ry, float* rz) { std::vector points; - calculatePossibleDestinations(points); + calculatePossibleDestinations(points); FleePoint* point = selectOptimalDestination(points); if (!point) @@ -148,18 +163,19 @@ bool FleeManager::CalculateDestination(float* rx, float* ry, float* rz) return false; } - *rx = point->x; - *ry = point->y; - *rz = point->z; + *rx = point->x; + *ry = point->y; + *rz = point->z; cleanup(points); - return true; + return true; } bool FleeManager::isUseful() { PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - if (!botAI) { + if (!botAI) + { return false; } GuidVector units = *botAI->GetAiObjectContext()->GetValue("possible targets no los"); @@ -169,7 +185,8 @@ bool FleeManager::isUseful() if (!creature) continue; - if (startPosition.sqDistance(WorldPosition(creature)) < creature->GetAttackDistance(bot) * creature->GetAttackDistance(bot)) + if (startPosition.sqDistance(WorldPosition(creature)) < + creature->GetAttackDistance(bot) * creature->GetAttackDistance(bot)) return true; // float d = sServerFacade->GetDistance2d(unit, bot); diff --git a/src/FleeManager.h b/src/FleeManager.h index 5ca801f0..1af8f7cf 100644 --- a/src/FleeManager.h +++ b/src/FleeManager.h @@ -1,54 +1,59 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_FLEEMANAGER_H #define _PLAYERBOT_FLEEMANAGER_H +#include + #include "Common.h" #include "TravelMgr.h" -#include - class Player; class PlayerbotAI; class FleePoint { - public: - FleePoint(PlayerbotAI* botAI, float x, float y, float z) : botAI(botAI), sumDistance(0.0f), minDistance(0.0f), x(x), y(y), z(z) { } +public: + FleePoint(PlayerbotAI* botAI, float x, float y, float z) + : botAI(botAI), sumDistance(0.0f), minDistance(0.0f), x(x), y(y), z(z) + { + } - float x; - float y; - float z; + float x; + float y; + float z; - float sumDistance; - float minDistance; + float sumDistance; + float minDistance; - private: - PlayerbotAI* botAI; +private: + PlayerbotAI* botAI; }; class FleeManager { - public: - FleeManager(Player* bot, float maxAllowedDistance, float followAngle, bool forceMaxDistance = false, WorldPosition startPosition = WorldPosition()); +public: + FleeManager(Player* bot, float maxAllowedDistance, float followAngle, bool forceMaxDistance = false, + WorldPosition startPosition = WorldPosition()); - bool CalculateDestination(float* rx, float* ry, float* rz); - bool isUseful(); + bool CalculateDestination(float* rx, float* ry, float* rz); + bool isUseful(); - private: - void calculatePossibleDestinations(std::vector &points); - void calculateDistanceToCreatures(FleePoint *point); - void cleanup(std::vector &points); - FleePoint* selectOptimalDestination(std::vector &points); - bool isBetterThan(FleePoint* point, FleePoint* other); +private: + void calculatePossibleDestinations(std::vector& points); + void calculateDistanceToCreatures(FleePoint* point); + void cleanup(std::vector& points); + FleePoint* selectOptimalDestination(std::vector& points); + bool isBetterThan(FleePoint* point, FleePoint* other); - Player* bot; - float maxAllowedDistance; - [[maybe_unused]] float followAngle; // unused - whipowill - bool forceMaxDistance; - WorldPosition startPosition; + Player* bot; + float maxAllowedDistance; + [[maybe_unused]] float followAngle; // unused - whipowill + bool forceMaxDistance; + WorldPosition startPosition; }; #endif diff --git a/src/GuildTaskMgr.cpp b/src/GuildTaskMgr.cpp index 41be5432..fad84bd9 100644 --- a/src/GuildTaskMgr.cpp +++ b/src/GuildTaskMgr.cpp @@ -1,15 +1,17 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GuildTaskMgr.h" + #include "ChatHelper.h" -#include "GuildMgr.h" #include "Group.h" +#include "GuildMgr.h" #include "Mail.h" #include "MapMgr.h" -#include "Playerbots.h" #include "PlayerbotFactory.h" +#include "Playerbots.h" #include "RandomItemMgr.h" #include "ServerFacade.h" @@ -42,13 +44,15 @@ void GuildTaskMgr::Update(Player* player, Player* guildMaster) if (!player->IsFriendlyTo(guildMaster)) return; - Guild* guild = sGuildMgr->GetGuildById(guildMaster->GetGuildId()); + Guild* guild = sGuildMgr->GetGuildById(guildMaster->GetGuildId()); DenyReason reason = PLAYERBOT_DENY_NONE; PlayerbotSecurityLevel secLevel = masterBotAI->GetSecurity()->LevelFor(player, &reason); - if (secLevel == PLAYERBOT_SECURITY_DENY_ALL || (secLevel == PLAYERBOT_SECURITY_TALK && reason != PLAYERBOT_DENY_FAR)) + if (secLevel == PLAYERBOT_SECURITY_DENY_ALL || + (secLevel == PLAYERBOT_SECURITY_TALK && reason != PLAYERBOT_DENY_FAR)) { - LOG_DEBUG("playerbots", "{} / {}: skipping guild task update - not enough security level, reason = {}", guild->GetName().c_str(), player->GetName().c_str(), reason); + LOG_DEBUG("playerbots", "{} / {}: skipping guild task update - not enough security level, reason = {}", + guild->GetName().c_str(), player->GetName().c_str(), reason); return; } @@ -72,14 +76,18 @@ void GuildTaskMgr::Update(Player* player, Player* guildMaster) if (task == GUILD_TASK_TYPE_NONE) { - LOG_ERROR("playerbots", "{} / {}: error creating guild task", guild->GetName().c_str(), player->GetName().c_str()); + LOG_ERROR("playerbots", "{} / {}: error creating guild task", guild->GetName().c_str(), + player->GetName().c_str()); } uint32 time = urand(sPlayerbotAIConfig->minGuildTaskChangeTime, sPlayerbotAIConfig->maxGuildTaskChangeTime); SetTaskValue(owner, guildId, "activeTask", task, time); - SetTaskValue(owner, guildId, "advertisement", 1, urand(sPlayerbotAIConfig->minGuildTaskAdvertisementTime, sPlayerbotAIConfig->maxGuildTaskAdvertisementTime)); + SetTaskValue(owner, guildId, "advertisement", 1, + urand(sPlayerbotAIConfig->minGuildTaskAdvertisementTime, + sPlayerbotAIConfig->maxGuildTaskAdvertisementTime)); - LOG_DEBUG("playerbots", "{} / {}: guild task {} is set for {} secs", guild->GetName().c_str(), player->GetName().c_str(), task, time); + LOG_DEBUG("playerbots", "{} / {}: guild task {} is set for {} secs", guild->GetName().c_str(), + player->GetName().c_str(), task, time); return; } @@ -92,11 +100,14 @@ void GuildTaskMgr::Update(Player* player, Player* guildMaster) if (SendAdvertisement(trans, owner, guildId)) { - SetTaskValue(owner, guildId, "advertisement", 1, urand(sPlayerbotAIConfig->minGuildTaskAdvertisementTime, sPlayerbotAIConfig->maxGuildTaskAdvertisementTime)); + SetTaskValue(owner, guildId, "advertisement", 1, + urand(sPlayerbotAIConfig->minGuildTaskAdvertisementTime, + sPlayerbotAIConfig->maxGuildTaskAdvertisementTime)); } else { - LOG_DEBUG("playerbots", "{} / {}: error sending advertisement", guild->GetName().c_str(), player->GetName().c_str()); + LOG_DEBUG("playerbots", "{} / {}: error sending advertisement", guild->GetName().c_str(), + player->GetName().c_str()); } } @@ -112,7 +123,8 @@ void GuildTaskMgr::Update(Player* player, Player* guildMaster) } else { - LOG_DEBUG("playerbots", "{} / {}: error sending thanks", guild->GetName().c_str(), player->GetName().c_str()); + LOG_DEBUG("playerbots", "{} / {}: error sending thanks", guild->GetName().c_str(), + player->GetName().c_str()); } } @@ -128,7 +140,8 @@ void GuildTaskMgr::Update(Player* player, Player* guildMaster) } else { - LOG_DEBUG("playerbots", "{} / {}: error sending reward", guild->GetName().c_str(), player->GetName().c_str()); + LOG_DEBUG("playerbots", "{} / {}: error sending reward", guild->GetName().c_str(), + player->GetName().c_str()); } } @@ -151,7 +164,7 @@ uint32 GuildTaskMgr::CreateTask(Player* owner, uint32 guildId) class RandomItemBySkillGuildTaskPredicate : public RandomItemPredicate { public: - RandomItemBySkillGuildTaskPredicate(Player* player) : RandomItemPredicate(), player(player) { } + RandomItemBySkillGuildTaskPredicate(Player* player) : RandomItemPredicate(), player(player) {} bool Apply(ItemTemplate const* proto) override { @@ -180,16 +193,20 @@ bool GuildTaskMgr::CreateItemTask(Player* player, uint32 guildId) uint32 itemId = sRandomItemMgr->GetRandomItem(player->GetLevel() - 5, RANDOM_ITEM_GUILD_TASK, &predicate); if (!itemId) { - LOG_ERROR("playerbots", "{} / {}: no items avaible for item task", sGuildMgr->GetGuildById(guildId)->GetName().c_str(), player->GetName().c_str()); + LOG_ERROR("playerbots", "{} / {}: no items avaible for item task", + sGuildMgr->GetGuildById(guildId)->GetName().c_str(), player->GetName().c_str()); return false; } uint32 count = GetMaxItemTaskCount(itemId); - LOG_DEBUG("playerbots", "{} / {}: item task {} (x{})", sGuildMgr->GetGuildById(guildId)->GetName().c_str(), player->GetName().c_str(), itemId, count); + LOG_DEBUG("playerbots", "{} / {}: item task {} (x{})", sGuildMgr->GetGuildById(guildId)->GetName().c_str(), + player->GetName().c_str(), itemId, count); - SetTaskValue(player->GetGUID().GetCounter(), guildId, "itemCount", count, sPlayerbotAIConfig->maxGuildTaskChangeTime); - SetTaskValue(player->GetGUID().GetCounter(), guildId, "itemTask", itemId, sPlayerbotAIConfig->maxGuildTaskChangeTime); + SetTaskValue(player->GetGUID().GetCounter(), guildId, "itemCount", count, + sPlayerbotAIConfig->maxGuildTaskChangeTime); + SetTaskValue(player->GetGUID().GetCounter(), guildId, "itemTask", itemId, + sPlayerbotAIConfig->maxGuildTaskChangeTime); return true; } @@ -204,8 +221,10 @@ bool GuildTaskMgr::CreateKillTask(Player* player, uint32 guildId) std::vector ids; uint32 level = player->GetLevel(); - QueryResult results = WorldDatabase.Query("SELECT ct.Entry, c.map, c.position_x, c.position_y, ct.Name FROM creature_template ct " - "JOIN creature c ON ct.Entry = c.id1 WHERE ct.MaxLevel < {} AND ct.MinLevel > {} AND ct.Rank = {} ", level + 4, level - 3, rank); + QueryResult results = WorldDatabase.Query( + "SELECT ct.Entry, c.map, c.position_x, c.position_y, ct.Name FROM creature_template ct " + "JOIN creature c ON ct.Entry = c.id1 WHERE ct.MaxLevel < {} AND ct.MinLevel > {} AND ct.Rank = {} ", + level + 4, level - 3, rank); if (results) { do @@ -231,16 +250,19 @@ bool GuildTaskMgr::CreateKillTask(Player* player, uint32 guildId) if (ids.empty()) { - LOG_ERROR("playerbots", "{} / {}: no rare creatures available for kill task", sGuildMgr->GetGuildById(guildId)->GetName().c_str(), player->GetName().c_str()); + LOG_ERROR("playerbots", "{} / {}: no rare creatures available for kill task", + sGuildMgr->GetGuildById(guildId)->GetName().c_str(), player->GetName().c_str()); return false; } uint32 index = urand(0, ids.size() - 1); uint32 creatureId = ids[index]; - LOG_DEBUG("playerbots", "{} / {}: kill task {}", sGuildMgr->GetGuildById(guildId)->GetName().c_str(), player->GetName().c_str(), creatureId); + LOG_DEBUG("playerbots", "{} / {}: kill task {}", sGuildMgr->GetGuildById(guildId)->GetName().c_str(), + player->GetName().c_str(), creatureId); - SetTaskValue(player->GetGUID().GetCounter(), guildId, "killTask", creatureId, sPlayerbotAIConfig->maxGuildTaskChangeTime); + SetTaskValue(player->GetGUID().GetCounter(), guildId, "killTask", creatureId, + sPlayerbotAIConfig->maxGuildTaskChangeTime); return true; } @@ -283,7 +305,8 @@ std::string const formatTime(uint32 secs) else if (secs < 3600 * 24) { out << secs / 3600 << " hr"; - } else + } + else { out << secs / 3600 / 24 << " days"; } @@ -294,7 +317,7 @@ std::string const formatTime(uint32 secs) std::string const formatDateTime(uint32 secs) { time_t rawtime = time(nullptr) + secs; - tm* timeinfo = localtime (&rawtime); + tm* timeinfo = localtime(&rawtime); char buffer[256]; strftime(buffer, sizeof(buffer), "%b %d, %H:%M", timeinfo); @@ -318,7 +341,8 @@ std::string const GetHelloText(uint32 owner) return body.str(); } -bool GuildTaskMgr::SendItemAdvertisement(CharacterDatabaseTransaction& trans, uint32 itemId, uint32 owner, uint32 guildId, uint32 validIn) +bool GuildTaskMgr::SendItemAdvertisement(CharacterDatabaseTransaction& trans, uint32 itemId, uint32 owner, + uint32 guildId, uint32 validIn) { Guild* guild = sGuildMgr->GetGuildById(guildId); Player* leader = ObjectAccessor::FindPlayer(guild->GetLeaderGUID()); @@ -352,7 +376,8 @@ bool GuildTaskMgr::SendItemAdvertisement(CharacterDatabaseTransaction& trans, ui return true; } -bool GuildTaskMgr::SendKillAdvertisement(CharacterDatabaseTransaction& trans, uint32 creatureId, uint32 owner, uint32 guildId, uint32 validIn) +bool GuildTaskMgr::SendKillAdvertisement(CharacterDatabaseTransaction& trans, uint32 creatureId, uint32 owner, + uint32 guildId, uint32 validIn) { Guild* guild = sGuildMgr->GetGuildById(guildId); Player* leader = ObjectAccessor::FindPlayer(guild->GetLeaderGUID()); @@ -361,7 +386,8 @@ bool GuildTaskMgr::SendKillAdvertisement(CharacterDatabaseTransaction& trans, ui if (!proto) return false; - QueryResult result = WorldDatabase.Query("SELECT map, position_x, position_y, position_z FROM creature WHERE id1 = {}", creatureId); + QueryResult result = + WorldDatabase.Query("SELECT map, position_x, position_y, position_z FROM creature WHERE id1 = {}", creatureId); if (!result) return false; @@ -387,7 +413,8 @@ bool GuildTaskMgr::SendKillAdvertisement(CharacterDatabaseTransaction& trans, ui std::ostringstream body; body << GetHelloText(owner); - body << "As you probably know " << proto->Name << " is wanted dead for the crimes it did against our guild. If you should kill it "; + body << "As you probably know " << proto->Name + << " is wanted dead for the crimes it did against our guild. If you should kill it "; body << "we'd really appreciate that.\n\n"; if (!location.empty()) body << proto->Name << "'s the last known location was " << location << ".\n"; @@ -399,7 +426,8 @@ bool GuildTaskMgr::SendKillAdvertisement(CharacterDatabaseTransaction& trans, ui std::ostringstream subject; subject << "Guild Task: "; - if (proto->rank == CREATURE_ELITE_ELITE || proto->rank == CREATURE_ELITE_RAREELITE || proto->rank == CREATURE_ELITE_WORLDBOSS) + if (proto->rank == CREATURE_ELITE_ELITE || proto->rank == CREATURE_ELITE_RAREELITE || + proto->rank == CREATURE_ELITE_WORLDBOSS) subject << "(Elite) "; subject << proto->Name; if (!location.empty()) @@ -441,9 +469,7 @@ bool GuildTaskMgr::SendThanks(CharacterDatabaseTransaction& trans, uint32 owner, body << guild->GetName() << "\n"; body << leader->GetName() << "\n"; - MailDraft("Thank You", body.str()). - AddMoney(payment). - SendMailTo(trans, MailReceiver(owner), MailSender(leader)); + MailDraft("Thank You", body.str()).AddMoney(payment).SendMailTo(trans, MailReceiver(owner), MailSender(leader)); Player* player = ObjectAccessor::FindPlayer(ObjectGuid::Create(owner)); if (player) @@ -501,7 +527,8 @@ bool GuildTaskMgr::IsGuildTaskItem(uint32 itemId, uint32 guildId) { uint32 value = 0; - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_GUILD_TASKS_BY_VALUE); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_GUILD_TASKS_BY_VALUE); stmt->SetData(0, itemId); stmt->SetData(1, guildId); stmt->SetData(2, "itemTask"); @@ -518,11 +545,13 @@ bool GuildTaskMgr::IsGuildTaskItem(uint32 itemId, uint32 guildId) return value; } -std::map GuildTaskMgr::GetTaskValues(uint32 owner, std::string const type, uint32* validIn /* = nullptr */) +std::map GuildTaskMgr::GetTaskValues(uint32 owner, std::string const type, + uint32* validIn /* = nullptr */) { std::map results; - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_GUILD_TASKS_BY_OWNER); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_GUILD_TASKS_BY_OWNER); stmt->SetData(0, owner); stmt->SetData(1, type); if (PreparedQueryResult result = PlayerbotsDatabase.Query(stmt)) @@ -542,14 +571,15 @@ std::map GuildTaskMgr::GetTaskValues(uint32 owner, std::string c } while (result->NextRow()); } - return std::move(results); + return std::move(results); } uint32 GuildTaskMgr::GetTaskValue(uint32 owner, uint32 guildId, std::string const type, uint32* validIn /* = nullptr */) { uint32 value = 0; - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_GUILD_TASKS_BY_OWNER_AND_TYPE); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_GUILD_TASKS_BY_OWNER_AND_TYPE); stmt->SetData(0, owner); stmt->SetData(1, guildId); stmt->SetData(2, type); @@ -566,7 +596,7 @@ uint32 GuildTaskMgr::GetTaskValue(uint32 owner, uint32 guildId, std::string cons *validIn = secs; } - return value; + return value; } uint32 GuildTaskMgr::SetTaskValue(uint32 owner, uint32 guildId, std::string const type, uint32 value, uint32 validIn) @@ -596,13 +626,13 @@ bool GuildTaskMgr::HandleConsoleCommand(ChatHandler* handler, char const* args) { if (!sPlayerbotAIConfig->guildTaskEnabled) { - LOG_ERROR("playerbots", "Guild task system is currently disabled!"); + LOG_ERROR("playerbots", "Guild task system is currently disabled!"); return false; } if (!args || !*args) { - LOG_ERROR("playerbots", "Usage: gtask stats/reset"); + LOG_ERROR("playerbots", "Usage: gtask stats/reset"); return false; } @@ -627,13 +657,14 @@ bool GuildTaskMgr::HandleConsoleCommand(ChatHandler* handler, char const* args) ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(charName); if (!guid) { - LOG_ERROR("playerbots", "Player {} not found", charName.c_str()); + LOG_ERROR("playerbots", "Player {} not found", charName.c_str()); return false; } uint32 owner = guid.GetCounter(); - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_GUILD_TASKS_BY_OWNER_ORDERED); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_GUILD_TASKS_BY_OWNER_ORDERED); stmt->SetData(0, owner); stmt->SetData(1, "activeTask"); if (PreparedQueryResult result = PlayerbotsDatabase.Query(stmt)) @@ -731,11 +762,10 @@ bool GuildTaskMgr::HandleConsoleCommand(ChatHandler* handler, char const* args) if (payment && paymentValidIn < validIn) name << " payment " << ChatHelper::formatMoney(payment) << " in " << formatTime(paymentValidIn); - LOG_INFO("playerbots", "{}: {} valid in {} [{}]", - charName.c_str(), name.str().c_str(), formatTime(validIn).c_str(), guild->GetName().c_str()); + LOG_INFO("playerbots", "{}: {} valid in {} [{}]", charName.c_str(), name.str().c_str(), + formatTime(validIn).c_str(), guild->GetName().c_str()); - } - while (result->NextRow()); + } while (result->NextRow()); } return true; @@ -774,13 +804,14 @@ bool GuildTaskMgr::HandleConsoleCommand(ChatHandler* handler, char const* args) ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(charName); if (!guid) { - LOG_ERROR("playerbots", "Player {} not found", charName.c_str()); + LOG_ERROR("playerbots", "Player {} not found", charName.c_str()); return false; } uint32 owner = guid.GetCounter(); - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_GUILD_TASKS_BY_OWNER_DISTINCT); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_GUILD_TASKS_BY_OWNER_DISTINCT); stmt->SetData(0, owner); if (PreparedQueryResult result = PlayerbotsDatabase.Query(stmt)) { @@ -818,19 +849,20 @@ bool GuildTaskMgr::CheckItemTask(uint32 itemId, uint32 obtained, Player* ownerPl return false; uint32 owner = ownerPlayer->GetGUID().GetCounter(); - Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId()); - if (!guild) - return false; + Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId()); + if (!guild) + return false; - if (!sRandomPlayerbotMgr->IsRandomBot(bot)) - return false; + if (!sRandomPlayerbotMgr->IsRandomBot(bot)) + return false; LOG_DEBUG("playerbots", "{} / {}: checking guild task", guild->GetName().c_str(), ownerPlayer->GetName().c_str()); uint32 itemTask = GetTaskValue(owner, guildId, "itemTask"); if (itemTask != itemId) { - LOG_DEBUG("playerbots", "{} / {}: item {} is not guild task item ({})", guild->GetName().c_str(), ownerPlayer->GetName().c_str(), itemId, itemTask); + LOG_DEBUG("playerbots", "{} / {}: item {} is not guild task item ({})", guild->GetName().c_str(), + ownerPlayer->GetName().c_str(), itemId, itemTask); if (byMail) SendCompletionMessage(ownerPlayer, "made a mistake with"); @@ -857,7 +889,8 @@ bool GuildTaskMgr::CheckItemTask(uint32 itemId, uint32 obtained, Player* ownerPl if (obtained >= count) { - LOG_DEBUG("playerbots", "{} / {}: guild task complete", guild->GetName().c_str(), ownerPlayer->GetName().c_str()); + LOG_DEBUG("playerbots", "{} / {}: guild task complete", guild->GetName().c_str(), + ownerPlayer->GetName().c_str()); SetTaskValue(owner, guildId, "reward", 1, rewardTime - 15); SetTaskValue(owner, guildId, "itemCount", 0, 0); SetTaskValue(owner, guildId, "thanks", 0, 0); @@ -865,7 +898,8 @@ bool GuildTaskMgr::CheckItemTask(uint32 itemId, uint32 obtained, Player* ownerPl } else { - LOG_DEBUG("playerbots", "{} / {}: guild task progress {}/{}", guild->GetName().c_str(), ownerPlayer->GetName().c_str(), obtained, count); + LOG_DEBUG("playerbots", "{} / {}: guild task progress {}/{}", guild->GetName().c_str(), + ownerPlayer->GetName().c_str(), obtained, count); SetTaskValue(owner, guildId, "itemCount", count - obtained, sPlayerbotAIConfig->maxGuildTaskChangeTime); SetTaskValue(owner, guildId, "thanks", 1, rewardTime - 30); SendCompletionMessage(ownerPlayer, "made a progress with"); @@ -904,12 +938,14 @@ bool GuildTaskMgr::Reward(CharacterDatabaseTransaction& trans, uint32 owner, uin if (!proto) return false; - body << "We wish to thank you for the " << proto->Name1 << " you provided so kindly. We really appreciate this and may this small gift bring you our thanks!\n"; + body << "We wish to thank you for the " << proto->Name1 + << " you provided so kindly. We really appreciate this and may this small gift bring you our thanks!\n"; body << "\n"; body << "Many thanks,\n"; body << guild->GetName() << "\n"; body << leader->GetName() << "\n"; - rewardType = proto->Quality > ITEM_QUALITY_NORMAL ? RANDOM_ITEM_GUILD_TASK_REWARD_EQUIP_BLUE : RANDOM_ITEM_GUILD_TASK_REWARD_EQUIP_GREEN; + rewardType = proto->Quality > ITEM_QUALITY_NORMAL ? RANDOM_ITEM_GUILD_TASK_REWARD_EQUIP_BLUE + : RANDOM_ITEM_GUILD_TASK_REWARD_EQUIP_GREEN; itemId = sRandomItemMgr->GetRandomItem(player->GetLevel() - 5, rewardType); } else if (killTask) @@ -918,12 +954,14 @@ bool GuildTaskMgr::Reward(CharacterDatabaseTransaction& trans, uint32 owner, uin if (!proto) return false; - body << "We wish to thank you for the " << proto->Name << " you've killed recently. We really appreciate this and may this small gift bring you our thanks!\n"; + body << "We wish to thank you for the " << proto->Name + << " you've killed recently. We really appreciate this and may this small gift bring you our thanks!\n"; body << "\n"; body << "Many thanks,\n"; body << guild->GetName() << "\n"; body << leader->GetName() << "\n"; - rewardType = proto->rank == CREATURE_ELITE_RARE ? RANDOM_ITEM_GUILD_TASK_REWARD_TRADE : RANDOM_ITEM_GUILD_TASK_REWARD_TRADE_RARE; + rewardType = proto->rank == CREATURE_ELITE_RARE ? RANDOM_ITEM_GUILD_TASK_REWARD_TRADE + : RANDOM_ITEM_GUILD_TASK_REWARD_TRADE_RARE; itemId = sRandomItemMgr->GetRandomItem(player->GetLevel(), rewardType); if (itemId) { @@ -1032,7 +1070,8 @@ void GuildTaskMgr::CheckKillTaskInternal(Player* player, Unit* victim) continue; LOG_DEBUG("playerbots", "{} / {}: guild task complete", guild->GetName().c_str(), player->GetName().c_str()); - SetTaskValue(owner, guildId, "reward", 1, urand(sPlayerbotAIConfig->minGuildTaskRewardTime, sPlayerbotAIConfig->maxGuildTaskRewardTime)); + SetTaskValue(owner, guildId, "reward", 1, + urand(sPlayerbotAIConfig->minGuildTaskRewardTime, sPlayerbotAIConfig->maxGuildTaskRewardTime)); SendCompletionMessage(player, "completed"); } @@ -1041,7 +1080,8 @@ void GuildTaskMgr::CheckKillTaskInternal(Player* player, Unit* victim) void GuildTaskMgr::CleanupAdverts() { uint32 deliverTime = time(nullptr) - sPlayerbotAIConfig->minGuildTaskChangeTime; - QueryResult result = CharacterDatabase.Query("SELECT id, receiver FROM mail WHERE subject LIKE 'Guild Task%%' AND deliver_time <= {}", deliverTime); + QueryResult result = CharacterDatabase.Query( + "SELECT id, receiver FROM mail WHERE subject LIKE 'Guild Task%%' AND deliver_time <= {}", deliverTime); if (!result) return; @@ -1059,7 +1099,8 @@ void GuildTaskMgr::CleanupAdverts() if (count > 0) { - CharacterDatabase.Execute("DELETE FROM mail WHERE subject LIKE 'Guild Task%%' AND deliver_time <= {}", deliverTime); + CharacterDatabase.Execute("DELETE FROM mail WHERE subject LIKE 'Guild Task%%' AND deliver_time <= {}", + deliverTime); LOG_INFO("playerbots", "{} old gtask adverts removed", count); } } @@ -1067,8 +1108,12 @@ void GuildTaskMgr::CleanupAdverts() void GuildTaskMgr::RemoveDuplicatedAdverts() { uint32 deliverTime = time(nullptr); - QueryResult result = CharacterDatabase.Query("SELECT m.id, m.receiver FROM (SELECT MAX(id) AS id, subject, receiver FROM mail WHERE subject LIKE 'Guild Task%%' " - "AND deliver_time <= {} GROUP BY subject, receiver) q JOIN mail m ON m.subject = q.subject WHERE m.id <> q.id AND m.deliver_time <= {}", deliverTime, deliverTime); + QueryResult result = CharacterDatabase.Query( + "SELECT m.id, m.receiver FROM (SELECT MAX(id) AS id, subject, receiver FROM mail WHERE subject LIKE 'Guild " + "Task%%' " + "AND deliver_time <= {} GROUP BY subject, receiver) q JOIN mail m ON m.subject = q.subject WHERE m.id <> q.id " + "AND m.deliver_time <= {}", + deliverTime, deliverTime); if (!result) return; @@ -1103,7 +1148,6 @@ void GuildTaskMgr::RemoveDuplicatedAdverts() DeleteMail(buffer); LOG_INFO("playerbots", "{} duplicated gtask adverts removed", count); } - } void GuildTaskMgr::DeleteMail(std::vector buffer) @@ -1147,7 +1191,8 @@ bool GuildTaskMgr::CheckTaskTransfer(std::string const text, Player* ownerPlayer if (text.empty()) return false; - LOG_DEBUG("playerbots", "{} / {}: checking guild task transfer", guild->GetName().c_str(), ownerPlayer->GetName().c_str()); + LOG_DEBUG("playerbots", "{} / {}: checking guild task transfer", guild->GetName().c_str(), + ownerPlayer->GetName().c_str()); uint32 account = ownerPlayer->GetSession()->GetAccountId(); diff --git a/src/GuildTaskMgr.h b/src/GuildTaskMgr.h index 62fd5958..f6826bf5 100644 --- a/src/GuildTaskMgr.h +++ b/src/GuildTaskMgr.h @@ -1,57 +1,60 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GUILDTASKMGR_H #define _PLAYERBOT_GUILDTASKMGR_H +#include + #include "Common.h" #include "Transaction.h" -#include - class ChatHandler; class Player; class Unit; class GuildTaskMgr { - public: - GuildTaskMgr() { }; - virtual ~GuildTaskMgr() { }; +public: + GuildTaskMgr(){}; + virtual ~GuildTaskMgr(){}; - static GuildTaskMgr* instance() - { - static GuildTaskMgr instance; - return &instance; - } + static GuildTaskMgr* instance() + { + static GuildTaskMgr instance; + return &instance; + } - void Update(Player* owner, Player* guildMaster); + void Update(Player* owner, Player* guildMaster); - static bool HandleConsoleCommand(ChatHandler* handler, char const* args); - bool IsGuildTaskItem(uint32 itemId, uint32 guildId); - bool CheckItemTask(uint32 itemId, uint32 obtained, Player* owner, Player* bot, bool byMail = false); - void CheckKillTask(Player* owner, Unit* victim); - void CheckKillTaskInternal(Player* owner, Unit* victim); - bool CheckTaskTransfer(std::string const text, Player* owner, Player* bot); + static bool HandleConsoleCommand(ChatHandler* handler, char const* args); + bool IsGuildTaskItem(uint32 itemId, uint32 guildId); + bool CheckItemTask(uint32 itemId, uint32 obtained, Player* owner, Player* bot, bool byMail = false); + void CheckKillTask(Player* owner, Unit* victim); + void CheckKillTaskInternal(Player* owner, Unit* victim); + bool CheckTaskTransfer(std::string const text, Player* owner, Player* bot); - private: - std::map GetTaskValues(uint32 owner, std::string const type, uint32* validIn = nullptr); - uint32 GetTaskValue(uint32 owner, uint32 guildId, std::string const type, uint32* validIn = nullptr); - uint32 SetTaskValue(uint32 owner, uint32 guildId, std::string const type, uint32 value, uint32 validIn); - uint32 CreateTask(Player* owner, uint32 guildId); - bool SendAdvertisement(CharacterDatabaseTransaction& trans, uint32 owner, uint32 guildId); - bool SendItemAdvertisement(CharacterDatabaseTransaction& trans, uint32 itemId, uint32 owner, uint32 guildId, uint32 validIn); - bool SendKillAdvertisement(CharacterDatabaseTransaction& trans, uint32 creatureId, uint32 owner, uint32 guildId, uint32 validIn); - bool SendThanks(CharacterDatabaseTransaction& trans, uint32 owner, uint32 guildId, uint32 payment); - bool Reward(CharacterDatabaseTransaction& trans, uint32 owner, uint32 guildId); - bool CreateItemTask(Player* owner, uint32 guildId); - bool CreateKillTask(Player* owner, uint32 guildId); - uint32 GetMaxItemTaskCount(uint32 itemId); - void CleanupAdverts(); - void RemoveDuplicatedAdverts(); - void DeleteMail(std::vector buffer); - void SendCompletionMessage(Player* player, std::string const verb); +private: + std::map GetTaskValues(uint32 owner, std::string const type, uint32* validIn = nullptr); + uint32 GetTaskValue(uint32 owner, uint32 guildId, std::string const type, uint32* validIn = nullptr); + uint32 SetTaskValue(uint32 owner, uint32 guildId, std::string const type, uint32 value, uint32 validIn); + uint32 CreateTask(Player* owner, uint32 guildId); + bool SendAdvertisement(CharacterDatabaseTransaction& trans, uint32 owner, uint32 guildId); + bool SendItemAdvertisement(CharacterDatabaseTransaction& trans, uint32 itemId, uint32 owner, uint32 guildId, + uint32 validIn); + bool SendKillAdvertisement(CharacterDatabaseTransaction& trans, uint32 creatureId, uint32 owner, uint32 guildId, + uint32 validIn); + bool SendThanks(CharacterDatabaseTransaction& trans, uint32 owner, uint32 guildId, uint32 payment); + bool Reward(CharacterDatabaseTransaction& trans, uint32 owner, uint32 guildId); + bool CreateItemTask(Player* owner, uint32 guildId); + bool CreateKillTask(Player* owner, uint32 guildId); + uint32 GetMaxItemTaskCount(uint32 itemId); + void CleanupAdverts(); + void RemoveDuplicatedAdverts(); + void DeleteMail(std::vector buffer); + void SendCompletionMessage(Player* player, std::string const verb); }; #define sGuildTaskMgr GuildTaskMgr::instance() diff --git a/src/Helpers.cpp b/src/Helpers.cpp index ab7d340f..5ab06cb7 100644 --- a/src/Helpers.cpp +++ b/src/Helpers.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "Helpers.h" @@ -15,7 +16,7 @@ char* strstri(char const* haystack, char const* needle) { if (tolower(*haystack) == tolower(*needle)) { - char const* h = haystack, * n = needle; + char const *h = haystack, *n = needle; for (; *h && *n; ++h, ++n) { if (tolower(*h) != tolower(*n)) @@ -36,17 +37,14 @@ char* strstri(char const* haystack, char const* needle) std::string& ltrim(std::string& s) { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int c) {return !std::isspace(c); })); + s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int c) { return !std::isspace(c); })); return s; } std::string& rtrim(std::string& s) { - s.erase(std::find_if(s.rbegin(), s.rend(), [](int c) {return !std::isspace(c); }).base(), s.end()); + s.erase(std::find_if(s.rbegin(), s.rend(), [](int c) { return !std::isspace(c); }).base(), s.end()); return s; } -std::string& trim(std::string& s) -{ - return ltrim(rtrim(s)); -} +std::string& trim(std::string& s) { return ltrim(rtrim(s)); } diff --git a/src/Helpers.h b/src/Helpers.h index 2d9e5454..02340fa6 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -1,21 +1,23 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HELPERS_H #define _PLAYERBOT_HELPERS_H -#include "Common.h" - -#include -#include -#include -#include -#include -#include #include #include + #include +#include +#include +#include +#include +#include +#include + +#include "Common.h" void split(std::vector& dest, std::string const str, char const* delim) { diff --git a/src/LazyCalculatedValue.h b/src/LazyCalculatedValue.h index a2e273fe..2d9fd8a1 100644 --- a/src/LazyCalculatedValue.h +++ b/src/LazyCalculatedValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LAZYCALCULATEDVALUE_H @@ -8,37 +9,31 @@ template class LazyCalculatedValue { - public: - typedef TValue (TOwner::*Calculator)(); +public: + typedef TValue (TOwner::*Calculator)(); - public: - LazyCalculatedValue(TOwner* owner, Calculator calculator) : calculator(calculator), owner(owner) +public: + LazyCalculatedValue(TOwner* owner, Calculator calculator) : calculator(calculator), owner(owner) { Reset(); } + +public: + TValue GetValue() + { + if (!calculated) { - Reset(); + value = (owner->*calculator)(); + calculated = true; } - public: - TValue GetValue() - { - if (!calculated) - { - value = (owner->*calculator)(); - calculated = true; - } + return value; + } - return value; - } + void Reset() { calculated = false; } - void Reset() - { - calculated = false; - } - - protected: - Calculator calculator; - TOwner* owner; - bool calculated; - TValue value; +protected: + Calculator calculator; + TOwner* owner; + bool calculated; + TValue value; }; #endif diff --git a/src/LootObjectStack.cpp b/src/LootObjectStack.cpp index d2c6cf3f..aed30c12 100644 --- a/src/LootObjectStack.cpp +++ b/src/LootObjectStack.cpp @@ -1,17 +1,17 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LootObjectStack.h" + #include "LootMgr.h" #include "Playerbots.h" #include "Unit.h" #define MAX_LOOT_OBJECT_COUNT 10 -LootTarget::LootTarget(ObjectGuid guid) : guid(guid), asOfTime(time(nullptr)) -{ -} +LootTarget::LootTarget(ObjectGuid guid) : guid(guid), asOfTime(time(nullptr)) {} LootTarget::LootTarget(LootTarget const& other) { @@ -30,19 +30,16 @@ LootTarget& LootTarget::operator=(LootTarget const& other) return *this; } -bool LootTarget::operator<(LootTarget const& other) const -{ - return guid < other.guid; -} +bool LootTarget::operator<(LootTarget const& other) const { return guid < other.guid; } void LootTargetList::shrink(time_t fromTime) { - for (std::set::iterator i = begin(); i != end(); ) + for (std::set::iterator i = begin(); i != end();) { if (i->asOfTime <= fromTime) erase(i++); - else - ++i; + else + ++i; } } @@ -59,7 +56,8 @@ void LootObject::Refresh(Player* bot, ObjectGuid lootGUID) guid.Clear(); PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - if (!botAI) { + if (!botAI) + { return; } Creature* creature = botAI->GetCreature(lootGUID); @@ -73,7 +71,7 @@ void LootObject::Refresh(Player* bot, ObjectGuid lootGUID) skillId = creature->GetCreatureTemplate()->GetRequiredLootSkill(); uint32 targetLevel = creature->GetLevel(); reqSkillValue = targetLevel < 10 ? 1 : targetLevel < 20 ? (targetLevel - 10) * 10 : targetLevel * 5; - if (botAI->HasSkill((SkillType) skillId) && bot->GetSkillValue(skillId) >= reqSkillValue) + if (botAI->HasSkill((SkillType)skillId) && bot->GetSkillValue(skillId) >= reqSkillValue) guid = lootGUID; } @@ -83,7 +81,6 @@ void LootObject::Refresh(Player* bot, ObjectGuid lootGUID) GameObject* go = botAI->GetGameObject(lootGUID); if (go && go->isSpawned() && go->GetGoState() == GO_STATE_READY) { - bool isQuestItemOnly = false; GameObjectQuestItemList const* items = sObjectMgr->GetGameObjectQuestItemList(go->GetEntry()); @@ -123,21 +120,21 @@ void LootObject::Refresh(Player* bot, ObjectGuid lootGUID) } break; case LOCK_KEY_SKILL: - if (goId == 13891 || goId == 19535) // Serpentbloom + if (goId == 13891 || goId == 19535) // Serpentbloom { this->guid = lootGUID; } else if (SkillByLockType(LockType(lockInfo->Index[i])) > 0) { skillId = SkillByLockType(LockType(lockInfo->Index[i])); - reqSkillValue = std::max((uint32) 1, lockInfo->Skill[i]); + reqSkillValue = std::max((uint32)1, lockInfo->Skill[i]); guid = lootGUID; } break; case LOCK_KEY_NONE: guid = lootGUID; break; - } + } } } } @@ -178,7 +175,8 @@ WorldObject* LootObject::GetWorldObject(Player* bot) Refresh(bot, guid); PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - if (!botAI) { + if (!botAI) + { return nullptr; } Creature* creature = botAI->GetCreature(guid); @@ -206,7 +204,8 @@ bool LootObject::IsLootPossible(Player* bot) return false; PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - if (!botAI) { + if (!botAI) + { return false; } if (reqItem && !bot->HasItemCount(reqItem, 1)) @@ -214,7 +213,7 @@ bool LootObject::IsLootPossible(Player* bot) if (abs(GetWorldObject(bot)->GetPositionZ() - bot->GetPositionZ()) > INTERACTION_DISTANCE) return false; - + Creature* creature = botAI->GetCreature(guid); if (creature && creature->getDeathState() == DeathState::Corpse) { @@ -249,11 +248,13 @@ bool LootObject::IsLootPossible(Player* bot) bool LootObjectStack::Add(ObjectGuid guid) { - if (availableLoot.size() >= MAX_LOOT_OBJECT_COUNT) { + if (availableLoot.size() >= MAX_LOOT_OBJECT_COUNT) + { availableLoot.shrink(time(nullptr) - 30); } - if (availableLoot.size() >= MAX_LOOT_OBJECT_COUNT) { + if (availableLoot.size() >= MAX_LOOT_OBJECT_COUNT) + { availableLoot.clear(); } @@ -270,10 +271,7 @@ void LootObjectStack::Remove(ObjectGuid guid) availableLoot.erase(i); } -void LootObjectStack::Clear() -{ - availableLoot.clear(); -} +void LootObjectStack::Clear() { availableLoot.clear(); } bool LootObjectStack::CanLoot(float maxDistance) { @@ -299,7 +297,7 @@ std::vector LootObjectStack::OrderByDistance(float maxDistance) LootObject lootObject(bot, guid); if (!lootObject.IsLootPossible(bot)) continue; - + float distance = bot->GetDistance(lootObject.GetWorldObject(bot)); if (!maxDistance || distance <= maxDistance) sortedMap[distance] = lootObject; @@ -311,4 +309,3 @@ std::vector LootObjectStack::OrderByDistance(float maxDistance) return result; } - diff --git a/src/LootObjectStack.h b/src/LootObjectStack.h index 05ba0fb5..24153930 100644 --- a/src/LootObjectStack.h +++ b/src/LootObjectStack.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LOOTOBJECTSTACK_H @@ -15,29 +16,29 @@ struct ItemTemplate; class LootStrategy { - public: - LootStrategy() { } - virtual ~LootStrategy() { }; - virtual bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) = 0; - virtual std::string const GetName() = 0; +public: + LootStrategy() {} + virtual ~LootStrategy(){}; + virtual bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) = 0; + virtual std::string const GetName() = 0; }; class LootObject { - public: - LootObject() : skillId(0), reqSkillValue(0), reqItem(0) { } - LootObject(Player* bot, ObjectGuid guid); - LootObject(LootObject const& other); +public: + LootObject() : skillId(0), reqSkillValue(0), reqItem(0) {} + LootObject(Player* bot, ObjectGuid guid); + LootObject(LootObject const& other); - bool IsEmpty() { return !guid; } - bool IsLootPossible(Player* bot); - void Refresh(Player* bot, ObjectGuid guid); - WorldObject* GetWorldObject(Player* bot); - ObjectGuid guid; + bool IsEmpty() { return !guid; } + bool IsLootPossible(Player* bot); + void Refresh(Player* bot, ObjectGuid guid); + WorldObject* GetWorldObject(Player* bot); + ObjectGuid guid; - uint32 skillId; - uint32 reqSkillValue; - uint32 reqItem; + uint32 skillId; + uint32 reqSkillValue; + uint32 reqItem; private: static bool IsNeededForQuest(Player* bot, uint32 itemId); @@ -45,41 +46,41 @@ private: class LootTarget { - public: - LootTarget(ObjectGuid guid); - LootTarget(LootTarget const& other); +public: + LootTarget(ObjectGuid guid); + LootTarget(LootTarget const& other); - public: - LootTarget& operator=(LootTarget const& other); - bool operator<(LootTarget const& other) const; +public: + LootTarget& operator=(LootTarget const& other); + bool operator<(LootTarget const& other) const; - public: - ObjectGuid guid; - time_t asOfTime; +public: + ObjectGuid guid; + time_t asOfTime; }; class LootTargetList : public std::set { - public: - void shrink(time_t fromTime); +public: + void shrink(time_t fromTime); }; class LootObjectStack { - public: - LootObjectStack(Player* bot) : bot(bot) { } +public: + LootObjectStack(Player* bot) : bot(bot) {} - bool Add(ObjectGuid guid); - void Remove(ObjectGuid guid); - void Clear(); - bool CanLoot(float maxDistance); - LootObject GetLoot(float maxDistance = 0); + bool Add(ObjectGuid guid); + void Remove(ObjectGuid guid); + void Clear(); + bool CanLoot(float maxDistance); + LootObject GetLoot(float maxDistance = 0); - private: - std::vector OrderByDistance(float maxDistance = 0); +private: + std::vector OrderByDistance(float maxDistance = 0); - Player* bot; - LootTargetList availableLoot; + Player* bot; + LootTargetList availableLoot; }; #endif diff --git a/src/PerformanceMonitor.cpp b/src/PerformanceMonitor.cpp index 397cef47..6219576e 100644 --- a/src/PerformanceMonitor.cpp +++ b/src/PerformanceMonitor.cpp @@ -1,11 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PerformanceMonitor.h" + #include "Playerbots.h" -PerformanceMonitorOperation* PerformanceMonitor::start(PerformanceMetric metric, std::string const name, PerformanceStack* stack) +PerformanceMonitorOperation* PerformanceMonitor::start(PerformanceMetric metric, std::string const name, + PerformanceStack* stack) { if (!sPlayerbotAIConfig->perfMonEnabled) return nullptr; @@ -50,7 +53,6 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack) if (data.empty()) return; - if (!perTick) { float updateAITotalTime = 0; @@ -58,11 +60,17 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack) if (map.first.find("PlayerbotAI::UpdateAIInternal") != std::string::npos) updateAITotalTime += map.second->totalTime; - LOG_INFO("playerbots", "--------------------------------------[TOTAL BOT]------------------------------------------------------"); - LOG_INFO("playerbots", "percentage time | min .. max ( avg of count) - type : name"); - LOG_INFO("playerbots", "-------------------------------------------------------------------------------------------------------"); + LOG_INFO( + "playerbots", + "--------------------------------------[TOTAL BOT]------------------------------------------------------"); + LOG_INFO("playerbots", + "percentage time | min .. max ( avg of count) - type : name"); + LOG_INFO( + "playerbots", + "-------------------------------------------------------------------------------------------------------"); - for (std::map>::iterator i = data.begin(); i != data.end(); ++i) + for (std::map>::iterator i = data.begin(); + i != data.end(); ++i) { std::map pdMap = i->second; @@ -99,10 +107,9 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack) names.push_back(j->first); } - std::sort(names.begin(), names.end(), [pdMap](std::string const i, std::string const j) - { - return pdMap.at(i)->totalTime < pdMap.at(j)->totalTime; - }); + std::sort(names.begin(), names.end(), + [pdMap](std::string const i, std::string const j) + { return pdMap.at(i)->totalTime < pdMap.at(j)->totalTime; }); uint64 typeTotalTime = 0; uint64 typeMinTime = 0xffffffffu; @@ -128,15 +135,9 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack) if (perc >= 0.1f || avg >= 0.25f || pd->maxTime > 1000) { - LOG_INFO("playerbots", "{:7.3f}% {:10.3f}s | {:7.1f} .. {:7.1f} ({:10.3f} of {:10d}) - {:6} : {}" - , perc - , time - , minTime - , maxTime - , avg - , pd->count - , key.c_str() - , disName.c_str()); + LOG_INFO("playerbots", + "{:7.3f}% {:10.3f}s | {:7.1f} .. {:7.1f} ({:10.3f} of {:10d}) - {:6} : {}", perc, time, + minTime, maxTime, avg, pd->count, key.c_str(), disName.c_str()); } } float tPerc = (float)typeTotalTime / (float)updateAITotalTime * 100.0f; @@ -144,15 +145,8 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack) float tMinTime = (float)typeMinTime / 1000.0f; float tMaxTime = (float)typeMaxTime / 1000.0f; float tAvg = (float)typeTotalTime / (float)typeCount / 1000.0f; - LOG_INFO("playerbots", "{:7.3f}% {:10.3f}s | {:7.1f} .. {:7.1f} ({:10.3f} of {:10d}) - {:6} : {}" - , tPerc - , tTime - , tMinTime - , tMaxTime - , tAvg - , typeCount - , key.c_str() - , "Total"); + LOG_INFO("playerbots", "{:7.3f}% {:10.3f}s | {:7.1f} .. {:7.1f} ({:10.3f} of {:10d}) - {:6} : {}", tPerc, + tTime, tMinTime, tMaxTime, tAvg, typeCount, key.c_str(), "Total"); LOG_INFO("playerbots", " "); } } @@ -161,11 +155,17 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack) float fullTickCount = data[PERF_MON_TOTAL]["RandomPlayerbotMgr::FullTick"]->count; float fullTickTotalTime = data[PERF_MON_TOTAL]["RandomPlayerbotMgr::FullTick"]->totalTime; - LOG_INFO("playerbots", "---------------------------------------[PER TICK]------------------------------------------------------"); - LOG_INFO("playerbots", "percentage time | min .. max ( avg of count) - type : name"); - LOG_INFO("playerbots", "-------------------------------------------------------------------------------------------------------"); + LOG_INFO( + "playerbots", + "---------------------------------------[PER TICK]------------------------------------------------------"); + LOG_INFO("playerbots", + "percentage time | min .. max ( avg of count) - type : name"); + LOG_INFO( + "playerbots", + "-------------------------------------------------------------------------------------------------------"); - for (std::map>::iterator i = data.begin(); i != data.end(); ++i) + for (std::map>::iterator i = data.begin(); + i != data.end(); ++i) { std::map pdMap = i->second; @@ -198,10 +198,9 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack) names.push_back(j->first); } - std::sort(names.begin(), names.end(), [pdMap](std::string const i, std::string const j) - { - return pdMap.at(i)->totalTime < pdMap.at(j)->totalTime; - }); + std::sort(names.begin(), names.end(), + [pdMap](std::string const i, std::string const j) + { return pdMap.at(i)->totalTime < pdMap.at(j)->totalTime; }); uint64 typeTotalTime = 0; uint64 typeMinTime = 0xffffffffu; @@ -227,15 +226,9 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack) disName = disName.substr(0, disName.find("|")) + "]"; if (perc >= 0.1f || avg >= 0.25f || pd->maxTime > 1000) { - LOG_INFO("playerbots", "{:7.3f}% {:9.3f}ms | {:7.1f} .. {:7.1f} ({:10.3f} of {:10.2f}) - {:6} : {}" - , perc - , time - , minTime - , maxTime - , avg - , amount - , key.c_str() - , disName.c_str()); + LOG_INFO("playerbots", + "{:7.3f}% {:9.3f}ms | {:7.1f} .. {:7.1f} ({:10.3f} of {:10.2f}) - {:6} : {}", perc, + time, minTime, maxTime, avg, amount, key.c_str(), disName.c_str()); } } if (PERF_MON_TOTAL != i->first) @@ -246,15 +239,8 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack) float tMaxTime = (float)typeMaxTime / 1000.0f; float tAvg = (float)typeTotalTime / (float)typeCount / 1000.0f; float tAmount = (float)typeCount / fullTickCount; - LOG_INFO("playerbots", "{:7.3f}% {:9.3f}ms | {:7.1f} .. {:7.1f} ({:10.3f} of {:10.2f}) - {:6} : {}" - , tPerc - , tTime - , tMinTime - , tMaxTime - , tAvg - , tAmount - , key.c_str() - , "Total"); + LOG_INFO("playerbots", "{:7.3f}% {:9.3f}ms | {:7.1f} .. {:7.1f} ({:10.3f} of {:10.2f}) - {:6} : {}", + tPerc, tTime, tMinTime, tMaxTime, tAvg, tAmount, key.c_str(), "Total"); } LOG_INFO("playerbots", " "); } @@ -263,7 +249,8 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack) void PerformanceMonitor::Reset() { - for (std::map >::iterator i = data.begin(); i != data.end(); ++i) + for (std::map>::iterator i = data.begin(); + i != data.end(); ++i) { std::map pdMap = i->second; for (std::map::iterator j = pdMap.begin(); j != pdMap.end(); ++j) @@ -278,14 +265,19 @@ void PerformanceMonitor::Reset() } } -PerformanceMonitorOperation::PerformanceMonitorOperation(PerformanceData* data, std::string const name, PerformanceStack* stack) : data(data), name(name), stack(stack) +PerformanceMonitorOperation::PerformanceMonitorOperation(PerformanceData* data, std::string const name, + PerformanceStack* stack) + : data(data), name(name), stack(stack) { - started = (std::chrono::time_point_cast(std::chrono::high_resolution_clock::now())).time_since_epoch(); + started = (std::chrono::time_point_cast(std::chrono::high_resolution_clock::now())) + .time_since_epoch(); } void PerformanceMonitorOperation::finish() { - std::chrono::microseconds finished = (std::chrono::time_point_cast(std::chrono::high_resolution_clock::now())).time_since_epoch(); + std::chrono::microseconds finished = + (std::chrono::time_point_cast(std::chrono::high_resolution_clock::now())) + .time_since_epoch(); uint64_t elapsed = (finished - started).count(); std::lock_guard guard(data->lock); @@ -309,4 +301,3 @@ void PerformanceMonitorOperation::finish() delete this; } - diff --git a/src/PerformanceMonitor.h b/src/PerformanceMonitor.h index 1871020a..77f6e64b 100644 --- a/src/PerformanceMonitor.h +++ b/src/PerformanceMonitor.h @@ -1,18 +1,19 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PERFORMANCEMONITOR_H #define _PLAYERBOT_PERFORMANCEMONITOR_H -#include "Common.h" - #include #include #include #include #include +#include "Common.h" + typedef std::vector PerformanceStack; struct PerformanceData @@ -35,36 +36,37 @@ enum PerformanceMetric class PerformanceMonitorOperation { - public: - PerformanceMonitorOperation(PerformanceData* data, std::string const name, PerformanceStack* stack); - void finish(); +public: + PerformanceMonitorOperation(PerformanceData* data, std::string const name, PerformanceStack* stack); + void finish(); - private: - PerformanceData* data; - std::string const name; - PerformanceStack* stack; - std::chrono::microseconds started; +private: + PerformanceData* data; + std::string const name; + PerformanceStack* stack; + std::chrono::microseconds started; }; class PerformanceMonitor { - public: - PerformanceMonitor() { }; - virtual ~PerformanceMonitor() { }; - static PerformanceMonitor* instance() - { - static PerformanceMonitor instance; - return &instance; - } +public: + PerformanceMonitor(){}; + virtual ~PerformanceMonitor(){}; + static PerformanceMonitor* instance() + { + static PerformanceMonitor instance; + return &instance; + } - public: - PerformanceMonitorOperation* start(PerformanceMetric metric, std::string const name, PerformanceStack* stack = nullptr); - void PrintStats(bool perTick = false, bool fullStack = false); - void Reset(); +public: + PerformanceMonitorOperation* start(PerformanceMetric metric, std::string const name, + PerformanceStack* stack = nullptr); + void PrintStats(bool perTick = false, bool fullStack = false); + void Reset(); - private: - std::map > data; - std::mutex lock; +private: + std::map > data; + std::mutex lock; }; #define sPerformanceMonitor PerformanceMonitor::instance() diff --git a/src/PlaceholderHelper.cpp b/src/PlaceholderHelper.cpp index 6e4729cf..d2b215e2 100644 --- a/src/PlaceholderHelper.cpp +++ b/src/PlaceholderHelper.cpp @@ -1,18 +1,17 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PlaceholderHelper.h" + #include "AiFactory.h" -#include "Playerbots.h" #include "PlayerbotTextMgr.h" +#include "Playerbots.h" #include "Util.h" -void PlaceholderHelper::MapDungeon( - PlaceholderMap& placeholders, - DungeonSuggestion const* dungeonSuggestion, - Player* bot -) +void PlaceholderHelper::MapDungeon(PlaceholderMap& placeholders, DungeonSuggestion const* dungeonSuggestion, + Player* bot) { std::ostringstream out; Insertion insertion = {out, dungeonSuggestion}; @@ -23,7 +22,6 @@ void PlaceholderHelper::MapDungeon( placeholders["%dungeon"] = out.str(); } - void PlaceholderHelper::MapRole(PlaceholderMap& placeholders, Player* bot) { BotRoles const role = AiFactory::GetPlayerRoles(bot); @@ -82,8 +80,8 @@ void PlaceholderHelper::InsertDifficulty(Insertion& insertion, [[maybe_unused]] { bool const isRandomlyNormal = urand(0, 1); bool const isRandomlyHeroic = urand(0, 1); - std::vector normalAbbrevations = { "Normal", "N" }; - std::vector heroicAbbrevations = { "Heroic", "HC", "H"}; + std::vector normalAbbrevations = {"Normal", "N"}; + std::vector heroicAbbrevations = {"Heroic", "HC", "H"}; uint32 const randomAbbrevationIndex = urand(0, 1); if (isRandomlyNormal) { diff --git a/src/PlaceholderHelper.h b/src/PlaceholderHelper.h index 75a85e36..c6a50eea 100644 --- a/src/PlaceholderHelper.h +++ b/src/PlaceholderHelper.h @@ -1,38 +1,35 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PLACEHOLDERHELPER_H #define _PLAYERBOT_PLACEHOLDERHELPER_H +#include + #include "Common.h" #include "Player.h" #include "PlayerbotDungeonSuggestionMgr.h" -#include - typedef std::map PlaceholderMap; class PlaceholderHelper { - public: - static void MapRole(PlaceholderMap& placeholders, Player* bot); - static void MapDungeon( - PlaceholderMap& placeholders, - DungeonSuggestion const* dungeonSuggestion, - Player* bot - ); +public: + static void MapRole(PlaceholderMap& placeholders, Player* bot); + static void MapDungeon(PlaceholderMap& placeholders, DungeonSuggestion const* dungeonSuggestion, Player* bot); - private: - struct Insertion - { - std::ostringstream& out; - DungeonSuggestion const* dungeonSuggestion; - }; +private: + struct Insertion + { + std::ostringstream& out; + DungeonSuggestion const* dungeonSuggestion; + }; - static void InsertDungeonName(Insertion& insertion); - static void InsertDungeonStrategy(Insertion& insertion); - static void InsertDifficulty(Insertion& insertion, Player* bot); + static void InsertDungeonName(Insertion& insertion); + static void InsertDungeonStrategy(Insertion& insertion); + static void InsertDifficulty(Insertion& insertion, Player* bot); }; #endif diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 52dcbfbf..5394959f 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -1,14 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ -#include "MotionMaster.h" -#include "MoveSpline.h" -#include "MoveSplineInit.h" -#include "ObjectGuid.h" -#include "Player.h" #include "PlayerbotAI.h" -#include "Playerbots.h" + +#include +#include +#include + #include "AiFactory.h" #include "BudgetValues.h" #include "CharacterPackets.h" @@ -16,18 +16,26 @@ #include "EmoteAction.h" #include "Engine.h" #include "ExternalEventHelper.h" +#include "GuildMgr.h" #include "GuildTaskMgr.h" +#include "LFGMgr.h" +#include "LastMovementValue.h" +#include "LastSpellCastValue.h" +#include "LogLevelAction.h" #include "LootObjectStack.h" #include "MapMgr.h" -#include "LFGMgr.h" -#include "LogLevelAction.h" -#include "LastSpellCastValue.h" -#include "LastMovementValue.h" +#include "MotionMaster.h" +#include "MoveSpline.h" +#include "MoveSplineInit.h" +#include "ObjectGuid.h" #include "PerformanceMonitor.h" +#include "Player.h" #include "PlayerbotDbStore.h" #include "PlayerbotMgr.h" +#include "Playerbots.h" #include "PointMovementGenerator.h" #include "PositionValue.h" +#include "SayAction.h" #include "ScriptMgr.h" #include "ServerFacade.h" #include "SharedDefines.h" @@ -36,11 +44,6 @@ #include "Unit.h" #include "UpdateTime.h" #include "Vehicle.h" -#include "GuildMgr.h" -#include "SayAction.h" -#include -#include -#include std::vector PlayerbotAI::dispel_whitelist = { "mutating injection", @@ -54,7 +57,7 @@ std::string& trim(std::string& s); std::set PlayerbotAI::unsecuredCommands; -PlayerbotChatHandler::PlayerbotChatHandler(Player* pMasterPlayer) : ChatHandler(pMasterPlayer->GetSession()) { } +PlayerbotChatHandler::PlayerbotChatHandler(Player* pMasterPlayer) : ChatHandler(pMasterPlayer->GetSession()) {} uint32 PlayerbotChatHandler::extractQuestId(std::string const str) { @@ -63,10 +66,7 @@ uint32 PlayerbotChatHandler::extractQuestId(std::string const str) return cId ? atol(cId) : 0; } -void PacketHandlingHelper::AddHandler(uint16 opcode, std::string const handler) -{ - handlers[opcode] = handler; -} +void PacketHandlingHelper::AddHandler(uint16 opcode, std::string const handler) { handlers[opcode] = handler; } void PacketHandlingHelper::Handle(ExternalEventHelper& helper) { @@ -84,14 +84,23 @@ void PacketHandlingHelper::AddPacket(WorldPacket const& packet) // assert(handlers); // assert(packet); // assert(packet.GetOpcode()); - if (handlers.find(packet.GetOpcode()) != handlers.end()) + if (handlers.find(packet.GetOpcode()) != handlers.end()) queue.push(WorldPacket(packet)); } -PlayerbotAI::PlayerbotAI() : PlayerbotAIBase(true), bot(nullptr), aiObjectContext(nullptr), - currentEngine(nullptr), chatHelper(this), chatFilter(this), accountId(0), security(nullptr), master(nullptr), currentState(BOT_STATE_NON_COMBAT) +PlayerbotAI::PlayerbotAI() + : PlayerbotAIBase(true), + bot(nullptr), + aiObjectContext(nullptr), + currentEngine(nullptr), + chatHelper(this), + chatFilter(this), + accountId(0), + security(nullptr), + master(nullptr), + currentState(BOT_STATE_NON_COMBAT) { - for (uint8 i = 0 ; i < BOT_STATE_MAX; i++) + for (uint8 i = 0; i < BOT_STATE_MAX; i++) engines[i] = nullptr; for (uint8 i = 0; i < MAX_ACTIVITY_TYPE; i++) @@ -101,7 +110,13 @@ PlayerbotAI::PlayerbotAI() : PlayerbotAIBase(true), bot(nullptr), aiObjectContex } } -PlayerbotAI::PlayerbotAI(Player* bot) : PlayerbotAIBase(true), bot(bot), chatHelper(this), chatFilter(this), master(nullptr), security(bot) // reorder args - whipowill +PlayerbotAI::PlayerbotAI(Player* bot) + : PlayerbotAIBase(true), + bot(bot), + chatHelper(this), + chatFilter(this), + master(nullptr), + security(bot) // reorder args - whipowill { if (!bot->isTaxiCheater() && HasCheat((BotCheatMask::taxi))) bot->SetTaxiCheater(true); @@ -112,7 +127,7 @@ PlayerbotAI::PlayerbotAI(Player* bot) : PlayerbotAIBase(true), bot(bot), chatHel allowActive[i] = false; } - accountId = bot->GetSession()->GetAccountId(); + accountId = bot->GetSession()->GetAccountId(); aiObjectContext = AiFactory::createAiObjectContext(bot, this); @@ -171,7 +186,6 @@ PlayerbotAI::PlayerbotAI(Player* bot) : PlayerbotAIBase(true), bot(bot), chatHel botOutgoingPacketHandlers.AddHandler(SMSG_QUEST_CONFIRM_ACCEPT, "quest confirm accept"); botOutgoingPacketHandlers.AddHandler(SMSG_GROUP_DESTROYED, "group destroyed"); botOutgoingPacketHandlers.AddHandler(SMSG_GROUP_LIST, "group list"); - masterOutgoingPacketHandlers.AddHandler(SMSG_PARTY_COMMAND_RESULT, "party command"); masterOutgoingPacketHandlers.AddHandler(MSG_RAID_READY_CHECK, "ready check"); @@ -181,7 +195,7 @@ PlayerbotAI::PlayerbotAI(Player* bot) : PlayerbotAIBase(true), bot(bot), chatHel PlayerbotAI::~PlayerbotAI() { - for (uint8 i = 0 ; i < BOT_STATE_MAX; i++) + for (uint8 i = 0; i < BOT_STATE_MAX; i++) { if (engines[i]) delete engines[i]; @@ -201,7 +215,8 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) else nextAICheckDelay = 0; - if (!bot || !bot->IsInWorld()) { + if (!bot || !bot->IsInWorld()) + { return; } @@ -209,10 +224,12 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) { return; } - if (bot->IsDuringRemoveFromWorld()) { + if (bot->IsDuringRemoveFromWorld()) + { return; } - // if (!GetMaster() || !GetMaster()->IsInWorld() || !GetMaster()->GetSession() || GetMaster()->GetSession()->isLogingOut()) { + // if (!GetMaster() || !GetMaster()->IsInWorld() || !GetMaster()->GetSession() || + // GetMaster()->GetSession()->isLogingOut()) { // return; // } // if (bot->HasUnitMovementFlag(MOVEMENTFLAG_FALLING)) { @@ -243,7 +260,7 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) // if (bot->GetPositionZ() - z > 0.1f) { // } - + // wake up if in combat // if (bot->IsInCombat()) // { @@ -302,15 +319,17 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) return; } - if (!bot->InBattleground() && !bot->inRandomLfgDungeon() && bot->GetGroup()) { + if (!bot->InBattleground() && !bot->inRandomLfgDungeon() && bot->GetGroup()) + { Player* leader = bot->GetGroup()->GetLeader(); PlayerbotAI* leaderAI = GET_PLAYERBOT_AI(leader); - if (leaderAI && !leaderAI->IsRealPlayer()) { + if (leaderAI && !leaderAI->IsRealPlayer()) + { bot->RemoveFromGroup(); ResetStrategies(); } } - + bool min = minimal; UpdateAIInternal(elapsed, min); inCombat = bot->IsInCombat(); @@ -321,8 +340,6 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) if (HasRealPlayerMaster()) min = false; - - YieldThread(min); } @@ -333,7 +350,8 @@ void PlayerbotAI::UpdateAIInternal([[maybe_unused]] uint32 elapsed, bool minimal 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); std::vector delayed; @@ -352,10 +370,8 @@ void PlayerbotAI::UpdateAIInternal([[maybe_unused]] uint32 elapsed, bool minimal Player* owner = holder.GetOwner(); if (!helper.ParseChatCommand(command, owner) && holder.GetType() == CHAT_MSG_WHISPER) { - // To prevent spam caused by WIM - if (!(command.rfind("WIM", 0) == 0) && - !(command.rfind("QHpr", 0) == 0) - ) + // To prevent spam caused by WIM + if (!(command.rfind("WIM", 0) == 0) && !(command.rfind("QHpr", 0) == 0)) { std::ostringstream out; out << "Unknown command " << command; @@ -372,7 +388,7 @@ void PlayerbotAI::UpdateAIInternal([[maybe_unused]] uint32 elapsed, bool minimal chatCommands.push(*i); } - // chat replies + // chat replies std::list delayedResponses; while (!chatReplies.empty()) { @@ -384,7 +400,8 @@ void PlayerbotAI::UpdateAIInternal([[maybe_unused]] uint32 elapsed, bool minimal chatReplies.pop(); continue; } - ChatReplyAction::ChatReplyDo(bot, holder.m_type, holder.m_guid1, holder.m_guid2, holder.m_msg, holder.m_chanName, holder.m_name); + ChatReplyAction::ChatReplyDo(bot, holder.m_type, holder.m_guid1, holder.m_guid2, holder.m_msg, + holder.m_chanName, holder.m_name); chatReplies.pop(); } @@ -407,8 +424,10 @@ void PlayerbotAI::UpdateAIInternal([[maybe_unused]] uint32 elapsed, bool minimal logout = true; } - if (master && (master->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || master->HasUnitState(UNIT_STATE_IN_FLIGHT) || - (master->GetSession() && master->GetSession()->GetSecurity() >= (AccountTypes)sWorld->getIntConfig(CONFIG_INSTANT_LOGOUT)))) + if (master && + (master->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || master->HasUnitState(UNIT_STATE_IN_FLIGHT) || + (master->GetSession() && + master->GetSession()->GetSecurity() >= (AccountTypes)sWorld->getIntConfig(CONFIG_INSTANT_LOGOUT)))) { logout = true; } @@ -437,9 +456,9 @@ void PlayerbotAI::UpdateAIInternal([[maybe_unused]] uint32 elapsed, bool minimal masterIncomingPacketHandlers.Handle(helper); masterOutgoingPacketHandlers.Handle(helper); - DoNextAction(minimal); + DoNextAction(minimal); - if (pmo) + if (pmo) pmo->finish(); } @@ -448,28 +467,32 @@ void PlayerbotAI::HandleTeleportAck() if (IsRealPlayer()) return; - bot->GetMotionMaster()->Clear(true); - bot->StopMoving(); - if (bot->IsBeingTeleportedNear()) { + bot->GetMotionMaster()->Clear(true); + bot->StopMoving(); + if (bot->IsBeingTeleportedNear()) + { // Temporary fix for instance can not enter - if (!bot->IsInWorld()) { + if (!bot->IsInWorld()) + { bot->GetMap()->AddPlayerToMap(bot); } - while (bot->IsInWorld() && bot->IsBeingTeleportedNear()) { + while (bot->IsInWorld() && bot->IsBeingTeleportedNear()) + { Player* plMover = bot->m_mover->ToPlayer(); if (!plMover) return; WorldPacket p = WorldPacket(MSG_MOVE_TELEPORT_ACK, 20); p << plMover->GetPackGUID(); - p << (uint32) 0; // supposed to be flags? not used currently - p << (uint32) 0; // time - not currently used + p << (uint32)0; // supposed to be flags? not used currently + p << (uint32)0; // time - not currently used bot->GetSession()->HandleMoveTeleportAck(p); } SetNextCheckDelay(urand(1000, 3000)); } - if (bot->IsBeingTeleportedFar()) - { - while (bot->IsBeingTeleportedFar()) { + if (bot->IsBeingTeleportedFar()) + { + while (bot->IsBeingTeleportedFar()) + { bot->GetSession()->HandleMoveWorldportAck(); } SetNextCheckDelay(urand(2000, 5000)); @@ -517,7 +540,9 @@ void PlayerbotAI::Reset(bool full) aiObjectContext->GetValue("last movement")->Get().Set(nullptr); aiObjectContext->GetValue("last area trigger")->Get().Set(nullptr); aiObjectContext->GetValue("last taxi")->Get().Set(nullptr); - aiObjectContext->GetValue("travel target")->Get()->setTarget(sTravelMgr->nullTravelDestination, sTravelMgr->nullWorldPosition, true); + aiObjectContext->GetValue("travel target") + ->Get() + ->setTarget(sTravelMgr->nullTravelDestination, sTravelMgr->nullWorldPosition, true); aiObjectContext->GetValue("travel target")->Get()->setStatus(TRAVEL_STATUS_EXPIRED); aiObjectContext->GetValue("travel target")->Get()->setExpireIn(1000); } @@ -621,13 +646,15 @@ void PlayerbotAI::HandleCommand(uint32 type, std::string const text, Player* fro { std::string const response = HandleRemoteCommand(filtered.substr(6)); WorldPacket data; - ChatHandler::BuildChatPacket(data, (ChatMsg)type, type == CHAT_MSG_ADDON ? LANG_ADDON : LANG_UNIVERSAL, bot, nullptr, response.c_str()); + ChatHandler::BuildChatPacket(data, (ChatMsg)type, type == CHAT_MSG_ADDON ? LANG_ADDON : LANG_UNIVERSAL, bot, + nullptr, response.c_str()); fromPlayer->SendDirectMessage(&data); return; } - if (!IsAllowedCommand(filtered) && - (master != fromPlayer || !GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_ALLOW_ALL, type != CHAT_MSG_WHISPER, fromPlayer))) + if (!IsAllowedCommand(filtered) && + (master != fromPlayer || + !GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_ALLOW_ALL, type != CHAT_MSG_WHISPER, fromPlayer))) return; if (!IsAllowedCommand(filtered) && master != fromPlayer) @@ -641,7 +668,8 @@ void PlayerbotAI::HandleCommand(uint32 type, std::string const text, Player* fro 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 ")) { std::string const action = filtered.substr(filtered.find(" ") + 1); DoSpecificAction(action); @@ -708,16 +736,17 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet) { if (packet.empty()) return; - if (!bot || !bot->IsInWorld() || bot->IsDuringRemoveFromWorld()) { + if (!bot || !bot->IsInWorld() || bot->IsDuringRemoveFromWorld()) + { return; } - switch (packet.GetOpcode()) - { - case SMSG_SPELL_FAILURE: - { - WorldPacket p(packet); - p.rpos(0); - ObjectGuid casterGuid; + switch (packet.GetOpcode()) + { + case SMSG_SPELL_FAILURE: + { + WorldPacket p(packet); + p.rpos(0); + ObjectGuid casterGuid; p >> casterGuid.ReadAsPacked(); if (casterGuid != bot->GetGUID()) return; @@ -733,16 +762,16 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet) p.rpos(0); ObjectGuid casterGuid; p >> casterGuid.ReadAsPacked(); - if (casterGuid != bot->GetGUID()) - return; + if (casterGuid != bot->GetGUID()) + return; - uint32 delaytime; - p >> delaytime; - if (delaytime <= 1000) - IncreaseNextCheckDelay(delaytime); - return; - } - case SMSG_EMOTE: // do not react to NPC emotes + uint32 delaytime; + p >> delaytime; + if (delaytime <= 1000) + IncreaseNextCheckDelay(delaytime); + return; + } + case SMSG_EMOTE: // do not react to NPC emotes { WorldPacket p(packet); ObjectGuid source; @@ -754,7 +783,7 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet) return; } - case SMSG_MESSAGECHAT: // do not react to self or if not ready to reply + case SMSG_MESSAGECHAT: // do not react to self or if not ready to reply { if (!AllowActivity()) return; @@ -784,7 +813,7 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet) p >> guid2; p >> textLen >> message >> chatTag; - if (guid1 != bot->GetGUID()) // do not reply to self + if (guid1 != bot->GetGUID()) // do not reply to self { // try to always reply to real player time_t lastChat = GetAiObjectContext()->GetValue("last said", "chat")->Get(); @@ -800,7 +829,8 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet) if (isRandomBot && isPaused) return; // BG: react only if mentioned or if not channel and real player spoke - if (bot->InBattleground() && bot->GetBattleground() && !(isMentioned || (msgtype != CHAT_MSG_CHANNEL && !isRandomBot))) + if (bot->InBattleground() && bot->GetBattleground() && + !(isMentioned || (msgtype != CHAT_MSG_CHANNEL && !isRandomBot))) return; // Reduce chat spam @@ -810,10 +840,16 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet) if (isRandomBot && urand(0, 20)) return; - if (!message.empty() && ((isRandomBot && !isPaused && (!urand(0, 20) || (!urand(0, 10) && message.find(bot->GetName()) != std::string::npos))) || (!isRandomBot && (isMentioned || !urand(0, 4))))) + if (!message.empty() && + ((isRandomBot && !isPaused && + (!urand(0, 20) || + (!urand(0, 10) && message.find(bot->GetName()) != std::string::npos))) || + (!isRandomBot && (isMentioned || !urand(0, 4))))) { QueueChatResponse(msgtype, guid1, ObjectGuid(), message, chanName, name); - GetAiObjectContext()->GetValue("last said", "chat")->Set(time(0) + urand(5, 25)); + GetAiObjectContext() + ->GetValue("last said", "chat") + ->Set(time(0) + urand(5, 25)); return; } } @@ -825,7 +861,7 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet) return; } - case SMSG_MOVE_KNOCK_BACK: // handle knockbacks + case SMSG_MOVE_KNOCK_BACK: // handle knockbacks { WorldPacket p(packet); p.rpos(0); @@ -835,7 +871,8 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet) float vcos, vsin, horizontalSpeed, verticalSpeed = 0.f; p >> guid.ReadAsPacked() >> counter >> vcos >> vsin >> horizontalSpeed >> verticalSpeed; - if (horizontalSpeed <= 0.1f) { + if (horizontalSpeed <= 0.1f) + { horizontalSpeed = 0.11f; } verticalSpeed = -verticalSpeed; @@ -848,8 +885,9 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet) bot->GetMotionMaster()->Clear(); Unit* currentTarget = GetAiObjectContext()->GetValue("current target")->Get(); - bot->GetMotionMaster()->MoveKnockbackFromForPlayer(bot->GetPositionX() + vcos, bot->GetPositionY() + vsin, horizontalSpeed, verticalSpeed); - + bot->GetMotionMaster()->MoveKnockbackFromForPlayer(bot->GetPositionX() + vcos, bot->GetPositionY() + vsin, + horizontalSpeed, verticalSpeed); + // bot->AddUnitMovementFlag(MOVEMENTFLAG_FALLING); // bot->AddUnitMovementFlag(MOVEMENTFLAG_FORWARD); // bot->m_movementInfo.AddMovementFlag(MOVEMENTFLAG_PENDING_STOP); @@ -891,15 +929,15 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet) // // // set jump destination for MSG_LAND packet // SetJumpDestination(Position(x, y, z, bot->GetOrientation())); - + // bot->Heart(); // */ return; } - default: - botOutgoingPacketHandlers.AddPacket(packet); - } + default: + botOutgoingPacketHandlers.AddPacket(packet); + } } void PlayerbotAI::SpellInterrupted(uint32 spellid) @@ -977,7 +1015,7 @@ void PlayerbotAI::DoNextAction(bool min) SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown); return; } - + if (bot->HasUnitState(UNIT_STATE_IN_FLIGHT)) { SetNextCheckDelay(sPlayerbotAIConfig->passiveDelay); @@ -991,8 +1029,8 @@ void PlayerbotAI::DoNextAction(bool min) bot->GetMotionMaster()->Clear(); bot->GetMotionMaster()->MoveIdle(); - //Death Count to prevent skeleton piles - Player* master = GetMaster(); // warning here - whipowill + // Death Count to prevent skeleton piles + Player* master = GetMaster(); // warning here - whipowill if (!HasActivePlayerMaster() && !bot->InBattleground()) { uint32 dCount = aiObjectContext->GetValue("death count")->Get(); @@ -1019,7 +1057,8 @@ void PlayerbotAI::DoNextAction(bool min) if (currentEngine == engines[BOT_STATE_NON_COMBAT] && bot->IsInCombat()) { if (aiObjectContext->GetValue("current target")->Get() != nullptr || - aiObjectContext->GetValue("pull target")->Get() != ObjectGuid::Empty || aiObjectContext->GetValue("dps target")->Get() != nullptr) + aiObjectContext->GetValue("pull target")->Get() != ObjectGuid::Empty || + aiObjectContext->GetValue("dps target")->Get() != nullptr) { Reset(); } @@ -1049,7 +1088,8 @@ void PlayerbotAI::DoNextAction(bool min) if ((!master || (masterBotAI && !masterBotAI->IsRealPlayer())) && group) { PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - if (!botAI) { + if (!botAI) + { return; } // Ideally we want to have the leader as master. @@ -1088,7 +1128,9 @@ void PlayerbotAI::DoNextAction(bool min) } // same BG - if (bot->InBattleground() && bot->GetBattleground() && bot->GetBattleground()->GetBgTypeID() == BATTLEGROUND_AV && !GET_PLAYERBOT_AI(member) && member->InBattleground() && bot->GetMapId() == member->GetMapId()) + if (bot->InBattleground() && bot->GetBattleground() && + bot->GetBattleground()->GetBgTypeID() == BATTLEGROUND_AV && !GET_PLAYERBOT_AI(member) && + member->InBattleground() && bot->GetMapId() == member->GetMapId()) { // TODO disable move to objective if have master in bg continue; @@ -1149,7 +1191,8 @@ void PlayerbotAI::DoNextAction(bool min) if (master && master->IsInWorld()) { - if (master->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING) && sServerFacade->GetDistance2d(bot, master) < 20.0f) + if (master->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING) && + sServerFacade->GetDistance2d(bot, master) < 20.0f) bot->m_movementInfo.AddMovementFlag(MOVEMENTFLAG_WALKING); else bot->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_WALKING); @@ -1166,15 +1209,17 @@ void PlayerbotAI::DoNextAction(bool min) bot->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_WALKING); else if ((nextAICheckDelay < 1000) && bot->IsSitState()) bot->SetStandState(UNIT_STAND_STATE_STAND); - - bool hasMountAura = bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED) || bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED); + + bool hasMountAura = bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED) || + bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED); if (hasMountAura && !bot->IsMounted()) { bot->RemoveAurasByType(SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED); bot->RemoveAurasByType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED); } - // if (bot->IsFlying() && !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !bot->HasAuraType(SPELL_AURA_FLY)) + // if (bot->IsFlying() && !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && + // !bot->HasAuraType(SPELL_AURA_FLY)) // { // if (bot->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING)) // bot->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_FLYING); @@ -1186,37 +1231,37 @@ void PlayerbotAI::DoNextAction(bool min) // bot->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); // } -/* - // land after kncokback/jump - if (bot->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING)) - { - // stop movement - bot->StopMoving(); - bot->GetMotionMaster()->Clear(); - bot->GetMotionMaster()->MoveIdle(); + /* + // land after kncokback/jump + if (bot->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING)) + { + // stop movement + bot->StopMoving(); + bot->GetMotionMaster()->Clear(); + bot->GetMotionMaster()->MoveIdle(); - // remove moveFlags - bot->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_FALLING); - bot->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_PENDING_STOP); + // remove moveFlags + bot->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_FALLING); + bot->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_PENDING_STOP); - // set jump destination - bot->m_movementInfo.pos = !GetJumpDestination().m_positionZ == 0 ? GetJumpDestination() : bot->GetPosition(); - bot->m_movementInfo.jump = MovementInfo::JumpInfo(); + // set jump destination + bot->m_movementInfo.pos = !GetJumpDestination().m_positionZ == 0 ? GetJumpDestination() : + bot->GetPosition(); bot->m_movementInfo.jump = MovementInfo::JumpInfo(); - WorldPacket land(MSG_MOVE_FALL_LAND); - land << bot->GetGUID().WriteAsPacked(); - bot->m_mover->BuildMovementPacket(&land); - bot->GetSession()->HandleMovementOpcodes(land); + WorldPacket land(MSG_MOVE_FALL_LAND); + land << bot->GetGUID().WriteAsPacked(); + bot->m_mover->BuildMovementPacket(&land); + bot->GetSession()->HandleMovementOpcodes(land); - // move stop - WorldPacket stop(MSG_MOVE_STOP); - stop << bot->GetGUID().WriteAsPacked(); - bot->m_mover->BuildMovementPacket(&stop); - bot->GetSession()->HandleMovementOpcodes(stop); + // move stop + WorldPacket stop(MSG_MOVE_STOP); + stop << bot->GetGUID().WriteAsPacked(); + bot->m_mover->BuildMovementPacket(&stop); + bot->GetSession()->HandleMovementOpcodes(stop); - ResetJumpDestination(); - } -*/ + ResetJumpDestination(); + } + */ } void PlayerbotAI::ReInitCurrentEngine() @@ -1256,7 +1301,7 @@ bool PlayerbotAI::DoSpecificAction(std::string const name, Event event, bool sil { std::ostringstream out; - for (uint8 i = 0 ; i < BOT_STATE_MAX; i++) + for (uint8 i = 0; i < BOT_STATE_MAX; i++) { ActionResult res = engines[i]->ExecuteAction(name, event, qualifier); switch (res) @@ -1320,7 +1365,9 @@ bool PlayerbotAI::PlayEmote(uint32 emote) WorldPacket data(SMSG_TEXT_EMOTE); data << (TextEmotes)emote; data << EmoteAction::GetNumberOfEmoteVariants((TextEmotes)emote, bot->getRace(), bot->getGender()); - data << ((master && (sServerFacade->GetDistance2d(bot, master) < 30.0f) && urand(0, 1)) ? master->GetGUID() : (bot->GetTarget() && urand(0, 1)) ? bot->GetTarget() : ObjectGuid::Empty); + data << ((master && (sServerFacade->GetDistance2d(bot, master) < 30.0f) && urand(0, 1)) ? master->GetGUID() + : (bot->GetTarget() && urand(0, 1)) ? bot->GetTarget() + : ObjectGuid::Empty); bot->GetSession()->HandleTextEmoteOpcode(data); return false; @@ -1328,7 +1375,7 @@ bool PlayerbotAI::PlayEmote(uint32 emote) bool PlayerbotAI::ContainsStrategy(StrategyType type) { - for (uint8 i = 0 ; i < BOT_STATE_MAX; i++) + for (uint8 i = 0; i < BOT_STATE_MAX; i++) { if (engines[i]->ContainsStrategy(type)) return true; @@ -1337,14 +1384,11 @@ bool PlayerbotAI::ContainsStrategy(StrategyType type) return false; } -bool PlayerbotAI::HasStrategy(std::string const name, BotState type) -{ - return engines[type]->HasStrategy(name); -} +bool PlayerbotAI::HasStrategy(std::string const name, BotState type) { return engines[type]->HasStrategy(name); } void PlayerbotAI::ResetStrategies(bool load) { - for (uint8 i = 0 ; i < BOT_STATE_MAX; i++) + for (uint8 i = 0; i < BOT_STATE_MAX; i++) engines[i]->removeAllStrategies(); AiFactory::AddDefaultCombatStrategies(bot, this, engines[BOT_STATE_COMBAT]); @@ -1364,74 +1408,75 @@ bool PlayerbotAI::IsRanged(Player* player) int tab = AiFactory::GetPlayerSpecTab(player); switch (player->getClass()) { - case CLASS_DEATH_KNIGHT: - case CLASS_WARRIOR: - case CLASS_ROGUE: - return false; - break; - case CLASS_DRUID: - if (tab == 1) { + case CLASS_DEATH_KNIGHT: + case CLASS_WARRIOR: + case CLASS_ROGUE: return false; - } - break; - case CLASS_PALADIN: - if (tab != 0) { - return false; - } - break; - case CLASS_SHAMAN: - if (tab == 1) { - return false; - } - break; + break; + case CLASS_DRUID: + if (tab == 1) + { + return false; + } + break; + case CLASS_PALADIN: + if (tab != 0) + { + return false; + } + break; + case CLASS_SHAMAN: + if (tab == 1) + { + return false; + } + break; } return true; } -bool PlayerbotAI::IsMelee(Player *player) -{ - return !IsRanged(player); -} +bool PlayerbotAI::IsMelee(Player* player) { return !IsRanged(player); } -bool PlayerbotAI::IsCaster(Player* player) -{ - return IsRanged(player) && player->getClass() != CLASS_HUNTER; -} +bool PlayerbotAI::IsCaster(Player* player) { return IsRanged(player) && player->getClass() != CLASS_HUNTER; } bool PlayerbotAI::IsCombo(Player* player) { int tab = AiFactory::GetPlayerSpecTab(player); return player->getClass() == CLASS_ROGUE || - (player->getClass() == CLASS_DRUID && player->HasAura(768)); // cat druid + (player->getClass() == CLASS_DRUID && player->HasAura(768)); // cat druid } -bool PlayerbotAI::IsRangedDps(Player* player) -{ - return IsRanged(player) && IsDps(player); -} +bool PlayerbotAI::IsRangedDps(Player* player) { return IsRanged(player) && IsDps(player); } bool PlayerbotAI::IsHealAssistantOfIndex(Player* player, int index) { Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { return false; } Group::MemberSlotList const& slots = group->GetMemberSlots(); int counter = 0; - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { Player* member = ref->GetSource(); - if (group->IsAssistant(member->GetGUID()) && IsHeal(member)) { - if (index == counter) { + if (group->IsAssistant(member->GetGUID()) && IsHeal(member)) + { + if (index == counter) + { return player == member; } counter++; } } // not enough - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { Player* member = ref->GetSource(); - if (!group->IsAssistant(member->GetGUID()) && IsHeal(member)) { - if (index == counter) { + if (!group->IsAssistant(member->GetGUID()) && IsHeal(member)) + { + if (index == counter) + { return player == member; } counter++; @@ -1443,25 +1488,32 @@ bool PlayerbotAI::IsHealAssistantOfIndex(Player* player, int index) bool PlayerbotAI::IsRangedDpsAssistantOfIndex(Player* player, int index) { Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { return false; } Group::MemberSlotList const& slots = group->GetMemberSlots(); int counter = 0; - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { Player* member = ref->GetSource(); - if (group->IsAssistant(member->GetGUID()) && IsRangedDps(member)) { - if (index == counter) { + if (group->IsAssistant(member->GetGUID()) && IsRangedDps(member)) + { + if (index == counter) + { return player == member; } counter++; } } // not enough - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { Player* member = ref->GetSource(); - if (!group->IsAssistant(member->GetGUID()) && IsRangedDps(member)) { - if (index == counter) { + if (!group->IsAssistant(member->GetGUID()) && IsRangedDps(member)) + { + if (index == counter) + { return player == member; } counter++; @@ -1472,12 +1524,14 @@ bool PlayerbotAI::IsRangedDpsAssistantOfIndex(Player* player, int index) bool PlayerbotAI::HasAggro(Unit* unit) { - if (!unit) { + if (!unit) + { return false; } bool isMT = IsMainTank(bot); Unit* victim = unit->GetVictim(); - if (victim && (victim->GetGUID() == bot->GetGUID() || (!isMT && victim->ToPlayer() && IsTank(victim->ToPlayer())))) { + if (victim && (victim->GetGUID() == bot->GetGUID() || (!isMT && victim->ToPlayer() && IsTank(victim->ToPlayer())))) + { return true; } return false; @@ -1486,14 +1540,17 @@ bool PlayerbotAI::HasAggro(Unit* unit) int32 PlayerbotAI::GetGroupSlotIndex(Player* player) { Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { return -1; } Group::MemberSlotList const& slots = group->GetMemberSlots(); int counter = 0; - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { Player* member = ref->GetSource(); - if (player == member) { + if (player == member) + { return counter; } counter++; @@ -1503,21 +1560,26 @@ int32 PlayerbotAI::GetGroupSlotIndex(Player* player) int32 PlayerbotAI::GetRangedIndex(Player* player) { - if (!IsRanged(player)) { + if (!IsRanged(player)) + { return -1; } Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { return -1; } Group::MemberSlotList const& slots = group->GetMemberSlots(); int counter = 0; - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { Player* member = ref->GetSource(); - if (player == member) { + if (player == member) + { return counter; } - if (IsRanged(member)) { + if (IsRanged(member)) + { counter++; } } @@ -1526,21 +1588,26 @@ int32 PlayerbotAI::GetRangedIndex(Player* player) int32 PlayerbotAI::GetClassIndex(Player* player, uint8_t cls) { - if (player->getClass() != cls) { + if (player->getClass() != cls) + { return -1; } Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { return -1; } Group::MemberSlotList const& slots = group->GetMemberSlots(); int counter = 0; - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { Player* member = ref->GetSource(); - if (player == member) { + if (player == member) + { return counter; } - if (member->getClass() == cls) { + if (member->getClass() == cls) + { counter++; } } @@ -1548,21 +1615,26 @@ int32 PlayerbotAI::GetClassIndex(Player* player, uint8_t cls) } int32 PlayerbotAI::GetRangedDpsIndex(Player* player) { - if (!IsRangedDps(player)) { + if (!IsRangedDps(player)) + { return -1; } Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { return -1; } Group::MemberSlotList const& slots = group->GetMemberSlots(); int counter = 0; - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { Player* member = ref->GetSource(); - if (player == member) { + if (player == member) + { return counter; } - if (IsRangedDps(member)) { + if (IsRangedDps(member)) + { counter++; } } @@ -1571,28 +1643,32 @@ int32 PlayerbotAI::GetRangedDpsIndex(Player* player) int32 PlayerbotAI::GetMeleeIndex(Player* player) { - if (IsRanged(player)) { + if (IsRanged(player)) + { return -1; } Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { return -1; } Group::MemberSlotList const& slots = group->GetMemberSlots(); int counter = 0; - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { Player* member = ref->GetSource(); - if (player == member) { + if (player == member) + { return counter; } - if (!IsRanged(member)) { + if (!IsRanged(member)) + { counter++; } } return 0; } - bool PlayerbotAI::IsTank(Player* player) { PlayerbotAI* botAi = GET_PLAYERBOT_AI(player); @@ -1603,22 +1679,27 @@ bool PlayerbotAI::IsTank(Player* player) switch (player->getClass()) { case CLASS_DEATH_KNIGHT: - if (tab == DEATHKNIGT_TAB_BLOOD) { + if (tab == DEATHKNIGT_TAB_BLOOD) + { return true; } break; case CLASS_PALADIN: - if (tab == PALADIN_TAB_PROTECTION) { + if (tab == PALADIN_TAB_PROTECTION) + { return true; } break; case CLASS_WARRIOR: - if (tab == WARRIOR_TAB_PROTECTION) { + if (tab == WARRIOR_TAB_PROTECTION) + { return true; } break; case CLASS_DRUID: - if (tab == DRUID_TAB_FERAL && (player->GetShapeshiftForm() == FORM_BEAR || player->GetShapeshiftForm() == FORM_DIREBEAR || player->HasAura(16931))) { + if (tab == DRUID_TAB_FERAL && (player->GetShapeshiftForm() == FORM_BEAR || + player->GetShapeshiftForm() == FORM_DIREBEAR || player->HasAura(16931))) + { return true; } break; @@ -1635,26 +1716,30 @@ bool PlayerbotAI::IsHeal(Player* player) int tab = AiFactory::GetPlayerSpecTab(player); switch (player->getClass()) { - case CLASS_PRIEST: - if (tab == PRIEST_TAB_DISIPLINE || tab == PRIEST_TAB_HOLY) { - return true; - } - break; - case CLASS_DRUID: - if (tab == DRUID_TAB_RESTORATION) { - return true; - } - break; - case CLASS_SHAMAN: - if (tab == SHAMAN_TAB_RESTORATION) { - return true; - } - break; - case CLASS_PALADIN: - if (tab == PALADIN_TAB_HOLY) { - return true; - } - break; + case CLASS_PRIEST: + if (tab == PRIEST_TAB_DISIPLINE || tab == PRIEST_TAB_HOLY) + { + return true; + } + break; + case CLASS_DRUID: + if (tab == DRUID_TAB_RESTORATION) + { + return true; + } + break; + case CLASS_SHAMAN: + if (tab == SHAMAN_TAB_RESTORATION) + { + return true; + } + break; + case CLASS_PALADIN: + if (tab == PALADIN_TAB_HOLY) + { + return true; + } + break; } return false; } @@ -1668,41 +1753,47 @@ bool PlayerbotAI::IsDps(Player* player) int tab = AiFactory::GetPlayerSpecTab(player); switch (player->getClass()) { - case CLASS_MAGE: - case CLASS_WARLOCK: - case CLASS_HUNTER: - case CLASS_ROGUE: - return true; - case CLASS_PRIEST: - if (tab == PRIEST_TAB_SHADOW) { + case CLASS_MAGE: + case CLASS_WARLOCK: + case CLASS_HUNTER: + case CLASS_ROGUE: return true; - } - break; - case CLASS_DRUID: - if (tab == DRUID_TAB_BALANCE) { - return true; - } - break; - case CLASS_SHAMAN: - if (tab != SHAMAN_TAB_RESTORATION) { - return true; - } - break; - case CLASS_PALADIN: - if (tab == PALADIN_TAB_RETRIBUTION) { - return true; - } - break; - case CLASS_DEATH_KNIGHT: - if (tab != DEATHKNIGT_TAB_BLOOD) { - return true; - } - break; - case CLASS_WARRIOR: - if (tab != WARRIOR_TAB_PROTECTION) { - return true; - } - break; + case CLASS_PRIEST: + if (tab == PRIEST_TAB_SHADOW) + { + return true; + } + break; + case CLASS_DRUID: + if (tab == DRUID_TAB_BALANCE) + { + return true; + } + break; + case CLASS_SHAMAN: + if (tab != SHAMAN_TAB_RESTORATION) + { + return true; + } + break; + case CLASS_PALADIN: + if (tab == PALADIN_TAB_RETRIBUTION) + { + return true; + } + break; + case CLASS_DEATH_KNIGHT: + if (tab != DEATHKNIGT_TAB_BLOOD) + { + return true; + } + break; + case CLASS_WARRIOR: + if (tab != WARRIOR_TAB_PROTECTION) + { + return true; + } + break; } return false; } @@ -1710,101 +1801,115 @@ bool PlayerbotAI::IsDps(Player* player) bool PlayerbotAI::IsMainTank(Player* player) { Group* group = player->GetGroup(); - if (!group) { + if (!group) + { return false; } ObjectGuid mainTank = ObjectGuid(); Group::MemberSlotList const& slots = group->GetMemberSlots(); - for (Group::member_citerator itr = slots.begin(); itr != slots.end(); ++itr) { - if (itr->flags & MEMBER_FLAG_MAINTANK) { + for (Group::member_citerator itr = slots.begin(); itr != slots.end(); ++itr) + { + if (itr->flags & MEMBER_FLAG_MAINTANK) + { mainTank = itr->guid; break; } } - if (mainTank != ObjectGuid::Empty) { + if (mainTank != ObjectGuid::Empty) + { return player->GetGUID() == mainTank; } - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { Player* member = ref->GetSource(); - if (IsTank(member) && member->IsAlive()) { + if (IsTank(member) && member->IsAlive()) + { return player->GetGUID() == member->GetGUID(); } } return false; } -bool PlayerbotAI::IsAssistTank(Player* player) -{ - return IsTank(player) && !IsMainTank(player); -} +bool PlayerbotAI::IsAssistTank(Player* player) { return IsTank(player) && !IsMainTank(player); } bool PlayerbotAI::IsAssistTankOfIndex(Player* player, int index) { Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { return false; } Group::MemberSlotList const& slots = group->GetMemberSlots(); int counter = 0; - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { Player* member = ref->GetSource(); - if (group->IsAssistant(member->GetGUID()) && IsAssistTank(member)) { - if (index == counter) { + if (group->IsAssistant(member->GetGUID()) && IsAssistTank(member)) + { + if (index == counter) + { return player == member; } counter++; } } // not enough - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { Player* member = ref->GetSource(); - if (!group->IsAssistant(member->GetGUID()) && IsAssistTank(member)) { - if (index == counter) { + if (!group->IsAssistant(member->GetGUID()) && IsAssistTank(member)) + { + if (index == counter) + { return player == member; } counter++; } } return false; - } namespace acore { - class UnitByGuidInRangeCheck +class UnitByGuidInRangeCheck +{ +public: + UnitByGuidInRangeCheck(WorldObject const* obj, ObjectGuid guid, float range) + : i_obj(obj), i_range(range), i_guid(guid) { - public: - UnitByGuidInRangeCheck(WorldObject const* obj, ObjectGuid guid, float range) : i_obj(obj), i_range(range), i_guid(guid) { } - WorldObject const& GetFocusObject() const { return *i_obj; } - bool operator()(Unit* u) - { - return u->GetGUID() == i_guid && i_obj->IsWithinDistInMap(u, i_range); - } - private: - WorldObject const* i_obj; - float i_range; - ObjectGuid i_guid; - }; + } + WorldObject const& GetFocusObject() const { return *i_obj; } + bool operator()(Unit* u) { return u->GetGUID() == i_guid && i_obj->IsWithinDistInMap(u, i_range); } - class GameObjectByGuidInRangeCheck - { - public: - GameObjectByGuidInRangeCheck(WorldObject const* obj, ObjectGuid guid, float range) : i_obj(obj), i_range(range), i_guid(guid) { } - WorldObject const& GetFocusObject() const { return *i_obj; } - bool operator()(GameObject* u) - { - if (u && i_obj->IsWithinDistInMap(u, i_range) && u->isSpawned() && u->GetGOInfo() && u->GetGUID() == i_guid) - return true; - - return false; - } - private: - WorldObject const* i_obj; - float i_range; - ObjectGuid i_guid; - }; +private: + WorldObject const* i_obj; + float i_range; + ObjectGuid i_guid; }; +class GameObjectByGuidInRangeCheck +{ +public: + GameObjectByGuidInRangeCheck(WorldObject const* obj, ObjectGuid guid, float range) + : i_obj(obj), i_range(range), i_guid(guid) + { + } + WorldObject const& GetFocusObject() const { return *i_obj; } + bool operator()(GameObject* u) + { + if (u && i_obj->IsWithinDistInMap(u, i_range) && u->isSpawned() && u->GetGOInfo() && u->GetGUID() == i_guid) + return true; + + return false; + } + +private: + WorldObject const* i_obj; + float i_range; + ObjectGuid i_guid; +}; +}; // namespace acore + Unit* PlayerbotAI::GetUnit(ObjectGuid guid) { if (!guid) @@ -1821,8 +1926,10 @@ Player* PlayerbotAI::GetPlayer(ObjectGuid guid) uint32 GetCreatureIdForCreatureTemplateId(uint32 creatureTemplateId) { - QueryResult results = WorldDatabase.Query("SELECT guid FROM `creature` WHERE id1 = {} LIMIT 1;", creatureTemplateId); - if (results) { + QueryResult results = + WorldDatabase.Query("SELECT guid FROM `creature` WHERE id1 = {} LIMIT 1;", creatureTemplateId); + if (results) + { Field* fields = results->Fetch(); return fields[0].Get(); } @@ -1839,7 +1946,8 @@ Unit* PlayerbotAI::GetUnit(CreatureData const* creatureData) return nullptr; uint32 spawnId = creatureData->spawnId; - if (!spawnId) // workaround for CreatureData with missing spawnId (this just uses first matching creatureId in DB, but thats ok this method is only used for battlemasters and theres only 1 of each type) + if (!spawnId) // workaround for CreatureData with missing spawnId (this just uses first matching creatureId in DB, + // but thats ok this method is only used for battlemasters and theres only 1 of each type) spawnId = GetCreatureIdForCreatureTemplateId(creatureData->id1); auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(spawnId); if (creatureBounds.first == creatureBounds.second) @@ -1911,7 +2019,7 @@ bool PlayerbotAI::TellMasterNoFacing(std::string const text, PlayerbotSecurityLe return false; time_t lastSaid = whispers[text]; - + if (!lastSaid || (time(nullptr) - lastSaid) >= sPlayerbotAIConfig->repeatDelay / 1000) { whispers[text] = time(nullptr); @@ -1921,7 +2029,8 @@ bool PlayerbotAI::TellMasterNoFacing(std::string const text, PlayerbotSecurityLe type = currentChat.first; WorldPacket data; - ChatHandler::BuildChatPacket(data, type == CHAT_MSG_ADDON ? CHAT_MSG_PARTY : type, type == CHAT_MSG_ADDON ? LANG_ADDON : LANG_UNIVERSAL, bot, nullptr, text.c_str()); + ChatHandler::BuildChatPacket(data, type == CHAT_MSG_ADDON ? CHAT_MSG_PARTY : type, + type == CHAT_MSG_ADDON ? LANG_ADDON : LANG_UNIVERSAL, bot, nullptr, text.c_str()); master->SendDirectMessage(&data); } @@ -1949,8 +2058,10 @@ bool PlayerbotAI::IsTellAllowed(PlayerbotSecurityLevel securityLevel) if (!GetSecurity()->CheckLevelFor(securityLevel, true, master)) return false; - if (sPlayerbotAIConfig->whisperDistance && !bot->GetGroup() && sRandomPlayerbotMgr->IsRandomBot(bot) && master->GetSession()->GetSecurity() < SEC_GAMEMASTER && - (bot->GetMapId() != master->GetMapId() || sServerFacade->GetDistance2d(bot, master) > sPlayerbotAIConfig->whisperDistance)) + if (sPlayerbotAIConfig->whisperDistance && !bot->GetGroup() && sRandomPlayerbotMgr->IsRandomBot(bot) && + master->GetSession()->GetSecurity() < SEC_GAMEMASTER && + (bot->GetMapId() != master->GetMapId() || + sServerFacade->GetDistance2d(bot, master) > sPlayerbotAIConfig->whisperDistance)) return false; return true; @@ -1966,7 +2077,8 @@ bool PlayerbotAI::TellMaster(std::string const text, PlayerbotSecurityLevel secu if (!master || !TellMasterNoFacing(text, securityLevel)) return false; - if (!bot->isMoving() && !bot->IsInCombat() && bot->GetMapId() == master->GetMapId() && !bot->HasUnitState(UNIT_STATE_IN_FLIGHT) && !bot->IsFlying()) + if (!bot->isMoving() && !bot->IsInCombat() && bot->GetMapId() == master->GetMapId() && + !bot->HasUnitState(UNIT_STATE_IN_FLIGHT) && !bot->IsFlying()) { if (!bot->HasInArc(EMOTE_ANGLE_IN_FRONT, master, sPlayerbotAIConfig->sightDistance)) bot->SetFacingToObject(master); @@ -1991,13 +2103,15 @@ bool IsRealAura(Player* bot, AuraEffect const* aurEff, Unit const* unit) if (stacks >= spellInfo->StackAmount) return true; - if (aurEff->GetCaster() == bot || spellInfo->IsPositive() || spellInfo->Effects[aurEff->GetEffIndex()].IsAreaAuraEffect()) + if (aurEff->GetCaster() == bot || spellInfo->IsPositive() || + spellInfo->Effects[aurEff->GetEffIndex()].IsAreaAuraEffect()) return true; return false; } -bool PlayerbotAI::HasAura(std::string const name, Unit* unit, bool maxStack, bool checkIsOwner, int maxAuraAmount, bool checkDuration) +bool PlayerbotAI::HasAura(std::string const name, Unit* unit, bool maxStack, bool checkIsOwner, int maxAuraAmount, + bool checkDuration) { if (!unit) return false; @@ -2010,49 +2124,54 @@ bool PlayerbotAI::HasAura(std::string const name, Unit* unit, bool maxStack, boo int auraAmount = 0; - for (uint32 auraType = SPELL_AURA_BIND_SIGHT; auraType < TOTAL_AURAS; auraType++) - { - Unit::AuraEffectList const& auras = unit->GetAuraEffectsByType((AuraType)auraType); + for (uint32 auraType = SPELL_AURA_BIND_SIGHT; auraType < TOTAL_AURAS; auraType++) + { + Unit::AuraEffectList const& auras = unit->GetAuraEffectsByType((AuraType)auraType); if (auras.empty()) continue; - for (AuraEffect const* aurEff : auras) - { + for (AuraEffect const* aurEff : auras) + { SpellInfo const* spellInfo = aurEff->GetSpellInfo(); - std::string_view const auraName = spellInfo->SpellName[0]; - if (auraName.empty() || auraName.length() != wnamepart.length() || !Utf8FitTo(auraName, wnamepart)) - continue; + std::string_view const auraName = spellInfo->SpellName[0]; + if (auraName.empty() || auraName.length() != wnamepart.length() || !Utf8FitTo(auraName, wnamepart)) + continue; - if (IsRealAura(bot, aurEff, unit)) - { - if (checkIsOwner && aurEff) { + if (IsRealAura(bot, aurEff, unit)) + { + if (checkIsOwner && aurEff) + { if (aurEff->GetCasterGUID() != bot->GetGUID()) continue; } - if (checkDuration && aurEff) { - if (aurEff->GetBase()->GetDuration() == -1) { + if (checkDuration && aurEff) + { + if (aurEff->GetBase()->GetDuration() == -1) + { continue; } } - uint32 maxStackAmount = spellInfo->StackAmount; + uint32 maxStackAmount = spellInfo->StackAmount; uint32 maxProcCharges = spellInfo->ProcCharges; - - if (maxStack) { + if (maxStack) + { if (maxStackAmount && aurEff->GetBase()->GetStackAmount() >= maxStackAmount) auraAmount++; if (maxProcCharges && aurEff->GetBase()->GetCharges() >= maxProcCharges) auraAmount++; - } else { + } + else + { auraAmount++; } if (maxAuraAmount < 0) return auraAmount > 0; - } - } + } + } } if (maxAuraAmount >= 0) @@ -2065,18 +2184,18 @@ bool PlayerbotAI::HasAura(std::string const name, Unit* unit, bool maxStack, boo bool PlayerbotAI::HasAura(uint32 spellId, Unit const* unit) { - if (!spellId || !unit) - return false; - - return unit->HasAura(spellId); - // for (uint8 effect = EFFECT_0; effect <= EFFECT_2; effect++) - // { - // AuraEffect const* aurEff = unit->GetAuraEffect(spellId, effect); - // if (IsRealAura(bot, aurEff, unit)) - // return true; - // } + if (!spellId || !unit) + return false; - // return false; + return unit->HasAura(spellId); + // for (uint8 effect = EFFECT_0; effect <= EFFECT_2; effect++) + // { + // AuraEffect const* aurEff = unit->GetAuraEffect(spellId, effect); + // if (IsRealAura(bot, aurEff, unit)) + // return true; + // } + + // return false; } Aura* PlayerbotAI::GetAura(std::string const name, Unit* unit, bool checkIsOwner, bool checkDuration, int checkStack) @@ -2090,41 +2209,46 @@ Aura* PlayerbotAI::GetAura(std::string const name, Unit* unit, bool checkIsOwner wstrToLower(wnamepart); - for (uint32 auraType = SPELL_AURA_BIND_SIGHT; auraType < TOTAL_AURAS; auraType++) - { - Unit::AuraEffectList const& auras = unit->GetAuraEffectsByType((AuraType)auraType); + for (uint32 auraType = SPELL_AURA_BIND_SIGHT; auraType < TOTAL_AURAS; auraType++) + { + Unit::AuraEffectList const& auras = unit->GetAuraEffectsByType((AuraType)auraType); if (auras.empty()) continue; - for (AuraEffect const* aurEff : auras) - { + for (AuraEffect const* aurEff : auras) + { SpellInfo const* spellInfo = aurEff->GetSpellInfo(); - std::string const auraName = spellInfo->SpellName[0]; - if (auraName.empty() || auraName.length() != wnamepart.length() || !Utf8FitTo(auraName, wnamepart)) - continue; + std::string const auraName = spellInfo->SpellName[0]; + if (auraName.empty() || auraName.length() != wnamepart.length() || !Utf8FitTo(auraName, wnamepart)) + continue; - if (IsRealAura(bot, aurEff, unit)) - { - if (checkIsOwner && aurEff) { + if (IsRealAura(bot, aurEff, unit)) + { + if (checkIsOwner && aurEff) + { if (aurEff->GetCasterGUID() != bot->GetGUID()) continue; } - if (checkDuration && aurEff) { - if (aurEff->GetBase()->GetDuration() == -1) { + if (checkDuration && aurEff) + { + if (aurEff->GetBase()->GetDuration() == -1) + { continue; } } - if (checkStack != -1 && aurEff) { - if (aurEff->GetBase()->GetStackAmount() < checkStack) { + if (checkStack != -1 && aurEff) + { + if (aurEff->GetBase()->GetStackAmount() < checkStack) + { continue; } } - return aurEff->GetBase(); - } - } + return aurEff->GetBase(); + } + } } return nullptr; @@ -2147,8 +2271,7 @@ bool PlayerbotAI::HasAnyAuraOf(Unit* player, ...) va_end(vl); return true; } - } - while (cur); + } while (cur); va_end(vl); return false; @@ -2161,78 +2284,95 @@ bool PlayerbotAI::CanCastSpell(std::string const name, Unit* target, Item* itemT bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell, Item* itemTarget, Item* castItem) { - if (!spellid) { - if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - LOG_DEBUG("playerbots", "Can cast spell failed. No spellid. - spellid: {}, bot name: {}", - spellid, bot->GetName()); + if (!spellid) + { + if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) + { + LOG_DEBUG("playerbots", "Can cast spell failed. No spellid. - spellid: {}, bot name: {}", spellid, + bot->GetName()); } return false; } - if (bot->HasUnitState(UNIT_STATE_LOST_CONTROL)) { - if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - LOG_DEBUG("playerbots", "Can cast spell failed. Unit state lost control. - spellid: {}, bot name: {}", - spellid, bot->GetName()); + if (bot->HasUnitState(UNIT_STATE_LOST_CONTROL)) + { + if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) + { + LOG_DEBUG("playerbots", "Can cast spell failed. Unit state lost control. - spellid: {}, bot name: {}", + spellid, bot->GetName()); } return false; } - if (!target) target = bot; - + // if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) - // LOG_DEBUG("playerbots", "Can cast spell? - target name: {}, spellid: {}, bot name: {}", + // LOG_DEBUG("playerbots", "Can cast spell? - target name: {}, spellid: {}, bot name: {}", // target->GetName(), spellid, bot->GetName()); if (Pet* pet = bot->GetPet()) if (pet->HasSpell(spellid)) return true; - if (checkHasSpell && !bot->HasSpell(spellid)) { - if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - LOG_DEBUG("playerbots", "Can cast spell failed. Bot not has spell. - target name: {}, spellid: {}, bot name: {}", + if (checkHasSpell && !bot->HasSpell(spellid)) + { + if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) + { + LOG_DEBUG("playerbots", + "Can cast spell failed. Bot not has spell. - target name: {}, spellid: {}, bot name: {}", + target->GetName(), spellid, bot->GetName()); + } + return false; + } + + if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL) != nullptr) + { + if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) + { + LOG_DEBUG( + "playerbots", + "CanCastSpell() target name: {}, spellid: {}, bot name: {}, failed because has current channeled spell", target->GetName(), spellid, bot->GetName()); } return false; } - if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL) != nullptr) { - if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - LOG_DEBUG("playerbots", "CanCastSpell() target name: {}, spellid: {}, bot name: {}, failed because has current channeled spell", - target->GetName(), spellid, bot->GetName()); + if (bot->HasSpellCooldown(spellid)) + { + if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) + { + LOG_DEBUG("playerbots", + "Can cast spell failed. Spell not has cooldown. - target name: {}, spellid: {}, bot name: {}", + target->GetName(), spellid, bot->GetName()); } return false; } - if (bot->HasSpellCooldown(spellid)) { - if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - LOG_DEBUG("playerbots", "Can cast spell failed. Spell not has cooldown. - target name: {}, spellid: {}, bot name: {}", - target->GetName(), spellid, bot->GetName()); - } - return false; - } - - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); - if (!spellInfo) { - if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - LOG_DEBUG("playerbots", "Can cast spell failed. No spellInfo. - target name: {}, spellid: {}, bot name: {}", - target->GetName(), spellid, bot->GetName()); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); + if (!spellInfo) + { + if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) + { + LOG_DEBUG("playerbots", "Can cast spell failed. No spellInfo. - target name: {}, spellid: {}, bot name: {}", + target->GetName(), spellid, bot->GetName()); } return false; } uint32 CastingTime = !spellInfo->IsChanneled() ? spellInfo->CalcCastTime(bot) : spellInfo->GetDuration(); - if (CastingTime && bot->isMoving()) { - if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - LOG_DEBUG("playerbots", "Casting time and bot is moving - target name: {}, spellid: {}, bot name: {}", - target->GetName(), spellid, bot->GetName()); + if (CastingTime && bot->isMoving()) + { + if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) + { + LOG_DEBUG("playerbots", "Casting time and bot is moving - target name: {}, spellid: {}, bot name: {}", + target->GetName(), spellid, bot->GetName()); } return false; } - if (!itemTarget) - { + if (!itemTarget) + { bool positiveSpell = spellInfo->IsPositive(); // if (positiveSpell && bot->IsHostileTo(target)) // return false; @@ -2250,10 +2390,12 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell, // } // } - if (target->IsImmunedToSpell(spellInfo)) { - if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - LOG_DEBUG("playerbots", "target is immuned to spell - target name: {}, spellid: {}, bot name: {}", - target->GetName(), spellid, bot->GetName()); + if (target->IsImmunedToSpell(spellInfo)) + { + if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) + { + LOG_DEBUG("playerbots", "target is immuned to spell - target name: {}, spellid: {}, bot name: {}", + target->GetName(), spellid, bot->GetName()); } return false; } @@ -2264,7 +2406,8 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell, // { // if (target->IsImmunedToSpellEffect(spellInfo, i)) { // if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - // LOG_DEBUG("playerbots", "target is immuned to spell effect - target name: {}, spellid: {}, bot name: {}", + // LOG_DEBUG("playerbots", "target is immuned to spell effect - target name: {}, spellid: {}, + // bot name: {}", // target->GetName(), spellid, bot->GetName()); // } // return false; @@ -2272,22 +2415,26 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell, // } // } - if (bot != target && sServerFacade->GetDistance2d(bot, target) > sPlayerbotAIConfig->sightDistance) { - if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - LOG_DEBUG("playerbots", "target is out of sight distance - target name: {}, spellid: {}, bot name: {}", - target->GetName(), spellid, bot->GetName()); + if (bot != target && sServerFacade->GetDistance2d(bot, target) > sPlayerbotAIConfig->sightDistance) + { + if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) + { + LOG_DEBUG("playerbots", "target is out of sight distance - target name: {}, spellid: {}, bot name: {}", + target->GetName(), spellid, bot->GetName()); } return false; } - } + } - Unit* oldSel = bot->GetSelectedUnit(); - Spell* spell = new Spell(bot, spellInfo, TRIGGERED_NONE); + Unit* oldSel = bot->GetSelectedUnit(); + Spell* spell = new Spell(bot, spellInfo, TRIGGERED_NONE); spell->m_targets.SetUnitTarget(target); spell->m_CastItem = castItem; - if (itemTarget == nullptr) { - itemTarget = aiObjectContext->GetValue("item for spell", spellid)->Get();; + if (itemTarget == nullptr) + { + itemTarget = aiObjectContext->GetValue("item for spell", spellid)->Get(); + ; } spell->m_targets.SetItemTarget(itemTarget); @@ -2296,13 +2443,13 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell, // if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { // if (result != SPELL_FAILED_NOT_READY && result != SPELL_CAST_OK) { - // LOG_DEBUG("playerbots", "CanCastSpell - target name: {}, spellid: {}, bot name: {}, result: {}", + // LOG_DEBUG("playerbots", "CanCastSpell - target name: {}, spellid: {}, bot name: {}, result: {}", // target->GetName(), spellid, bot->GetName(), result); // } // } - if (oldSel) - bot->SetSelection(oldSel->GetGUID()); + if (oldSel) + bot->SetSelection(oldSel->GetGUID()); switch (result) { @@ -2316,10 +2463,12 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell, case SPELL_FAILED_OUT_OF_RANGE: return true; default: - if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { + if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) + { // if (result != SPELL_FAILED_NOT_READY && result != SPELL_CAST_OK) { - LOG_DEBUG("playerbots", "CanCastSpell Check Failed. - target name: {}, spellid: {}, bot name: {}, result: {}", - target->GetName(), spellid, bot->GetName(), result); + LOG_DEBUG("playerbots", + "CanCastSpell Check Failed. - target name: {}, spellid: {}, bot name: {}, result: {}", + target->GetName(), spellid, bot->GetName(), result); } return false; } @@ -2393,7 +2542,8 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effec return false; } -bool PlayerbotAI::CanCastSpell(uint32 spellid, float x, float y, float z, uint8 effectMask, bool checkHasSpell, Item* itemTarget) +bool PlayerbotAI::CanCastSpell(uint32 spellid, float x, float y, float z, uint8 effectMask, bool checkHasSpell, + Item* itemTarget) { if (!spellid) return false; @@ -2454,7 +2604,8 @@ bool PlayerbotAI::CastSpell(std::string const name, Unit* target, Item* itemTarg bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget) { - if (!spellId) { + if (!spellId) + { return false; } @@ -2462,23 +2613,23 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget) target = bot; Pet* pet = bot->GetPet(); - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); - if (pet && pet->HasSpell(spellId)) + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); + if (pet && pet->HasSpell(spellId)) { - bool autocast = false; - for(unsigned int & m_autospell : pet->m_autospells) - { - if (m_autospell == spellId) - { - autocast = true; - break; - } - } + bool autocast = false; + for (unsigned int& m_autospell : pet->m_autospells) + { + if (m_autospell == spellId) + { + autocast = true; + break; + } + } - pet->ToggleAutocast(spellInfo, !autocast); - std::ostringstream out; - out << (autocast ? "|cffff0000|Disabling" : "|cFF00ff00|Enabling") << " pet auto-cast for "; - out << chatHelper.FormatSpell(spellInfo); + pet->ToggleAutocast(spellInfo, !autocast); + std::ostringstream out; + out << (autocast ? "|cffff0000|Disabling" : "|cFF00ff00|Enabling") << " pet auto-cast for "; + out << chatHelper.FormatSpell(spellInfo); TellMaster(out); return true; } @@ -2486,31 +2637,32 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget) aiObjectContext->GetValue("last movement")->Get().Set(nullptr); aiObjectContext->GetValue("stay time")->Set(0); - if (bot->IsFlying() || bot->HasUnitState(UNIT_STATE_IN_FLIGHT)) { + if (bot->IsFlying() || bot->HasUnitState(UNIT_STATE_IN_FLIGHT)) + { // if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - // LOG_DEBUG("playerbots", "Spell cast is flying - target name: {}, spellid: {}, bot name: {}}", + // LOG_DEBUG("playerbots", "Spell cast is flying - target name: {}, spellid: {}, bot name: {}}", // target->GetName(), spellId, bot->GetName()); // } return false; } - // bot->ClearUnitState(UNIT_STATE_CHASE); - // bot->ClearUnitState(UNIT_STATE_FOLLOW); + // bot->ClearUnitState(UNIT_STATE_CHASE); + // bot->ClearUnitState(UNIT_STATE_FOLLOW); - bool failWithDelay = false; + bool failWithDelay = false; if (!bot->IsStandState()) { bot->SetStandState(UNIT_STAND_STATE_STAND); failWithDelay = true; } - ObjectGuid oldSel = bot->GetSelectedUnit() ? bot->GetSelectedUnit()->GetGUID() : ObjectGuid(); - bot->SetSelection(target->GetGUID()); + ObjectGuid oldSel = bot->GetSelectedUnit() ? bot->GetSelectedUnit()->GetGUID() : ObjectGuid(); + bot->SetSelection(target->GetGUID()); WorldObject* faceTo = target; if (!bot->HasInArc(CAST_ANGLE_IN_FRONT, faceTo) && (spellInfo->FacingCasterFlags & SPELL_FACING_FLAG_INFRONT)) { sServerFacade->SetFacingTo(bot, faceTo); - //failWithDelay = true; + // failWithDelay = true; } if (failWithDelay) @@ -2519,12 +2671,13 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget) return false; } - Spell *spell = new Spell(bot, spellInfo, TRIGGERED_NONE); + Spell* spell = new Spell(bot, spellInfo, TRIGGERED_NONE); SpellCastTargets targets; if (spellInfo->Targets & TARGET_FLAG_ITEM) { - spell->m_CastItem = itemTarget ? itemTarget : aiObjectContext->GetValue("item for spell", spellId)->Get(); + spell->m_CastItem = + itemTarget ? itemTarget : aiObjectContext->GetValue("item for spell", spellId)->Get(); targets.SetItemTarget(spell->m_CastItem); if (bot->GetTradeData()) @@ -2532,7 +2685,7 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget) bot->GetTradeData()->SetSpell(spellId); delete spell; // if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - // LOG_DEBUG("playerbots", "Spell cast no item - target name: {}, spellid: {}, bot name: {}", + // LOG_DEBUG("playerbots", "Spell cast no item - target name: {}, spellid: {}, bot name: {}", // target->GetName(), spellId, bot->GetName()); // } return true; @@ -2587,7 +2740,7 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget) // spell->m_targets.SetUnitTarget(target); // SpellCastResult spellSuccess = spell->CheckCast(true); // if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - // LOG_DEBUG("playerbots", "Spell cast result - target name: {}, spellid: {}, bot name: {}, result: {}", + // LOG_DEBUG("playerbots", "Spell cast result - target name: {}, spellid: {}, bot name: {}, result: {}", // target->GetName(), spellId, bot->GetName(), spellSuccess); // } // if (spellSuccess != SPELL_CAST_OK) @@ -2595,14 +2748,16 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget) SpellCastResult result = spell->prepare(&targets); - if (result != SPELL_CAST_OK) { + if (result != SPELL_CAST_OK) + { // if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - // LOG_DEBUG("playerbots", "Spell cast failed. - target name: {}, spellid: {}, bot name: {}, result: {}", + // LOG_DEBUG("playerbots", "Spell cast failed. - target name: {}, spellid: {}, bot name: {}, result: {}", // target->GetName(), spellId, bot->GetName(), result); // } return false; } - // if (spellInfo->Effects[0].Effect == SPELL_EFFECT_OPEN_LOCK || spellInfo->Effects[0].Effect == SPELL_EFFECT_SKINNING) + // if (spellInfo->Effects[0].Effect == SPELL_EFFECT_OPEN_LOCK || spellInfo->Effects[0].Effect == + // SPELL_EFFECT_SKINNING) // { // LootObject loot = *aiObjectContext->GetValue("loot target"); // if (!loot.IsLootPossible(bot)) @@ -2610,7 +2765,7 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget) // spell->cancel(); // delete spell; // if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) { - // LOG_DEBUG("playerbots", "Spell cast loot - target name: {}, spellid: {}, bot name: {}", + // LOG_DEBUG("playerbots", "Spell cast loot - target name: {}, spellid: {}, bot name: {}", // target->GetName(), spellId, bot->GetName()); // } // return false; @@ -2619,14 +2774,15 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget) WaitForSpellCast(spell); if (spell->GetCastTime()) - aiObjectContext->GetValue("last spell cast")->Get().Set(spellId, target->GetGUID(), time(nullptr)); + aiObjectContext->GetValue("last spell cast") + ->Get() + .Set(spellId, target->GetGUID(), time(nullptr)); aiObjectContext->GetValue("position")->Get()["random"].Reset(); if (oldSel) bot->SetSelection(oldSel); - if (HasStrategy("debug spell", BOT_STATE_NON_COMBAT)) { std::ostringstream out; @@ -2647,7 +2803,7 @@ bool PlayerbotAI::CastSpell(uint32 spellId, float x, float y, float z, Item* ite if (pet && pet->HasSpell(spellId)) { bool autocast = false; - for (unsigned int & m_autospell : pet->m_autospells) + for (unsigned int& m_autospell : pet->m_autospells) { if (m_autospell == spellId) { @@ -2698,7 +2854,8 @@ bool PlayerbotAI::CastSpell(uint32 spellId, float x, float y, float z, Item* ite SpellCastTargets targets; if (spellInfo->Targets & TARGET_FLAG_ITEM) { - spell->m_CastItem = itemTarget ? itemTarget : aiObjectContext->GetValue("item for spell", spellId)->Get(); + spell->m_CastItem = + itemTarget ? itemTarget : aiObjectContext->GetValue("item for spell", spellId)->Get(); targets.SetItemTarget(spell->m_CastItem); if (bot->GetTradeData()) @@ -2749,7 +2906,6 @@ bool PlayerbotAI::CastSpell(uint32 spellId, float x, float y, float z, Item* ite } } - WaitForSpellCast(spell); aiObjectContext->GetValue("last spell cast")->Get().Set(spellId, bot->GetGUID(), time(nullptr)); aiObjectContext->GetValue("position")->Get()["random"].Reset(); @@ -2890,15 +3046,15 @@ bool PlayerbotAI::CastVehicleSpell(uint32 spellId, Unit* target) if (seat->CanControl()) { - //aiObjectContext->GetValue("last movement")->Get().Set(nullptr); - //aiObjectContext->GetValue("stay time")->Set(0); + // aiObjectContext->GetValue("last movement")->Get().Set(nullptr); + // aiObjectContext->GetValue("stay time")->Set(0); } - //bot->clearUnitState(UNIT_STAT_CHASE); - //bot->clearUnitState(UNIT_STAT_FOLLOW); + // bot->clearUnitState(UNIT_STAT_CHASE); + // bot->clearUnitState(UNIT_STAT_FOLLOW); - //ObjectGuid oldSel = bot->GetSelectionGuid(); - //bot->SetSelectionGuid(target->GetGUID()); + // ObjectGuid oldSel = bot->GetSelectionGuid(); + // bot->SetSelectionGuid(target->GetGUID()); // turn vehicle if target is not in front bool failWithDelay = false; @@ -2931,7 +3087,8 @@ bool PlayerbotAI::CastVehicleSpell(uint32 spellId, Unit* target) if (spellTarget != vehicleBase) dest = WorldLocation(spellTarget->GetMapId(), spellTarget->GetPosition()); else if (siegePos.isSet()) - dest = WorldLocation(bot->GetMapId(), siegePos.x + frand(-5.0f, 5.0f), siegePos.y + frand(-5.0f, 5.0f), siegePos.z, 0.0f); + dest = WorldLocation(bot->GetMapId(), siegePos.x + frand(-5.0f, 5.0f), siegePos.y + frand(-5.0f, 5.0f), + siegePos.z, 0.0f); else return false; @@ -2972,14 +3129,14 @@ bool PlayerbotAI::CastVehicleSpell(uint32 spellId, Unit* target) vehicleBase->StopMoving(); SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown); spell->cancel(); - //delete spell; + // delete spell; return false; } WaitForSpellCast(spell); - //aiObjectContext->GetValue("last spell cast")->Get().Set(spellId, target->GetGUID(), time(0)); - //aiObjectContext->GetValue("position")->Get()["random"].Reset(); + // aiObjectContext->GetValue("last spell cast")->Get().Set(spellId, target->GetGUID(), time(0)); + // aiObjectContext->GetValue("position")->Get()["random"].Reset(); if (HasStrategy("debug spell", BOT_STATE_NON_COMBAT)) { @@ -3036,7 +3193,7 @@ void PlayerbotAI::WaitForSpellCast(Spell* spell) SpellInfo const* spellInfo = spell->GetSpellInfo(); uint32 castTime = spell->GetCastTime(); // float castTime = spell->GetCastTime(); - // if (spellInfo->IsChanneled()) + // if (spellInfo->IsChanneled()) // { // int32 duration = spellInfo->GetDuration(); // bot->ApplySpellMod(spellInfo->Id, SPELLMOD_DURATION, duration); @@ -3093,27 +3250,30 @@ void PlayerbotAI::RemoveAura(std::string const name) bool PlayerbotAI::IsInterruptableSpellCasting(Unit* target, std::string const spell) { - uint32 spellid = aiObjectContext->GetValue("spell id", spell)->Get(); - if (!spellid || !target->IsNonMeleeSpellCast(true)) - return false; + uint32 spellid = aiObjectContext->GetValue("spell id", spell)->Get(); + if (!spellid || !target->IsNonMeleeSpellCast(true)) + return false; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); - if (!spellInfo) - return false; + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); + if (!spellInfo) + return false; - for (uint8 i = EFFECT_0; i <= EFFECT_2; i++) - { - if ((spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT) && spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) - return true; - - if (spellInfo->Effects[i].Effect == SPELL_EFFECT_INTERRUPT_CAST && !target->IsImmunedToSpellEffect(spellInfo, i)) - return true; - - if ((spellInfo->Effects[i].Effect == SPELL_EFFECT_APPLY_AURA) && spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_SILENCE) + for (uint8 i = EFFECT_0; i <= EFFECT_2; i++) + { + if ((spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT) && + spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) return true; - } - return false; + if (spellInfo->Effects[i].Effect == SPELL_EFFECT_INTERRUPT_CAST && + !target->IsImmunedToSpellEffect(spellInfo, i)) + return true; + + if ((spellInfo->Effects[i].Effect == SPELL_EFFECT_APPLY_AURA) && + spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_SILENCE) + return true; + } + + return false; } bool PlayerbotAI::HasAuraToDispel(Unit* target, uint32 dispelType) @@ -3138,7 +3298,8 @@ bool PlayerbotAI::HasAuraToDispel(Unit* target, uint32 dispelType) if (!isPositiveSpell && !isFriend) continue; - if (sPlayerbotAIConfig->dispelAuraDuration && aura->GetDuration() && aura->GetDuration() < (int32)sPlayerbotAIConfig->dispelAuraDuration) + if (sPlayerbotAIConfig->dispelAuraDuration && aura->GetDuration() && + aura->GetDuration() < (int32)sPlayerbotAIConfig->dispelAuraDuration) continue; if (canDispel(spellInfo, dispelType)) @@ -3151,8 +3312,10 @@ bool PlayerbotAI::HasAuraToDispel(Unit* target, uint32 dispelType) #ifndef WIN32 inline int strcmpi(char const* s1, char const* s2) { - for (; *s1 && *s2 && (toupper(*s1) == toupper(*s2)); ++s1, ++s2) {} - return *s1 - *s2; + for (; *s1 && *s2 && (toupper(*s1) == toupper(*s2)); ++s1, ++s2) + { + } + return *s1 - *s2; } #endif @@ -3160,26 +3323,33 @@ bool PlayerbotAI::canDispel(SpellInfo const* spellInfo, uint32 dispelType) { if (spellInfo->Dispel != dispelType) return false; - - if (!spellInfo->SpellName[0]) { + + if (!spellInfo->SpellName[0]) + { return true; } - for (std::string &wl : dispel_whitelist) { - if (strcmpi((const char*)spellInfo->SpellName[0], wl.c_str()) == 0) { + for (std::string& wl : dispel_whitelist) + { + if (strcmpi((const char*)spellInfo->SpellName[0], wl.c_str()) == 0) + { return false; } } - return !spellInfo->SpellName[0] || (strcmpi((const char*)spellInfo->SpellName[0], "demon skin") && strcmpi((const char*)spellInfo->SpellName[0], "mage armor") && - strcmpi((const char*)spellInfo->SpellName[0], "frost armor") && strcmpi((const char*)spellInfo->SpellName[0], "wavering will") && - strcmpi((const char*)spellInfo->SpellName[0], "chilled") && strcmpi((const char*)spellInfo->SpellName[0], "mana tap") && - strcmpi((const char*)spellInfo->SpellName[0], "ice armor")); + return !spellInfo->SpellName[0] || (strcmpi((const char*)spellInfo->SpellName[0], "demon skin") && + strcmpi((const char*)spellInfo->SpellName[0], "mage armor") && + strcmpi((const char*)spellInfo->SpellName[0], "frost armor") && + strcmpi((const char*)spellInfo->SpellName[0], "wavering will") && + strcmpi((const char*)spellInfo->SpellName[0], "chilled") && + strcmpi((const char*)spellInfo->SpellName[0], "mana tap") && + strcmpi((const char*)spellInfo->SpellName[0], "ice armor")); } bool IsAlliance(uint8 race) { - return race == RACE_HUMAN || race == RACE_DWARF || race == RACE_NIGHTELF || race == RACE_GNOME || race == RACE_DRAENEI; + return race == RACE_HUMAN || race == RACE_DWARF || race == RACE_NIGHTELF || race == RACE_GNOME || + race == RACE_DRAENEI; } bool PlayerbotAI::HasRealPlayerMaster() @@ -3193,15 +3363,9 @@ bool PlayerbotAI::HasRealPlayerMaster() return false; } -bool PlayerbotAI::HasActivePlayerMaster() -{ - return master && !GET_PLAYERBOT_AI(master); -} +bool PlayerbotAI::HasActivePlayerMaster() { return master && !GET_PLAYERBOT_AI(master); } -bool PlayerbotAI::IsAlt() -{ - return HasRealPlayerMaster() && !sRandomPlayerbotMgr->IsRandomBot(bot); -} +bool PlayerbotAI::IsAlt() { return HasRealPlayerMaster() && !sRandomPlayerbotMgr->IsRandomBot(bot); } Player* PlayerbotAI::GetGroupMaster() { @@ -3215,18 +3379,19 @@ Player* PlayerbotAI::GetGroupMaster() uint32 PlayerbotAI::GetFixedBotNumer(BotTypeNumber typeNumber, uint32 maxNum, float cyclePerMin) { - uint32 randseed = rand32(); //Seed random number - uint32 randnum = bot->GetGUID().GetCounter() + randseed; //Semi-random but fixed number for each bot. + uint32 randseed = rand32(); // Seed random number + uint32 randnum = bot->GetGUID().GetCounter() + randseed; // Semi-random but fixed number for each bot. if (cyclePerMin > 0) { - uint32 cycle = floor(getMSTime() / (1000)); //Semi-random number adds 1 each second. - cycle = cycle * cyclePerMin / 60; //Cycles cyclePerMin per minute. - randnum += cycle; //Make the random number cylce. + uint32 cycle = floor(getMSTime() / (1000)); // Semi-random number adds 1 each second. + cycle = cycle * cyclePerMin / 60; // Cycles cyclePerMin per minute. + randnum += cycle; // Make the random number cylce. } - randnum = (randnum % (maxNum+1)); //Loops the randomnumber at maxNum. Bassically removes all the numbers above 99. - return randnum; //Now we have a number unique for each bot between 0 and maxNum that increases by cyclePerMin. + randnum = + (randnum % (maxNum + 1)); // Loops the randomnumber at maxNum. Bassically removes all the numbers above 99. + return randnum; // Now we have a number unique for each bot between 0 and maxNum that increases by cyclePerMin. } /* @@ -3260,7 +3425,7 @@ GrouperType PlayerbotAI::GetGrouperType() if (grouperNumber < 95) return GrouperType::LEADER_4; - return GrouperType::LEADER_5; + return GrouperType::LEADER_5; } GuilderType PlayerbotAI::GetGuilderType() @@ -3365,11 +3530,11 @@ inline bool HasRealPlayers(Map* map) bool PlayerbotAI::AllowActive(ActivityType activityType) { - //General exceptions + // General exceptions if (activityType == PACKET_ACTIVITY) return true; - if (GetMaster()) // Has player master. Always active. + if (GetMaster()) // Has player master. Always active. { PlayerbotAI* masterBotAI = GET_PLAYERBOT_AI(GetMaster()); if (!masterBotAI || masterBotAI->IsRealPlayer()) @@ -3400,10 +3565,10 @@ bool PlayerbotAI::AllowActive(ActivityType activityType) } } - if (!WorldPosition(bot).isOverworld()) // bg, raid, dungeon + if (!WorldPosition(bot).isOverworld()) // bg, raid, dungeon return true; - if (bot->InBattlegroundQueue()) //In bg queue. Speed up bg queue/join. + if (bot->InBattlegroundQueue()) // In bg queue. Speed up bg queue/join. return true; bool isLFG = false; @@ -3423,15 +3588,15 @@ bool PlayerbotAI::AllowActive(ActivityType activityType) if (isLFG) return true; - if (activityType != OUT_OF_PARTY_ACTIVITY && activityType != PACKET_ACTIVITY) // Is in combat. Defend yourself. + if (activityType != OUT_OF_PARTY_ACTIVITY && activityType != PACKET_ACTIVITY) // Is in combat. Defend yourself. if (bot->IsInCombat()) return true; - if (HasPlayerNearby(300.f)) //Player is near. Always active. + if (HasPlayerNearby(300.f)) // Player is near. Always active. return true; // friends always active - + // HasFriend sometimes cause crash, disable // for (auto& player : sRandomPlayerbotMgr->GetPlayers()) // { @@ -3442,17 +3607,18 @@ bool PlayerbotAI::AllowActive(ActivityType activityType) // return true; // } - if (activityType == OUT_OF_PARTY_ACTIVITY || activityType == GRIND_ACTIVITY) //Many bots nearby. Do not do heavy area checks. + if (activityType == OUT_OF_PARTY_ACTIVITY || + activityType == GRIND_ACTIVITY) // Many bots nearby. Do not do heavy area checks. if (HasManyPlayersNearby()) return false; - //Bots don't need to move using PathGenerator. + // Bots don't need to move using PathGenerator. if (activityType == DETAILED_MOVE_ACTIVITY) return false; - //All exceptions are now done. - //Below is code to have a specified % of bots active at all times. - //The default is 10%. With 0.1% of all bots going active or inactive each minute. + // All exceptions are now done. + // Below is code to have a specified % of bots active at all times. + // The default is 10%. With 0.1% of all bots going active or inactive each minute. if (sPlayerbotAIConfig->botActiveAlone <= 0) return false; @@ -3489,9 +3655,13 @@ bool PlayerbotAI::AllowActive(ActivityType activityType) } } - uint32 ActivityNumber = GetFixedBotNumer(BotTypeNumber::ACTIVITY_TYPE_NUMBER, 100, sPlayerbotAIConfig->botActiveAlone * static_cast(mod) / 100 * 0.01f); + uint32 ActivityNumber = + GetFixedBotNumer(BotTypeNumber::ACTIVITY_TYPE_NUMBER, 100, + sPlayerbotAIConfig->botActiveAlone * static_cast(mod) / 100 * 0.01f); - return ActivityNumber <= (sPlayerbotAIConfig->botActiveAlone * mod) / 100; //The given percentage of bots should be active and rotate 1% of those active bots each minute. + return ActivityNumber <= + (sPlayerbotAIConfig->botActiveAlone * mod) / + 100; // The given percentage of bots should be active and rotate 1% of those active bots each minute. } bool PlayerbotAI::AllowActivity(ActivityType activityType, bool checkNow) @@ -3508,10 +3678,7 @@ bool PlayerbotAI::AllowActivity(ActivityType activityType, bool checkNow) return allowed; } -bool PlayerbotAI::IsOpposing(Player* player) -{ - return IsOpposing(player->getRace(), bot->getRace()); -} +bool PlayerbotAI::IsOpposing(Player* player) { return IsOpposing(player->getRace(), bot->getRace()); } bool PlayerbotAI::IsOpposing(uint8 race1, uint8 race2) { @@ -3591,7 +3758,7 @@ uint32 PlayerbotAI::GetEquipGearScore(Player* player, bool withBags, bool withBa } } - uint8 count = EQUIPMENT_SLOT_END - 2; // ignore body and tabard slots + uint8 count = EQUIPMENT_SLOT_END - 2; // ignore body and tabard slots uint32 sum = 0; // check if 2h hand is higher level than main hand + off hand @@ -3604,7 +3771,7 @@ uint32 PlayerbotAI::GetEquipGearScore(Player* player, bool withBags, bool withBa for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) { - sum += gearScore[i]; + sum += gearScore[i]; } if (count) @@ -3674,8 +3841,9 @@ uint32 PlayerbotAI::GetMixedGearScore(Player* player, bool withBags, bool withBa } } } - if (!topN) { - uint8 count = EQUIPMENT_SLOT_END - 2; // ignore body and tabard slots + if (!topN) + { + uint8 count = EQUIPMENT_SLOT_END - 2; // ignore body and tabard slots uint32 sum = 0; // check if 2h hand is higher level than main hand + off hand @@ -3710,17 +3878,17 @@ uint32 PlayerbotAI::GetMixedGearScore(Player* player, bool withBags, bool withBa { topGearScore.push_back(gearScore[i]); } - std::sort(topGearScore.begin(), topGearScore.end(), [&](const uint32 lhs, const uint32 rhs) { - return lhs > rhs; - }); + std::sort(topGearScore.begin(), topGearScore.end(), [&](const uint32 lhs, const uint32 rhs) { return lhs > rhs; }); uint32 sum = 0; - for (int i = 0; i < std::min((uint32)topGearScore.size(), topN); i++) { + for (int i = 0; i < std::min((uint32)topGearScore.size(), topN); i++) + { sum += topGearScore[i]; } return sum / topN; } -void PlayerbotAI::_fillGearScoreData(Player* player, Item* item, std::vector* gearScore, uint32& twoHandScore, bool mixed) +void PlayerbotAI::_fillGearScoreData(Player* player, Item* item, std::vector* gearScore, uint32& twoHandScore, + bool mixed) { if (!item) return; @@ -3729,7 +3897,7 @@ void PlayerbotAI::_fillGearScoreData(Player* player, Item* item, std::vectorCanUseItem(proto) != EQUIP_ERR_OK) return; - uint8 type = proto->InventoryType; + uint8 type = proto->InventoryType; uint32 level = mixed ? proto->ItemLevel * (1 + proto->Quality) : proto->ItemLevel; switch (type) @@ -3782,8 +3950,8 @@ void PlayerbotAI::_fillGearScoreData(Player* player, Item* item, std::vectorGetPositionX() << " " << bot->GetPositionY() << " " << bot->GetPositionZ() << " " << bot->GetMapId() << " " << bot->GetOrientation(); + out << bot->GetPositionX() << " " << bot->GetPositionY() << " " << bot->GetPositionZ() << " " << bot->GetMapId() + << " " << bot->GetOrientation(); if (AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(bot->GetZoneId())) out << " |" << zoneEntry->area_name[0] << "|"; @@ -3849,14 +4018,16 @@ std::string const PlayerbotAI::HandleRemoteCommand(std::string const command) } std::ostringstream out; - out << target->GetPositionX() << " " << target->GetPositionY() << " " << target->GetPositionZ() << " " << target->GetMapId() << " " << target->GetOrientation(); + out << target->GetPositionX() << " " << target->GetPositionY() << " " << target->GetPositionZ() << " " + << target->GetMapId() << " " << target->GetOrientation(); return out.str(); } else if (command == "movement") { LastMovement& data = *GetAiObjectContext()->GetValue("last movement"); std::ostringstream out; - out << data.lastMoveShort.getX() << " " << data.lastMoveShort.getY() << " " << data.lastMoveShort.getZ() << " " << data.lastMoveShort.getMapId() << " " << data.lastMoveShort.getO(); + out << data.lastMoveShort.getX() << " " << data.lastMoveShort.getY() << " " << data.lastMoveShort.getZ() << " " + << data.lastMoveShort.getMapId() << " " << data.lastMoveShort.getO(); return out.str(); } else if (command == "target") @@ -3908,7 +4079,7 @@ std::string const PlayerbotAI::HandleRemoteCommand(std::string const command) out << ": " << target->getDestination()->getTitle(); - out << " v: " << target->getDestination()->getVisitors(); + out << " v: " << target->getDestination()->getVisitors(); if (!(*target->getPosition() == WorldPosition())) { @@ -3946,7 +4117,8 @@ std::string const PlayerbotAI::HandleRemoteCommand(std::string const command) AiObjectContext* context = GetAiObjectContext(); - out << "Current money: " << ChatHelper::formatMoney(bot->GetMoney()) << " free to use:" << ChatHelper::formatMoney(AI_VALUE2(uint32, "free money for", (uint32)NeedMoneyFor::anything)) << "\n"; + out << "Current money: " << ChatHelper::formatMoney(bot->GetMoney()) << " free to use:" + << ChatHelper::formatMoney(AI_VALUE2(uint32, "free money for", (uint32)NeedMoneyFor::anything)) << "\n"; out << "Purpose | Available / Needed \n"; for (uint32 i = 1; i < (uint32)NeedMoneyFor::anything; i++) @@ -3983,7 +4155,8 @@ std::string const PlayerbotAI::HandleRemoteCommand(std::string const command) break; } - out << " | " << ChatHelper::formatMoney(AI_VALUE2(uint32, "free money for", i)) << " / " << ChatHelper::formatMoney(AI_VALUE2(uint32, "money needed for", i)) << "\n"; + out << " | " << ChatHelper::formatMoney(AI_VALUE2(uint32, "free money for", i)) << " / " + << ChatHelper::formatMoney(AI_VALUE2(uint32, "money needed for", i)) << "\n"; } return out.str(); @@ -3994,10 +4167,7 @@ std::string const PlayerbotAI::HandleRemoteCommand(std::string const command) return out.str(); } -bool PlayerbotAI::HasSkill(SkillType skill) -{ - return bot->HasSkill(skill) && bot->GetSkillValue(skill) > 0; -} +bool PlayerbotAI::HasSkill(SkillType skill) { return bot->HasSkill(skill) && bot->GetSkillValue(skill) > 0; } float PlayerbotAI::GetRange(std::string const type) { @@ -4022,7 +4192,7 @@ float PlayerbotAI::GetRange(std::string const type) if (type == "melee") return sPlayerbotAIConfig->meleeDistance; - + return 0; } @@ -4043,7 +4213,7 @@ void PlayerbotAI::Ping(float x, float y) } } -//Find Poison ...Natsukawa +// Find Poison ...Natsukawa Item* PlayerbotAI::FindPoison() const { // list out items in main backpack @@ -4053,10 +4223,10 @@ Item* PlayerbotAI::FindPoison() const { ItemTemplate const* pItemProto = pItem->GetTemplate(); if (!pItemProto || bot->CanUseItem(pItemProto) != EQUIP_ERR_OK) - continue; + continue; if (pItemProto->Class == ITEM_CLASS_CONSUMABLE && pItemProto->SubClass == 6) - return pItem; + return pItem; } } // list out items in other removable backpacks @@ -4072,7 +4242,8 @@ Item* PlayerbotAI::FindPoison() const if (!pItemProto || bot->CanUseItem(pItemProto) != EQUIP_ERR_OK) continue; - if (pItemProto->Class == ITEM_CLASS_CONSUMABLE && pItemProto->SubClass == ITEM_SUBCLASS_ITEM_ENHANCEMENT) + if (pItemProto->Class == ITEM_CLASS_CONSUMABLE && + pItemProto->SubClass == ITEM_SUBCLASS_ITEM_ENHANCEMENT) return pItem; } } @@ -4093,7 +4264,8 @@ Item* PlayerbotAI::FindConsumable(uint32 displayId) const if (!pItemProto || bot->CanUseItem(pItemProto) != EQUIP_ERR_OK) continue; - if ((pItemProto->Class == ITEM_CLASS_CONSUMABLE || pItemProto->Class == ITEM_CLASS_TRADE_GOODS) && pItemProto->DisplayInfoID == displayId) + if ((pItemProto->Class == ITEM_CLASS_CONSUMABLE || pItemProto->Class == ITEM_CLASS_TRADE_GOODS) && + pItemProto->DisplayInfoID == displayId) return pItem; } } @@ -4111,7 +4283,8 @@ Item* PlayerbotAI::FindConsumable(uint32 displayId) const if (!pItemProto || bot->CanUseItem(pItemProto) != EQUIP_ERR_OK) continue; - if ((pItemProto->Class == ITEM_CLASS_CONSUMABLE || pItemProto->Class == ITEM_CLASS_TRADE_GOODS) && pItemProto->DisplayInfoID == displayId) + if ((pItemProto->Class == ITEM_CLASS_CONSUMABLE || pItemProto->Class == ITEM_CLASS_TRADE_GOODS) && + pItemProto->DisplayInfoID == displayId) return pItem; } } @@ -4130,10 +4303,10 @@ Item* PlayerbotAI::FindBandage() const { ItemTemplate const* pItemProto = pItem->GetTemplate(); if (!pItemProto || bot->CanUseItem(pItemProto) != EQUIP_ERR_OK) - continue; + continue; if (pItemProto->Class == ITEM_CLASS_CONSUMABLE && pItemProto->SubClass == ITEM_SUBCLASS_BANDAGE) - return pItem; + return pItem; } } @@ -4160,17 +4333,15 @@ Item* PlayerbotAI::FindBandage() const return nullptr; } -static const uint32 uPriorizedSharpStoneIds[8] = -{ - ADAMANTITE_SHARPENING_DISPLAYID, FEL_SHARPENING_DISPLAYID, ELEMENTAL_SHARPENING_DISPLAYID, DENSE_SHARPENING_DISPLAYID, - SOLID_SHARPENING_DISPLAYID, HEAVY_SHARPENING_DISPLAYID, COARSE_SHARPENING_DISPLAYID, ROUGH_SHARPENING_DISPLAYID -}; +static const uint32 uPriorizedSharpStoneIds[8] = {ADAMANTITE_SHARPENING_DISPLAYID, FEL_SHARPENING_DISPLAYID, + ELEMENTAL_SHARPENING_DISPLAYID, DENSE_SHARPENING_DISPLAYID, + SOLID_SHARPENING_DISPLAYID, HEAVY_SHARPENING_DISPLAYID, + COARSE_SHARPENING_DISPLAYID, ROUGH_SHARPENING_DISPLAYID}; -static const uint32 uPriorizedWeightStoneIds[7] = -{ - ADAMANTITE_WEIGHTSTONE_DISPLAYID, FEL_WEIGHTSTONE_DISPLAYID, DENSE_WEIGHTSTONE_DISPLAYID, SOLID_WEIGHTSTONE_DISPLAYID, - HEAVY_WEIGHTSTONE_DISPLAYID, COARSE_WEIGHTSTONE_DISPLAYID, ROUGH_WEIGHTSTONE_DISPLAYID -}; +static const uint32 uPriorizedWeightStoneIds[7] = {ADAMANTITE_WEIGHTSTONE_DISPLAYID, FEL_WEIGHTSTONE_DISPLAYID, + DENSE_WEIGHTSTONE_DISPLAYID, SOLID_WEIGHTSTONE_DISPLAYID, + HEAVY_WEIGHTSTONE_DISPLAYID, COARSE_WEIGHTSTONE_DISPLAYID, + ROUGH_WEIGHTSTONE_DISPLAYID}; /** * FindStoneFor() @@ -4185,23 +4356,27 @@ Item* PlayerbotAI::FindStoneFor(Item* weapon) const { Item* stone = nullptr; ItemTemplate const* pProto = weapon->GetTemplate(); - if (pProto && (pProto->SubClass == ITEM_SUBCLASS_WEAPON_SWORD || pProto->SubClass == ITEM_SUBCLASS_WEAPON_SWORD2 || pProto->SubClass == ITEM_SUBCLASS_WEAPON_AXE || - pProto->SubClass == ITEM_SUBCLASS_WEAPON_AXE2 || pProto->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER)) + if (pProto && (pProto->SubClass == ITEM_SUBCLASS_WEAPON_SWORD || pProto->SubClass == ITEM_SUBCLASS_WEAPON_SWORD2 || + pProto->SubClass == ITEM_SUBCLASS_WEAPON_AXE || pProto->SubClass == ITEM_SUBCLASS_WEAPON_AXE2 || + pProto->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER)) { for (uint8 i = 0; i < std::size(uPriorizedSharpStoneIds); ++i) { stone = FindConsumable(uPriorizedSharpStoneIds[i]); - if (stone) { + if (stone) + { return stone; } } } - else if (pProto && (pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE || pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE2)) + else if (pProto && + (pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE || pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE2)) { for (uint8 i = 0; i < std::size(uPriorizedWeightStoneIds); ++i) { stone = FindConsumable(uPriorizedWeightStoneIds[i]); - if (stone) { + if (stone) + { return stone; } } @@ -4210,42 +4385,44 @@ Item* PlayerbotAI::FindStoneFor(Item* weapon) const return stone; } -static const uint32 uPriorizedWizardOilIds[5] = -{ - MINOR_WIZARD_OIL, LESSER_WIZARD_OIL, BRILLIANT_WIZARD_OIL, WIZARD_OIL, SUPERIOR_WIZARD_OIL -}; +static const uint32 uPriorizedWizardOilIds[5] = {MINOR_WIZARD_OIL, LESSER_WIZARD_OIL, BRILLIANT_WIZARD_OIL, WIZARD_OIL, + SUPERIOR_WIZARD_OIL}; -static const uint32 uPriorizedManaOilIds[4] = -{ - MINOR_MANA_OIL, LESSER_MANA_OIL, BRILLIANT_MANA_OIL, SUPERIOR_MANA_OIL, +static const uint32 uPriorizedManaOilIds[4] = { + MINOR_MANA_OIL, + LESSER_MANA_OIL, + BRILLIANT_MANA_OIL, + SUPERIOR_MANA_OIL, }; Item* PlayerbotAI::FindOilFor(Item* weapon) const { Item* oil = nullptr; ItemTemplate const* pProto = weapon->GetTemplate(); - if (pProto && (pProto->SubClass == ITEM_SUBCLASS_WEAPON_SWORD || pProto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF || pProto->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER)) + if (pProto && (pProto->SubClass == ITEM_SUBCLASS_WEAPON_SWORD || pProto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF || + pProto->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER)) { for (uint8 i = 0; i < std::size(uPriorizedWizardOilIds); ++i) { oil = FindConsumable(uPriorizedWizardOilIds[i]); if (!oil) - oil = FindConsumable(uPriorizedManaOilIds[i]); + oil = FindConsumable(uPriorizedManaOilIds[i]); if (oil) - return oil; + return oil; } } - else if (pProto && (pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE || pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE2)) + else if (pProto && + (pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE || pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE2)) { for (uint8 i = 0; i < std::size(uPriorizedManaOilIds); ++i) { oil = FindConsumable(uPriorizedManaOilIds[i]); if (!oil) - oil = FindConsumable(uPriorizedWizardOilIds[i]); + oil = FindConsumable(uPriorizedWizardOilIds[i]); if (oil) - return oil; + return oil; } } @@ -4253,10 +4430,7 @@ Item* PlayerbotAI::FindOilFor(Item* weapon) const } // on self -void PlayerbotAI::ImbueItem(Item* item) -{ - ImbueItem(item, TARGET_FLAG_NONE, ObjectGuid::Empty); -} +void PlayerbotAI::ImbueItem(Item* item) { ImbueItem(item, TARGET_FLAG_NONE, ObjectGuid::Empty); } // item on unit void PlayerbotAI::ImbueItem(Item* item, Unit* target) @@ -4324,7 +4498,8 @@ void PlayerbotAI::ImbueItem(Item* item, uint32 targetFlag, ObjectGuid targetGUID void PlayerbotAI::EnchantItemT(uint32 spellid, uint8 slot) { Item* pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if (!pItem || !pItem->IsInWorld() || !pItem->GetOwner() || !pItem->GetOwner()->IsInWorld() || !pItem->GetOwner()->GetSession()) + if (!pItem || !pItem->IsInWorld() || !pItem->GetOwner() || !pItem->GetOwner()->IsInWorld() || + !pItem->GetOwner()->GetSession()) return; SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); @@ -4338,9 +4513,11 @@ void PlayerbotAI::EnchantItemT(uint32 spellid, uint8 slot) return; } - if (!((1 << pItem->GetTemplate()->SubClass) & spellInfo->EquippedItemSubClassMask) && !((1 << pItem->GetTemplate()->InventoryType) & spellInfo->EquippedItemInventoryTypeMask)) + if (!((1 << pItem->GetTemplate()->SubClass) & spellInfo->EquippedItemSubClassMask) && + !((1 << pItem->GetTemplate()->InventoryType) & spellInfo->EquippedItemInventoryTypeMask)) { - // LOG_ERROR("playerbots", "{}: items could not be enchanted, wrong item type equipped", bot->GetName().c_str()); + // LOG_ERROR("playerbots", "{}: items could not be enchanted, wrong item type equipped", + // bot->GetName().c_str()); return; } @@ -4380,10 +4557,10 @@ bool PlayerbotAI::CanMove() if (IsInVehicle() && !IsInVehicle(true)) return false; - if (bot->isFrozen() || bot->IsPolymorphed() || (bot->isDead() && !bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) || bot->IsBeingTeleported() || - bot->isInRoots() || bot->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION) || bot->HasAuraType(SPELL_AURA_MOD_CONFUSE) || bot->IsCharmed() || - bot->HasAuraType(SPELL_AURA_MOD_STUN) || bot->HasUnitState(UNIT_STATE_IN_FLIGHT) || - bot->HasUnitState(UNIT_STATE_LOST_CONTROL)) + if (bot->isFrozen() || bot->IsPolymorphed() || (bot->isDead() && !bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) || + bot->IsBeingTeleported() || bot->isInRoots() || bot->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION) || + bot->HasAuraType(SPELL_AURA_MOD_CONFUSE) || bot->IsCharmed() || bot->HasAuraType(SPELL_AURA_MOD_STUN) || + bot->HasUnitState(UNIT_STATE_IN_FLIGHT) || bot->HasUnitState(UNIT_STATE_LOST_CONTROL)) return false; return bot->GetMotionMaster()->GetCurrentMovementGeneratorType() != FLIGHT_MOTION_TYPE; @@ -4406,18 +4583,23 @@ bool PlayerbotAI::IsInRealGuild() return !(sPlayerbotAIConfig->IsInRandomAccountList(leaderAccount)); } -void PlayerbotAI::QueueChatResponse(uint8 msgtype, ObjectGuid guid1, ObjectGuid guid2, std::string message, std::string chanName, std::string name) +void PlayerbotAI::QueueChatResponse(uint8 msgtype, ObjectGuid guid1, ObjectGuid guid2, std::string message, + std::string chanName, std::string name) { - chatReplies.push(ChatQueuedReply(msgtype, guid1.GetCounter(), guid2.GetCounter(), message, chanName, name, time(nullptr) + urand(inCombat ? 10 : 5, inCombat ? 25 : 15))); + chatReplies.push(ChatQueuedReply(msgtype, guid1.GetCounter(), guid2.GetCounter(), message, chanName, name, + time(nullptr) + urand(inCombat ? 10 : 5, inCombat ? 25 : 15))); } bool PlayerbotAI::EqualLowercaseName(std::string s1, std::string s2) { - if (s1.length() != s2.length()) { + if (s1.length() != s2.length()) + { return false; } - for (int i = 0; i < s1.length(); i++) { - if (tolower(s1[i]) != tolower(s2[i])) { + for (int i = 0; i < s1.length(); i++) + { + if (tolower(s1[i]) != tolower(s2[i])) + { return false; } } @@ -4429,7 +4611,8 @@ InventoryResult PlayerbotAI::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, dest = 0; if (pItem) { - LOG_DEBUG("entities.player.items", "STORAGE: CanEquipItem slot = {}, item = {}, count = {}", slot, pItem->GetEntry(), pItem->GetCount()); + LOG_DEBUG("entities.player.items", "STORAGE: CanEquipItem slot = {}, item = {}, count = {}", slot, + pItem->GetEntry(), pItem->GetCount()); ItemTemplate const* pProto = pItem->GetTemplate(); if (pProto) { @@ -4442,15 +4625,19 @@ InventoryResult PlayerbotAI::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, if (pItem->IsBindedNotWith(bot)) return EQUIP_ERR_DONT_OWN_THAT_ITEM; - + // Yunfan: skip it // // check count of items (skip for auto move for same player from bank) // InventoryResult res = bot->CanTakeMoreSimilarItems(pItem); // if (res != EQUIP_ERR_OK) // return res; - ScalingStatDistributionEntry const* ssd = pProto->ScalingStatDistribution ? sScalingStatDistributionStore.LookupEntry(pProto->ScalingStatDistribution) : 0; - // check allowed level (extend range to upper values if MaxLevel more or equal max player level, this let GM set high level with 1...max range items) + ScalingStatDistributionEntry const* ssd = + pProto->ScalingStatDistribution + ? sScalingStatDistributionStore.LookupEntry(pProto->ScalingStatDistribution) + : 0; + // check allowed level (extend range to upper values if MaxLevel more or equal max player level, this let GM + // set high level with 1...max range items) if (ssd && ssd->MaxLevel < DEFAULT_MAX_LEVEL && ssd->MaxLevel < bot->GetLevel()) return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; @@ -4511,8 +4698,8 @@ InventoryResult PlayerbotAI::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, if (ItemTemplate const* pBagProto = pBag->GetTemplate()) if (pBagProto->Class == pProto->Class && (!swap || pBag->GetSlot() != eslot)) return (pBagProto->SubClass == ITEM_SUBCLASS_AMMO_POUCH) - ? EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH - : EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER; + ? EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH + : EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER; uint32 type = pProto->InventoryType; @@ -4520,7 +4707,8 @@ InventoryResult PlayerbotAI::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, { // Do not allow polearm to be equipped in the offhand (rare case for the only 1h polearm 41750) // xinef: same for fishing poles - if (type == INVTYPE_WEAPON && (pProto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || pProto->SubClass == ITEM_SUBCLASS_WEAPON_FISHING_POLE)) + if (type == INVTYPE_WEAPON && (pProto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || + pProto->SubClass == ITEM_SUBCLASS_WEAPON_FISHING_POLE)) return EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT; else if (type == INVTYPE_WEAPON || type == INVTYPE_WEAPONOFFHAND) @@ -4555,7 +4743,8 @@ InventoryResult PlayerbotAI::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, Item* offItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); ItemPosCountVec off_dest; if (offItem && (!not_loading || - bot->CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND, false) != EQUIP_ERR_OK || + bot->CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND, + false) != EQUIP_ERR_OK || bot->CanStoreItem(NULL_BAG, NULL_SLOT, off_dest, offItem, false) != EQUIP_ERR_OK)) return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_INVENTORY_FULL; } @@ -4645,7 +4834,8 @@ uint8 PlayerbotAI::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool sw { if (ItemTemplate const* mhWeaponProto = mhWeapon->GetTemplate()) { - if (mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF) + if (mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || + mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF) { bot->AutoUnequipOffhandIfNeed(true); break; @@ -4660,7 +4850,8 @@ uint8 PlayerbotAI::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool sw break; } } - if (bot->CanDualWield() && bot->CanTitanGrip() && proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF && proto->SubClass != ITEM_SUBCLASS_WEAPON_FISHING_POLE) + if (bot->CanDualWield() && bot->CanTitanGrip() && proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && + proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF && proto->SubClass != ITEM_SUBCLASS_WEAPON_FISHING_POLE) slots[1] = EQUIPMENT_SLOT_OFFHAND; break; case INVTYPE_TABARD: diff --git a/src/PlayerbotAI.h b/src/PlayerbotAI.h index 79eea13e..fb2382fd 100644 --- a/src/PlayerbotAI.h +++ b/src/PlayerbotAI.h @@ -1,25 +1,26 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PLAYERbotAI_H #define _PLAYERBOT_PLAYERbotAI_H +#include +#include + #include "Chat.h" -#include "ChatHelper.h" #include "ChatFilter.h" +#include "ChatHelper.h" #include "Common.h" #include "Event.h" #include "Item.h" #include "PlayerbotAIBase.h" #include "PlayerbotAIConfig.h" #include "PlayerbotSecurity.h" +#include "PlayerbotTextMgr.h" #include "SpellAuras.h" #include "WorldPacket.h" -#include "PlayerbotTextMgr.h" - -#include -#include class AiObjectContext; class Creature; @@ -43,228 +44,239 @@ enum StrategyType : uint32; enum HealingItemDisplayId { - HEALTHSTONE_DISPLAYID = 8026, - MAJOR_HEALING_POTION = 24152, - WHIPPER_ROOT_TUBER = 21974, - NIGHT_DRAGON_BREATH = 21975, - LIMITED_INVULNERABILITY_POTION = 24213, - GREATER_DREAMLESS_SLEEP_POTION = 17403, - SUPERIOR_HEALING_POTION = 15714, - CRYSTAL_RESTORE = 2516, - DREAMLESS_SLEEP_POTION = 17403, - GREATER_HEALING_POTION = 15713, - HEALING_POTION = 15712, - LESSER_HEALING_POTION = 15711, - DISCOLORED_HEALING_POTION = 15736, - MINOR_HEALING_POTION = 15710, - VOLATILE_HEALING_POTION = 24212, - SUPER_HEALING_POTION = 37807, - CRYSTAL_HEALING_POTION = 47132, - FEL_REGENERATION_POTION = 37864, - MAJOR_DREAMLESS_SLEEP_POTION = 37845 + HEALTHSTONE_DISPLAYID = 8026, + MAJOR_HEALING_POTION = 24152, + WHIPPER_ROOT_TUBER = 21974, + NIGHT_DRAGON_BREATH = 21975, + LIMITED_INVULNERABILITY_POTION = 24213, + GREATER_DREAMLESS_SLEEP_POTION = 17403, + SUPERIOR_HEALING_POTION = 15714, + CRYSTAL_RESTORE = 2516, + DREAMLESS_SLEEP_POTION = 17403, + GREATER_HEALING_POTION = 15713, + HEALING_POTION = 15712, + LESSER_HEALING_POTION = 15711, + DISCOLORED_HEALING_POTION = 15736, + MINOR_HEALING_POTION = 15710, + VOLATILE_HEALING_POTION = 24212, + SUPER_HEALING_POTION = 37807, + CRYSTAL_HEALING_POTION = 47132, + FEL_REGENERATION_POTION = 37864, + MAJOR_DREAMLESS_SLEEP_POTION = 37845 }; enum BotState { - BOT_STATE_COMBAT = 0, - BOT_STATE_NON_COMBAT = 1, - BOT_STATE_DEAD = 2, + BOT_STATE_COMBAT = 0, + BOT_STATE_NON_COMBAT = 1, + BOT_STATE_DEAD = 2, BOT_STATE_MAX }; bool IsAlliance(uint8 race); -class PlayerbotChatHandler: protected ChatHandler +class PlayerbotChatHandler : protected ChatHandler { - public: - explicit PlayerbotChatHandler(Player* pMasterPlayer); - void sysmessage(std::string const str) { SendSysMessage(str.c_str()); } - uint32 extractQuestId(std::string const str); - uint32 extractSpellId(std::string const str) - { - char* source = (char*)str.c_str(); - return extractSpellIdFromLink(source); - } +public: + explicit PlayerbotChatHandler(Player* pMasterPlayer); + void sysmessage(std::string const str) { SendSysMessage(str.c_str()); } + uint32 extractQuestId(std::string const str); + uint32 extractSpellId(std::string const str) + { + char* source = (char*)str.c_str(); + return extractSpellIdFromLink(source); + } }; class MinValueCalculator { - public: - MinValueCalculator(float def = 0.0f) : param(nullptr), minValue(def) { } +public: + MinValueCalculator(float def = 0.0f) : param(nullptr), minValue(def) {} - void probe(float value, void* p) + void probe(float value, void* p) + { + if (!param || minValue >= value) { - if (!param || minValue >= value) - { - minValue = value; - param = p; - } - } + minValue = value; + param = p; + } + } - void* param; - float minValue; + void* param; + float minValue; }; enum RoguePoisonDisplayId { - DEADLY_POISON_DISPLAYID = 13707, - INSTANT_POISON_DISPLAYID = 13710, - WOUND_POISON_DISPLAYID = 37278 + DEADLY_POISON_DISPLAYID = 13707, + INSTANT_POISON_DISPLAYID = 13710, + WOUND_POISON_DISPLAYID = 37278 }; enum SharpeningStoneDisplayId { - ROUGH_SHARPENING_DISPLAYID = 24673, - COARSE_SHARPENING_DISPLAYID = 24674, - HEAVY_SHARPENING_DISPLAYID = 24675, - SOLID_SHARPENING_DISPLAYID = 24676, - DENSE_SHARPENING_DISPLAYID = 24677, - CONSECRATED_SHARPENING_DISPLAYID = 24674, // will not be used because bot can not know if it will face undead targets - ELEMENTAL_SHARPENING_DISPLAYID = 21072, - FEL_SHARPENING_DISPLAYID = 39192, - ADAMANTITE_SHARPENING_DISPLAYID = 39193 + ROUGH_SHARPENING_DISPLAYID = 24673, + COARSE_SHARPENING_DISPLAYID = 24674, + HEAVY_SHARPENING_DISPLAYID = 24675, + SOLID_SHARPENING_DISPLAYID = 24676, + DENSE_SHARPENING_DISPLAYID = 24677, + CONSECRATED_SHARPENING_DISPLAYID = + 24674, // will not be used because bot can not know if it will face undead targets + ELEMENTAL_SHARPENING_DISPLAYID = 21072, + FEL_SHARPENING_DISPLAYID = 39192, + ADAMANTITE_SHARPENING_DISPLAYID = 39193 }; enum WeightStoneDisplayId { - ROUGH_WEIGHTSTONE_DISPLAYID = 24683, - COARSE_WEIGHTSTONE_DISPLAYID = 24684, - HEAVY_WEIGHTSTONE_DISPLAYID = 24685, - SOLID_WEIGHTSTONE_DISPLAYID = 24686, - DENSE_WEIGHTSTONE_DISPLAYID = 24687, - FEL_WEIGHTSTONE_DISPLAYID = 39548, + ROUGH_WEIGHTSTONE_DISPLAYID = 24683, + COARSE_WEIGHTSTONE_DISPLAYID = 24684, + HEAVY_WEIGHTSTONE_DISPLAYID = 24685, + SOLID_WEIGHTSTONE_DISPLAYID = 24686, + DENSE_WEIGHTSTONE_DISPLAYID = 24687, + FEL_WEIGHTSTONE_DISPLAYID = 39548, ADAMANTITE_WEIGHTSTONE_DISPLAYID = 39549 }; enum WizardOilDisplayId { - MINOR_WIZARD_OIL = 9731, - LESSER_WIZARD_OIL = 47903, - BRILLIANT_WIZARD_OIL = 47901, - WIZARD_OIL = 47905, - SUPERIOR_WIZARD_OIL = 47904, - /// Blessed Wizard Oil = 26865 //scourge inv + MINOR_WIZARD_OIL = 9731, + LESSER_WIZARD_OIL = 47903, + BRILLIANT_WIZARD_OIL = 47901, + WIZARD_OIL = 47905, + SUPERIOR_WIZARD_OIL = 47904, + /// Blessed Wizard Oil = 26865 //scourge inv }; enum ManaOilDisplayId { - MINOR_MANA_OIL = 34492, - LESSER_MANA_OIL = 47902, - BRILLIANT_MANA_OIL = 41488, - SUPERIOR_MANA_OIL = 36862 + MINOR_MANA_OIL = 34492, + LESSER_MANA_OIL = 47902, + BRILLIANT_MANA_OIL = 41488, + SUPERIOR_MANA_OIL = 36862 }; enum ShieldWardDisplayId { - LESSER_WARD_OFSHIELDING = 38759, + LESSER_WARD_OFSHIELDING = 38759, GREATER_WARD_OFSHIELDING = 38760 }; enum class BotTypeNumber : uint8 { ACTIVITY_TYPE_NUMBER = 1, - GROUPER_TYPE_NUMBER = 2, - GUILDER_TYPE_NUMBER = 3, + GROUPER_TYPE_NUMBER = 2, + GUILDER_TYPE_NUMBER = 3, }; enum class GrouperType : uint8 { - SOLO = 0, - MEMBER = 1, - LEADER_2 = 2, - LEADER_3 = 3, - LEADER_4 = 4, - LEADER_5 = 5 + SOLO = 0, + MEMBER = 1, + LEADER_2 = 2, + LEADER_3 = 3, + LEADER_4 = 4, + LEADER_5 = 5 }; enum class GuilderType : uint8 { - SOLO = 0, - TINY = 30, - SMALL = 50, + SOLO = 0, + TINY = 30, + SMALL = 50, MEDIUM = 70, - LARGE = 120, - VERY_LARGE = 250 + LARGE = 120, + VERY_LARGE = 250 }; enum ActivityType { - GRIND_ACTIVITY = 1, - RPG_ACTIVITY = 2, - TRAVEL_ACTIVITY = 3, - OUT_OF_PARTY_ACTIVITY = 4, - PACKET_ACTIVITY = 5, - DETAILED_MOVE_ACTIVITY = 6, - PARTY_ACTIVITY = 7, - ALL_ACTIVITY = 8, + GRIND_ACTIVITY = 1, + RPG_ACTIVITY = 2, + TRAVEL_ACTIVITY = 3, + OUT_OF_PARTY_ACTIVITY = 4, + PACKET_ACTIVITY = 5, + DETAILED_MOVE_ACTIVITY = 6, + PARTY_ACTIVITY = 7, + ALL_ACTIVITY = 8, MAX_ACTIVITY_TYPE }; enum BotRoles : uint8 { - BOT_ROLE_NONE = 0x00, - BOT_ROLE_TANK = 0x01, + BOT_ROLE_NONE = 0x00, + BOT_ROLE_TANK = 0x01, BOT_ROLE_HEALER = 0x02, - BOT_ROLE_DPS = 0x04 + BOT_ROLE_DPS = 0x04 }; -enum HUNTER_TABS { +enum HUNTER_TABS +{ HUNTER_TAB_BEASTMASTER, HUNTER_TAB_MARKSMANSHIP, HUNTER_TAB_SURVIVAL, }; -enum ROGUE_TABS { +enum ROGUE_TABS +{ ROGUE_TAB_ASSASSINATION, ROGUE_TAB_COMBAT, ROGUE_TAB_SUBTLETY }; -enum PRIEST_TABS { +enum PRIEST_TABS +{ PRIEST_TAB_DISIPLINE, PRIEST_TAB_HOLY, PRIEST_TAB_SHADOW, }; -enum DEATHKNIGT_TABS { +enum DEATHKNIGT_TABS +{ DEATHKNIGT_TAB_BLOOD, DEATHKNIGT_TAB_FROST, DEATHKNIGT_TAB_UNHOLY, }; -enum DRUID_TABS { +enum DRUID_TABS +{ DRUID_TAB_BALANCE, DRUID_TAB_FERAL, DRUID_TAB_RESTORATION, }; -enum MAGE_TABS { +enum MAGE_TABS +{ MAGE_TAB_ARCANE, MAGE_TAB_FIRE, MAGE_TAB_FROST, }; -enum SHAMAN_TABS { +enum SHAMAN_TABS +{ SHAMAN_TAB_ELEMENTAL, SHAMAN_TAB_ENHANCEMENT, SHAMAN_TAB_RESTORATION, }; -enum PALADIN_TABS { +enum PALADIN_TABS +{ PALADIN_TAB_HOLY, PALADIN_TAB_PROTECTION, PALADIN_TAB_RETRIBUTION, }; -enum WARLOCK_TABS { +enum WARLOCK_TABS +{ WARLOCK_TAB_AFFLICATION, WARLOCK_TAB_DEMONOLOGY, WARLOCK_TAB_DESTRUCTION, }; -enum WARRIOR_TABS { +enum WARRIOR_TABS +{ WARRIOR_TAB_ARMS, WARRIOR_TAB_FURY, WARRIOR_TAB_PROTECTION, @@ -272,215 +284,238 @@ enum WARRIOR_TABS { class PacketHandlingHelper { - public: - void AddHandler(uint16 opcode, std::string const handler); - void Handle(ExternalEventHelper &helper); - void AddPacket(WorldPacket const& packet); +public: + void AddHandler(uint16 opcode, std::string const handler); + void Handle(ExternalEventHelper& helper); + void AddPacket(WorldPacket const& packet); - private: - std::map handlers; - std::stack queue; +private: + std::map handlers; + std::stack queue; }; class ChatCommandHolder { - public: - ChatCommandHolder(std::string const command, Player* owner = nullptr, uint32 type = CHAT_MSG_WHISPER, time_t time = 0) : command(command), owner(owner), type(type), time(time) { } - ChatCommandHolder(ChatCommandHolder const& other) : command(other.command), owner(other.owner), type(other.type), time(other.time) { } +public: + ChatCommandHolder(std::string const command, Player* owner = nullptr, uint32 type = CHAT_MSG_WHISPER, + time_t time = 0) + : command(command), owner(owner), type(type), time(time) + { + } + ChatCommandHolder(ChatCommandHolder const& other) + : command(other.command), owner(other.owner), type(other.type), time(other.time) + { + } - std::string const GetCommand() { return command; } - Player* GetOwner() { return owner; } - uint32 GetType() { return type; } - time_t GetTime() { return time; } + std::string const GetCommand() { return command; } + Player* GetOwner() { return owner; } + uint32 GetType() { return type; } + time_t GetTime() { return time; } - private: - std::string const command; - Player* owner; - uint32 type; - time_t time; +private: + std::string const command; + Player* owner; + uint32 type; + time_t time; }; class PlayerbotAI : public PlayerbotAIBase { - public: - PlayerbotAI(); - PlayerbotAI(Player* bot); - virtual ~PlayerbotAI(); +public: + PlayerbotAI(); + PlayerbotAI(Player* bot); + virtual ~PlayerbotAI(); - void UpdateAI(uint32 elapsed, bool minimal = false) override; - void UpdateAIInternal(uint32 elapsed, bool minimal = false) override; + void UpdateAI(uint32 elapsed, bool minimal = false) override; + void UpdateAIInternal(uint32 elapsed, bool minimal = false) override; - std::string const HandleRemoteCommand(std::string const command); - void HandleCommand(uint32 type, std::string const text, Player* fromPlayer); - void QueueChatResponse(uint8 msgtype, ObjectGuid guid1, ObjectGuid guid2, std::string message, std::string chanName, std::string name); - void HandleBotOutgoingPacket(WorldPacket const& packet); - void HandleMasterIncomingPacket(WorldPacket const& packet); - void HandleMasterOutgoingPacket(WorldPacket const& packet); - void HandleTeleportAck(); - void ChangeEngine(BotState type); - void DoNextAction(bool minimal = false); - virtual bool DoSpecificAction(std::string const name, Event event = Event(), bool silent = false, std::string const qualifier = ""); - void ChangeStrategy(std::string const name, BotState type); - void ClearStrategies(BotState type); - std::vector GetStrategies(BotState type); - bool ContainsStrategy(StrategyType type); - bool HasStrategy(std::string const name, BotState type); - BotState GetState() { return currentState; }; - void ResetStrategies(bool load = false); - void ReInitCurrentEngine(); - void Reset(bool full = false); - static bool IsTank(Player* player); - static bool IsHeal(Player* player); - static bool IsDps(Player* player); - static bool IsRanged(Player* player); - static bool IsMelee(Player* player); - static bool IsCaster(Player* player); - static bool IsCombo(Player* player); - static bool IsRangedDps(Player* player); - static bool IsMainTank(Player* player); - bool IsAssistTank(Player* player); - bool IsAssistTankOfIndex(Player* player, int index); - bool IsHealAssistantOfIndex(Player* player, int index); - bool IsRangedDpsAssistantOfIndex(Player* player, int index); - bool HasAggro(Unit* unit); - int32 GetGroupSlotIndex(Player* player); - int32 GetRangedIndex(Player* player); - int32 GetClassIndex(Player* player, uint8_t cls); - int32 GetRangedDpsIndex(Player* player); - int32 GetMeleeIndex(Player* player); + std::string const HandleRemoteCommand(std::string const command); + void HandleCommand(uint32 type, std::string const text, Player* fromPlayer); + void QueueChatResponse(uint8 msgtype, ObjectGuid guid1, ObjectGuid guid2, std::string message, std::string chanName, + std::string name); + void HandleBotOutgoingPacket(WorldPacket const& packet); + void HandleMasterIncomingPacket(WorldPacket const& packet); + void HandleMasterOutgoingPacket(WorldPacket const& packet); + void HandleTeleportAck(); + void ChangeEngine(BotState type); + void DoNextAction(bool minimal = false); + virtual bool DoSpecificAction(std::string const name, Event event = Event(), bool silent = false, + std::string const qualifier = ""); + void ChangeStrategy(std::string const name, BotState type); + void ClearStrategies(BotState type); + std::vector GetStrategies(BotState type); + bool ContainsStrategy(StrategyType type); + bool HasStrategy(std::string const name, BotState type); + BotState GetState() { return currentState; }; + void ResetStrategies(bool load = false); + void ReInitCurrentEngine(); + void Reset(bool full = false); + static bool IsTank(Player* player); + static bool IsHeal(Player* player); + static bool IsDps(Player* player); + static bool IsRanged(Player* player); + static bool IsMelee(Player* player); + static bool IsCaster(Player* player); + static bool IsCombo(Player* player); + static bool IsRangedDps(Player* player); + static bool IsMainTank(Player* player); + bool IsAssistTank(Player* player); + bool IsAssistTankOfIndex(Player* player, int index); + bool IsHealAssistantOfIndex(Player* player, int index); + bool IsRangedDpsAssistantOfIndex(Player* player, int index); + bool HasAggro(Unit* unit); + int32 GetGroupSlotIndex(Player* player); + int32 GetRangedIndex(Player* player); + int32 GetClassIndex(Player* player, uint8_t cls); + int32 GetRangedDpsIndex(Player* player); + int32 GetMeleeIndex(Player* player); - Creature* GetCreature(ObjectGuid guid); - Unit* GetUnit(ObjectGuid guid); - Player* GetPlayer(ObjectGuid guid); - static Unit* GetUnit(CreatureData const* creatureData); - GameObject* GetGameObject(ObjectGuid guid); - // static GameObject* GetGameObject(GameObjectData const* gameObjectData); - WorldObject* GetWorldObject(ObjectGuid guid); - bool TellMaster(std::ostringstream& stream, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); - bool TellMaster(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); - bool TellMasterNoFacing(std::ostringstream& stream, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); - bool TellMasterNoFacing(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); - bool TellError(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); - void SpellInterrupted(uint32 spellid); - int32 CalculateGlobalCooldown(uint32 spellid); - void InterruptSpell(); - void RemoveAura(std::string const name); - void RemoveShapeshift(); - void WaitForSpellCast(Spell* spell); - bool PlaySound(uint32 emote); - bool PlayEmote(uint32 emote); - void Ping(float x, float y); - Item* FindPoison() const; - Item* FindBandage() const; - Item* FindConsumable(uint32 displayId) const; - Item* FindStoneFor(Item* weapon) const; - Item* FindOilFor(Item* weapon) const; - void ImbueItem(Item* item, uint32 targetFlag, ObjectGuid targetGUID); - void ImbueItem(Item* item, uint8 targetInventorySlot); - void ImbueItem(Item* item, Unit* target); - void ImbueItem(Item* item); - void EnchantItemT(uint32 spellid, uint8 slot); - uint32 GetBuffedCount(Player* player, std::string const spellname); + Creature* GetCreature(ObjectGuid guid); + Unit* GetUnit(ObjectGuid guid); + Player* GetPlayer(ObjectGuid guid); + static Unit* GetUnit(CreatureData const* creatureData); + GameObject* GetGameObject(ObjectGuid guid); + // static GameObject* GetGameObject(GameObjectData const* gameObjectData); + WorldObject* GetWorldObject(ObjectGuid guid); + bool TellMaster(std::ostringstream& stream, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); + bool TellMaster(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); + bool TellMasterNoFacing(std::ostringstream& stream, + PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); + bool TellMasterNoFacing(std::string const text, + PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); + bool TellError(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); + void SpellInterrupted(uint32 spellid); + int32 CalculateGlobalCooldown(uint32 spellid); + void InterruptSpell(); + void RemoveAura(std::string const name); + void RemoveShapeshift(); + void WaitForSpellCast(Spell* spell); + bool PlaySound(uint32 emote); + bool PlayEmote(uint32 emote); + void Ping(float x, float y); + Item* FindPoison() const; + Item* FindBandage() const; + Item* FindConsumable(uint32 displayId) const; + Item* FindStoneFor(Item* weapon) const; + Item* FindOilFor(Item* weapon) const; + void ImbueItem(Item* item, uint32 targetFlag, ObjectGuid targetGUID); + void ImbueItem(Item* item, uint8 targetInventorySlot); + void ImbueItem(Item* item, Unit* target); + void ImbueItem(Item* item); + void EnchantItemT(uint32 spellid, uint8 slot); + uint32 GetBuffedCount(Player* player, std::string const spellname); - virtual bool CanCastSpell(std::string const name, Unit* target, Item* itemTarget = nullptr); - virtual bool CastSpell(std::string const name, Unit* target, Item* itemTarget = nullptr); - virtual bool HasAura(std::string const spellName, Unit* player, bool maxStack = false, bool checkIsOwner = false, int maxAmount = -1, bool checkDuration = false); - virtual bool HasAnyAuraOf(Unit* player, ...); + virtual bool CanCastSpell(std::string const name, Unit* target, Item* itemTarget = nullptr); + virtual bool CastSpell(std::string const name, Unit* target, Item* itemTarget = nullptr); + virtual bool HasAura(std::string const spellName, Unit* player, bool maxStack = false, bool checkIsOwner = false, + int maxAmount = -1, bool checkDuration = false); + virtual bool HasAnyAuraOf(Unit* player, ...); - virtual bool IsInterruptableSpellCasting(Unit* player, std::string const spell); - virtual bool HasAuraToDispel(Unit* player, uint32 dispelType); - bool CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell = true, Item* itemTarget = nullptr, Item* castItem = nullptr); - bool CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effectMask, bool checkHasSpell = true); - bool CanCastSpell(uint32 spellid, float x, float y, float z, uint8 effectMask, bool checkHasSpell = true, Item* itemTarget = nullptr); + virtual bool IsInterruptableSpellCasting(Unit* player, std::string const spell); + virtual bool HasAuraToDispel(Unit* player, uint32 dispelType); + bool CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell = true, Item* itemTarget = nullptr, + Item* castItem = nullptr); + bool CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effectMask, bool checkHasSpell = true); + bool CanCastSpell(uint32 spellid, float x, float y, float z, uint8 effectMask, bool checkHasSpell = true, + Item* itemTarget = nullptr); - bool HasAura(uint32 spellId, Unit const* player); - Aura* GetAura(std::string const spellName, Unit* unit, bool checkIsOwner = false, bool checkDuration = false, int checkStack = -1); - bool CastSpell(uint32 spellId, Unit* target, Item* itemTarget = nullptr); - bool CastSpell(uint32 spellId, float x, float y, float z, Item* itemTarget = nullptr); - bool canDispel(SpellInfo const* spellInfo, uint32 dispelType); + bool HasAura(uint32 spellId, Unit const* player); + Aura* GetAura(std::string const spellName, Unit* unit, bool checkIsOwner = false, bool checkDuration = false, + int checkStack = -1); + bool CastSpell(uint32 spellId, Unit* target, Item* itemTarget = nullptr); + bool CastSpell(uint32 spellId, float x, float y, float z, Item* itemTarget = nullptr); + bool canDispel(SpellInfo const* spellInfo, uint32 dispelType); - bool CanCastVehicleSpell(uint32 spellid, Unit* target); - bool CastVehicleSpell(uint32 spellId, Unit* target); - bool CastVehicleSpell(uint32 spellId, float x, float y, float z); - bool IsInVehicle(bool canControl = false, bool canCast = false, bool canAttack = false, bool canTurn = false, bool fixed = false); + bool CanCastVehicleSpell(uint32 spellid, Unit* target); + bool CastVehicleSpell(uint32 spellId, Unit* target); + bool CastVehicleSpell(uint32 spellId, float x, float y, float z); + bool IsInVehicle(bool canControl = false, bool canCast = false, bool canAttack = false, bool canTurn = false, + bool fixed = false); - uint32 GetEquipGearScore(Player* player, bool withBags, bool withBank); - static uint32 GetMixedGearScore(Player* player, bool withBags, bool withBank, uint32 topN = 0); - bool HasSkill(SkillType skill); - bool IsAllowedCommand(std::string const text); - float GetRange(std::string const type); + uint32 GetEquipGearScore(Player* player, bool withBags, bool withBank); + static uint32 GetMixedGearScore(Player* player, bool withBags, bool withBank, uint32 topN = 0); + bool HasSkill(SkillType skill); + bool IsAllowedCommand(std::string const text); + float GetRange(std::string const type); - Player* GetBot() { return bot; } - Player* GetMaster() { return master; } + Player* GetBot() { return bot; } + Player* GetMaster() { return master; } - //Checks if the bot is really a player. Players always have themselves as master. - bool IsRealPlayer() { return master ? (master == bot) : false; } - //Bot has a master that is a player. - bool HasRealPlayerMaster(); - //Bot has a master that is activly playing. - bool HasActivePlayerMaster(); - //Get the group leader or the master of the bot. - //Checks if the bot is summoned as alt of a player - bool IsAlt(); - Player* GetGroupMaster(); - //Returns a semi-random (cycling) number that is fixed for each bot. - uint32 GetFixedBotNumer(BotTypeNumber typeNumber, uint32 maxNum = 100, float cyclePerMin = 1); - GrouperType GetGrouperType(); - GuilderType GetGuilderType(); - bool HasPlayerNearby(WorldPosition* pos, float range = sPlayerbotAIConfig->reactDistance); - bool HasPlayerNearby(float range = sPlayerbotAIConfig->reactDistance); - bool HasManyPlayersNearby(uint32 trigerrValue = 20, float range = sPlayerbotAIConfig->sightDistance); - bool AllowActive(ActivityType activityType); - bool AllowActivity(ActivityType activityType = ALL_ACTIVITY, bool checkNow = false); + // Checks if the bot is really a player. Players always have themselves as master. + bool IsRealPlayer() { return master ? (master == bot) : false; } + // Bot has a master that is a player. + bool HasRealPlayerMaster(); + // Bot has a master that is activly playing. + bool HasActivePlayerMaster(); + // Get the group leader or the master of the bot. + // Checks if the bot is summoned as alt of a player + bool IsAlt(); + Player* GetGroupMaster(); + // Returns a semi-random (cycling) number that is fixed for each bot. + uint32 GetFixedBotNumer(BotTypeNumber typeNumber, uint32 maxNum = 100, float cyclePerMin = 1); + GrouperType GetGrouperType(); + GuilderType GetGuilderType(); + bool HasPlayerNearby(WorldPosition* pos, float range = sPlayerbotAIConfig->reactDistance); + bool HasPlayerNearby(float range = sPlayerbotAIConfig->reactDistance); + bool HasManyPlayersNearby(uint32 trigerrValue = 20, float range = sPlayerbotAIConfig->sightDistance); + bool AllowActive(ActivityType activityType); + bool AllowActivity(ActivityType activityType = ALL_ACTIVITY, bool checkNow = false); - bool HasCheat(BotCheatMask mask) { return ((uint32)mask & (uint32)cheatMask) != 0 || ((uint32)mask & (uint32)sPlayerbotAIConfig->botCheatMask) != 0; } - BotCheatMask GetCheat() { return cheatMask; } - void SetCheat(BotCheatMask mask) { cheatMask = mask; } + bool HasCheat(BotCheatMask mask) + { + return ((uint32)mask & (uint32)cheatMask) != 0 || + ((uint32)mask & (uint32)sPlayerbotAIConfig->botCheatMask) != 0; + } + BotCheatMask GetCheat() { return cheatMask; } + void SetCheat(BotCheatMask mask) { cheatMask = mask; } - void SetMaster(Player* newMaster) { master = newMaster; } - AiObjectContext* GetAiObjectContext() { return aiObjectContext; } - ChatHelper* GetChatHelper() { return &chatHelper; } - bool IsOpposing(Player* player); - static bool IsOpposing(uint8 race1, uint8 race2); - PlayerbotSecurity* GetSecurity() { return &security; } + void SetMaster(Player* newMaster) { master = newMaster; } + AiObjectContext* GetAiObjectContext() { return aiObjectContext; } + ChatHelper* GetChatHelper() { return &chatHelper; } + bool IsOpposing(Player* player); + static bool IsOpposing(uint8 race1, uint8 race2); + PlayerbotSecurity* GetSecurity() { return &security; } - Position GetJumpDestination() { return jumpDestination; } - void SetJumpDestination(Position pos) { jumpDestination = pos; } - void ResetJumpDestination() { jumpDestination = Position(); } + Position GetJumpDestination() { return jumpDestination; } + void SetJumpDestination(Position pos) { jumpDestination = pos; } + void ResetJumpDestination() { jumpDestination = Position(); } - bool CanMove(); - bool IsInRealGuild(); - static std::vector dispel_whitelist; - bool EqualLowercaseName(std::string s1, std::string s2); - InventoryResult CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool swap, bool not_loading = true) const; - uint8 FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const; - private: - static void _fillGearScoreData(Player* player, Item* item, std::vector* gearScore, uint32& twoHandScore, bool mixed = false); - bool IsTellAllowed(PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); - protected: - Player* bot; - Player* master; - uint32 accountId; - AiObjectContext* aiObjectContext; - Engine* currentEngine; - Engine* engines[BOT_STATE_MAX]; - BotState currentState; - ChatHelper chatHelper; - std::queue chatCommands; - std::queue chatReplies; - PacketHandlingHelper botOutgoingPacketHandlers; - PacketHandlingHelper masterIncomingPacketHandlers; - PacketHandlingHelper masterOutgoingPacketHandlers; - CompositeChatFilter chatFilter; - PlayerbotSecurity security; - std::map whispers; - std::pair currentChat; - static std::set unsecuredCommands; - bool allowActive[MAX_ACTIVITY_TYPE]; - time_t allowActiveCheckTimer[MAX_ACTIVITY_TYPE]; - bool inCombat = false; - BotCheatMask cheatMask = BotCheatMask::none; - Position jumpDestination = Position(); + bool CanMove(); + bool IsInRealGuild(); + static std::vector dispel_whitelist; + bool EqualLowercaseName(std::string s1, std::string s2); + InventoryResult CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool swap, bool not_loading = true) const; + uint8 FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const; + +private: + static void _fillGearScoreData(Player* player, Item* item, std::vector* gearScore, uint32& twoHandScore, + bool mixed = false); + bool IsTellAllowed(PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); + +protected: + Player* bot; + Player* master; + uint32 accountId; + AiObjectContext* aiObjectContext; + Engine* currentEngine; + Engine* engines[BOT_STATE_MAX]; + BotState currentState; + ChatHelper chatHelper; + std::queue chatCommands; + std::queue chatReplies; + PacketHandlingHelper botOutgoingPacketHandlers; + PacketHandlingHelper masterIncomingPacketHandlers; + PacketHandlingHelper masterOutgoingPacketHandlers; + CompositeChatFilter chatFilter; + PlayerbotSecurity security; + std::map whispers; + std::pair currentChat; + static std::set unsecuredCommands; + bool allowActive[MAX_ACTIVITY_TYPE]; + time_t allowActiveCheckTimer[MAX_ACTIVITY_TYPE]; + bool inCombat = false; + BotCheatMask cheatMask = BotCheatMask::none; + Position jumpDestination = Position(); }; #endif diff --git a/src/PlayerbotAIAware.h b/src/PlayerbotAIAware.h index c83604f0..a43ba60c 100644 --- a/src/PlayerbotAIAware.h +++ b/src/PlayerbotAIAware.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PLAYERbotAIAWARE_H @@ -9,11 +10,11 @@ class PlayerbotAI; class PlayerbotAIAware { - public: - PlayerbotAIAware(PlayerbotAI* botAI) : botAI(botAI) { } +public: + PlayerbotAIAware(PlayerbotAI* botAI) : botAI(botAI) {} - protected: - PlayerbotAI* botAI; +protected: + PlayerbotAI* botAI; }; #endif diff --git a/src/PlayerbotAIBase.cpp b/src/PlayerbotAIBase.cpp index b2d41340..57b40727 100644 --- a/src/PlayerbotAIBase.cpp +++ b/src/PlayerbotAIBase.cpp @@ -1,13 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PlayerbotAIBase.h" + #include "Playerbots.h" -PlayerbotAIBase::PlayerbotAIBase(bool isBotAI) : nextAICheckDelay(0), _isBotAI(isBotAI) -{ -} +PlayerbotAIBase::PlayerbotAIBase(bool isBotAI) : nextAICheckDelay(0), _isBotAI(isBotAI) {} void PlayerbotAIBase::UpdateAI(uint32 elapsed, bool minimal) { @@ -26,12 +26,12 @@ void PlayerbotAIBase::UpdateAI(uint32 elapsed, bool minimal) void PlayerbotAIBase::SetNextCheckDelay(uint32 const delay) { // if (nextAICheckDelay < delay) - // LOG_DEBUG("playerbots", "Setting lesser delay {} -> {}", nextAICheckDelay, delay); + // LOG_DEBUG("playerbots", "Setting lesser delay {} -> {}", nextAICheckDelay, delay); nextAICheckDelay = delay; // if (nextAICheckDelay > sPlayerbotAIConfig->globalCoolDown) - // LOG_DEBUG("playerbots", "std::set next check delay: {}", nextAICheckDelay); + // LOG_DEBUG("playerbots", "std::set next check delay: {}", nextAICheckDelay); } void PlayerbotAIBase::IncreaseNextCheckDelay(uint32 delay) @@ -42,10 +42,7 @@ void PlayerbotAIBase::IncreaseNextCheckDelay(uint32 delay) // LOG_DEBUG("playerbots", "increase next check delay: {}", nextAICheckDelay); } -bool PlayerbotAIBase::CanUpdateAI() -{ - return nextAICheckDelay == 0; -} +bool PlayerbotAIBase::CanUpdateAI() { return nextAICheckDelay == 0; } void PlayerbotAIBase::YieldThread(bool delay) { @@ -53,12 +50,6 @@ void PlayerbotAIBase::YieldThread(bool delay) nextAICheckDelay = delay ? sPlayerbotAIConfig->reactDelay * 10 : sPlayerbotAIConfig->reactDelay; } -bool PlayerbotAIBase::IsActive() -{ - return nextAICheckDelay < sPlayerbotAIConfig->maxWaitForMove; -} +bool PlayerbotAIBase::IsActive() { return nextAICheckDelay < sPlayerbotAIConfig->maxWaitForMove; } -bool PlayerbotAIBase::IsBotAI() const -{ - return _isBotAI; -} +bool PlayerbotAIBase::IsBotAI() const { return _isBotAI; } diff --git a/src/PlayerbotAIBase.h b/src/PlayerbotAIBase.h index 6fa40d6b..66fec542 100644 --- a/src/PlayerbotAIBase.h +++ b/src/PlayerbotAIBase.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PLAYERBOTAIBASE_H @@ -9,23 +10,23 @@ class PlayerbotAIBase { - public: - PlayerbotAIBase(bool isBotAI); +public: + PlayerbotAIBase(bool isBotAI); - bool CanUpdateAI(); - void SetNextCheckDelay(uint32 const delay); - void IncreaseNextCheckDelay(uint32 delay); - void YieldThread(bool delay = false); - virtual void UpdateAI(uint32 elapsed, bool minimal = false); - virtual void UpdateAIInternal(uint32 elapsed, bool minimal = false) = 0; - bool IsActive(); - bool IsBotAI() const; + bool CanUpdateAI(); + void SetNextCheckDelay(uint32 const delay); + void IncreaseNextCheckDelay(uint32 delay); + void YieldThread(bool delay = false); + virtual void UpdateAI(uint32 elapsed, bool minimal = false); + virtual void UpdateAIInternal(uint32 elapsed, bool minimal = false) = 0; + bool IsActive(); + bool IsBotAI() const; - protected: - uint32 nextAICheckDelay; +protected: + uint32 nextAICheckDelay; - private: - bool _isBotAI; +private: + bool _isBotAI; }; #endif diff --git a/src/PlayerbotAIConfig.cpp b/src/PlayerbotAIConfig.cpp index e90d847f..d567e058 100644 --- a/src/PlayerbotAIConfig.cpp +++ b/src/PlayerbotAIConfig.cpp @@ -1,17 +1,19 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PlayerbotAIConfig.h" + +#include + #include "Config.h" -#include "Playerbots.h" +#include "PlayerbotDungeonSuggestionMgr.h" #include "PlayerbotFactory.h" +#include "Playerbots.h" #include "RandomItemMgr.h" #include "RandomPlayerbotFactory.h" #include "Talentspec.h" -#include "PlayerbotDungeonSuggestionMgr.h" - -#include template void LoadList(std::string const value, T& list) @@ -110,49 +112,71 @@ bool PlayerbotAIConfig::Initialize() randomBotMapsAsString = sConfigMgr->GetOption("AiPlayerbot.RandomBotMaps", "0,1,530,571"); LoadList>(randomBotMapsAsString, randomBotMaps); probTeleToBankers = sConfigMgr->GetOption("AiPlayerbot.ProbTeleToBankers", 0.25f); - LoadList>(sConfigMgr->GetOption("AiPlayerbot.RandomBotQuestItems", "6948,5175,5176,5177,5178,16309,12382,13704,11000"), randomBotQuestItems); - LoadList>(sConfigMgr->GetOption("AiPlayerbot.RandomBotSpellIds", "54197"), randomBotSpellIds); - LoadList>(sConfigMgr->GetOption("AiPlayerbot.PvpProhibitedZoneIds", "2255,656,2361,2362,2363,976,35,2268,3425,392,541,1446,3828,3712,3738,3565,3539,3623,4152,3988,4658,4284,4418,4436,4275,4323,4395"), pvpProhibitedZoneIds); - LoadList>(sConfigMgr->GetOption("AiPlayerbot.PvpProhibitedAreaIds", "976,35"), pvpProhibitedAreaIds); + LoadList>( + sConfigMgr->GetOption("AiPlayerbot.RandomBotQuestItems", + "6948,5175,5176,5177,5178,16309,12382,13704,11000"), + randomBotQuestItems); + LoadList>(sConfigMgr->GetOption("AiPlayerbot.RandomBotSpellIds", "54197"), + randomBotSpellIds); + LoadList>( + sConfigMgr->GetOption("AiPlayerbot.PvpProhibitedZoneIds", + "2255,656,2361,2362,2363,976,35,2268,3425,392,541,1446,3828,3712,3738,3565," + "3539,3623,4152,3988,4658,4284,4418,4436,4275,4323,4395"), + pvpProhibitedZoneIds); + LoadList>(sConfigMgr->GetOption("AiPlayerbot.PvpProhibitedAreaIds", "976,35"), + pvpProhibitedAreaIds); - LoadList>(sConfigMgr->GetOption("AiPlayerbot.RandomBotQuestIds", "7848,3802,5505,6502,7761"), randomBotQuestIds); + LoadList>( + sConfigMgr->GetOption("AiPlayerbot.RandomBotQuestIds", "7848,3802,5505,6502,7761"), + randomBotQuestIds); botAutologin = sConfigMgr->GetOption("AiPlayerbot.BotAutologin", false); randomBotAutologin = sConfigMgr->GetOption("AiPlayerbot.RandomBotAutologin", true); minRandomBots = sConfigMgr->GetOption("AiPlayerbot.MinRandomBots", 50); maxRandomBots = sConfigMgr->GetOption("AiPlayerbot.MaxRandomBots", 200); randomBotUpdateInterval = sConfigMgr->GetOption("AiPlayerbot.RandomBotUpdateInterval", MINUTE); - randomBotCountChangeMinInterval = sConfigMgr->GetOption("AiPlayerbot.RandomBotCountChangeMinInterval", 30 * MINUTE); - randomBotCountChangeMaxInterval = sConfigMgr->GetOption("AiPlayerbot.RandomBotCountChangeMaxInterval", 2 * HOUR); + randomBotCountChangeMinInterval = + sConfigMgr->GetOption("AiPlayerbot.RandomBotCountChangeMinInterval", 30 * MINUTE); + randomBotCountChangeMaxInterval = + sConfigMgr->GetOption("AiPlayerbot.RandomBotCountChangeMaxInterval", 2 * HOUR); minRandomBotInWorldTime = sConfigMgr->GetOption("AiPlayerbot.MinRandomBotInWorldTime", 2 * HOUR); maxRandomBotInWorldTime = sConfigMgr->GetOption("AiPlayerbot.MaxRandomBotInWorldTime", 12 * HOUR); minRandomBotRandomizeTime = sConfigMgr->GetOption("AiPlayerbot.MinRandomBotRandomizeTime", 2 * HOUR); maxRandomBotRandomizeTime = sConfigMgr->GetOption("AiPlayerbot.MaxRandomBotRandomizeTime", 14 * 24 * HOUR); - minRandomBotChangeStrategyTime = sConfigMgr->GetOption("AiPlayerbot.MinRandomBotChangeStrategyTime", 30 * MINUTE); - maxRandomBotChangeStrategyTime = sConfigMgr->GetOption("AiPlayerbot.MaxRandomBotChangeStrategyTime", 2 * HOUR); + minRandomBotChangeStrategyTime = + sConfigMgr->GetOption("AiPlayerbot.MinRandomBotChangeStrategyTime", 30 * MINUTE); + maxRandomBotChangeStrategyTime = + sConfigMgr->GetOption("AiPlayerbot.MaxRandomBotChangeStrategyTime", 2 * HOUR); minRandomBotReviveTime = sConfigMgr->GetOption("AiPlayerbot.MinRandomBotReviveTime", MINUTE); maxRandomBotReviveTime = sConfigMgr->GetOption("AiPlayerbot.MaxRandomBotReviveTime", 5 * MINUTE); minRandomBotTeleportInterval = sConfigMgr->GetOption("AiPlayerbot.MinRandomBotTeleportInterval", 1 * HOUR); maxRandomBotTeleportInterval = sConfigMgr->GetOption("AiPlayerbot.MaxRandomBotTeleportInterval", 5 * HOUR); - randomBotInWorldWithRotationDisabled = sConfigMgr->GetOption("AiPlayerbot.RandomBotInWorldWithRotationDisabled", 1 * YEAR); + randomBotInWorldWithRotationDisabled = + sConfigMgr->GetOption("AiPlayerbot.RandomBotInWorldWithRotationDisabled", 1 * YEAR); randomBotTeleportDistance = sConfigMgr->GetOption("AiPlayerbot.RandomBotTeleportDistance", 100); randomBotsPerInterval = sConfigMgr->GetOption("AiPlayerbot.RandomBotsPerInterval", MINUTE); - minRandomBotsPriceChangeInterval = sConfigMgr->GetOption("AiPlayerbot.MinRandomBotsPriceChangeInterval", 2 * HOUR); - maxRandomBotsPriceChangeInterval = sConfigMgr->GetOption("AiPlayerbot.MaxRandomBotsPriceChangeInterval", 48 * HOUR); + minRandomBotsPriceChangeInterval = + sConfigMgr->GetOption("AiPlayerbot.MinRandomBotsPriceChangeInterval", 2 * HOUR); + maxRandomBotsPriceChangeInterval = + sConfigMgr->GetOption("AiPlayerbot.MaxRandomBotsPriceChangeInterval", 48 * HOUR); randomBotJoinLfg = sConfigMgr->GetOption("AiPlayerbot.RandomBotJoinLfg", true); randomBotTalk = sConfigMgr->GetOption("AiPlayerbot.RandomBotTalk", false); randomBotEmote = sConfigMgr->GetOption("AiPlayerbot.RandomBotEmote", false); randomBotSuggestDungeons = sConfigMgr->GetOption("AiPlayerbot.RandomBotSuggestDungeons", true); randomBotGuildTalk = sConfigMgr->GetOption("AiPlayerbot.RandomBotGuildTalk", false); - suggestDungeonsInLowerCaseRandomly = sConfigMgr->GetOption("AiPlayerbot.SuggestDungeonsInLowerCaseRandomly", false); + suggestDungeonsInLowerCaseRandomly = + sConfigMgr->GetOption("AiPlayerbot.SuggestDungeonsInLowerCaseRandomly", false); randomBotJoinBG = sConfigMgr->GetOption("AiPlayerbot.RandomBotJoinBG", true); randomBotAutoJoinBG = sConfigMgr->GetOption("AiPlayerbot.RandomBotAutoJoinBG", false); randomBotAutoJoinWarsongBracket = sConfigMgr->GetOption("AiPlayerbot.RandomBotAutoJoinWarsongBracket", 14); randomBotAutoJoinArenaBracket = sConfigMgr->GetOption("AiPlayerbot.RandomBotAutoJoinArenaBracket", 7); randomBotAutoJoinBGWarsongCount = sConfigMgr->GetOption("AiPlayerbot.RandomBotAutoJoinBGWarsongCount", 0); - randomBotAutoJoinBGRatedArena2v2Count = sConfigMgr->GetOption("AiPlayerbot.RandomBotAutoJoinBGRatedArena2v2Count", 0); - randomBotAutoJoinBGRatedArena3v3Count = sConfigMgr->GetOption("AiPlayerbot.RandomBotAutoJoinBGRatedArena3v3Count", 0); - randomBotAutoJoinBGRatedArena5v5Count = sConfigMgr->GetOption("AiPlayerbot.RandomBotAutoJoinBGRatedArena5v5Count", 0); + randomBotAutoJoinBGRatedArena2v2Count = + sConfigMgr->GetOption("AiPlayerbot.RandomBotAutoJoinBGRatedArena2v2Count", 0); + randomBotAutoJoinBGRatedArena3v3Count = + sConfigMgr->GetOption("AiPlayerbot.RandomBotAutoJoinBGRatedArena3v3Count", 0); + randomBotAutoJoinBGRatedArena5v5Count = + sConfigMgr->GetOption("AiPlayerbot.RandomBotAutoJoinBGRatedArena5v5Count", 0); logInGroupOnly = sConfigMgr->GetOption("AiPlayerbot.LogInGroupOnly", true); logValuesPerTick = sConfigMgr->GetOption("AiPlayerbot.LogValuesPerTick", false); fleeingEnabled = sConfigMgr->GetOption("AiPlayerbot.FleeingEnabled", true); @@ -183,7 +207,8 @@ bool PlayerbotAIConfig::Initialize() for (uint32 cls = 1; cls < MAX_CLASSES; ++cls) { - if (cls == 10) { + if (cls == 10) + { continue; } for (uint32 spec = 0; spec < MAX_SPECNO; ++spec) @@ -196,12 +221,15 @@ bool PlayerbotAIConfig::Initialize() os << "AiPlayerbot.PremadeSpecGlyph." << cls << "." << spec; premadeSpecGlyph[cls][spec] = sConfigMgr->GetOption(os.str().c_str(), "", false); std::vector splitSpecGlyph = split(premadeSpecGlyph[cls][spec], ','); - for (std::string &split : splitSpecGlyph) { - if (split.size() != 0) { + for (std::string& split : splitSpecGlyph) + { + if (split.size() != 0) + { parsedSpecGlyph[cls][spec].push_back(atoi(split.c_str())); } } - for (uint32 level = 0; level < MAX_LEVEL; ++level) { + for (uint32 level = 0; level < MAX_LEVEL; ++level) + { std::ostringstream os; os << "AiPlayerbot.PremadeSpecLink." << cls << "." << spec << "." << level; premadeSpecLink[cls][spec][level] = sConfigMgr->GetOption(os.str().c_str(), "", false); @@ -221,7 +249,8 @@ bool PlayerbotAIConfig::Initialize() } botCheats.clear(); - LoadListString>(sConfigMgr->GetOption("AiPlayerbot.BotCheats", "taxi"), botCheats); + LoadListString>(sConfigMgr->GetOption("AiPlayerbot.BotCheats", "taxi"), + botCheats); botCheatMask = 0; @@ -236,7 +265,8 @@ bool PlayerbotAIConfig::Initialize() if (std::find(botCheats.begin(), botCheats.end(), "power") != botCheats.end()) botCheatMask |= (uint32)BotCheatMask::power; - LoadListString>(sConfigMgr->GetOption("AiPlayerbot.AllowedLogFiles", ""), allowedLogFiles); + LoadListString>(sConfigMgr->GetOption("AiPlayerbot.AllowedLogFiles", ""), + allowedLogFiles); worldBuffs.clear(); @@ -264,7 +294,8 @@ bool PlayerbotAIConfig::Initialize() minGuildTaskChangeTime = sConfigMgr->GetOption("AiPlayerbot.MinGuildTaskChangeTime", 3 * 24 * 3600); maxGuildTaskChangeTime = sConfigMgr->GetOption("AiPlayerbot.MaxGuildTaskChangeTime", 4 * 24 * 3600); minGuildTaskAdvertisementTime = sConfigMgr->GetOption("AiPlayerbot.MinGuildTaskAdvertisementTime", 300); - maxGuildTaskAdvertisementTime = sConfigMgr->GetOption("AiPlayerbot.MaxGuildTaskAdvertisementTime", 12 * 3600); + maxGuildTaskAdvertisementTime = + sConfigMgr->GetOption("AiPlayerbot.MaxGuildTaskAdvertisementTime", 12 * 3600); minGuildTaskRewardTime = sConfigMgr->GetOption("AiPlayerbot.MinGuildTaskRewardTime", 300); maxGuildTaskRewardTime = sConfigMgr->GetOption("AiPlayerbot.MaxGuildTaskRewardTime", 3600); guildTaskAdvertCleanupTime = sConfigMgr->GetOption("AiPlayerbot.GuildTaskAdvertCleanupTime", 300); @@ -292,7 +323,7 @@ bool PlayerbotAIConfig::Initialize() botRepairWhenSummon = sConfigMgr->GetOption("AiPlayerbot.BotRepairWhenSummon", true); autoInitOnly = sConfigMgr->GetOption("AiPlayerbot.AutoInitOnly", false); autoInitEquipLevelLimitRatio = sConfigMgr->GetOption("AiPlayerbot.AutoInitEquipLevelLimitRatio", 1.0); - + maxAddedBots = sConfigMgr->GetOption("AiPlayerbot.MaxAddedBots", 40); maxAddedBotsPerClass = sConfigMgr->GetOption("AiPlayerbot.MaxAddedBotsPerClass", 10); addClassCommand = sConfigMgr->GetOption("AiPlayerbot.AddClassCommand", 1); @@ -352,7 +383,8 @@ bool PlayerbotAIConfig::Initialize() selfBotLevel = sConfigMgr->GetOption("AiPlayerbot.SelfBotLevel", 1); RandomPlayerbotFactory::CreateRandomBots(); - if (World::IsStopped()) { + if (World::IsStopped()) + { return true; } PlayerbotFactory::Init(); @@ -418,7 +450,8 @@ std::string const PlayerbotAIConfig::GetTimestampStr() // MM minutes (2 digits 00-59) // SS seconds (2 digits 00-59) char buf[20]; - snprintf(buf, 20, "%04d-%02d-%02d %02d-%02d-%02d", aTm->tm_year + 1900, aTm->tm_mon + 1, aTm->tm_mday, aTm->tm_hour, aTm->tm_min, aTm->tm_sec); + snprintf(buf, 20, "%04d-%02d-%02d %02d-%02d-%02d", aTm->tm_year + 1900, aTm->tm_mon + 1, aTm->tm_mday, aTm->tm_hour, + aTm->tm_min, aTm->tm_sec); return std::string(buf); } @@ -437,7 +470,7 @@ bool PlayerbotAIConfig::openLog(std::string const fileName, char const* mode) FILE* file = logFileIt->second.first; bool fileOpen = logFileIt->second.second; - if (fileOpen) //close log file + if (fileOpen) // close log file fclose(file); std::string m_logsDir = sConfigMgr->GetOption("LogsDir", "", false); @@ -447,7 +480,6 @@ bool PlayerbotAIConfig::openLog(std::string const fileName, char const* mode) m_logsDir.append("/"); } - file = fopen((m_logsDir + fileName).c_str(), mode); fileOpen = true; @@ -490,7 +522,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, minLevel1, maxLevel1}; worldBuffs.push_back(wb); } @@ -503,7 +535,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, minLevel1, maxLevel1}; worldBuffs.push_back(wb); } } @@ -517,7 +549,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, minLevel1, maxLevel1}; worldBuffs.push_back(wb); } } @@ -531,7 +563,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, minLevel1, maxLevel1}; worldBuffs.push_back(wb); } } @@ -545,34 +577,35 @@ void PlayerbotAIConfig::loadWorldBuf(uint32 factionId1, uint32 classId1, uint32 for (auto buff : buffs) { - worldBuff wb = { buff, factionId1, classId1, minLevel1, maxLevel1 }; + worldBuff wb = {buff, factionId1, classId1, minLevel1, maxLevel1}; worldBuffs.push_back(wb); } } } -static std::vector split(const std::string &str, const std::string &pattern) +static std::vector split(const std::string& str, const std::string& pattern) { std::vector res; - if(str == "") + if (str == "") return res; // Also add separators to string connections to facilitate intercepting the last paragraph. std::string strs = str + pattern; size_t pos = strs.find(pattern); - while(pos != strs.npos) + while (pos != strs.npos) { std::string temp = strs.substr(0, pos); res.push_back(temp); // Remove the split string and split the remaining string - strs = strs.substr(pos+1, strs.size()); + strs = strs.substr(pos + 1, strs.size()); pos = strs.find(pattern); } return res; } -std::vector> PlayerbotAIConfig::ParseTempTalentsOrder(uint32 cls, std::string tab_link) { +std::vector> PlayerbotAIConfig::ParseTempTalentsOrder(uint32 cls, std::string tab_link) +{ // check bad link uint32 classMask = 1 << (cls - 1); std::vector> res; @@ -581,40 +614,44 @@ std::vector> PlayerbotAIConfig::ParseTempTalentsOrder(uint32 std::vector>> orders(3); for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if(!talentInfo) + TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); + if (!talentInfo) continue; - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - if(!talentTabInfo) + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + if (!talentTabInfo) continue; - if( (classMask & talentTabInfo->ClassMask) == 0 ) + if ((classMask & talentTabInfo->ClassMask) == 0) continue; spells[talentTabInfo->tabpage].push_back(talentInfo); } - for (int tab = 0; tab < 3; tab++) { - if (tab_links.size() <= tab) { + for (int tab = 0; tab < 3; tab++) + { + if (tab_links.size() <= tab) + { break; } - std::sort(spells[tab].begin(), spells[tab].end(), [&](TalentEntry const* lhs, TalentEntry const* rhs) { - return lhs->Row != rhs->Row ? lhs->Row < rhs->Row : lhs->Col < rhs->Col; - }); - for (int i = 0; i < tab_links[tab].size(); i++) { - if (i >= spells[tab].size()) { + std::sort(spells[tab].begin(), spells[tab].end(), + [&](TalentEntry const* lhs, TalentEntry const* rhs) + { return lhs->Row != rhs->Row ? lhs->Row < rhs->Row : lhs->Col < rhs->Col; }); + for (int i = 0; i < tab_links[tab].size(); i++) + { + if (i >= spells[tab].size()) + { break; } int lvl = tab_links[tab][i] - '0'; - if (lvl == 0) continue; + if (lvl == 0) + continue; orders[tab].push_back({(uint32)tab, spells[tab][i]->Row, spells[tab][i]->Col, (uint32)lvl}); } } // sort by talent tab size - std::sort(orders.begin(), orders.end(), [&](auto &lhs, auto &rhs) { - return lhs.size() > rhs.size(); - }); - for (auto &order : orders) { + std::sort(orders.begin(), orders.end(), [&](auto& lhs, auto& rhs) { return lhs.size() > rhs.size(); }); + for (auto& order : orders) + { res.insert(res.end(), order.begin(), order.end()); } return res; diff --git a/src/PlayerbotAIConfig.h b/src/PlayerbotAIConfig.h index 3971d819..c4209bd9 100644 --- a/src/PlayerbotAIConfig.h +++ b/src/PlayerbotAIConfig.h @@ -1,256 +1,262 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PLAYERbotAICONFIG_H #define _PLAYERBOT_PLAYERbotAICONFIG_H +#include + #include "Common.h" #include "DBCEnums.h" #include "SharedDefines.h" #include "Talentspec.h" -#include - enum class BotCheatMask : uint32 { - none = 0, - taxi = 1, - gold = 2, - health = 4, - mana = 8, - power = 16, + none = 0, + taxi = 1, + gold = 2, + health = 4, + mana = 8, + power = 16, maxMask = 32 }; enum class HealingManaEfficiency : uint8 { - VERY_LOW = 1, - LOW = 2, - MEDIUM = 4, - HIGH = 8, - VERY_HIGH = 16, - SUPERIOR = 32 + VERY_LOW = 1, + LOW = 2, + MEDIUM = 4, + HIGH = 8, + VERY_HIGH = 16, + SUPERIOR = 32 }; #define MAX_SPECNO 20 class PlayerbotAIConfig { - public: - PlayerbotAIConfig() { }; - static PlayerbotAIConfig* instance() - { - static PlayerbotAIConfig instance; - return &instance; - } +public: + PlayerbotAIConfig(){}; + static PlayerbotAIConfig* instance() + { + static PlayerbotAIConfig instance; + return &instance; + } - bool Initialize(); - bool IsInRandomAccountList(uint32 id); - bool IsInRandomQuestItemList(uint32 id); - bool IsPvpProhibited(uint32 zoneId, uint32 areaId); - bool IsInPvpProhibitedZone(uint32 id); - bool IsInPvpProhibitedArea(uint32 id); + bool Initialize(); + bool IsInRandomAccountList(uint32 id); + bool IsInRandomQuestItemList(uint32 id); + bool IsPvpProhibited(uint32 zoneId, uint32 areaId); + bool IsInPvpProhibitedZone(uint32 id); + bool IsInPvpProhibitedArea(uint32 id); - bool enabled; - bool allowGuildBots, allowPlayerBots; - uint32 globalCoolDown, reactDelay, maxWaitForMove, disableMoveSplinePath, maxMovementSearchTime, - expireActionTime, dispelAuraDuration, passiveDelay, repeatDelay, - errorDelay, rpgDelay, sitDelay, returnDelay, lootDelay; - float sightDistance, spellDistance, reactDistance, grindDistance, lootDistance, shootDistance, - fleeDistance, tooCloseDistance, meleeDistance, followDistance, whisperDistance, contactDistance, - aoeRadius, rpgDistance, targetPosRecalcDistance, farDistance, healDistance, aggroDistance; - uint32 criticalHealth, lowHealth, mediumHealth, almostFullHealth; - uint32 lowMana, mediumMana; - bool autoSaveMana; - uint32 saveManaThreshold; - bool autoAvoidAoe; - bool tellWhenAvoidAoe; - - uint32 openGoSpell; - bool randomBotAutologin; - bool botAutologin; - std::string randomBotMapsAsString; - float probTeleToBankers; - std::vector randomBotMaps; - std::vector randomBotQuestItems; - std::vector randomBotAccounts; - std::vector randomBotSpellIds; - std::vector randomBotQuestIds; - uint32 randomBotTeleportDistance; - float randomGearLoweringChance; - int32 randomGearQualityLimit; - int32 randomGearScoreLimit; - float randomBotMaxLevelChance; - float randomBotRpgChance; - uint32 minRandomBots, maxRandomBots; - uint32 randomBotUpdateInterval, randomBotCountChangeMinInterval, randomBotCountChangeMaxInterval; - uint32 minRandomBotInWorldTime, maxRandomBotInWorldTime; - uint32 minRandomBotRandomizeTime, maxRandomBotRandomizeTime; - uint32 minRandomBotChangeStrategyTime, maxRandomBotChangeStrategyTime; - uint32 minRandomBotReviveTime, maxRandomBotReviveTime; - uint32 minRandomBotTeleportInterval, maxRandomBotTeleportInterval; - uint32 randomBotInWorldWithRotationDisabled; - uint32 minRandomBotPvpTime, maxRandomBotPvpTime; - uint32 randomBotsPerInterval; - uint32 minRandomBotsPriceChangeInterval, maxRandomBotsPriceChangeInterval; - bool randomBotJoinLfg; - bool randomBotTalk; - bool randomBotEmote; - bool randomBotSuggestDungeons; - bool randomBotGuildTalk; - bool suggestDungeonsInLowerCaseRandomly; - bool randomBotJoinBG; - bool randomBotAutoJoinBG; - uint32 randomBotAutoJoinWarsongBracket; - uint32 randomBotAutoJoinArenaBracket; - uint32 randomBotAutoJoinBGWarsongCount; - uint32 randomBotAutoJoinBGRatedArena2v2Count; - uint32 randomBotAutoJoinBGRatedArena3v3Count; - uint32 randomBotAutoJoinBGRatedArena5v5Count; - bool randomBotLoginAtStartup; - uint32 randomBotTeleLowerLevel, randomBotTeleHigherLevel; - bool logInGroupOnly, logValuesPerTick; - bool fleeingEnabled; - bool summonAtInnkeepersEnabled; - std::string combatStrategies, nonCombatStrategies; - std::string randomBotCombatStrategies, randomBotNonCombatStrategies; - uint32 randomBotMinLevel, randomBotMaxLevel; - float randomChangeMultiplier; + bool enabled; + bool allowGuildBots, allowPlayerBots; + uint32 globalCoolDown, reactDelay, maxWaitForMove, disableMoveSplinePath, maxMovementSearchTime, expireActionTime, + dispelAuraDuration, passiveDelay, repeatDelay, errorDelay, rpgDelay, sitDelay, returnDelay, lootDelay; + float sightDistance, spellDistance, reactDistance, grindDistance, lootDistance, shootDistance, fleeDistance, + tooCloseDistance, meleeDistance, followDistance, whisperDistance, contactDistance, aoeRadius, rpgDistance, + targetPosRecalcDistance, farDistance, healDistance, aggroDistance; + uint32 criticalHealth, lowHealth, mediumHealth, almostFullHealth; + uint32 lowMana, mediumMana; + bool autoSaveMana; + uint32 saveManaThreshold; + bool autoAvoidAoe; + bool tellWhenAvoidAoe; + uint32 openGoSpell; + bool randomBotAutologin; + bool botAutologin; + std::string randomBotMapsAsString; + float probTeleToBankers; + std::vector randomBotMaps; + std::vector randomBotQuestItems; + std::vector randomBotAccounts; + std::vector randomBotSpellIds; + std::vector randomBotQuestIds; + uint32 randomBotTeleportDistance; + float randomGearLoweringChance; + int32 randomGearQualityLimit; + int32 randomGearScoreLimit; + float randomBotMaxLevelChance; + float randomBotRpgChance; + uint32 minRandomBots, maxRandomBots; + uint32 randomBotUpdateInterval, randomBotCountChangeMinInterval, randomBotCountChangeMaxInterval; + uint32 minRandomBotInWorldTime, maxRandomBotInWorldTime; + uint32 minRandomBotRandomizeTime, maxRandomBotRandomizeTime; + uint32 minRandomBotChangeStrategyTime, maxRandomBotChangeStrategyTime; + uint32 minRandomBotReviveTime, maxRandomBotReviveTime; + uint32 minRandomBotTeleportInterval, maxRandomBotTeleportInterval; + uint32 randomBotInWorldWithRotationDisabled; + uint32 minRandomBotPvpTime, maxRandomBotPvpTime; + uint32 randomBotsPerInterval; + uint32 minRandomBotsPriceChangeInterval, maxRandomBotsPriceChangeInterval; + bool randomBotJoinLfg; + bool randomBotTalk; + bool randomBotEmote; + bool randomBotSuggestDungeons; + bool randomBotGuildTalk; + bool suggestDungeonsInLowerCaseRandomly; + bool randomBotJoinBG; + bool randomBotAutoJoinBG; + uint32 randomBotAutoJoinWarsongBracket; + uint32 randomBotAutoJoinArenaBracket; + uint32 randomBotAutoJoinBGWarsongCount; + uint32 randomBotAutoJoinBGRatedArena2v2Count; + uint32 randomBotAutoJoinBGRatedArena3v3Count; + uint32 randomBotAutoJoinBGRatedArena5v5Count; + bool randomBotLoginAtStartup; + uint32 randomBotTeleLowerLevel, randomBotTeleHigherLevel; + bool logInGroupOnly, logValuesPerTick; + bool fleeingEnabled; + bool summonAtInnkeepersEnabled; + std::string combatStrategies, nonCombatStrategies; + std::string randomBotCombatStrategies, randomBotNonCombatStrategies; + uint32 randomBotMinLevel, randomBotMaxLevel; + float randomChangeMultiplier; - // std::string premadeLevelSpec[MAX_CLASSES][10][91]; //lvl 10 - 100 - // ClassSpecs classSpecs[MAX_CLASSES]; + // std::string premadeLevelSpec[MAX_CLASSES][10][91]; //lvl 10 - 100 + // ClassSpecs classSpecs[MAX_CLASSES]; - std::string premadeSpecName[MAX_CLASSES][MAX_SPECNO]; - std::string premadeSpecGlyph[MAX_CLASSES][MAX_SPECNO]; - std::vector parsedSpecGlyph[MAX_CLASSES][MAX_SPECNO]; - std::string premadeSpecLink[MAX_CLASSES][MAX_SPECNO][MAX_LEVEL]; - std::vector> parsedSpecLinkOrder[MAX_CLASSES][MAX_SPECNO][MAX_LEVEL]; - uint32 randomClassSpecProb[MAX_CLASSES][MAX_SPECNO]; - uint32 randomClassSpecIndex[MAX_CLASSES][MAX_SPECNO]; + std::string premadeSpecName[MAX_CLASSES][MAX_SPECNO]; + std::string premadeSpecGlyph[MAX_CLASSES][MAX_SPECNO]; + std::vector parsedSpecGlyph[MAX_CLASSES][MAX_SPECNO]; + std::string premadeSpecLink[MAX_CLASSES][MAX_SPECNO][MAX_LEVEL]; + std::vector> parsedSpecLinkOrder[MAX_CLASSES][MAX_SPECNO][MAX_LEVEL]; + uint32 randomClassSpecProb[MAX_CLASSES][MAX_SPECNO]; + uint32 randomClassSpecIndex[MAX_CLASSES][MAX_SPECNO]; - std::string commandPrefix, commandSeparator; - std::string randomBotAccountPrefix; - uint32 randomBotAccountCount; - bool randomBotRandomPassword; - bool deleteRandomBotAccounts; - uint32 randomBotGuildCount; - bool deleteRandomBotGuilds; - std::vector randomBotGuilds; - std::vector pvpProhibitedZoneIds; - std::vector pvpProhibitedAreaIds; + std::string commandPrefix, commandSeparator; + std::string randomBotAccountPrefix; + uint32 randomBotAccountCount; + bool randomBotRandomPassword; + bool deleteRandomBotAccounts; + uint32 randomBotGuildCount; + bool deleteRandomBotGuilds; + std::vector randomBotGuilds; + std::vector pvpProhibitedZoneIds; + std::vector pvpProhibitedAreaIds; - bool randombotsWalkingRPG; - bool randombotsWalkingRPGInDoors; - uint32 minEnchantingBotLevel; - uint32 limitEnchantExpansion; - uint32 limitGearExpansion; - uint32 randombotStartingLevel; - bool enableRotation; - uint32 rotationPoolSize; - bool gearscorecheck; - bool randomBotPreQuests; + bool randombotsWalkingRPG; + bool randombotsWalkingRPGInDoors; + uint32 minEnchantingBotLevel; + uint32 limitEnchantExpansion; + uint32 limitGearExpansion; + uint32 randombotStartingLevel; + bool enableRotation; + uint32 rotationPoolSize; + bool gearscorecheck; + bool randomBotPreQuests; - bool guildTaskEnabled; - uint32 minGuildTaskChangeTime, maxGuildTaskChangeTime; - uint32 minGuildTaskAdvertisementTime, maxGuildTaskAdvertisementTime; - uint32 minGuildTaskRewardTime, maxGuildTaskRewardTime; - uint32 guildTaskAdvertCleanupTime; - uint32 guildTaskKillTaskDistance; + bool guildTaskEnabled; + uint32 minGuildTaskChangeTime, maxGuildTaskChangeTime; + uint32 minGuildTaskAdvertisementTime, maxGuildTaskAdvertisementTime; + uint32 minGuildTaskRewardTime, maxGuildTaskRewardTime; + uint32 guildTaskAdvertCleanupTime; + uint32 guildTaskKillTaskDistance; - uint32 iterationsPerTick; + uint32 iterationsPerTick; - std::mutex m_logMtx; - std::vector allowedLogFiles; - std::unordered_map> logFiles; + std::mutex m_logMtx; + std::vector allowedLogFiles; + std::unordered_map> logFiles; - std::vector botCheats; - uint32 botCheatMask = 0; + std::vector botCheats; + uint32 botCheatMask = 0; - struct worldBuff - { - uint32 spellId; - uint32 factionId = 0; - uint32 classId = 0; - uint32 minLevel = 0; - uint32 maxLevel = 0; - }; + struct worldBuff + { + uint32 spellId; + uint32 factionId = 0; + uint32 classId = 0; + uint32 minLevel = 0; + uint32 maxLevel = 0; + }; - std::vector worldBuffs; + std::vector worldBuffs; - uint32 commandServerPort; - bool perfMonEnabled; + uint32 commandServerPort; + bool perfMonEnabled; - bool enableGreet; - bool summonWhenGroup; - bool randomBotShowHelmet; - bool randomBotShowCloak; - bool randomBotFixedLevel; - bool disableRandomLevels; - uint32 playerbotsXPrate; - bool disableDeathKnightLogin; - uint32 botActiveAlone; + bool enableGreet; + bool summonWhenGroup; + bool randomBotShowHelmet; + bool randomBotShowCloak; + bool randomBotFixedLevel; + bool disableRandomLevels; + uint32 playerbotsXPrate; + bool disableDeathKnightLogin; + uint32 botActiveAlone; - uint32 enablePrototypePerformanceDiff; - uint32 diffWithPlayer; - uint32 diffEmpty; + uint32 enablePrototypePerformanceDiff; + uint32 diffWithPlayer; + uint32 diffEmpty; - bool freeMethodLoot; - int32 lootRollLevel; - std::string autoPickReward; - bool autoEquipUpgradeLoot; - float equipUpgradeThreshold; - bool syncQuestWithPlayer; - bool syncQuestForPlayer; - std::string autoTrainSpells; - bool autoPickTalents; - bool autoUpgradeEquip; - bool autoLearnTrainerSpells; - bool autoDoQuests; - bool syncLevelWithPlayers; - bool freeFood; - bool autoLearnQuestSpells; - bool autoTeleportForLevel; - bool randomBotSayWithoutMaster; - bool sayWhenCollectingItems; - bool randomBotGroupNearby; - uint32 tweakValue; //Debugging config + bool freeMethodLoot; + int32 lootRollLevel; + std::string autoPickReward; + bool autoEquipUpgradeLoot; + float equipUpgradeThreshold; + bool syncQuestWithPlayer; + bool syncQuestForPlayer; + std::string autoTrainSpells; + bool autoPickTalents; + bool autoUpgradeEquip; + bool autoLearnTrainerSpells; + bool autoDoQuests; + bool syncLevelWithPlayers; + bool freeFood; + bool autoLearnQuestSpells; + bool autoTeleportForLevel; + bool randomBotSayWithoutMaster; + bool sayWhenCollectingItems; + bool randomBotGroupNearby; + uint32 tweakValue; // Debugging config - uint32 randomBotArenaTeamCount; - uint32 randomBotArenaTeamMaxRating; - uint32 randomBotArenaTeamMinRating; - uint32 randomBotArenaTeam2v2Count; - uint32 randomBotArenaTeam3v3Count; - uint32 randomBotArenaTeam5v5Count; - bool deleteRandomBotArenaTeams; - std::vector randomBotArenaTeams; + uint32 randomBotArenaTeamCount; + uint32 randomBotArenaTeamMaxRating; + uint32 randomBotArenaTeamMinRating; + uint32 randomBotArenaTeam2v2Count; + uint32 randomBotArenaTeam3v3Count; + uint32 randomBotArenaTeam5v5Count; + bool deleteRandomBotArenaTeams; + std::vector randomBotArenaTeams; - uint32 selfBotLevel; - bool downgradeMaxLevelBot; - bool equipmentPersistence; - int32 equipmentPersistenceLevel; - int32 groupInvitationPermission; - bool allowSummonInCombat; - bool allowSummonWhenMasterIsDead; - bool allowSummonWhenBotIsDead; - int reviveBotWhenSummoned; - bool botRepairWhenSummon; - bool autoInitOnly; - float autoInitEquipLevelLimitRatio; - int32 maxAddedBots, maxAddedBotsPerClass; - int32 addClassCommand; - int32 maintenanceCommand; - int32 autoGearCommand, autoGearQualityLimit, autoGearScoreLimit; + uint32 selfBotLevel; + bool downgradeMaxLevelBot; + bool equipmentPersistence; + int32 equipmentPersistenceLevel; + int32 groupInvitationPermission; + bool allowSummonInCombat; + bool allowSummonWhenMasterIsDead; + bool allowSummonWhenBotIsDead; + int reviveBotWhenSummoned; + bool botRepairWhenSummon; + bool autoInitOnly; + float autoInitEquipLevelLimitRatio; + int32 maxAddedBots, maxAddedBotsPerClass; + int32 addClassCommand; + int32 maintenanceCommand; + int32 autoGearCommand, autoGearQualityLimit, autoGearScoreLimit; - std::string const GetTimestampStr(); - bool hasLog(std::string const fileName) { return std::find(allowedLogFiles.begin(), allowedLogFiles.end(), fileName) != allowedLogFiles.end(); }; - bool openLog(std::string const fileName, char const* mode = "a"); - bool isLogOpen(std::string const fileName) { auto it = logFiles.find(fileName); return it != logFiles.end() && it->second.second; } - void log(std::string const fileName, const char* str, ...); + std::string const GetTimestampStr(); + bool hasLog(std::string const fileName) + { + return std::find(allowedLogFiles.begin(), allowedLogFiles.end(), fileName) != allowedLogFiles.end(); + }; + bool openLog(std::string const fileName, char const* mode = "a"); + bool isLogOpen(std::string const fileName) + { + auto it = logFiles.find(fileName); + return it != logFiles.end() && it->second.second; + } + void log(std::string const fileName, const char* str, ...); - void loadWorldBuf(uint32 factionId, uint32 classId, uint32 minLevel, uint32 maxLevel); - static std::vector> ParseTempTalentsOrder(uint32 cls, std::string temp_talents_order); + void loadWorldBuf(uint32 factionId, uint32 classId, uint32 minLevel, uint32 maxLevel); + static std::vector> ParseTempTalentsOrder(uint32 cls, std::string temp_talents_order); }; #define sPlayerbotAIConfig PlayerbotAIConfig::instance() diff --git a/src/PlayerbotCommandServer.cpp b/src/PlayerbotCommandServer.cpp index f2b94380..482c2348 100644 --- a/src/PlayerbotCommandServer.cpp +++ b/src/PlayerbotCommandServer.cpp @@ -1,18 +1,19 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PlayerbotCommandServer.h" -#include "IoContext.h" -#include "Playerbots.h" +#include +#include +#include +#include #include #include -#include -#include -#include -#include +#include "IoContext.h" +#include "Playerbots.h" using boost::asio::ip::tcp; typedef boost::shared_ptr socket_ptr; @@ -29,7 +30,7 @@ bool ReadLine(socket_ptr sock, std::string* buffer, std::string* line) if (n == -1 || error == boost::asio::error::eof) return false; else if (error) - throw boost::system::system_error(error); // Some other error. + throw boost::system::system_error(error); // Some other error. buf[n] = 0; *buffer += buf; diff --git a/src/PlayerbotCommandServer.h b/src/PlayerbotCommandServer.h index c6de454d..6ba0d24c 100644 --- a/src/PlayerbotCommandServer.h +++ b/src/PlayerbotCommandServer.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PLAYERBOTCOMMANDSERVER_H @@ -7,16 +8,16 @@ class PlayerbotCommandServer { - public: - PlayerbotCommandServer() { } - virtual ~PlayerbotCommandServer() { } - static PlayerbotCommandServer* instance() - { - static PlayerbotCommandServer instance; - return &instance; - } +public: + PlayerbotCommandServer() {} + virtual ~PlayerbotCommandServer() {} + static PlayerbotCommandServer* instance() + { + static PlayerbotCommandServer instance; + return &instance; + } - void Start(); + void Start(); }; #define sPlayerbotCommandServer PlayerbotCommandServer::instance() diff --git a/src/PlayerbotDbStore.cpp b/src/PlayerbotDbStore.cpp index edbacf8d..c644eb4e 100644 --- a/src/PlayerbotDbStore.cpp +++ b/src/PlayerbotDbStore.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PlayerbotDbStore.h" -#include "Playerbots.h" #include +#include "Playerbots.h" + void PlayerbotDbStore::Load(PlayerbotAI* botAI) { ObjectGuid::LowType guid = botAI->GetBot()->GetGUID().GetCounter(); @@ -35,8 +37,7 @@ void PlayerbotDbStore::Load(PlayerbotAI* botAI) botAI->ChangeStrategy(value, BOT_STATE_NON_COMBAT); else if (key == "dead") botAI->ChangeStrategy(value, BOT_STATE_DEAD); - } - while (result->NextRow()); + } while (result->NextRow()); botAI->GetAiObjectContext()->Load(values); } diff --git a/src/PlayerbotDbStore.h b/src/PlayerbotDbStore.h index 49ccd7f3..184bafd7 100644 --- a/src/PlayerbotDbStore.h +++ b/src/PlayerbotDbStore.h @@ -1,34 +1,35 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PLAYERBOTDBSTORE_H #define _PLAYERBOT_PLAYERBOTDBSTORE_H -#include "Common.h" - #include +#include "Common.h" + class PlayerbotAI; class PlayerbotDbStore { - public: - PlayerbotDbStore() { } - virtual ~PlayerbotDbStore() { } - static PlayerbotDbStore* instance() - { - static PlayerbotDbStore instance; - return &instance; - } +public: + PlayerbotDbStore() {} + virtual ~PlayerbotDbStore() {} + static PlayerbotDbStore* instance() + { + static PlayerbotDbStore instance; + return &instance; + } - void Save(PlayerbotAI* botAI); - void Load(PlayerbotAI* botAI); - void Reset(PlayerbotAI* botAI); + void Save(PlayerbotAI* botAI); + void Load(PlayerbotAI* botAI); + void Reset(PlayerbotAI* botAI); - private: - void SaveValue(uint32 guid, std::string const key, std::string const value); - std::string const FormatStrategies(std::string const type, std::vector strategies); +private: + void SaveValue(uint32 guid, std::string const key, std::string const value); + std::string const FormatStrategies(std::string const type, std::vector strategies); }; #define sPlayerbotDbStore PlayerbotDbStore::instance() diff --git a/src/PlayerbotDungeonSuggestionMgr.cpp b/src/PlayerbotDungeonSuggestionMgr.cpp index f240ab41..e4402d6d 100644 --- a/src/PlayerbotDungeonSuggestionMgr.cpp +++ b/src/PlayerbotDungeonSuggestionMgr.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PlayerbotDungeonSuggestionMgr.h" + #include "Playerbots.h" std::vector const PlayerbotDungeonSuggestionMgr::GetDungeonSuggestions() @@ -33,22 +35,14 @@ void PlayerbotDungeonSuggestionMgr::LoadDungeonSuggestions() std::string const abbrevation = fields[4].Get(); std::string const strategy = fields[5].Get(); - DungeonSuggestion const row = - { - name, - static_cast(difficulty), - min_level, - max_level, - abbrevation, - strategy - }; + DungeonSuggestion const row = { + name, static_cast(difficulty), min_level, max_level, abbrevation, strategy}; m_dungeonSuggestions.push_back(row); ++count; - } - while (result->NextRow()); + } while (result->NextRow()); } - LOG_INFO("server.loading", "{} playerbots dungeon suggestions loaded in {} ms", - count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", "{} playerbots dungeon suggestions loaded in {} ms", count, + GetMSTimeDiffToNow(oldMSTime)); } diff --git a/src/PlayerbotDungeonSuggestionMgr.h b/src/PlayerbotDungeonSuggestionMgr.h index 65ecce4a..5d9bb50a 100644 --- a/src/PlayerbotDungeonSuggestionMgr.h +++ b/src/PlayerbotDungeonSuggestionMgr.h @@ -1,16 +1,17 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PLAYERBOTDUNGEONSUGGESTIONMGR_H #define _PLAYERBOT_PLAYERBOTDUNGEONSUGGESTIONMGR_H -#include "Common.h" -#include "DBCEnums.h" - #include #include +#include "Common.h" +#include "DBCEnums.h" + struct DungeonSuggestion { std::string name; @@ -23,20 +24,20 @@ struct DungeonSuggestion class PlayerbotDungeonSuggestionMgr { - public: - PlayerbotDungeonSuggestionMgr() { }; - ~PlayerbotDungeonSuggestionMgr() { }; - static PlayerbotDungeonSuggestionMgr* instance() - { - static PlayerbotDungeonSuggestionMgr instance; - return &instance; - } +public: + PlayerbotDungeonSuggestionMgr(){}; + ~PlayerbotDungeonSuggestionMgr(){}; + static PlayerbotDungeonSuggestionMgr* instance() + { + static PlayerbotDungeonSuggestionMgr instance; + return &instance; + } - void LoadDungeonSuggestions(); - std::vector const GetDungeonSuggestions(); + void LoadDungeonSuggestions(); + std::vector const GetDungeonSuggestions(); - private: - std::vector m_dungeonSuggestions; +private: + std::vector m_dungeonSuggestions; }; #define sPlayerbotDungeonSuggestionMgr PlayerbotDungeonSuggestionMgr::instance() diff --git a/src/PlayerbotFactory.cpp b/src/PlayerbotFactory.cpp index 3f7279f8..4591471b 100644 --- a/src/PlayerbotFactory.cpp +++ b/src/PlayerbotFactory.cpp @@ -1,8 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PlayerbotFactory.h" + +#include +#include + #include "AccountMgr.h" #include "AiFactory.h" #include "ArenaTeam.h" @@ -10,57 +15,44 @@ #include "DBCStores.h" #include "DBCStructure.h" #include "GuildMgr.h" +#include "InventoryAction.h" #include "Item.h" #include "ItemTemplate.h" +#include "ItemVisitors.h" #include "Log.h" #include "LogCommon.h" #include "LootMgr.h" #include "MapMgr.h" #include "ObjectMgr.h" +#include "PerformanceMonitor.h" #include "PetDefines.h" #include "Player.h" #include "PlayerbotAI.h" #include "PlayerbotAIConfig.h" -#include "Playerbots.h" -#include "PerformanceMonitor.h" #include "PlayerbotDbStore.h" +#include "Playerbots.h" #include "RandomItemMgr.h" #include "RandomPlayerbotFactory.h" -#include "ItemVisitors.h" -#include "InventoryAction.h" #include "SharedDefines.h" #include "SpellAuraDefines.h" -#include -#include -#define PLAYER_SKILL_INDEX(x) (PLAYER_SKILL_INFO_1_1 + ((x)*3)) -#define ITEM_SUBCLASS_MASK_SINGLE_HAND (\ - (1 << ITEM_SUBCLASS_WEAPON_AXE) | (1 << ITEM_SUBCLASS_WEAPON_MACE) |\ - (1 << ITEM_SUBCLASS_WEAPON_SWORD) | (1 << ITEM_SUBCLASS_WEAPON_DAGGER) | (1 << ITEM_SUBCLASS_WEAPON_FIST)) +#define PLAYER_SKILL_INDEX(x) (PLAYER_SKILL_INFO_1_1 + ((x)*3)) +#define ITEM_SUBCLASS_MASK_SINGLE_HAND \ + ((1 << ITEM_SUBCLASS_WEAPON_AXE) | (1 << ITEM_SUBCLASS_WEAPON_MACE) | (1 << ITEM_SUBCLASS_WEAPON_SWORD) | \ + (1 << ITEM_SUBCLASS_WEAPON_DAGGER) | (1 << ITEM_SUBCLASS_WEAPON_FIST)) -uint32 PlayerbotFactory::tradeSkills[] = -{ - SKILL_ALCHEMY, - SKILL_ENCHANTING, - SKILL_SKINNING, - SKILL_TAILORING, - SKILL_LEATHERWORKING, - SKILL_ENGINEERING, - SKILL_HERBALISM, - SKILL_MINING, - SKILL_BLACKSMITHING, - SKILL_COOKING, - SKILL_FIRST_AID, - SKILL_FISHING, - SKILL_JEWELCRAFTING -}; +uint32 PlayerbotFactory::tradeSkills[] = {SKILL_ALCHEMY, SKILL_ENCHANTING, SKILL_SKINNING, SKILL_TAILORING, + SKILL_LEATHERWORKING, SKILL_ENGINEERING, SKILL_HERBALISM, SKILL_MINING, + SKILL_BLACKSMITHING, SKILL_COOKING, SKILL_FIRST_AID, SKILL_FISHING, + SKILL_JEWELCRAFTING}; std::list PlayerbotFactory::classQuestIds; std::list PlayerbotFactory::specialQuestIds; std::vector PlayerbotFactory::enchantSpellIdCache; std::vector PlayerbotFactory::enchantGemIdCache; -PlayerbotFactory::PlayerbotFactory(Player* bot, uint32 level, uint32 itemQuality, uint32 gearScoreLimit) : level(level), itemQuality(itemQuality), gearScoreLimit(gearScoreLimit), bot(bot) +PlayerbotFactory::PlayerbotFactory(Player* bot, uint32 level, uint32 itemQuality, uint32 gearScoreLimit) + : level(level), itemQuality(itemQuality), gearScoreLimit(gearScoreLimit), bot(bot) { botAI = GET_PLAYERBOT_AI(bot); } @@ -84,7 +76,8 @@ void PlayerbotFactory::Init() } } - for (std::vector::iterator i = sPlayerbotAIConfig->randomBotQuestIds.begin(); i != sPlayerbotAIConfig->randomBotQuestIds.end(); ++i) + for (std::vector::iterator i = sPlayerbotAIConfig->randomBotQuestIds.begin(); + i != sPlayerbotAIConfig->randomBotQuestIds.end(); ++i) { uint32 questId = *i; AddPrevQuests(questId, specialQuestIds); @@ -98,7 +91,7 @@ void PlayerbotFactory::Init() if (!spellInfo) continue; - if (id == 47181 || id == 50358 || id == 47242 || id == 52639 || id == 47147 || id == 7218) // Test Enchant + if (id == 47181 || id == 50358 || id == 47242 || id == 52639 || id == 47147 || id == 7218) // Test Enchant continue; if (strstr(spellInfo->SpellName[0], "Test")) @@ -118,29 +111,34 @@ void PlayerbotFactory::Init() SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!enchant || (enchant->slot != PERM_ENCHANTMENT_SLOT && enchant->slot != TEMP_ENCHANTMENT_SLOT)) continue; - - // SpellInfo const* enchantSpell = sSpellMgr->GetSpellInfo(enchant->spellid[0]); + + // SpellInfo const* enchantSpell = sSpellMgr->GetSpellInfo(enchant->spellid[0]); // if (!enchantSpell) // continue; - + enchantSpellIdCache.push_back(id); // LOG_INFO("playerbots", "Add {} to enchantment spells", id); } } LOG_INFO("playerbots", "Loading {} enchantment spells", enchantSpellIdCache.size()); - for (auto iter = sSpellItemEnchantmentStore.begin(); iter != sSpellItemEnchantmentStore.end(); iter++) { + for (auto iter = sSpellItemEnchantmentStore.begin(); iter != sSpellItemEnchantmentStore.end(); iter++) + { uint32 gemId = iter->GemID; - if (gemId == 0) { + if (gemId == 0) + { continue; } - if (gemId == 49110) { // unique gem + if (gemId == 49110) + { // unique gem continue; } ItemTemplate const* proto = sObjectMgr->GetItemTemplate(gemId); - if (proto->Flags & ITEM_FLAG_UNIQUE_EQUIPPABLE) { // unique gem + if (proto->Flags & ITEM_FLAG_UNIQUE_EQUIPPABLE) + { // unique gem continue; } - if (!proto || !sGemPropertiesStore.LookupEntry(proto->GemProperties)) { + if (!proto || !sGemPropertiesStore.LookupEntry(proto->GemProperties)) + { continue; } // LOG_INFO("playerbots", "Add {} to enchantment gems", gemId); @@ -153,8 +151,10 @@ void PlayerbotFactory::Prepare() { if (!itemQuality) { - uint32 gs = sPlayerbotAIConfig->randomGearScoreLimit == 0 ? 0 : - PlayerbotFactory::CalcMixedGearScore(sPlayerbotAIConfig->randomGearScoreLimit, sPlayerbotAIConfig->randomGearQualityLimit); + uint32 gs = sPlayerbotAIConfig->randomGearScoreLimit == 0 + ? 0 + : PlayerbotFactory::CalcMixedGearScore(sPlayerbotAIConfig->randomGearScoreLimit, + sPlayerbotAIConfig->randomGearQualityLimit); itemQuality = sPlayerbotAIConfig->randomGearQualityLimit; gearScoreLimit = gs; } @@ -165,7 +165,8 @@ void PlayerbotFactory::Prepare() bot->CombatStop(true); uint32 currentLevel = bot->GetLevel(); bot->GiveLevel(level); - if (level != currentLevel) { + if (level != currentLevel) + { bot->SetUInt32Value(PLAYER_XP, 0); } if (!sPlayerbotAIConfig->randomBotShowHelmet || !urand(0, 4)) @@ -185,7 +186,8 @@ void PlayerbotFactory::Randomize(bool incremental) // { // return; // } - LOG_INFO("playerbots", "{} randomizing {} (level {} class = {})...", (incremental ? "Incremental" : "Full"), bot->GetName().c_str(), level, bot->getClass()); + LOG_INFO("playerbots", "{} randomizing {} (level {} class = {})...", (incremental ? "Incremental" : "Full"), + bot->GetName().c_str(), level, bot->getClass()); // LOG_DEBUG("playerbots", "Preparing to {} randomize...", (incremental ? "incremental" : "full")); Prepare(); LOG_DEBUG("playerbots", "Resetting player..."); @@ -200,7 +202,8 @@ void PlayerbotFactory::Randomize(bool incremental) { ResetQuests(); } - if (!sPlayerbotAIConfig->equipmentPersistence || level < sPlayerbotAIConfig->equipmentPersistenceLevel) { + if (!sPlayerbotAIConfig->equipmentPersistence || level < sPlayerbotAIConfig->equipmentPersistenceLevel) + { ClearAllItems(); } // bot->SaveToDB(false, false); @@ -220,10 +223,11 @@ void PlayerbotFactory::Randomize(bool incremental) pmo->finish(); */ - if (sPlayerbotAIConfig->randomBotPreQuests){ + if (sPlayerbotAIConfig->randomBotPreQuests) + { pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Quests"); InitInstanceQuests(); - if (pmo) + if (pmo) pmo->finish(); } @@ -239,21 +243,23 @@ void PlayerbotFactory::Randomize(bool incremental) pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Skills1"); InitSkills(); InitSpecialSpells(); - + // InitTradeSkills(); if (pmo) pmo->finish(); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Talents"); LOG_DEBUG("playerbots", "Initializing talents..."); - if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) { + if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) + { InitTalentsTree(); } sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specNo", 0); - if (botAI) { + if (botAI) + { sPlayerbotDbStore->Reset(botAI); // botAI->DoSpecificAction("auto talents"); - botAI->ResetStrategies(false); // fix wrong stored strategy + botAI->ResetStrategies(false); // fix wrong stored strategy } if (pmo) pmo->finish(); @@ -279,7 +285,8 @@ void PlayerbotFactory::Randomize(bool incremental) pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Equip"); LOG_DEBUG("playerbots", "Initializing equipmemt..."); - if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) { + if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) + { InitEquipment(incremental); } // bot->SaveToDB(false, false); @@ -332,15 +339,16 @@ void PlayerbotFactory::Randomize(bool incremental) if (pmo) pmo->finish(); - if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel) { + if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel) + { ApplyEnchantAndGemsNew(); } // { - // pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_EnchantTemplate"); - // LOG_INFO("playerbots", "Initializing enchant templates..."); - // ApplyEnchantTemplate(); - // if (pmo) - // pmo->finish(); + // pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_EnchantTemplate"); + // LOG_INFO("playerbots", "Initializing enchant templates..."); + // ApplyEnchantTemplate(); + // if (pmo) + // pmo->finish(); // } pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Inventory"); @@ -354,17 +362,17 @@ void PlayerbotFactory::Randomize(bool incremental) AddConsumables(); if (pmo) pmo->finish(); - + LOG_DEBUG("playerbots", "Initializing glyphs..."); InitGlyphs(); // bot->SaveToDB(false, false); - + // pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Guilds"); // LOG_INFO("playerbots", "Initializing guilds..."); // bot->SaveToDB(false, false); // InitGuild(); // bot->SaveToDB(false, false); - //if (pmo) + // if (pmo) // pmo->finish(); if (bot->GetLevel() >= 70) @@ -376,7 +384,8 @@ void PlayerbotFactory::Randomize(bool incremental) pmo->finish(); } - if (!incremental) { + if (!incremental) + { bot->RemovePet(nullptr, PET_SAVE_AS_CURRENT, true); bot->RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT, true); // bot->SaveToDB(false, false); @@ -406,7 +415,8 @@ void PlayerbotFactory::Randomize(bool incremental) void PlayerbotFactory::Refresh() { // Prepare(); - if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) { + if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) + { InitEquipment(true); } ClearInventory(); @@ -421,7 +431,8 @@ void PlayerbotFactory::Refresh() InitAvailableSpells(); InitSkills(); InitMounts(); - if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel) { + if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel) + { ApplyEnchantAndGemsNew(); } bot->DurabilityRepairAll(false, 1.0f, false); @@ -463,7 +474,8 @@ void PlayerbotFactory::AddConsumables() StoreItem(CONSUM_ID_BRILLIANT_MANA_OIL, 5); StoreItem(CONSUM_ID_BRILLIANT_WIZARD_OIL, 5); } - if (level >= 52 && level < 58) { + if (level >= 52 && level < 58) + { StoreItem(CONSUM_ID_SUPERIOR_MANA_OIL, 5); StoreItem(CONSUM_ID_BRILLIANT_WIZARD_OIL, 5); } @@ -551,7 +563,8 @@ void PlayerbotFactory::AddConsumables() StoreItem(CONSUM_ID_DEADLY_POISON_III, 5); StoreItem(CONSUM_ID_INSTANT_POISON_IV, 5); } - if (level >= 52 && level < 60) { + if (level >= 52 && level < 60) + { StoreItem(CONSUM_ID_DEADLY_POISON_IV, 5); StoreItem(CONSUM_ID_INSTANT_POISON_V, 5); } @@ -581,31 +594,35 @@ void PlayerbotFactory::AddConsumables() void PlayerbotFactory::InitPetTalents() { Pet* pet = bot->GetPet(); - if (!pet) { + if (!pet) + { // LOG_INFO("playerbots", "{} init pet talents failed with no pet", bot->GetName().c_str()); return; } CreatureTemplate const* ci = pet->GetCreatureTemplate(); - if (!ci) { + if (!ci) + { // LOG_INFO("playerbots", "{} init pet talents failed with no creature template", bot->GetName().c_str()); return; } CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->family); - if (!pet_family || pet_family->petTalentType < 0) { - // LOG_INFO("playerbots", "{} init pet talents failed with petTalentType < 0({})", bot->GetName().c_str(), pet_family->petTalentType); + if (!pet_family || pet_family->petTalentType < 0) + { + // LOG_INFO("playerbots", "{} init pet talents failed with petTalentType < 0({})", bot->GetName().c_str(), + // pet_family->petTalentType); return; } // pet->resetTalents(); - std::unordered_map > spells; + std::unordered_map> spells; for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if(!talentInfo) + TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); + if (!talentInfo) continue; - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); - // prevent learn talent for different family (cheating) + // prevent learn talent for different family (cheating) if (!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) continue; @@ -615,10 +632,11 @@ void PlayerbotFactory::InitPetTalents() uint32 curTalentPoints = pet->GetFreeTalentPoints(); uint32 maxTalentPoints = pet->GetMaxTalentPointsForLevel(pet->GetLevel()); int row = 0; - // LOG_INFO("playerbots", "{} learning, max talent points: {}, cur: {}", bot->GetName().c_str(), maxTalentPoints, curTalentPoints); + // LOG_INFO("playerbots", "{} learning, max talent points: {}, cur: {}", bot->GetName().c_str(), maxTalentPoints, + // curTalentPoints); for (auto i = spells.begin(); i != spells.end(); ++i, ++row) { - std::vector &spells_row = i->second; + std::vector& spells_row = i->second; if (spells_row.empty()) { LOG_INFO("playerbots", "{}: No spells for talent row {}", bot->GetName().c_str(), i->first); @@ -626,11 +644,12 @@ void PlayerbotFactory::InitPetTalents() } int attemptCount = 0; // keep learning for the last row - while (!spells_row.empty() && ((((int)maxTalentPoints - (int)pet->GetFreeTalentPoints()) < 3 * (row + 1)) || (row == 5)) - && attemptCount++ < 10 && pet->GetFreeTalentPoints()) + while (!spells_row.empty() && + ((((int)maxTalentPoints - (int)pet->GetFreeTalentPoints()) < 3 * (row + 1)) || (row == 5)) && + attemptCount++ < 10 && pet->GetFreeTalentPoints()) { int index = urand(0, spells_row.size() - 1); - TalentEntry const *talentInfo = spells_row[index]; + TalentEntry const* talentInfo = spells_row[index]; int maxRank = 0; for (int rank = 0; rank < std::min((uint32)MAX_TALENT_RANK, (uint32)pet->GetFreeTalentPoints()); ++rank) { @@ -640,12 +659,15 @@ void PlayerbotFactory::InitPetTalents() maxRank = rank; } - // LOG_INFO("playerbots", "{} learn pet talent {}({})", bot->GetName().c_str(), talentInfo->TalentID, maxRank); - if (talentInfo->DependsOn) { - bot->LearnPetTalent(pet->GetGUID(), talentInfo->DependsOn, std::min(talentInfo->DependsOnRank, bot->GetFreeTalentPoints() - 1)); + // LOG_INFO("playerbots", "{} learn pet talent {}({})", bot->GetName().c_str(), talentInfo->TalentID, + // maxRank); + if (talentInfo->DependsOn) + { + bot->LearnPetTalent(pet->GetGUID(), talentInfo->DependsOn, + std::min(talentInfo->DependsOnRank, bot->GetFreeTalentPoints() - 1)); } bot->LearnPetTalent(pet->GetGUID(), talentInfo->TalentID, maxRank); - spells_row.erase(spells_row.begin() + index); + spells_row.erase(spells_row.begin() + index); } } bot->SendTalentsInfoData(true); @@ -663,7 +685,7 @@ void PlayerbotFactory::InitPet() if (!map) return; - std::vector ids; + std::vector ids; CreatureTemplateContainer const* creatures = sObjectMgr->GetCreatureTemplates(); for (CreatureTemplateContainer::const_iterator itr = creatures->begin(); itr != creatures->end(); ++itr) @@ -673,9 +695,9 @@ void PlayerbotFactory::InitPet() if (itr->second.minlevel > bot->GetLevel()) continue; - - ids.push_back(itr->first); - } + + ids.push_back(itr->first); + } if (ids.empty()) { @@ -683,9 +705,9 @@ void PlayerbotFactory::InitPet() return; } - for (uint32 i = 0; i < 10; i++) - { - uint32 index = urand(0, ids.size() - 1); + for (uint32 i = 0; i < 10; i++) + { + uint32 index = urand(0, ids.size() - 1); CreatureTemplate const* co = sObjectMgr->GetCreatureTemplate(ids[index]); if (!co) continue; @@ -693,13 +715,15 @@ void PlayerbotFactory::InitPet() continue; uint32 guid = map->GenerateLowGuid(); uint32 pet_number = sObjectMgr->GeneratePetNumber(); - if (bot->GetPetStable() && bot->GetPetStable()->CurrentPet) { + if (bot->GetPetStable() && bot->GetPetStable()->CurrentPet) + { bot->GetPetStable()->CurrentPet.value(); // bot->GetPetStable()->CurrentPet.reset(); bot->RemovePet(nullptr, PET_SAVE_AS_CURRENT); bot->RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT); } - if (bot->GetPetStable() && bot->GetPetStable()->GetUnslottedHunterPet()) { + if (bot->GetPetStable() && bot->GetPetStable()->GetUnslottedHunterPet()) + { bot->GetPetStable()->UnslottedPets.clear(); bot->RemovePet(nullptr, PET_SAVE_AS_CURRENT); bot->RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT); @@ -744,7 +768,8 @@ void PlayerbotFactory::InitPet() return; } - // LOG_INFO("playerbots", "Start make spell auto cast for {} spells. {} already auto casted.", pet->m_spells.size(), pet->GetPetAutoSpellSize()); + // LOG_INFO("playerbots", "Start make spell auto cast for {} spells. {} already auto casted.", pet->m_spells.size(), + // pet->GetPetAutoSpellSize()); for (PetSpellMap::const_iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr) { if (itr->second.state == PETSPELL_REMOVED) @@ -754,7 +779,8 @@ void PlayerbotFactory::InitPet() if (!spellInfo) continue; - if (spellInfo->IsPassive()) { + if (spellInfo->IsPassive()) + { continue; } pet->ToggleAutocast(spellInfo, true); @@ -783,7 +809,8 @@ void PlayerbotFactory::ClearSkills() void PlayerbotFactory::ClearEverything() { bot->SaveToDB(false, false); - bot->GiveLevel(bot->getClass() == CLASS_DEATH_KNIGHT ? sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL) : sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL)); + bot->GiveLevel(bot->getClass() == CLASS_DEATH_KNIGHT ? sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL) + : sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL)); bot->SetUInt32Value(PLAYER_XP, 0); LOG_INFO("playerbots", "Resetting player..."); bot->resetTalents(true); @@ -800,11 +827,12 @@ void PlayerbotFactory::ClearEverything() void PlayerbotFactory::ClearSpells() { std::list spells; - for(PlayerSpellMap::iterator itr = bot->GetSpellMap().begin(); itr != bot->GetSpellMap().end(); ++itr) + for (PlayerSpellMap::iterator itr = bot->GetSpellMap().begin(); itr != bot->GetSpellMap().end(); ++itr) { uint32 spellId = itr->first; const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId); - if(itr->second->State == PLAYERSPELL_REMOVED) { + if (itr->second->State == PLAYERSPELL_REMOVED) + { continue; } @@ -838,39 +866,43 @@ void PlayerbotFactory::ResetQuests() // reset rewarded for restart repeatable quest bot->getQuestStatusMap().erase(entry); - //bot->getQuestStatusMap()[entry].m_rewarded = false; - //bot->getQuestStatusMap()[entry].m_status = QUEST_STATUS_NONE; + // bot->getQuestStatusMap()[entry].m_rewarded = false; + // bot->getQuestStatusMap()[entry].m_status = QUEST_STATUS_NONE; } - //bot->UpdateForQuestWorldObjects(); + // bot->UpdateForQuestWorldObjects(); CharacterDatabase.Execute("DELETE FROM character_queststatus WHERE guid = {}", bot->GetGUID().GetCounter()); } -void PlayerbotFactory::InitSpells() -{ - InitAvailableSpells(); -} +void PlayerbotFactory::InitSpells() { InitAvailableSpells(); } -void PlayerbotFactory::InitTalentsTree(bool increment/*false*/, bool use_template/*true*/, bool reset/*false*/) +void PlayerbotFactory::InitTalentsTree(bool increment /*false*/, bool use_template /*true*/, bool reset /*false*/) { uint32 specTab; uint8 cls = bot->getClass(); std::map tabs = AiFactory::GetPlayerSpecTabs(bot); uint32 total_tabs = tabs[0] + tabs[1] + tabs[2]; - if (increment && total_tabs != 0) { + if (increment && total_tabs != 0) + { specTab = AiFactory::GetPlayerSpecTab(bot); - } else { + } + else + { uint32 point = urand(0, 100); uint32 p1 = sPlayerbotAIConfig->randomClassSpecProb[cls][0]; uint32 p2 = p1 + sPlayerbotAIConfig->randomClassSpecProb[cls][1]; specTab = point < p1 ? 0 : (point < p2 ? 1 : 2); } - if (reset) { + if (reset) + { bot->resetTalents(true); } // use template if can - if (use_template) { + if (use_template) + { InitTalentsByTemplate(specTab); - } else { + } + else + { InitTalents(specTab); if (bot->GetFreeTalentPoints()) InitTalents((specTab + 1) % 3); @@ -880,113 +912,137 @@ void PlayerbotFactory::InitTalentsTree(bool increment/*false*/, bool use_templat void PlayerbotFactory::InitTalentsBySpecNo(Player* bot, int specNo, bool reset) { - if (reset) { + if (reset) + { bot->resetTalents(true); } uint32 cls = bot->getClass(); int startLevel = bot->GetLevel(); uint32 classMask = bot->getClassMask(); - std::unordered_map > spells_row; + std::unordered_map> spells_row; for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if(!talentInfo) + TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); + if (!talentInfo) continue; - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - if(!talentTabInfo) + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + if (!talentTabInfo) continue; - if( (classMask & talentTabInfo->ClassMask) == 0 ) + if ((classMask & talentTabInfo->ClassMask) == 0) continue; spells_row[talentInfo->Row].push_back(talentInfo); } - while (startLevel > 1 && startLevel < 80 && sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specNo][startLevel].size() == 0) { + while (startLevel > 1 && startLevel < 80 && + sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specNo][startLevel].size() == 0) + { startLevel--; } - for (int level = startLevel; level <= 80; level++) { - if (sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specNo][level].size() == 0) { + for (int level = startLevel; level <= 80; level++) + { + if (sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specNo][level].size() == 0) + { continue; } - for (std::vector &p : sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specNo][level]) { + for (std::vector& p : sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specNo][level]) + { uint32 tab = p[0], row = p[1], col = p[2], lvl = p[3]; uint32 talentID = -1; - std::vector &spells = spells_row[row]; - if (spells.size() <= 0) { + std::vector& spells = spells_row[row]; + if (spells.size() <= 0) + { return; } - for (TalentEntry const* talentInfo : spells) { - if (talentInfo->Col != col) { + for (TalentEntry const* talentInfo : spells) + { + if (talentInfo->Col != col) + { continue; } - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - if (talentTabInfo->tabpage != tab) { + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + if (talentTabInfo->tabpage != tab) + { continue; } - if (talentInfo->DependsOn) { - bot->LearnTalent(talentInfo->DependsOn, std::min(talentInfo->DependsOnRank, bot->GetFreeTalentPoints() - 1)); + if (talentInfo->DependsOn) + { + bot->LearnTalent(talentInfo->DependsOn, + std::min(talentInfo->DependsOnRank, bot->GetFreeTalentPoints() - 1)); } talentID = talentInfo->TalentID; } bot->LearnTalent(talentID, std::min(lvl, bot->GetFreeTalentPoints()) - 1); - if (bot->GetFreeTalentPoints() == 0) { + if (bot->GetFreeTalentPoints() == 0) + { break; } } - if (bot->GetFreeTalentPoints() == 0) { + if (bot->GetFreeTalentPoints() == 0) + { break; } } bot->SendTalentsInfoData(false); } -void PlayerbotFactory::InitTalentsByParsedSpecLink(Player* bot, std::vector> parsedSpecLink, bool reset) +void PlayerbotFactory::InitTalentsByParsedSpecLink(Player* bot, std::vector> parsedSpecLink, + bool reset) { - if (reset) { + if (reset) + { bot->resetTalents(true); } uint32 classMask = bot->getClassMask(); - std::unordered_map > spells_row; + std::unordered_map> spells_row; for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if(!talentInfo) + TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); + if (!talentInfo) continue; - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - if(!talentTabInfo) + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + if (!talentTabInfo) continue; - if( (classMask & talentTabInfo->ClassMask) == 0 ) + if ((classMask & talentTabInfo->ClassMask) == 0) continue; spells_row[talentInfo->Row].push_back(talentInfo); } - for (std::vector &p : parsedSpecLink) { + for (std::vector& p : parsedSpecLink) + { uint32 tab = p[0], row = p[1], col = p[2], lvl = p[3]; uint32 talentID = -1; - std::vector &spells = spells_row[row]; - if (spells.size() <= 0) { + std::vector& spells = spells_row[row]; + if (spells.size() <= 0) + { return; } - for (TalentEntry const* talentInfo : spells) { - if (talentInfo->Col != col) { + for (TalentEntry const* talentInfo : spells) + { + if (talentInfo->Col != col) + { continue; } - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - if (talentTabInfo->tabpage != tab) { + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + if (talentTabInfo->tabpage != tab) + { continue; } - if (talentInfo->DependsOn) { - bot->LearnTalent(talentInfo->DependsOn, std::min(talentInfo->DependsOnRank, bot->GetFreeTalentPoints() - 1)); + if (talentInfo->DependsOn) + { + bot->LearnTalent(talentInfo->DependsOn, + std::min(talentInfo->DependsOnRank, bot->GetFreeTalentPoints() - 1)); } talentID = talentInfo->TalentID; } bot->LearnTalent(talentID, std::min(lvl, bot->GetFreeTalentPoints()) - 1); - if (bot->GetFreeTalentPoints() == 0) { + if (bot->GetFreeTalentPoints() == 0) + { break; } } @@ -995,56 +1051,61 @@ void PlayerbotFactory::InitTalentsByParsedSpecLink(Player* bot, std::vectorGetTemplate()->ItemId; + if (CanKeep(id)) { - uint32 id = item->GetTemplate()->ItemId; - if (CanKeep(id)) - { - keep.insert(id); - return true; - } - - bot->DestroyItem(item->GetBagSlot(), item->GetSlot(), true); + keep.insert(id); return true; } - private: - bool CanKeep(uint32 id) - { - if (keep.find(id) != keep.end()) - return false; - - if (sPlayerbotAIConfig->IsInRandomQuestItemList(id)) - return true; + bot->DestroyItem(item->GetBagSlot(), item->GetSlot(), true); + return true; + } +private: + bool CanKeep(uint32 id) + { + if (keep.find(id) != keep.end()) return false; - } - Player* bot; - std::set keep; + if (sPlayerbotAIConfig->IsInRandomQuestItemList(id)) + return true; + + return false; + } + + Player* bot; + std::set keep; }; bool PlayerbotFactory::CanEquipArmor(ItemTemplate const* proto) { - if (proto->SubClass == ITEM_SUBCLASS_ARMOR_PLATE && !bot->HasSkill(SKILL_PLATE_MAIL)) { + if (proto->SubClass == ITEM_SUBCLASS_ARMOR_PLATE && !bot->HasSkill(SKILL_PLATE_MAIL)) + { return false; } - if (proto->SubClass == ITEM_SUBCLASS_ARMOR_MAIL && !bot->HasSkill(SKILL_MAIL)) { + if (proto->SubClass == ITEM_SUBCLASS_ARMOR_MAIL && !bot->HasSkill(SKILL_MAIL)) + { return false; } - if (proto->SubClass == ITEM_SUBCLASS_ARMOR_LEATHER && !bot->HasSkill(SKILL_LEATHER)) { + if (proto->SubClass == ITEM_SUBCLASS_ARMOR_LEATHER && !bot->HasSkill(SKILL_LEATHER)) + { return false; } - if (proto->SubClass == ITEM_SUBCLASS_ARMOR_CLOTH && !bot->HasSkill(SKILL_CLOTH)) { + if (proto->SubClass == ITEM_SUBCLASS_ARMOR_CLOTH && !bot->HasSkill(SKILL_CLOTH)) + { return false; } - if (proto->SubClass == ITEM_SUBCLASS_ARMOR_SHIELD && !bot->HasSkill(SKILL_SHIELD)) { + if (proto->SubClass == ITEM_SUBCLASS_ARMOR_SHIELD && !bot->HasSkill(SKILL_SHIELD)) + { return false; } - + return true; // for (uint8 slot = 0; slot < EQUIPMENT_SLOT_END; ++slot) // { @@ -1054,7 +1115,8 @@ bool PlayerbotFactory::CanEquipArmor(ItemTemplate const* proto) // if (slot == EQUIPMENT_SLOT_OFFHAND && bot->getClass() == CLASS_ROGUE && proto->Class != ITEM_CLASS_WEAPON) // continue; - // if (slot == EQUIPMENT_SLOT_OFFHAND && bot->getClass() == CLASS_PALADIN && proto->SubClass != ITEM_SUBCLASS_ARMOR_SHIELD) + // if (slot == EQUIPMENT_SLOT_OFFHAND && bot->getClass() == CLASS_PALADIN && proto->SubClass != + // ITEM_SUBCLASS_ARMOR_SHIELD) // continue; // } @@ -1102,7 +1164,7 @@ bool PlayerbotFactory::CheckItemStats(uint8 sp, uint8 ap, uint8 tank) return sp || ap || tank; } -void PlayerbotFactory::AddItemStats(uint32 mod, uint8 &sp, uint8 &ap, uint8 &tank) +void PlayerbotFactory::AddItemStats(uint32 mod, uint8& sp, uint8& ap, uint8& tank) { switch (mod) { @@ -1140,92 +1202,65 @@ bool PlayerbotFactory::CanEquipWeapon(ItemTemplate const* proto) { switch (bot->getClass()) { - case CLASS_PRIEST: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF && - proto->SubClass != ITEM_SUBCLASS_WEAPON_WAND && + case CLASS_PRIEST: + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF && proto->SubClass != ITEM_SUBCLASS_WEAPON_WAND && proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE) - return false; - break; - case CLASS_MAGE: - case CLASS_WARLOCK: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF && - proto->SubClass != ITEM_SUBCLASS_WEAPON_WAND && - proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER && + return false; + break; + case CLASS_MAGE: + case CLASS_WARLOCK: + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF && proto->SubClass != ITEM_SUBCLASS_WEAPON_WAND && + proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD) + return false; + break; + case CLASS_WARRIOR: + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE && + proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && + proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD && + proto->SubClass != ITEM_SUBCLASS_WEAPON_GUN && proto->SubClass != ITEM_SUBCLASS_WEAPON_CROSSBOW && + proto->SubClass != ITEM_SUBCLASS_WEAPON_BOW && proto->SubClass != ITEM_SUBCLASS_WEAPON_THROWN) + return false; + break; + case CLASS_PALADIN: + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && + proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD) - return false; - break; - case CLASS_WARRIOR: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && - proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE && - proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && - proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && - proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && - proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD && - proto->SubClass != ITEM_SUBCLASS_WEAPON_GUN && - proto->SubClass != ITEM_SUBCLASS_WEAPON_CROSSBOW && - proto->SubClass != ITEM_SUBCLASS_WEAPON_BOW && - proto->SubClass != ITEM_SUBCLASS_WEAPON_THROWN) - return false; - break; - case CLASS_PALADIN: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && - proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && - proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && - proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE2 && + return false; + break; + case CLASS_DEATH_KNIGHT: + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && + proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE2 && + proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE && proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD) - return false; - break; - case CLASS_DEATH_KNIGHT: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && - proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && - proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && - proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE2 && - proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE && - proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && - proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD) - return false; - break; - case CLASS_SHAMAN: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && - proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE && - proto->SubClass != ITEM_SUBCLASS_WEAPON_FIST && - proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && - proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE2 && - proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER && - proto->SubClass != ITEM_SUBCLASS_WEAPON_FIST && - proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF) - return false; - break; - case CLASS_DRUID: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && - proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && - proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER && - proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF) - return false; - break; - case CLASS_HUNTER: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE2 && - proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE && - proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && - proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && - proto->SubClass != ITEM_SUBCLASS_WEAPON_FIST && - proto->SubClass != ITEM_SUBCLASS_WEAPON_GUN && - proto->SubClass != ITEM_SUBCLASS_WEAPON_CROSSBOW && - proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF && + return false; + break; + case CLASS_SHAMAN: + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE && + proto->SubClass != ITEM_SUBCLASS_WEAPON_FIST && proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && + proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER && + proto->SubClass != ITEM_SUBCLASS_WEAPON_FIST && proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF) + return false; + break; + case CLASS_DRUID: + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && + proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER && proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF) + return false; + break; + case CLASS_HUNTER: + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE && + proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && + proto->SubClass != ITEM_SUBCLASS_WEAPON_FIST && proto->SubClass != ITEM_SUBCLASS_WEAPON_GUN && + proto->SubClass != ITEM_SUBCLASS_WEAPON_CROSSBOW && proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF && proto->SubClass != ITEM_SUBCLASS_WEAPON_BOW) - return false; - break; - case CLASS_ROGUE: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER && - proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD && - proto->SubClass != ITEM_SUBCLASS_WEAPON_FIST && - proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && - proto->SubClass != ITEM_SUBCLASS_WEAPON_GUN && - proto->SubClass != ITEM_SUBCLASS_WEAPON_CROSSBOW && - proto->SubClass != ITEM_SUBCLASS_WEAPON_BOW && - proto->SubClass != ITEM_SUBCLASS_WEAPON_THROWN) - return false; - break; + return false; + break; + case CLASS_ROGUE: + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD && + proto->SubClass != ITEM_SUBCLASS_WEAPON_FIST && proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && + proto->SubClass != ITEM_SUBCLASS_WEAPON_GUN && proto->SubClass != ITEM_SUBCLASS_WEAPON_CROSSBOW && + proto->SubClass != ITEM_SUBCLASS_WEAPON_BOW && proto->SubClass != ITEM_SUBCLASS_WEAPON_THROWN) + return false; + break; } return true; @@ -1252,24 +1287,23 @@ bool PlayerbotFactory::CanEquipItem(ItemTemplate const* proto, uint32 desiredQua uint32 level = bot->GetLevel(); uint32 delta = 2; if (level < 15) - delta = std::min(level, 15u); // urand(7, 15); + delta = std::min(level, 15u); // urand(7, 15); // else if (proto->Class == ITEM_CLASS_WEAPON || proto->SubClass == ITEM_SUBCLASS_ARMOR_SHIELD) // delta = urand(2, 3); // else if (!(level % 10) || (level % 10) == 9) // delta = 2; else if (level < 40) - delta = 10; //urand(5, 10); + delta = 10; // urand(5, 10); else if (level < 60) - delta = 6; // urand(3, 7); + delta = 6; // urand(3, 7); else if (level < 70) - delta = 9; // urand(2, 5); + delta = 9; // urand(2, 5); else if (level < 80) - delta = 9; // urand(2, 4); + delta = 9; // urand(2, 4); else if (level == 80) - delta = 9; // urand(2, 4); + delta = 9; // urand(2, 4); - if (desiredQuality > ITEM_QUALITY_NORMAL && - (requiredLevel > level || requiredLevel < level - delta)) + if (desiredQuality > ITEM_QUALITY_NORMAL && (requiredLevel > level || requiredLevel < level - delta)) return false; return true; @@ -1371,7 +1405,8 @@ void Shuffle(std::vector& items) // newItem->SetOwnerGUID(bot->GetGUID()); // EnchantItem(newItem); // LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Equip: {}, slot: {}, Old item: {}", -// bot->GetGUID().ToString().c_str(), IsAlliance(bot->getRace()) ? "A" : "H", bot->GetLevel(), bot->GetName(), newItemId, slot, itemInSlot); +// bot->GetGUID().ToString().c_str(), IsAlliance(bot->getRace()) ? "A" : "H", +// bot->GetLevel(), bot->GetName(), newItemId, slot, itemInSlot); // found = true; // break; // } @@ -1398,7 +1433,8 @@ void Shuffle(std::vector& items) // EnchantItem(newItem); // found = true; // LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Equip: {}, slot: {}", -// bot->GetGUID().ToString().c_str(), IsAlliance(bot->getRace()) ? "A" : "H", bot->GetLevel(), bot->GetName(), newItemId, slot); +// bot->GetGUID().ToString().c_str(), IsAlliance(bot->getRace()) ? "A" : "H", +// bot->GetLevel(), bot->GetName(), newItemId, slot); // break; // } // } @@ -1408,7 +1444,8 @@ void Shuffle(std::vector& items) // if (!found) // { // LOG_INFO("playerbots", "Bot {} {}:{} <{}>: no item for slot {}", -// bot->GetGUID().ToString().c_str(), IsAlliance(bot->getRace()) ? "A" : "H", bot->GetLevel(), bot->GetName(), slot); +// bot->GetGUID().ToString().c_str(), IsAlliance(bot->getRace()) ? "A" : "H", bot->GetLevel(), +// bot->GetName(), slot); // continue; // } // } @@ -1416,9 +1453,9 @@ void Shuffle(std::vector& items) void PlayerbotFactory::InitEquipment(bool incremental) { - std::unordered_map > items; + std::unordered_map> items; int tab = AiFactory::GetPlayerSpecTab(bot); - + uint32 blevel = bot->GetLevel(); int32 delta = 2; if (blevel < 15) @@ -1438,30 +1475,36 @@ void PlayerbotFactory::InitEquipment(bool incremental) { if (slot == EQUIPMENT_SLOT_TABARD || slot == EQUIPMENT_SLOT_BODY) continue; - + if (level < 40 && (slot == EQUIPMENT_SLOT_TRINKET1 || slot == EQUIPMENT_SLOT_TRINKET2)) continue; if (level < 30 && slot == EQUIPMENT_SLOT_NECK) continue; - + if (level < 25 && slot == EQUIPMENT_SLOT_HEAD) continue; - + if (level < 20 && (slot == EQUIPMENT_SLOT_FINGER1 || slot == EQUIPMENT_SLOT_FINGER2)) continue; uint32 desiredQuality = itemQuality; - if (urand(0, 100) < 100 * sPlayerbotAIConfig->randomGearLoweringChance && desiredQuality > ITEM_QUALITY_NORMAL) { + if (urand(0, 100) < 100 * sPlayerbotAIConfig->randomGearLoweringChance && desiredQuality > ITEM_QUALITY_NORMAL) + { desiredQuality--; } do { ItemTemplateContainer const* itemTemplate = sObjectMgr->GetItemTemplateStore(); - for (uint32 requiredLevel = bot->GetLevel(); requiredLevel > std::max((int32)bot->GetLevel() - delta, 0); requiredLevel--) { - for (InventoryType inventoryType : GetPossibleInventoryTypeListBySlot((EquipmentSlots)slot)) { - for (uint32 itemId : sRandomItemMgr->GetCachedEquipments(requiredLevel, inventoryType)) { - if (itemId == 46978) { // shaman earth ring totem + for (uint32 requiredLevel = bot->GetLevel(); requiredLevel > std::max((int32)bot->GetLevel() - delta, 0); + requiredLevel--) + { + for (InventoryType inventoryType : GetPossibleInventoryTypeListBySlot((EquipmentSlots)slot)) + { + for (uint32 itemId : sRandomItemMgr->GetCachedEquipments(requiredLevel, inventoryType)) + { + if (itemId == 46978) + { // shaman earth ring totem continue; } @@ -1469,46 +1512,49 @@ void PlayerbotFactory::InitEquipment(bool incremental) if (sPlayerbotAIConfig->limitGearExpansion && bot->GetLevel() <= 60 && itemId >= 23728) continue; - if (sPlayerbotAIConfig->limitGearExpansion && bot->GetLevel() <= 70 && itemId >= 35570 && itemId != 36737 && itemId != 37739 && itemId != 37740)//transition point from TBC -> WOTLK isn't as clear, and there are other wearable TBC items above 35570 but nothing of significance + if (sPlayerbotAIConfig->limitGearExpansion && bot->GetLevel() <= 70 && itemId >= 35570 && + itemId != 36737 && itemId != 37739 && + itemId != 37740) // transition point from TBC -> WOTLK isn't as clear, and there are other + // wearable TBC items above 35570 but nothing of significance continue; ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId); if (!proto) continue; - - if (gearScoreLimit != 0 && CalcMixedGearScore(proto->ItemLevel, proto->Quality) > gearScoreLimit) { + + if (gearScoreLimit != 0 && + CalcMixedGearScore(proto->ItemLevel, proto->Quality) > gearScoreLimit) + { continue; } - if (proto->Class != ITEM_CLASS_WEAPON && - proto->Class != ITEM_CLASS_ARMOR) + if (proto->Class != ITEM_CLASS_WEAPON && proto->Class != ITEM_CLASS_ARMOR) continue; if (!CanEquipItem(proto, desiredQuality)) continue; - if (proto->Class == ITEM_CLASS_ARMOR && ( - slot == EQUIPMENT_SLOT_HEAD || - slot == EQUIPMENT_SLOT_SHOULDERS || - slot == EQUIPMENT_SLOT_CHEST || - slot == EQUIPMENT_SLOT_WAIST || - slot == EQUIPMENT_SLOT_LEGS || - slot == EQUIPMENT_SLOT_FEET || - slot == EQUIPMENT_SLOT_WRISTS || - slot == EQUIPMENT_SLOT_HANDS) && !CanEquipArmor(proto)) - continue; + if (proto->Class == ITEM_CLASS_ARMOR && + (slot == EQUIPMENT_SLOT_HEAD || slot == EQUIPMENT_SLOT_SHOULDERS || + slot == EQUIPMENT_SLOT_CHEST || slot == EQUIPMENT_SLOT_WAIST || + slot == EQUIPMENT_SLOT_LEGS || slot == EQUIPMENT_SLOT_FEET || + slot == EQUIPMENT_SLOT_WRISTS || slot == EQUIPMENT_SLOT_HANDS) && + !CanEquipArmor(proto)) + continue; if (proto->Class == ITEM_CLASS_WEAPON && !CanEquipWeapon(proto)) continue; - if (slot == EQUIPMENT_SLOT_OFFHAND && bot->getClass() == CLASS_ROGUE && proto->Class != ITEM_CLASS_WEAPON) + if (slot == EQUIPMENT_SLOT_OFFHAND && bot->getClass() == CLASS_ROGUE && + proto->Class != ITEM_CLASS_WEAPON) continue; - + uint16 dest = 0; if (CanEquipUnseenItem(slot, dest, itemId)) items[slot].push_back(itemId); } } - if (items[slot].size() >= 25) break; + if (items[slot].size() >= 25) + break; } } while (items[slot].size() < 25 && desiredQuality-- > ITEM_QUALITY_NORMAL); } @@ -1517,13 +1563,13 @@ void PlayerbotFactory::InitEquipment(bool incremental) { if (slot == EQUIPMENT_SLOT_TABARD || slot == EQUIPMENT_SLOT_BODY) continue; - + if (level < 40 && (slot == EQUIPMENT_SLOT_TRINKET1 || slot == EQUIPMENT_SLOT_TRINKET2)) continue; if (level < 25 && slot == EQUIPMENT_SLOT_NECK) continue; - + if (level < 25 && slot == EQUIPMENT_SLOT_HEAD) continue; @@ -1534,7 +1580,8 @@ void PlayerbotFactory::InitEquipment(bool incremental) } Item* oldItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if (incremental && !IsDesiredReplacement(oldItem)) { + if (incremental && !IsDesiredReplacement(oldItem)) + { continue; } @@ -1544,22 +1591,24 @@ void PlayerbotFactory::InitEquipment(bool incremental) { uint32 index = urand(0, ids.size() - 1); uint32 newItemId = ids[index]; - + uint16 dest; if (oldItem && oldItem->GetTemplate()->ItemId == newItemId) continue; - + if (!CanEquipUnseenItem(slot, dest, newItemId)) continue; - + float cur_score = CalculateItemScore(newItemId, bot); - if (cur_score > bestScoreForSlot) { + if (cur_score > bestScoreForSlot) + { bestScoreForSlot = cur_score; bestItemForSlot = newItemId; } } - if (bestItemForSlot == 0) { + if (bestItemForSlot == 0) + { continue; } if (oldItem) @@ -1593,14 +1642,15 @@ bool PlayerbotFactory::IsDesiredReplacement(Item* item) ItemTemplate const* proto = item->GetTemplate(); uint32 requiredLevel = proto->RequiredLevel; - if (!requiredLevel) { + if (!requiredLevel) + { return true; } // if (!requiredLevel) // { // requiredLevel = sRandomItemMgr->GetMinLevelFromCache(proto->ItemId); // } - + uint32 delta = 1 + (80 - bot->GetLevel()) / 10; return proto->Quality < ITEM_QUALITY_RARE || int32(bot->GetLevel() - requiredLevel) > delta; } @@ -1628,7 +1678,8 @@ inline Item* StoreNewItemInInventorySlot(Player* player, uint32 newItemId, uint3 // std::map> items; // uint32 desiredQuality = itemQuality; -// while (urand(0, 100) < 100 * sPlayerbotAIConfig->randomGearLoweringChance && desiredQuality > ITEM_QUALITY_NORMAL) +// while (urand(0, 100) < 100 * sPlayerbotAIConfig->randomGearLoweringChance && desiredQuality > +// ITEM_QUALITY_NORMAL) // { // desiredQuality--; // } @@ -1665,14 +1716,16 @@ inline Item* StoreNewItemInInventorySlot(Player* player, uint32 newItemId, uint3 // case ITEM_SUBCLASS_WEAPON_FIST: // case ITEM_SUBCLASS_WEAPON_MACE: // case ITEM_SUBCLASS_WEAPON_SWORD: -// if (proto->SubClass == ITEM_SUBCLASS_WEAPON_AXE || proto->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER || proto->SubClass == ITEM_SUBCLASS_WEAPON_FIST || -// proto->SubClass == ITEM_SUBCLASS_WEAPON_MACE || proto->SubClass == ITEM_SUBCLASS_WEAPON_SWORD) -// continue; +// if (proto->SubClass == ITEM_SUBCLASS_WEAPON_AXE || proto->SubClass == +// ITEM_SUBCLASS_WEAPON_DAGGER || proto->SubClass == ITEM_SUBCLASS_WEAPON_FIST || +// proto->SubClass == ITEM_SUBCLASS_WEAPON_MACE || proto->SubClass == +// ITEM_SUBCLASS_WEAPON_SWORD) continue; // break; // default: -// if (proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE && proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER && proto->SubClass != ITEM_SUBCLASS_WEAPON_FIST && -// proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD) -// continue; +// if (proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE && proto->SubClass != +// ITEM_SUBCLASS_WEAPON_DAGGER && proto->SubClass != ITEM_SUBCLASS_WEAPON_FIST && +// proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != +// ITEM_SUBCLASS_WEAPON_SWORD) continue; // break; // } // } @@ -1697,15 +1750,16 @@ inline Item* StoreNewItemInInventorySlot(Player* player, uint32 newItemId, uint3 // items[proto->Class].push_back(itr.first); // } -// } while (items[ITEM_CLASS_ARMOR].empty() && items[ITEM_CLASS_WEAPON].empty() && desiredQuality-- > ITEM_QUALITY_NORMAL); +// } while (items[ITEM_CLASS_ARMOR].empty() && items[ITEM_CLASS_WEAPON].empty() && desiredQuality-- > +// ITEM_QUALITY_NORMAL); // for (std::map>::iterator i = items.begin(); i != items.end(); ++i) // { // std::vector& ids = i->second; // if (ids.empty()) // { -// LOG_DEBUG("playerbots", "{}: no items to make second equipment set for slot {}", bot->GetName().c_str(), i->first); -// continue; +// LOG_DEBUG("playerbots", "{}: no items to make second equipment set for slot {}", +// bot->GetName().c_str(), i->first); continue; // } // for (uint32 attempts = 0; attempts < 15; attempts++) @@ -1730,18 +1784,21 @@ void PlayerbotFactory::InitBags(bool destroyOld) for (uint8 slot = INVENTORY_SLOT_BAG_START; slot < INVENTORY_SLOT_BAG_END; ++slot) { uint32 newItemId = 51809; - Item *old_bag = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if (old_bag && old_bag->GetTemplate()->ItemId == newItemId) { + Item* old_bag = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); + if (old_bag && old_bag->GetTemplate()->ItemId == newItemId) + { continue; } uint16 dest; if (!CanEquipUnseenItem(slot, dest, newItemId)) continue; - - if (old_bag && destroyOld) { + + if (old_bag && destroyOld) + { bot->DestroyItem(INVENTORY_SLOT_BAG_0, slot, true); } - if (old_bag) { + if (old_bag) + { continue; } Item* newItem = bot->EquipNewItem(dest, newItemId, true); @@ -1796,7 +1853,7 @@ void PlayerbotFactory::EnchantItem(Item* item) if (!enchant || enchant->slot != PERM_ENCHANTMENT_SLOT) continue; - SpellInfo const* enchantSpell = sSpellMgr->GetSpellInfo(enchant->spellid[0]); + SpellInfo const* enchantSpell = sSpellMgr->GetSpellInfo(enchant->spellid[0]); if (!enchantSpell || (enchantSpell->SpellLevel && enchantSpell->SpellLevel > level)) continue; @@ -1826,7 +1883,8 @@ void PlayerbotFactory::EnchantItem(Item* item) if (ids.empty()) { - LOG_DEBUG("playerbots", "{}: no enchantments found for item {}", bot->GetName().c_str(), item->GetTemplate()->ItemId); + LOG_DEBUG("playerbots", "{}: no enchantments found for item {}", bot->GetName().c_str(), + item->GetTemplate()->ItemId); return; } @@ -1842,7 +1900,7 @@ void PlayerbotFactory::EnchantItem(Item* item) bot->ApplyEnchantment(item, PERM_ENCHANTMENT_SLOT, true); } -bool PlayerbotFactory::CanEquipUnseenItem(uint8 slot, uint16 &dest, uint32 item) +bool PlayerbotFactory::CanEquipUnseenItem(uint8 slot, uint16& dest, uint32 item) { dest = 0; @@ -2101,9 +2159,11 @@ void PlayerbotFactory::InitAvailableSpells() { bot->LearnDefaultSkills(); - if (trainerIdCache.empty()) { + if (trainerIdCache.empty()) + { CreatureTemplateContainer const* creatureTemplateContainer = sObjectMgr->GetCreatureTemplates(); - for (CreatureTemplateContainer::const_iterator i = creatureTemplateContainer->begin(); i != creatureTemplateContainer->end(); ++i) + for (CreatureTemplateContainer::const_iterator i = creatureTemplateContainer->begin(); + i != creatureTemplateContainer->end(); ++i) { CreatureTemplate const& co = i->second; if (co.trainer_type != TRAINER_TYPE_TRADESKILLS && co.trainer_type != TRAINER_TYPE_CLASS) @@ -2116,15 +2176,17 @@ void PlayerbotFactory::InitAvailableSpells() trainerIdCache.push_back(trainerId); } } - for (uint32 trainerId : trainerIdCache) { - TrainerSpellData const* trainer_spells = sObjectMgr->GetNpcTrainerSpells(trainerId); + for (uint32 trainerId : trainerIdCache) + { + TrainerSpellData const* trainer_spells = sObjectMgr->GetNpcTrainerSpells(trainerId); if (!trainer_spells) trainer_spells = sObjectMgr->GetNpcTrainerSpells(trainerId); if (!trainer_spells) continue; - for (TrainerSpellMap::const_iterator itr = trainer_spells->spellList.begin(); itr != trainer_spells->spellList.end(); ++itr) + for (TrainerSpellMap::const_iterator itr = trainer_spells->spellList.begin(); + itr != trainer_spells->spellList.end(); ++itr) { TrainerSpell const* tSpell = &itr->second; @@ -2153,14 +2215,17 @@ void PlayerbotFactory::InitAvailableSpells() break; } } - if (!learn) { + if (!learn) + { continue; } - if (tSpell->learnedSpell[0]) { + if (tSpell->learnedSpell[0]) + { bot->learnSpell(tSpell->learnedSpell[0], false); } - else { + else + { botAI->CastSpell(tSpell->spell, bot); } } @@ -2175,20 +2240,23 @@ void PlayerbotFactory::InitClassSpells() case CLASS_WARRIOR: bot->learnSpell(78, true); bot->learnSpell(2457, true); - if (level >= 10) { - bot->learnSpell(71, false); // Defensive Stance - bot->learnSpell(355, false); // Taunt - bot->learnSpell(7386, false); // Sunder Armor + if (level >= 10) + { + bot->learnSpell(71, false); // Defensive Stance + bot->learnSpell(355, false); // Taunt + bot->learnSpell(7386, false); // Sunder Armor } - if (level >= 30) { - bot->learnSpell(2458, false); // Berserker Stance + if (level >= 30) + { + bot->learnSpell(2458, false); // Berserker Stance } break; case CLASS_PALADIN: bot->learnSpell(21084, true); bot->learnSpell(635, true); - if (level >= 12) { - bot->learnSpell(7328, false); // Redemption + if (level >= 12) + { + bot->learnSpell(7328, false); // Redemption } break; case CLASS_ROGUE: @@ -2200,18 +2268,19 @@ void PlayerbotFactory::InitClassSpells() bot->learnSpell(47541, true); bot->learnSpell(45462, true); bot->learnSpell(45902, true); - //to leave DK starting area + // to leave DK starting area bot->learnSpell(50977, false); break; case CLASS_HUNTER: bot->learnSpell(2973, true); bot->learnSpell(75, true); - if (level >= 10) { - bot->learnSpell(883, false); // call pet - bot->learnSpell(1515, false); // tame pet - bot->learnSpell(6991, false); // feed pet - bot->learnSpell(982, false); // revive pet - bot->learnSpell(2641, false); // dismiss pet + if (level >= 10) + { + bot->learnSpell(883, false); // call pet + bot->learnSpell(1515, false); // tame pet + bot->learnSpell(6991, false); // feed pet + bot->learnSpell(982, false); // revive pet + bot->learnSpell(2641, false); // dismiss pet } break; case CLASS_PRIEST: @@ -2225,38 +2294,45 @@ void PlayerbotFactory::InitClassSpells() case CLASS_WARLOCK: bot->learnSpell(687, true); bot->learnSpell(686, true); - bot->learnSpell(688, true); // summon imp - if (level >= 10) { - bot->learnSpell(697, false); // summon voidwalker + bot->learnSpell(688, true); // summon imp + if (level >= 10) + { + bot->learnSpell(697, false); // summon voidwalker } - if (level >= 20) { - bot->learnSpell(712, false); // summon succubus + if (level >= 20) + { + bot->learnSpell(712, false); // summon succubus } - if (level >= 30) { - bot->learnSpell(691, false); // summon felhunter + if (level >= 30) + { + bot->learnSpell(691, false); // summon felhunter } break; case CLASS_DRUID: bot->learnSpell(5176, true); bot->learnSpell(5185, true); - if (level >= 10) { - bot->learnSpell(5487, false); // bear form - bot->learnSpell(6795, false); // Growl - bot->learnSpell(6807, false); // Maul + if (level >= 10) + { + bot->learnSpell(5487, false); // bear form + bot->learnSpell(6795, false); // Growl + bot->learnSpell(6807, false); // Maul } break; case CLASS_SHAMAN: bot->learnSpell(403, true); bot->learnSpell(331, true); // bot->learnSpell(66747, true); // Totem of the Earthen Ring - if (level >= 4) { - bot->learnSpell(8071, false); // stoneskin totem + if (level >= 4) + { + bot->learnSpell(8071, false); // stoneskin totem } - if (level >= 10) { - bot->learnSpell(3599, false); // searing totem + if (level >= 10) + { + bot->learnSpell(3599, false); // searing totem } - if (level >= 20) { - bot->learnSpell(5394, false); // healing stream totem + if (level >= 20) + { + bot->learnSpell(5394, false); // healing stream totem } break; default: @@ -2266,33 +2342,34 @@ void PlayerbotFactory::InitClassSpells() void PlayerbotFactory::InitSpecialSpells() { - for (std::vector::iterator i = sPlayerbotAIConfig->randomBotSpellIds.begin(); i != sPlayerbotAIConfig->randomBotSpellIds.end(); ++i) + for (std::vector::iterator i = sPlayerbotAIConfig->randomBotSpellIds.begin(); + i != sPlayerbotAIConfig->randomBotSpellIds.end(); ++i) { uint32 spellId = *i; bot->learnSpell(spellId); } - // to leave DK starting area - if (bot->getClass() == CLASS_DEATH_KNIGHT) - { - bot->learnSpell(50977, false); - } + // to leave DK starting area + if (bot->getClass() == CLASS_DEATH_KNIGHT) + { + bot->learnSpell(50977, false); + } } void PlayerbotFactory::InitTalents(uint32 specNo) { uint32 classMask = bot->getClassMask(); - std::unordered_map > spells; + std::unordered_map> spells; for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if(!talentInfo) + TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); + if (!talentInfo) continue; - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - if(!talentTabInfo || talentTabInfo->tabpage != specNo) + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + if (!talentTabInfo || talentTabInfo->tabpage != specNo) continue; - if( (classMask & talentTabInfo->ClassMask) == 0 ) + if ((classMask & talentTabInfo->ClassMask) == 0) continue; spells[talentInfo->Row].push_back(talentInfo); @@ -2301,17 +2378,18 @@ void PlayerbotFactory::InitTalents(uint32 specNo) uint32 freePoints = bot->GetFreeTalentPoints(); for (auto i = spells.begin(); i != spells.end(); ++i) { - std::vector &spells_row = i->second; + std::vector& spells_row = i->second; if (spells_row.empty()) { LOG_INFO("playerbots", "{}: No spells for talent row {}", bot->GetName().c_str(), i->first); continue; } int attemptCount = 0; - while (!spells_row.empty() && (int)freePoints - (int)bot->GetFreeTalentPoints() < 5 && attemptCount++ < 3 && bot->GetFreeTalentPoints()) + while (!spells_row.empty() && (int)freePoints - (int)bot->GetFreeTalentPoints() < 5 && attemptCount++ < 3 && + bot->GetFreeTalentPoints()) { int index = urand(0, spells_row.size() - 1); - TalentEntry const *talentInfo = spells_row[index]; + TalentEntry const* talentInfo = spells_row[index]; int maxRank = 0; for (int rank = 0; rank < std::min((uint32)MAX_TALENT_RANK, bot->GetFreeTalentPoints()); ++rank) { @@ -2321,11 +2399,13 @@ void PlayerbotFactory::InitTalents(uint32 specNo) maxRank = rank; } - if (talentInfo->DependsOn) { - bot->LearnTalent(talentInfo->DependsOn, std::min(talentInfo->DependsOnRank, bot->GetFreeTalentPoints() - 1)); + if (talentInfo->DependsOn) + { + bot->LearnTalent(talentInfo->DependsOn, + std::min(talentInfo->DependsOnRank, bot->GetFreeTalentPoints() - 1)); } bot->LearnTalent(talentInfo->TalentID, maxRank); - spells_row.erase(spells_row.begin() + index); + spells_row.erase(spells_row.begin() + index); } freePoints = bot->GetFreeTalentPoints(); @@ -2341,47 +2421,58 @@ void PlayerbotFactory::InitTalentsByTemplate(uint32 specTab) int startLevel = bot->GetLevel(); uint32 specIndex = sPlayerbotAIConfig->randomClassSpecIndex[cls][specTab]; uint32 classMask = bot->getClassMask(); - std::unordered_map > spells_row; + std::unordered_map> spells_row; for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if(!talentInfo) + TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); + if (!talentInfo) continue; - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - if(!talentTabInfo) + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + if (!talentTabInfo) continue; - if( (classMask & talentTabInfo->ClassMask) == 0 ) + if ((classMask & talentTabInfo->ClassMask) == 0) continue; spells_row[talentInfo->Row].push_back(talentInfo); } - while (startLevel > 1 && startLevel < 80 && sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specIndex][startLevel].size() == 0) { + while (startLevel > 1 && startLevel < 80 && + sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specIndex][startLevel].size() == 0) + { startLevel--; } - for (int level = startLevel; level <= 80; level++) { - if (sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specIndex][level].size() == 0) { + for (int level = startLevel; level <= 80; level++) + { + if (sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specIndex][level].size() == 0) + { continue; } - for (std::vector &p : sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specIndex][level]) { + for (std::vector& p : sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specIndex][level]) + { uint32 tab = p[0], row = p[1], col = p[2], lvl = p[3]; uint32 talentID = 0; uint32 learnLevel = 0; - std::vector &spells = spells_row[row]; - if (spells.size() <= 0) { + std::vector& spells = spells_row[row]; + if (spells.size() <= 0) + { return; } - for (TalentEntry const* talentInfo : spells) { - if (talentInfo->Col != col) { + for (TalentEntry const* talentInfo : spells) + { + if (talentInfo->Col != col) + { continue; } - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - if (talentTabInfo->tabpage != tab) { + TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); + if (talentTabInfo->tabpage != tab) + { continue; } - if (talentInfo->DependsOn) { - bot->LearnTalent(talentInfo->DependsOn, std::min(talentInfo->DependsOnRank, bot->GetFreeTalentPoints() - 1)); + if (talentInfo->DependsOn) + { + bot->LearnTalent(talentInfo->DependsOn, + std::min(talentInfo->DependsOnRank, bot->GetFreeTalentPoints() - 1)); } talentID = talentInfo->TalentID; @@ -2397,11 +2488,13 @@ void PlayerbotFactory::InitTalentsByTemplate(uint32 specTab) learnLevel = std::min(lvl, bot->GetFreeTalentPoints() + currentTalentRank) - 1; } bot->LearnTalent(talentID, learnLevel); - if (bot->GetFreeTalentPoints() == 0) { + if (bot->GetFreeTalentPoints() == 0) + { break; } } - if (bot->GetFreeTalentPoints() == 0) { + if (bot->GetFreeTalentPoints() == 0) + { break; } } @@ -2410,13 +2503,14 @@ void PlayerbotFactory::InitTalentsByTemplate(uint32 specTab) ObjectGuid PlayerbotFactory::GetRandomBot() { GuidVector guids; - for (std::vector::iterator i = sPlayerbotAIConfig->randomBotAccounts.begin(); i != sPlayerbotAIConfig->randomBotAccounts.end(); i++) + for (std::vector::iterator i = sPlayerbotAIConfig->randomBotAccounts.begin(); + i != sPlayerbotAIConfig->randomBotAccounts.end(); i++) { uint32 accountId = *i; if (!AccountMgr::GetCharactersCount(accountId)) continue; - CharacterDatabasePreparedStatement * stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID); + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID); stmt->SetData(0, accountId); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) @@ -2440,7 +2534,7 @@ ObjectGuid PlayerbotFactory::GetRandomBot() void PlayerbotFactory::AddPrevQuests(uint32 questId, std::list& questIds) { - Quest const *quest = sObjectMgr->GetQuestTemplate(questId); + Quest const* quest = sObjectMgr->GetQuestTemplate(questId); for (Quest::PrevQuests::const_iterator iter = quest->prevQuests.begin(); iter != quest->prevQuests.end(); ++iter) { uint32 prevId = abs(*iter); @@ -2456,16 +2550,18 @@ void PlayerbotFactory::InitQuests(std::list& questMap) for (std::list::iterator i = questMap.begin(); i != questMap.end(); ++i) { uint32 questId = *i; - Quest const *quest = sObjectMgr->GetQuestTemplate(questId); + Quest const* quest = sObjectMgr->GetQuestTemplate(questId); - if (!bot->SatisfyQuestClass(quest, false) || quest->GetMinLevel() > bot->GetLevel() || !bot->SatisfyQuestRace(quest, false)) + if (!bot->SatisfyQuestClass(quest, false) || quest->GetMinLevel() > bot->GetLevel() || + !bot->SatisfyQuestRace(quest, false)) continue; bot->SetQuestStatus(questId, QUEST_STATUS_COMPLETE); bot->RewardQuest(quest, 0, bot, false); LOG_INFO("playerbots", "Bot {} ({} level) rewarded quest {}: {} (MinLevel={}, QuestLevel={})", - bot->GetName().c_str(), bot->GetLevel(), questId, quest->GetTitle().c_str(), quest->GetMinLevel(), quest->GetQuestLevel()); + bot->GetName().c_str(), bot->GetLevel(), questId, quest->GetTitle().c_str(), quest->GetMinLevel(), + quest->GetQuestLevel()); if (!(count++ % 10)) ClearInventory(); @@ -2484,7 +2580,7 @@ void PlayerbotFactory::InitInstanceQuests() // quest rewards boost bot level, so reduce back bot->GiveLevel(level); - + ClearInventory(); bot->SetUInt32Value(PLAYER_XP, currentXP); bot->SaveToDB(false, false); @@ -2534,17 +2630,15 @@ void PlayerbotFactory::InitAmmo() if (count < maxCount / 2) { - if (Item* newItem = StoreNewItemInInventorySlot(bot, entry, maxCount / 2)) { + if (Item* newItem = StoreNewItemInInventorySlot(bot, entry, maxCount / 2)) + { newItem->AddToUpdateQueueOf(bot); } } bot->SetAmmo(entry); } -uint32 PlayerbotFactory::CalcMixedGearScore(uint32 gs, uint32 quality) -{ - return gs * (quality + 1); -} +uint32 PlayerbotFactory::CalcMixedGearScore(uint32 gs, uint32 quality) { return gs * (quality + 1); } void PlayerbotFactory::InitMounts() { @@ -2562,56 +2656,56 @@ void PlayerbotFactory::InitMounts() switch (bot->getRace()) { case RACE_HUMAN: - slow = { 470, 6648, 458, 472 }; - fast = { 23228, 23227, 23229 }; + slow = {470, 6648, 458, 472}; + fast = {23228, 23227, 23229}; break; case RACE_ORC: - slow = { 6654, 6653, 580 }; - fast = { 23250, 23252, 23251 }; + slow = {6654, 6653, 580}; + fast = {23250, 23252, 23251}; break; case RACE_DWARF: - slow = { 6899, 6777, 6898 }; - fast = { 23238, 23239, 23240 }; + slow = {6899, 6777, 6898}; + fast = {23238, 23239, 23240}; break; case RACE_NIGHTELF: - slow = { 10789, 8394, 10793 }; - fast = { 23219, 23220, 63637 }; + slow = {10789, 8394, 10793}; + fast = {23219, 23220, 63637}; break; case RACE_UNDEAD_PLAYER: - slow = { 17463, 17464, 17462 }; - fast = { 17465, 23246, 66846 }; + slow = {17463, 17464, 17462}; + fast = {17465, 23246, 66846}; break; case RACE_TAUREN: - slow = { 18990, 18989, 64657 }; - fast = { 23249, 23248, 23247 }; + slow = {18990, 18989, 64657}; + fast = {23249, 23248, 23247}; break; case RACE_GNOME: - slow = { 10969, 17453, 10873, 17454 }; - fast = { 23225, 23223, 23222 }; + slow = {10969, 17453, 10873, 17454}; + fast = {23225, 23223, 23222}; break; case RACE_TROLL: - slow = { 10796, 10799, 8395, 472 }; - fast = { 23241, 23242, 23243 }; + slow = {10796, 10799, 8395, 472}; + fast = {23241, 23242, 23243}; break; case RACE_DRAENEI: - slow = { 34406, 35711, 35710 }; - fast = { 35713, 35712, 35714 }; + slow = {34406, 35711, 35710}; + fast = {35713, 35712, 35714}; break; case RACE_BLOODELF: - slow = { 33660, 35020, 35022, 35018 }; - fast = { 35025, 35025, 35027 }; + slow = {33660, 35020, 35022, 35018}; + fast = {35025, 35025, 35027}; break; } switch (bot->GetTeamId()) { case TEAM_ALLIANCE: - fslow = { 32235, 32239, 32240 }; - ffast = { 32242, 32289, 32290, 32292 }; + fslow = {32235, 32239, 32240}; + ffast = {32242, 32289, 32290, 32292}; break; case TEAM_HORDE: - fslow = { 32244, 32245, 32243 }; - ffast = { 32295, 32297, 32246, 32296 }; + fslow = {32244, 32245, 32243}; + ffast = {32295, 32297, 32246, 32296}; break; default: break; @@ -2625,15 +2719,17 @@ void PlayerbotFactory::InitMounts() for (uint32 type = 0; type < 4; type++) { bool hasMount = false; - for (uint32 &spell : mounts[bot->getRace()][type]) { - if (bot->HasSpell(spell)) { + for (uint32& spell : mounts[bot->getRace()][type]) + { + if (bot->HasSpell(spell)) + { hasMount = true; break; } } if (hasMount) continue; - + if (bot->GetLevel() < secondmount && type == 1) continue; @@ -2648,12 +2744,14 @@ void PlayerbotFactory::InitMounts() if (spell) { bot->learnSpell(spell); - LOG_DEBUG("playerbots", "Bot {} ({}) learned {} mount {}", bot->GetGUID().ToString().c_str(), bot->GetLevel(), type == 0 ? "slow" : (type == 1 ? "fast" : "flying"), spell); + LOG_DEBUG("playerbots", "Bot {} ({}) learned {} mount {}", bot->GetGUID().ToString().c_str(), + bot->GetLevel(), type == 0 ? "slow" : (type == 1 ? "fast" : "flying"), spell); } } } -void PlayerbotFactory::UnbindInstance(){ +void PlayerbotFactory::UnbindInstance() +{ Player* p = bot; ObjectGuid guid = p->GetGUID(); @@ -2673,7 +2771,7 @@ void PlayerbotFactory::UnbindInstance(){ void PlayerbotFactory::InitPotions() { - uint32 effects[] = { SPELL_EFFECT_HEAL, SPELL_EFFECT_ENERGIZE }; + uint32 effects[] = {SPELL_EFFECT_HEAL, SPELL_EFFECT_ENERGIZE}; for (uint8 i = 0; i < 2; ++i) { uint32 effect = effects[i]; @@ -2685,7 +2783,8 @@ void PlayerbotFactory::InitPotions() uint32 itemId = sRandomItemMgr->GetRandomPotion(level, effect); if (!itemId) { - // LOG_INFO("playerbots", "No potions (type {}) available for bot {} ({} level)", effect, bot->GetName().c_str(), bot->GetLevel()); + // LOG_INFO("playerbots", "No potions (type {}) available for bot {} ({} level)", effect, + // bot->GetName().c_str(), bot->GetLevel()); continue; } @@ -2696,27 +2795,27 @@ void PlayerbotFactory::InitPotions() uint32 maxCount = proto->GetMaxStackSize(); if (Item* newItem = StoreNewItemInInventorySlot(bot, itemId, urand(maxCount / 2, maxCount))) newItem->AddToUpdateQueueOf(bot); - } + } } void PlayerbotFactory::InitFood() { - if (sPlayerbotAIConfig->freeFood) { + if (sPlayerbotAIConfig->freeFood) + { return; } - std::unordered_map > items; + std::unordered_map> items; ItemTemplateContainer const* itemTemplateContainer = sObjectMgr->GetItemTemplateStore(); - for (ItemTemplateContainer::const_iterator i = itemTemplateContainer->begin(); i != itemTemplateContainer->end(); ++i) + for (ItemTemplateContainer::const_iterator i = itemTemplateContainer->begin(); i != itemTemplateContainer->end(); + ++i) { uint32 itemId = i->first; ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId); if (!proto) continue; - if (proto->Class != ITEM_CLASS_CONSUMABLE || - proto->SubClass != ITEM_SUBCLASS_FOOD || - (proto->Spells[0].SpellCategory != 11 && proto->Spells[0].SpellCategory != 59) || - proto->Bonding != NO_BIND) + if (proto->Class != ITEM_CLASS_CONSUMABLE || proto->SubClass != ITEM_SUBCLASS_FOOD || + (proto->Spells[0].SpellCategory != 11 && proto->Spells[0].SpellCategory != 59) || proto->Bonding != NO_BIND) continue; if (proto->RequiredLevel > bot->GetLevel() || proto->RequiredLevel < bot->GetLevel() - 9) @@ -2731,25 +2830,28 @@ void PlayerbotFactory::InitFood() items[proto->Spells[0].SpellCategory].push_back(itemId); } - uint32 categories[] = { 11, 59 }; + uint32 categories[] = {11, 59}; for (int i = 0; i < sizeof(categories) / sizeof(uint32); ++i) { uint32 category = categories[i]; std::vector& ids = items[category]; int tries = 0; - for (int j = 0; j < 2; j++) { + for (int j = 0; j < 2; j++) + { uint32 index = urand(0, ids.size() - 1); if (index >= ids.size()) continue; uint32 itemId = ids[index]; ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId); - // beer / wine ... - if (proto->Spells[0].SpellId == 11007 || proto->Spells[0].SpellId == 11008 || proto->Spells[0].SpellId == 11009 || - proto->Spells[0].SpellId == 11629 || proto->Spells[0].SpellId == 50986) + // beer / wine ... + if (proto->Spells[0].SpellId == 11007 || proto->Spells[0].SpellId == 11008 || + proto->Spells[0].SpellId == 11009 || proto->Spells[0].SpellId == 11629 || + proto->Spells[0].SpellId == 50986) { tries++; - if (tries > 5) { + if (tries > 5) + { continue; } j--; @@ -2757,84 +2859,98 @@ void PlayerbotFactory::InitFood() } StoreItem(itemId, proto->GetMaxStackSize()); } - } + } } void PlayerbotFactory::InitReagents() { int level = bot->GetLevel(); std::vector> items; - switch (bot->getClass()) + switch (bot->getClass()) { case CLASS_ROGUE: { std::vector instant_poison_ids = {43231, 43230, 21927, 8928, 8927, 8926, 6950, 6949, 6947}; std::vector deadly_poison_ids = {43233, 43232, 22054, 22053, 20844, 8985, 8984, 2893, 2892}; - for (int& itemId: deadly_poison_ids) { + for (int& itemId : deadly_poison_ids) + { ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId); if (proto->RequiredLevel > bot->GetLevel()) continue; - items.push_back({itemId, 20}); // deadly poison - break; + items.push_back({itemId, 20}); // deadly poison + break; } - for (int& itemId: instant_poison_ids) { + for (int& itemId : instant_poison_ids) + { ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId); if (proto->RequiredLevel > bot->GetLevel()) continue; - items.push_back({itemId, 20}); // instant poison - break; + items.push_back({itemId, 20}); // instant poison + break; } } - break; + break; case CLASS_SHAMAN: // items.push_back({46978, 1}); // Totem - items.push_back({5175, 1}); // Earth Totem - items.push_back({5176, 1}); // Flame Totem - items.push_back({5177, 1}); // Water Totem - items.push_back({5178, 1}); // Air Totem + items.push_back({5175, 1}); // Earth Totem + items.push_back({5176, 1}); // Flame Totem + items.push_back({5177, 1}); // Water Totem + items.push_back({5178, 1}); // Air Totem if (bot->GetLevel() >= 30) - items.push_back({17030, 40}); // Ankh + items.push_back({17030, 40}); // Ankh break; case CLASS_WARLOCK: - items.push_back({6265, 10}); // shard + items.push_back({6265, 10}); // shard break; case CLASS_PRIEST: - if (level >= 48 && level < 60) { - items.push_back({17028, 40}); // Wild Berries - } else if (level >= 60 && level < 80) { - items.push_back({17029, 40}); // Wild Berries - } else if (level >= 80) { - items.push_back({44615, 40}); // Wild Berries + if (level >= 48 && level < 60) + { + items.push_back({17028, 40}); // Wild Berries + } + else if (level >= 60 && level < 80) + { + items.push_back({17029, 40}); // Wild Berries + } + else if (level >= 80) + { + items.push_back({44615, 40}); // Wild Berries } break; case CLASS_MAGE: - items.push_back({17020, 40}); // Arcane Powder - items.push_back({17031, 40}); // portal - items.push_back({17032, 40}); // portal + items.push_back({17020, 40}); // Arcane Powder + items.push_back({17031, 40}); // portal + items.push_back({17032, 40}); // portal break; case CLASS_DRUID: - if (level >= 20 && level < 30) { + if (level >= 20 && level < 30) + { items.push_back({17034, 40}); } - if (level >= 30 && level < 40) { + if (level >= 30 && level < 40) + { items.push_back({17035, 40}); } - if (level >= 40 && level < 50) { + if (level >= 40 && level < 50) + { items.push_back({17036, 40}); } - if (level >= 50 && level < 60) { + if (level >= 50 && level < 60) + { items.push_back({17037, 40}); items.push_back({17021, 40}); } - if (level >= 60 && level < 70) { + if (level >= 60 && level < 70) + { items.push_back({17038, 40}); items.push_back({17026, 40}); - } - if (level >= 70 && level < 80) { + } + if (level >= 70 && level < 80) + { items.push_back({22147, 40}); items.push_back({22148, 40}); - } - if (level >= 80) { + } + if (level >= 80) + { items.push_back({44614, 40}); items.push_back({44605, 40}); } @@ -2848,7 +2964,8 @@ void PlayerbotFactory::InitReagents() default: break; } - for (std::pair item : items) { + for (std::pair item : items) + { int count = (int)item.second - (int)bot->GetItemCount(item.first); if (count > 0) StoreItem(item.first, count); @@ -2859,7 +2976,8 @@ void PlayerbotFactory::InitGlyphs(bool increment) { bot->InitGlyphsForLevel(); - if (!increment) { + if (!increment) + { for (uint32 slotIndex = 0; slotIndex < MAX_GLYPH_SLOT_INDEX; ++slotIndex) { uint32 glyph = bot->GetGlyph(slotIndex); @@ -2900,12 +3018,12 @@ void PlayerbotFactory::InitGlyphs(bool increment) maxSlot = 5; if (level >= 80) maxSlot = 6; - + uint8 glyphOrder[6] = {0, 1, 3, 2, 4, 5}; if (!maxSlot) return; - + uint8 cls = bot->getClass(); uint8 tab = AiFactory::GetPlayerSpecTab(bot); std::list glyphs; @@ -2926,7 +3044,7 @@ void PlayerbotFactory::InitGlyphs(bool increment) for (uint32 spell = 0; spell < MAX_ITEM_PROTO_SPELLS; spell++) { uint32 spellId = proto->Spells[spell].SpellId; - SpellInfo const *entry = sSpellMgr->GetSpellInfo(spellId); + SpellInfo const* entry = sSpellMgr->GetSpellInfo(spellId); if (!entry) continue; @@ -2945,14 +3063,17 @@ void PlayerbotFactory::InitGlyphs(bool increment) for (uint32 slotIndex = 0; slotIndex < maxSlot; ++slotIndex) { uint8 realSlot = glyphOrder[slotIndex]; - if (bot->GetGlyph(realSlot)) { + if (bot->GetGlyph(realSlot)) + { continue; } // uint32 slot = bot->GetGlyphSlot(slotIndex); // GlyphSlotEntry const *gs = sGlyphSlotStore.LookupEntry(slot); // if (!gs) // continue; - if (sPlayerbotAIConfig->parsedSpecGlyph[cls][tab].size() > slotIndex && sPlayerbotAIConfig->parsedSpecGlyph[cls][tab][slotIndex] != 0) { + if (sPlayerbotAIConfig->parsedSpecGlyph[cls][tab].size() > slotIndex && + sPlayerbotAIConfig->parsedSpecGlyph[cls][tab][slotIndex] != 0) + { uint32 itemId = sPlayerbotAIConfig->parsedSpecGlyph[cls][tab][slotIndex]; ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId); if (proto->Class != ITEM_CLASS_GLYPH) @@ -2960,7 +3081,7 @@ void PlayerbotFactory::InitGlyphs(bool increment) if ((proto->AllowableClass & bot->getClassMask()) == 0 || (proto->AllowableRace & bot->getRaceMask()) == 0) continue; - + if (proto->RequiredLevel > bot->GetLevel()) continue; @@ -2968,7 +3089,7 @@ void PlayerbotFactory::InitGlyphs(bool increment) for (uint32 spell = 0; spell < MAX_ITEM_PROTO_SPELLS; spell++) { uint32 spellId = proto->Spells[spell].SpellId; - SpellInfo const *entry = sSpellMgr->GetSpellInfo(spellId); + SpellInfo const* entry = sSpellMgr->GetSpellInfo(spellId); if (!entry) continue; @@ -2980,16 +3101,21 @@ void PlayerbotFactory::InitGlyphs(bool increment) glyph = entry->Effects[effect].MiscValue; } } - if (!glyph) { + if (!glyph) + { continue; } GlyphPropertiesEntry const* glyphEntry = sGlyphPropertiesStore.LookupEntry(glyph); - bot->CastSpell(bot, glyphEntry->SpellId, TriggerCastFlags(TRIGGERED_FULL_MASK & ~(TRIGGERED_IGNORE_SHAPESHIFT | TRIGGERED_IGNORE_CASTER_AURASTATE))); + bot->CastSpell(bot, glyphEntry->SpellId, + TriggerCastFlags(TRIGGERED_FULL_MASK & + ~(TRIGGERED_IGNORE_SHAPESHIFT | TRIGGERED_IGNORE_CASTER_AURASTATE))); bot->SetGlyph(realSlot, glyph, true); chosen.insert(glyph); - } else { + } + else + { uint32 slot = bot->GetGlyphSlot(realSlot); - GlyphSlotEntry const *gs = sGlyphSlotStore.LookupEntry(slot); + GlyphSlotEntry const* gs = sGlyphSlotStore.LookupEntry(slot); if (!gs) continue; @@ -2997,7 +3123,7 @@ void PlayerbotFactory::InitGlyphs(bool increment) for (std::list::iterator i = glyphs.begin(); i != glyphs.end(); ++i) { uint32 id = *i; - GlyphPropertiesEntry const *gp = sGlyphPropertiesStore.LookupEntry(id); + GlyphPropertiesEntry const* gp = sGlyphPropertiesStore.LookupEntry(id); if (!gp || gp->TypeFlags != gs->TypeFlags) continue; @@ -3019,8 +3145,10 @@ void PlayerbotFactory::InitGlyphs(bool increment) chosen.insert(id); GlyphPropertiesEntry const* glyphEntry = sGlyphPropertiesStore.LookupEntry(id); - bot->CastSpell(bot, glyphEntry->SpellId, TriggerCastFlags(TRIGGERED_FULL_MASK & ~(TRIGGERED_IGNORE_SHAPESHIFT | TRIGGERED_IGNORE_CASTER_AURASTATE))); - + bot->CastSpell(bot, glyphEntry->SpellId, + TriggerCastFlags(TRIGGERED_FULL_MASK & + ~(TRIGGERED_IGNORE_SHAPESHIFT | TRIGGERED_IGNORE_CASTER_AURASTATE))); + bot->SetGlyph(realSlot, id, true); found = true; break; @@ -3030,10 +3158,7 @@ void PlayerbotFactory::InitGlyphs(bool increment) bot->SendTalentsInfoData(false); } -void PlayerbotFactory::CancelAuras() -{ - bot->RemoveAllAuras(); -} +void PlayerbotFactory::CancelAuras() { bot->RemoveAllAuras(); } void PlayerbotFactory::InitInventory() { @@ -3046,27 +3171,27 @@ void PlayerbotFactory::InitInventorySkill() { if (bot->HasSkill(SKILL_MINING)) { - StoreItem(2901, 1); // Mining Pick + StoreItem(2901, 1); // Mining Pick } if (bot->HasSkill(SKILL_BLACKSMITHING) || bot->HasSkill(SKILL_ENGINEERING)) { - StoreItem(5956, 1); // Blacksmith Hammer + StoreItem(5956, 1); // Blacksmith Hammer } if (bot->HasSkill(SKILL_ENGINEERING)) { - StoreItem(6219, 1); // Arclight Spanner + StoreItem(6219, 1); // Arclight Spanner } if (bot->HasSkill(SKILL_ENCHANTING)) { - StoreItem(16207, 1); // Runed Arcanite Rod + StoreItem(16207, 1); // Runed Arcanite Rod } if (bot->HasSkill(SKILL_SKINNING)) { - StoreItem(7005, 1); // Skinning Knife + StoreItem(7005, 1); // Skinning Knife } } @@ -3086,7 +3211,8 @@ void PlayerbotFactory::InitInventoryTrade() uint32 itemId = sRandomItemMgr->GetRandomTrade(level); if (!itemId) { - LOG_ERROR("playerbots", "No trade items available for bot {} ({} level)", bot->GetName().c_str(), bot->GetLevel()); + LOG_ERROR("playerbots", "No trade items available for bot {} ({} level)", bot->GetName().c_str(), + bot->GetLevel()); return; } @@ -3103,7 +3229,7 @@ void PlayerbotFactory::InitInventoryTrade() break; case ITEM_QUALITY_UNCOMMON: stacks = 1; - int maxStackSize = proto->GetMaxStackSize()/2; + int maxStackSize = proto->GetMaxStackSize() / 2; uint32 max = std::max(1, maxStackSize); count = urand(1, max); break; @@ -3130,7 +3256,8 @@ void PlayerbotFactory::InitInventoryEquip() if (!proto) continue; - if ((proto->Class != ITEM_CLASS_ARMOR && proto->Class != ITEM_CLASS_WEAPON) || (proto->Bonding == BIND_WHEN_PICKED_UP || proto->Bonding == BIND_WHEN_USE)) + if ((proto->Class != ITEM_CLASS_ARMOR && proto->Class != ITEM_CLASS_WEAPON) || + (proto->Bonding == BIND_WHEN_PICKED_UP || proto->Bonding == BIND_WHEN_USE)) continue; if (proto->Class == ITEM_CLASS_ARMOR && !CanEquipArmor(proto)) @@ -3156,7 +3283,7 @@ void PlayerbotFactory::InitInventoryEquip() uint32 itemId = ids[index]; if (StoreItem(itemId, 1) && count++ >= maxCount) break; - } + } } void PlayerbotFactory::InitGuild() @@ -3174,7 +3301,8 @@ void PlayerbotFactory::InitGuild() RandomPlayerbotFactory::CreateRandomGuilds(); std::vector guilds; - for (std::vector::iterator i = sPlayerbotAIConfig->randomBotGuilds.begin(); i != sPlayerbotAIConfig->randomBotGuilds.end(); ++i) + for (std::vector::iterator i = sPlayerbotAIConfig->randomBotGuilds.begin(); + i != sPlayerbotAIConfig->randomBotGuilds.end(); ++i) guilds.push_back(*i); if (guilds.empty()) @@ -3334,7 +3462,8 @@ void PlayerbotFactory::InitArenaTeam() } std::vector arenateams; - for (std::vector::iterator i = sPlayerbotAIConfig->randomBotArenaTeams.begin(); i != sPlayerbotAIConfig->randomBotArenaTeams.end(); ++i) + for (std::vector::iterator i = sPlayerbotAIConfig->randomBotArenaTeams.begin(); + i != sPlayerbotAIConfig->randomBotArenaTeams.end(); ++i) arenateams.push_back(*i); if (arenateams.empty()) @@ -3347,7 +3476,7 @@ void PlayerbotFactory::InitArenaTeam() { int index = urand(0, arenateams.size() - 1); uint32 arenateamID = arenateams[index]; - ArenaTeam *arenateam = sArenaTeamMgr->GetArenaTeamById(arenateamID); + ArenaTeam* arenateam = sArenaTeamMgr->GetArenaTeamById(arenateamID); if (!arenateam) { LOG_ERROR("playerbots", "Invalid arena team {}", arenateamID); @@ -3378,7 +3507,7 @@ void PlayerbotFactory::InitArenaTeam() } } - if (botcaptain && botcaptain->GetTeamId() == bot->GetTeamId()) // need? + if (botcaptain && botcaptain->GetTeamId() == bot->GetTeamId()) // need? { arenateam->AddMember(bot->GetGUID()); arenateam->SaveToDB(); @@ -3404,7 +3533,7 @@ void PlayerbotFactory::ApplyEnchantTemplate() else ApplyEnchantTemplate(10); break; - case CLASS_DRUID: + case CLASS_DRUID: if (tab == 2) ApplyEnchantTemplate(112); else if (tab == 0) @@ -3412,7 +3541,7 @@ void PlayerbotFactory::ApplyEnchantTemplate() else ApplyEnchantTemplate(111); break; - case CLASS_SHAMAN: + case CLASS_SHAMAN: if (tab == 0) ApplyEnchantTemplate(70); else if (tab == 2) @@ -3420,7 +3549,7 @@ void PlayerbotFactory::ApplyEnchantTemplate() else ApplyEnchantTemplate(72); break; - case CLASS_PALADIN: + case CLASS_PALADIN: if (tab == 0) ApplyEnchantTemplate(20); else if (tab == 2) @@ -3428,108 +3557,122 @@ void PlayerbotFactory::ApplyEnchantTemplate() else if (tab == 1) ApplyEnchantTemplate(21); break; - case CLASS_HUNTER: + case CLASS_HUNTER: ApplyEnchantTemplate(30); break; - case CLASS_ROGUE: + case CLASS_ROGUE: ApplyEnchantTemplate(40); break; - case CLASS_MAGE: + case CLASS_MAGE: ApplyEnchantTemplate(80); break; - case CLASS_WARLOCK: + case CLASS_WARLOCK: ApplyEnchantTemplate(90); break; - case CLASS_PRIEST: - ApplyEnchantTemplate(50); + case CLASS_PRIEST: + ApplyEnchantTemplate(50); break; } } void PlayerbotFactory::ApplyEnchantTemplate(uint8 spec) { - for (EnchantContainer::const_iterator itr = GetEnchantContainerBegin(); itr != GetEnchantContainerEnd(); ++itr) - if ((*itr).ClassId == bot->getClass() && (*itr).SpecId == spec) { - uint32 spellid = (*itr).SpellId; - uint32 slot = (*itr).SlotId; - Item* pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if (!pItem || !pItem->IsInWorld() || !pItem->GetOwner() || !pItem->GetOwner()->IsInWorld() || !pItem->GetOwner()->GetSession()) - return; - - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); - if (!spellInfo) - return; - - uint32 enchantid = spellInfo->Effects[0].MiscValue; - if (!enchantid) + for (EnchantContainer::const_iterator itr = GetEnchantContainerBegin(); itr != GetEnchantContainerEnd(); ++itr) + if ((*itr).ClassId == bot->getClass() && (*itr).SpecId == spec) { - // LOG_ERROR("playerbots", "{}: Invalid enchantid ", enchantid, " report to devs", bot->GetName().c_str()); - return; - } + uint32 spellid = (*itr).SpellId; + uint32 slot = (*itr).SlotId; + Item* pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); + if (!pItem || !pItem->IsInWorld() || !pItem->GetOwner() || !pItem->GetOwner()->IsInWorld() || + !pItem->GetOwner()->GetSession()) + return; - if (!((1 << pItem->GetTemplate()->SubClass) & spellInfo->EquippedItemSubClassMask) && !((1 << pItem->GetTemplate()->InventoryType) & spellInfo->EquippedItemInventoryTypeMask)) - { - // LOG_ERROR("playerbots", "{}: items could not be enchanted, wrong item type equipped", bot->GetName().c_str()); - return; - } + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); + if (!spellInfo) + return; - bot->ApplyEnchantment(pItem, PERM_ENCHANTMENT_SLOT, false); - pItem->SetEnchantment(PERM_ENCHANTMENT_SLOT, enchantid, 0, 0); - bot->ApplyEnchantment(pItem, PERM_ENCHANTMENT_SLOT, true); - } + uint32 enchantid = spellInfo->Effects[0].MiscValue; + if (!enchantid) + { + // LOG_ERROR("playerbots", "{}: Invalid enchantid ", enchantid, " report to devs", + // bot->GetName().c_str()); + return; + } + + if (!((1 << pItem->GetTemplate()->SubClass) & spellInfo->EquippedItemSubClassMask) && + !((1 << pItem->GetTemplate()->InventoryType) & spellInfo->EquippedItemInventoryTypeMask)) + { + // LOG_ERROR("playerbots", "{}: items could not be enchanted, wrong item type equipped", + // bot->GetName().c_str()); + return; + } + + bot->ApplyEnchantment(pItem, PERM_ENCHANTMENT_SLOT, false); + pItem->SetEnchantment(PERM_ENCHANTMENT_SLOT, enchantid, 0, 0); + bot->ApplyEnchantment(pItem, PERM_ENCHANTMENT_SLOT, true); + } // botAI->EnchantItemT((*itr).SpellId, (*itr).SlotId); // const SpellItemEnchantmentEntry* a = sSpellItemEnchantmentStore.LookupEntry(1); } void PlayerbotFactory::ApplyEnchantAndGemsNew(bool destoryOld) { - int32 bestGemEnchantId[4] = {-1, -1, -1, -1}; // 1, 2, 4, 8 color + int32 bestGemEnchantId[4] = {-1, -1, -1, -1}; // 1, 2, 4, 8 color float bestGemScore[4] = {0, 0, 0, 0}; - for (const uint32 &enchantGem : enchantGemIdCache) { + for (const uint32& enchantGem : enchantGemIdCache) + { ItemTemplate const* gemTemplate = sObjectMgr->GetItemTemplate(enchantGem); if (!gemTemplate) continue; const GemPropertiesEntry* gemProperties = sGemPropertiesStore.LookupEntry(gemTemplate->GemProperties); - if (!gemProperties) + if (!gemProperties) continue; uint32 requiredLevel = gemTemplate->ItemLevel; - if (requiredLevel > bot->GetLevel()) { + if (requiredLevel > bot->GetLevel()) + { continue; } uint32 enchant_id = gemProperties->spellitemenchantement; if (!enchant_id) continue; - + SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if (!enchant || (enchant->slot != PERM_ENCHANTMENT_SLOT && enchant->slot != TEMP_ENCHANTMENT_SLOT)) { + if (!enchant || (enchant->slot != PERM_ENCHANTMENT_SLOT && enchant->slot != TEMP_ENCHANTMENT_SLOT)) + { continue; } - if (enchant->requiredSkill && bot->GetSkillValue(enchant->requiredSkill) < enchant->requiredSkillValue) { + if (enchant->requiredSkill && bot->GetSkillValue(enchant->requiredSkill) < enchant->requiredSkillValue) + { continue; } - - if (enchant->requiredLevel > bot->GetLevel()) { + + if (enchant->requiredLevel > bot->GetLevel()) + { continue; } float score = CalculateEnchantScore(enchant_id, bot); - if ((gemProperties->color & 1) && score >= bestGemScore[0]) { + if ((gemProperties->color & 1) && score >= bestGemScore[0]) + { bestGemScore[0] = score; bestGemEnchantId[0] = enchant_id; } - if ((gemProperties->color & 2) && score >= bestGemScore[1]) { + if ((gemProperties->color & 2) && score >= bestGemScore[1]) + { bestGemScore[1] = score; bestGemEnchantId[1] = enchant_id; } - if ((gemProperties->color & 4) && score >= bestGemScore[2]) { + if ((gemProperties->color & 4) && score >= bestGemScore[2]) + { bestGemScore[2] = score; bestGemEnchantId[2] = enchant_id; } - if ((gemProperties->color & 8) && score >= bestGemScore[3]) { + if ((gemProperties->color & 8) && score >= bestGemScore[3]) + { bestGemScore[3] = score; bestGemEnchantId[3] = enchant_id; } @@ -3540,25 +3683,29 @@ void PlayerbotFactory::ApplyEnchantAndGemsNew(bool destoryOld) if (slot == EQUIPMENT_SLOT_TABARD || slot == EQUIPMENT_SLOT_BODY) continue; Item* item = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if (!item || !item->GetOwner()) { + if (!item || !item->GetOwner()) + { continue; } int32 bestEnchantId = -1; float bestScore = 0; - for (const uint32 &enchantSpell : enchantSpellIdCache) { + for (const uint32& enchantSpell : enchantSpellIdCache) + { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(enchantSpell); if (!spellInfo) continue; - if (!item->IsFitToSpellRequirements(spellInfo)) { + if (!item->IsFitToSpellRequirements(spellInfo)) + { continue; } uint32 requiredLevel = spellInfo->BaseLevel; - if (requiredLevel > bot->GetLevel()) { + if (requiredLevel > bot->GetLevel()) + { continue; } - + // disable next expansion enchantments if (sPlayerbotAIConfig->limitEnchantExpansion && bot->GetLevel() <= 60 && enchantSpell >= 25072) continue; @@ -3574,50 +3721,55 @@ void PlayerbotFactory::ApplyEnchantAndGemsNew(bool destoryOld) uint32 enchant_id = spellInfo->Effects[j].MiscValue; if (!enchant_id) continue; - + SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if (!enchant || (enchant->slot != PERM_ENCHANTMENT_SLOT && enchant->slot != TEMP_ENCHANTMENT_SLOT)) { + if (!enchant || (enchant->slot != PERM_ENCHANTMENT_SLOT && enchant->slot != TEMP_ENCHANTMENT_SLOT)) + { continue; } - if (enchant->requiredSkill && bot->GetSkillValue(enchant->requiredSkill) < enchant->requiredSkillValue) { + if (enchant->requiredSkill && bot->GetSkillValue(enchant->requiredSkill) < enchant->requiredSkillValue) + { continue; } - - if (enchant->requiredLevel > bot->GetLevel()) { + + if (enchant->requiredLevel > bot->GetLevel()) + { continue; } float score = CalculateEnchantScore(enchant_id, bot); - if (score >= bestScore) { + if (score >= bestScore) + { bestScore = score; bestEnchantId = enchant_id; } } } // enchant item - if (bestEnchantId != -1) { + if (bestEnchantId != -1) + { bot->ApplyEnchantment(item, PERM_ENCHANTMENT_SLOT, false); item->SetEnchantment(PERM_ENCHANTMENT_SLOT, bestEnchantId, 0, 0, bot->GetGUID()); bot->ApplyEnchantment(item, PERM_ENCHANTMENT_SLOT, true); } if (!item->HasSocket()) continue; - + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot) { - uint8 socketColor = item->GetTemplate()->Socket[enchant_slot - SOCK_ENCHANTMENT_SLOT].Color; - if (!socketColor) { + if (!socketColor) + { continue; } int32 gemId; - if (1 == socketColor)//meta + if (1 == socketColor) // meta gemId = bestGemEnchantId[0]; - else if (2 == socketColor)//red + else if (2 == socketColor) // red gemId = bestGemEnchantId[1]; - else if (4 == socketColor)//yellow + else if (4 == socketColor) // yellow gemId = bestGemEnchantId[2]; - else if (8 == socketColor)//blue + else if (8 == socketColor) // blue gemId = bestGemEnchantId[3]; else continue; @@ -3628,9 +3780,11 @@ void PlayerbotFactory::ApplyEnchantAndGemsNew(bool destoryOld) } } -std::vector PlayerbotFactory::GetPossibleInventoryTypeListBySlot(EquipmentSlots slot) { +std::vector PlayerbotFactory::GetPossibleInventoryTypeListBySlot(EquipmentSlots slot) +{ std::vector ret; - switch (slot) { + switch (slot) + { case EQUIPMENT_SLOT_HEAD: ret.push_back(INVTYPE_HEAD); break; @@ -3698,25 +3852,24 @@ std::vector PlayerbotFactory::GetPossibleInventoryTypeListBySlot( void PlayerbotFactory::LoadEnchantContainer() { - m_EnchantContainer.clear(); + m_EnchantContainer.clear(); - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_ENCHANTS); - if (PreparedQueryResult result = PlayerbotsDatabase.Query(stmt)) - { - do - { - Field* fields = result->Fetch(); + PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_ENCHANTS); + if (PreparedQueryResult result = PlayerbotsDatabase.Query(stmt)) + { + do + { + Field* fields = result->Fetch(); - EnchantTemplate pEnchant; - pEnchant.ClassId = fields[0].Get(); - pEnchant.SpecId = fields[1].Get(); - pEnchant.SpellId = fields[2].Get(); - pEnchant.SlotId = fields[3].Get(); + EnchantTemplate pEnchant; + pEnchant.ClassId = fields[0].Get(); + pEnchant.SpecId = fields[1].Get(); + pEnchant.SpellId = fields[2].Get(); + pEnchant.SlotId = fields[3].Get(); - m_EnchantContainer.push_back(std::move(pEnchant)); - } - while (result->NextRow()); - } + m_EnchantContainer.push_back(std::move(pEnchant)); + } while (result->NextRow()); + } } float PlayerbotFactory::CalculateItemScore(uint32 item_id, Player* bot) @@ -3734,17 +3887,22 @@ float PlayerbotFactory::CalculateItemScore(uint32 item_id, Player* bot) int quality = proto->Quality; int meleeDps = 0, rangeDps = 0; float score = 0; - if (proto->IsRangedWeapon()) { + if (proto->IsRangedWeapon()) + { rangeDps = (proto->Damage[0].DamageMin + proto->Damage[0].DamageMax) / 2 * 1000 / proto->Delay; - } else if (proto->IsWeapon()) { + } + else if (proto->IsWeapon()) + { meleeDps = (proto->Damage[0].DamageMin + proto->Damage[0].DamageMax) / 2 * 1000 / proto->Delay; } armor += proto->Armor; block += proto->Block; - for (int i = 0; i < proto->StatsCount; i++) { - const _ItemStat &stat = proto->ItemStat[i]; - const int32 &value = stat.ItemStatValue; - switch (stat.ItemStatType) { + for (int i = 0; i < proto->StatsCount; i++) + { + const _ItemStat& stat = proto->ItemStat[i]; + const int32& value = stat.ItemStatValue; + switch (stat.ItemStatType) + { case ITEM_MOD_AGILITY: agility += value; break; @@ -3892,8 +4050,8 @@ float PlayerbotFactory::CalculateItemScore(uint32 item_id, Player* bot) // { // multiplier = 0.2f; // if (spellInfo->Effects[i].TriggerSpell) { - // SpellInfo const* triggerSpellInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[i].TriggerSpell); - // if (!triggerSpellInfo) + // SpellInfo const* triggerSpellInfo = + // sSpellMgr->GetSpellInfo(spellInfo->Effects[i].TriggerSpell); if (!triggerSpellInfo) // continue; // for (uint8 k = 0; k < 3; i++) // { @@ -3923,58 +4081,75 @@ float PlayerbotFactory::CalculateItemScore(uint32 item_id, Player* bot) // } } // Basic score - score += (agility + strength + intellect + spirit + stamina + defense + dodge + parry + block + - resilience + hit + crit + haste + expertise + attack_power + mana_regeneration + spell_power + armor_penetration + - spell_penetration + armor + rangeDps + meleeDps) * 0.001; + score += (agility + strength + intellect + spirit + stamina + defense + dodge + parry + block + resilience + hit + + crit + haste + expertise + attack_power + mana_regeneration + spell_power + armor_penetration + + spell_penetration + armor + rangeDps + meleeDps) * + 0.001; // todo: remove duplicate code - if (cls == CLASS_HUNTER) { + if (cls == CLASS_HUNTER) + { // AGILITY only - score += agility * 2.5 + attack_power + armor_penetration * 2 + rangeDps * 5 + hit * 2 + crit * 2 + haste * 2 + intellect; - } else if (cls == CLASS_WARLOCK || - cls == CLASS_MAGE || - (cls == CLASS_PRIEST && tab == 2) || // shadow - (cls == CLASS_SHAMAN && tab == 0) || // element - (cls == CLASS_DRUID && tab == 0) // balance - ) { + score += agility * 2.5 + attack_power + armor_penetration * 2 + rangeDps * 5 + hit * 2 + crit * 2 + haste * 2 + + intellect; + } + else if (cls == CLASS_WARLOCK || cls == CLASS_MAGE || (cls == CLASS_PRIEST && tab == 2) || // shadow + (cls == CLASS_SHAMAN && tab == 0) || // element + (cls == CLASS_DRUID && tab == 0) // balance + ) + { // SPELL DPS - score += intellect * 0.5 + spirit * 0.5 + spell_power + spell_penetration - + hit * 1 + crit * 0.7 + haste * 1 + rangeDps; - } else if ((cls == CLASS_PALADIN && tab == 0) || // holy - (cls == CLASS_PRIEST && tab != 2) || // discipline / holy - (cls == CLASS_SHAMAN && tab == 2) || // heal - (cls == CLASS_DRUID && tab == 2) - ) { + score += intellect * 0.5 + spirit * 0.5 + spell_power + spell_penetration + hit * 1 + crit * 0.7 + haste * 1 + + rangeDps; + } + else if ((cls == CLASS_PALADIN && tab == 0) || // holy + (cls == CLASS_PRIEST && tab != 2) || // discipline / holy + (cls == CLASS_SHAMAN && tab == 2) || // heal + (cls == CLASS_DRUID && tab == 2)) + { // HEALER - score += intellect * 0.5 + spirit * 0.5 + spell_power + mana_regeneration * 0.5 + crit * 0.5 + haste * 1 + rangeDps; - } else if (cls == CLASS_ROGUE || (cls == CLASS_DRUID && tab == 2 && !PlayerbotAI::IsTank(bot))) { + score += + intellect * 0.5 + spirit * 0.5 + spell_power + mana_regeneration * 0.5 + crit * 0.5 + haste * 1 + rangeDps; + } + else if (cls == CLASS_ROGUE || (cls == CLASS_DRUID && tab == 2 && !PlayerbotAI::IsTank(bot))) + { // AGILITY mainly (STRENGTH also) - score += agility * 2 + strength + attack_power + armor_penetration * 1 + meleeDps * 5 + hit * 1.5 + crit * 1.5 + haste * 1.5 + expertise * 2.5; - } else if ((cls == CLASS_PALADIN && tab == 2) || // retribution - (cls == CLASS_WARRIOR && tab != 2) || // arm / fury - (cls == CLASS_DEATH_KNIGHT && tab != 0) // ice / unholy - ) { + score += agility * 2 + strength + attack_power + armor_penetration * 1 + meleeDps * 5 + hit * 1.5 + crit * 1.5 + + haste * 1.5 + expertise * 2.5; + } + else if ((cls == CLASS_PALADIN && tab == 2) || // retribution + (cls == CLASS_WARRIOR && tab != 2) || // arm / fury + (cls == CLASS_DEATH_KNIGHT && tab != 0) // ice / unholy + ) + { // STRENGTH mainly (AGILITY also) - score += strength * 2 + agility + attack_power + armor_penetration + meleeDps * 5 + hit * 1.5 + crit * 1.5 + haste * 1.5 + expertise * 2; - } else if ((cls == CLASS_SHAMAN && tab == 1)) { // enhancement + score += strength * 2 + agility + attack_power + armor_penetration + meleeDps * 5 + hit * 1.5 + crit * 1.5 + + haste * 1.5 + expertise * 2; + } + else if ((cls == CLASS_SHAMAN && tab == 1)) + { // enhancement // STRENGTH mainly (AGILITY, INTELLECT also) - score += strength * 1 + agility * 1.5 + intellect * 1.5 + attack_power + spell_power * 1.5 + armor_penetration * 0.5 + meleeDps * 5 - + hit * 1.5 + crit * 1.5 + haste * 1.5 + expertise * 2; - } else if ((cls == CLASS_WARRIOR && tab == 2) || - (cls == CLASS_PALADIN && tab == 1)) { + score += strength * 1 + agility * 1.5 + intellect * 1.5 + attack_power + spell_power * 1.5 + + armor_penetration * 0.5 + meleeDps * 5 + hit * 1.5 + crit * 1.5 + haste * 1.5 + expertise * 2; + } + else if ((cls == CLASS_WARRIOR && tab == 2) || (cls == CLASS_PALADIN && tab == 1)) + { // TANK WITH SHIELD - score += strength * 1 + agility * 2 + attack_power * 0.2 - + defense * 2.5 + parry * 2 + dodge * 2 + resilience * 2 + block * 2 + armor * 0.3 + stamina * 3 - + hit * 0.5 + crit * 0.2 + haste * 0.5 + expertise * 3; - } else if (cls == CLASS_DEATH_KNIGHT && tab == 0){ + score += strength * 1 + agility * 2 + attack_power * 0.2 + defense * 2.5 + parry * 2 + dodge * 2 + + resilience * 2 + block * 2 + armor * 0.3 + stamina * 3 + hit * 0.5 + crit * 0.2 + haste * 0.5 + + expertise * 3; + } + else if (cls == CLASS_DEATH_KNIGHT && tab == 0) + { // BLOOD DK TANK - score += strength * 1 + agility * 2 + attack_power * 0.2 - + defense * 3.5 + parry * 2 + dodge * 2 + resilience * 2 + armor * 0.3 + stamina * 2.5 - + hit * 0.5 + crit * 0.5 + haste * 0.5 + expertise * 3.5; - } else { + score += strength * 1 + agility * 2 + attack_power * 0.2 + defense * 3.5 + parry * 2 + dodge * 2 + + resilience * 2 + armor * 0.3 + stamina * 2.5 + hit * 0.5 + crit * 0.5 + haste * 0.5 + expertise * 3.5; + } + else + { // BEAR DRUID TANK - score += agility * 1.5 + strength * 1 + attack_power * 0.5 + armor_penetration * 0.5 + meleeDps * 2 - + defense * 0.25 + dodge * 0.25 + armor * 0.3 + stamina * 1.5 - + hit * 1 + crit * 1 + haste * 0.5 + expertise * 3; + score += agility * 1.5 + strength * 1 + attack_power * 0.5 + armor_penetration * 0.5 + meleeDps * 2 + + defense * 0.25 + dodge * 0.25 + armor * 0.3 + stamina * 1.5 + hit * 1 + crit * 1 + haste * 0.5 + + expertise * 3; } // penalty for different type armor if (proto->Class == ITEM_CLASS_ARMOR && proto->SubClass >= ITEM_SUBCLASS_ARMOR_CLOTH && @@ -3983,50 +4158,54 @@ float PlayerbotFactory::CalculateItemScore(uint32 item_id, Player* bot) score *= 0.8; } // double hand - if (proto->Class == ITEM_CLASS_WEAPON) { - bool isDoubleHand = proto->Class == ITEM_CLASS_WEAPON && - !(ITEM_SUBCLASS_MASK_SINGLE_HAND & (1 << proto->SubClass)) && - !(ITEM_SUBCLASS_MASK_WEAPON_RANGED & (1 << proto->SubClass)); + if (proto->Class == ITEM_CLASS_WEAPON) + { + bool isDoubleHand = proto->Class == ITEM_CLASS_WEAPON && + !(ITEM_SUBCLASS_MASK_SINGLE_HAND & (1 << proto->SubClass)) && + !(ITEM_SUBCLASS_MASK_WEAPON_RANGED & (1 << proto->SubClass)); - if (isDoubleHand) { + if (isDoubleHand) + { score *= 0.5; } // spec without double hand // enhancement, rogue, ice dk, unholy dk, shield tank, fury warrior without titan's grip but with duel wield - if (isDoubleHand && - ((cls == CLASS_SHAMAN && tab == 1 && bot->CanDualWield()) || - (cls == CLASS_ROGUE) || - (cls == CLASS_DEATH_KNIGHT && tab != 0) || - (cls == CLASS_WARRIOR && tab == 1 && !bot->CanTitanGrip() && bot->CanDualWield()) || - IsShieldTank(bot))) { - score *= 0.1; + if (isDoubleHand && + ((cls == CLASS_SHAMAN && tab == 1 && bot->CanDualWield()) || (cls == CLASS_ROGUE) || + (cls == CLASS_DEATH_KNIGHT && tab != 0) || + (cls == CLASS_WARRIOR && tab == 1 && !bot->CanTitanGrip() && bot->CanDualWield()) || IsShieldTank(bot))) + { + score *= 0.1; } // spec with double hand // fury without duel wield, arms, bear, retribution, blood dk - if (isDoubleHand && - ((cls == CLASS_WARRIOR && tab == WARRIOR_TAB_FURY && !bot->CanDualWield()) || - (cls == CLASS_WARRIOR && tab == WARRIOR_TAB_ARMS) || - (cls == CLASS_DRUID && tab == 1) || - (cls == CLASS_PALADIN && tab == 2) || - (cls == CLASS_DEATH_KNIGHT && tab == 0) || - (cls == CLASS_SHAMAN && tab == 1 && !bot->CanDualWield()))) { + if (isDoubleHand && ((cls == CLASS_WARRIOR && tab == WARRIOR_TAB_FURY && !bot->CanDualWield()) || + (cls == CLASS_WARRIOR && tab == WARRIOR_TAB_ARMS) || (cls == CLASS_DRUID && tab == 1) || + (cls == CLASS_PALADIN && tab == 2) || (cls == CLASS_DEATH_KNIGHT && tab == 0) || + (cls == CLASS_SHAMAN && tab == 1 && !bot->CanDualWield()))) + { score *= 10; } // fury with titan's grip - if (isDoubleHand && proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && - (cls == CLASS_WARRIOR && tab == WARRIOR_TAB_FURY && bot->CanTitanGrip())) { + if (isDoubleHand && proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && + (cls == CLASS_WARRIOR && tab == WARRIOR_TAB_FURY && bot->CanTitanGrip())) + { score *= 10; } } - if (proto->Class == ITEM_CLASS_WEAPON) { - if (cls == CLASS_HUNTER && proto->SubClass == ITEM_SUBCLASS_WEAPON_THROWN) { + if (proto->Class == ITEM_CLASS_WEAPON) + { + if (cls == CLASS_HUNTER && proto->SubClass == ITEM_SUBCLASS_WEAPON_THROWN) + { score *= 0.1; } - if (cls == CLASS_ROGUE && tab == ROGUE_TAB_ASSASSINATION && proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER) { + if (cls == CLASS_ROGUE && tab == ROGUE_TAB_ASSASSINATION && proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER) + { score *= 0.1; } } - if (proto->ItemSet != 0) { + if (proto->ItemSet != 0) + { score *= 1.1; } return (0.0001 + score) * itemLevel * (quality + 1); @@ -4035,7 +4214,8 @@ float PlayerbotFactory::CalculateItemScore(uint32 item_id, Player* bot) float PlayerbotFactory::CalculateEnchantScore(uint32 enchant_id, Player* bot) { SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if (!enchant) { + if (!enchant) + { return 0; } int agility = 0, strength = 0, intellect = 0, spirit = 0; @@ -4056,17 +4236,24 @@ float PlayerbotFactory::CalculateEnchantScore(uint32 enchant_id, Player* bot) break; case ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL: { - if (PlayerbotAI::IsMelee(bot) && enchant_spell_id == 28093) { // mongoose + if (PlayerbotAI::IsMelee(bot) && enchant_spell_id == 28093) + { // mongoose agility += 40; - } else if (PlayerbotAI::IsMelee(bot) && enchant_spell_id == 20007) { // crusader + } + else if (PlayerbotAI::IsMelee(bot) && enchant_spell_id == 20007) + { // crusader strength += 30; - } else if (PlayerbotAI::IsMelee(bot) && enchant_spell_id == 59620) { // Berserk + } + else if (PlayerbotAI::IsMelee(bot) && enchant_spell_id == 59620) + { // Berserk attack_power += 120; - } else if (PlayerbotAI::IsMelee(bot) && enchant_spell_id == 64440) { // Blade Warding + } + else if (PlayerbotAI::IsMelee(bot) && enchant_spell_id == 64440) + { // Blade Warding parry += 50; } break; - } + } // processed in Player::CastItemCombatSpell case ITEM_ENCHANTMENT_TYPE_DAMAGE: // if (botAI->IsRanged(bot) && !botAI->IsCaster(bot)) { @@ -4112,14 +4299,16 @@ float PlayerbotFactory::CalculateEnchantScore(uint32 enchant_id, Player* bot) default: break; } - if (allStatsAmount != 0) { + if (allStatsAmount != 0) + { agility += allStatsAmount; strength += allStatsAmount; intellect += allStatsAmount; spirit += allStatsAmount; stamina += allStatsAmount; } - if (PlayerbotAI::IsMelee(bot) && enchant_spell_id == 64571) { // Blood Draining + if (PlayerbotAI::IsMelee(bot) && enchant_spell_id == 64571) + { // Blood Draining stamina += 80; } // if (enchant_spell_id) @@ -4127,26 +4316,28 @@ float PlayerbotFactory::CalculateEnchantScore(uint32 enchant_id, Player* bot) // if (apply) // { // int32 basepoints = 0; - // // Random Property Exist - try found basepoints for spell (basepoints depends from item suffix factor) - // if (item->GetItemRandomPropertyId()) + // // Random Property Exist - try found basepoints for spell (basepoints depends from item + // suffix factor) if (item->GetItemRandomPropertyId()) // { - // ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(std::abs(item->GetItemRandomPropertyId())); - // if (item_rand) + // ItemRandomSuffixEntry const* item_rand = + // sItemRandomSuffixStore.LookupEntry(std::abs(item->GetItemRandomPropertyId())); if + // (item_rand) // { // // Search enchant_amount // for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) // { // if (item_rand->Enchantment[k] == enchant_id) // { - // basepoints = int32((item_rand->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000); - // break; + // basepoints = int32((item_rand->AllocationPct[k] * + // item->GetItemSuffixFactor()) / 10000); break; // } // } // } // } // // Cast custom spell vs all equal basepoints got from enchant_amount // if (basepoints) - // CastCustomSpell(this, enchant_spell_id, &basepoints, &basepoints, &basepoints, true, item); + // CastCustomSpell(this, enchant_spell_id, &basepoints, &basepoints, &basepoints, true, + // item); // else // CastSpell(this, enchant_spell_id, true, item); // } @@ -4158,35 +4349,37 @@ float PlayerbotFactory::CalculateEnchantScore(uint32 enchant_id, Player* bot) case ITEM_ENCHANTMENT_TYPE_RESISTANCE: // if (!enchant_amount) // { - // ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(std::abs(item->GetItemRandomPropertyId())); - // if (item_rand) + // ItemRandomSuffixEntry const* item_rand = + // sItemRandomSuffixStore.LookupEntry(std::abs(item->GetItemRandomPropertyId())); if (item_rand) // { // for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) // { // if (item_rand->Enchantment[k] == enchant_id) // { - // enchant_amount = uint32((item_rand->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000); - // break; + // enchant_amount = uint32((item_rand->AllocationPct[k] * item->GetItemSuffixFactor()) / + // 10000); break; // } // } // } // } - // HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + enchant_spell_id), TOTAL_VALUE, float(enchant_amount), apply); + // HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + enchant_spell_id), TOTAL_VALUE, + // float(enchant_amount), apply); break; case ITEM_ENCHANTMENT_TYPE_STAT: { if (!enchant_amount) { - // ItemRandomSuffixEntry const* item_rand_suffix = sItemRandomSuffixStore.LookupEntry(std::abs(item->GetItemRandomPropertyId())); - // if (item_rand_suffix) + // ItemRandomSuffixEntry const* item_rand_suffix = + // sItemRandomSuffixStore.LookupEntry(std::abs(item->GetItemRandomPropertyId())); if + // (item_rand_suffix) // { // for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) // { // if (item_rand_suffix->Enchantment[k] == enchant_id) // { - // enchant_amount = uint32((item_rand_suffix->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000); - // break; + // enchant_amount = uint32((item_rand_suffix->AllocationPct[k] * + // item->GetItemSuffixFactor()) / 10000); break; // } // } // } @@ -4216,7 +4409,7 @@ float PlayerbotFactory::CalculateEnchantScore(uint32 enchant_id, Player* bot) case ITEM_MOD_DEFENSE_SKILL_RATING: defense += float(enchant_amount); break; - case ITEM_MOD_DODGE_RATING: + case ITEM_MOD_DODGE_RATING: dodge += float(enchant_amount); break; case ITEM_MOD_PARRY_RATING: @@ -4226,42 +4419,50 @@ float PlayerbotFactory::CalculateEnchantScore(uint32 enchant_id, Player* bot) block += float(enchant_amount); break; case ITEM_MOD_HIT_MELEE_RATING: - if (PlayerbotAI::IsMelee(bot)) { + if (PlayerbotAI::IsMelee(bot)) + { hit += float(enchant_amount); } break; case ITEM_MOD_HIT_RANGED_RATING: - if (PlayerbotAI::IsRanged(bot) && !PlayerbotAI::IsCaster(bot)) { + if (PlayerbotAI::IsRanged(bot) && !PlayerbotAI::IsCaster(bot)) + { hit += float(enchant_amount); } break; case ITEM_MOD_HIT_SPELL_RATING: - if (PlayerbotAI::IsCaster(bot)) { + if (PlayerbotAI::IsCaster(bot)) + { hit += float(enchant_amount); } break; case ITEM_MOD_CRIT_MELEE_RATING: - if (PlayerbotAI::IsMelee(bot)) { + if (PlayerbotAI::IsMelee(bot)) + { crit += float(enchant_amount); } break; case ITEM_MOD_CRIT_RANGED_RATING: - if (PlayerbotAI::IsRanged(bot) && !PlayerbotAI::IsCaster(bot)) { + if (PlayerbotAI::IsRanged(bot) && !PlayerbotAI::IsCaster(bot)) + { crit += float(enchant_amount); } break; case ITEM_MOD_CRIT_SPELL_RATING: - if (PlayerbotAI::IsCaster(bot)) { + if (PlayerbotAI::IsCaster(bot)) + { crit += float(enchant_amount); - } + } break; case ITEM_MOD_HASTE_RANGED_RATING: - if (PlayerbotAI::IsRanged(bot) && !PlayerbotAI::IsCaster(bot)) { + if (PlayerbotAI::IsRanged(bot) && !PlayerbotAI::IsCaster(bot)) + { crit += float(enchant_amount); } break; case ITEM_MOD_HASTE_SPELL_RATING: - if (PlayerbotAI::IsCaster(bot)) { + if (PlayerbotAI::IsCaster(bot)) + { haste += float(enchant_amount); } break; @@ -4284,7 +4485,8 @@ float PlayerbotFactory::CalculateEnchantScore(uint32 enchant_id, Player* bot) attack_power += float(enchant_amount); break; case ITEM_MOD_RANGED_ATTACK_POWER: - if (PlayerbotAI::IsRanged(bot) && !PlayerbotAI::IsCaster(bot)) { + if (PlayerbotAI::IsRanged(bot) && !PlayerbotAI::IsCaster(bot)) + { attack_power += float(enchant_amount); } break; @@ -4306,14 +4508,14 @@ float PlayerbotFactory::CalculateEnchantScore(uint32 enchant_id, Player* bot) case ITEM_MOD_BLOCK_VALUE: block += float(enchant_amount); break; - case ITEM_MOD_SPELL_HEALING_DONE: // deprecated - case ITEM_MOD_SPELL_DAMAGE_DONE: // deprecated + case ITEM_MOD_SPELL_HEALING_DONE: // deprecated + case ITEM_MOD_SPELL_DAMAGE_DONE: // deprecated default: break; } break; } - case ITEM_ENCHANTMENT_TYPE_TOTEM: // Shaman Rockbiter Weapon + case ITEM_ENCHANTMENT_TYPE_TOTEM: // Shaman Rockbiter Weapon { // if (IsClass(CLASS_SHAMAN, CLASS_CONTEXT_ABILITY)) // { @@ -4338,65 +4540,81 @@ float PlayerbotFactory::CalculateEnchantScore(uint32 enchant_id, Player* bot) // nothing do.. break; default: - // LOG_ERROR("entities.player", "Unknown item enchantment (id = {}) display type: {}", enchant_id, enchant_display_type); + // LOG_ERROR("entities.player", "Unknown item enchantment (id = {}) display type: {}", enchant_id, + // enchant_display_type); break; - } /*switch (enchant_display_type)*/ + } /*switch (enchant_display_type)*/ } int tab = AiFactory::GetPlayerSpecTab(bot); uint8 cls = bot->getClass(); // Basic score - float score = (agility + strength + intellect + spirit + stamina + defense + dodge + parry + block + - resilience + hit + crit + haste + expertise + attack_power + mana_regeneration + spell_power + armor_penetration + - spell_penetration + armor + dps) * 0.001; + float score = (agility + strength + intellect + spirit + stamina + defense + dodge + parry + block + resilience + + hit + crit + haste + expertise + attack_power + mana_regeneration + spell_power + armor_penetration + + spell_penetration + armor + dps) * + 0.001; // todo: remove duplicate code - if (cls == CLASS_HUNTER) { + if (cls == CLASS_HUNTER) + { // AGILITY only - score += agility * 2.5 + attack_power + armor_penetration * 2 + dps * 5 + hit * 2 + crit * 2 + haste * 2.5 + intellect; - } else if (cls == CLASS_WARLOCK || - cls == CLASS_MAGE || - (cls == CLASS_PRIEST && tab == 2) || // shadow - (cls == CLASS_SHAMAN && tab == 0) || // element - (cls == CLASS_DRUID && tab == 0) // balance - ) { + score += agility * 2.5 + attack_power + armor_penetration * 2 + dps * 5 + hit * 2 + crit * 2 + haste * 2.5 + + intellect; + } + else if (cls == CLASS_WARLOCK || cls == CLASS_MAGE || (cls == CLASS_PRIEST && tab == 2) || // shadow + (cls == CLASS_SHAMAN && tab == 0) || // element + (cls == CLASS_DRUID && tab == 0) // balance + ) + { // SPELL DPS - score += intellect * 0.5 + spirit * 0.5 + spell_power + spell_penetration - + hit * 1 + crit * 0.7 + haste * 1; - } else if ((cls == CLASS_PALADIN && tab == 0) || // holy - (cls == CLASS_PRIEST && tab != 2) || // discipline / holy - (cls == CLASS_SHAMAN && tab == 2) || // heal - (cls == CLASS_DRUID && tab == 2) - ) { + score += intellect * 0.5 + spirit * 0.5 + spell_power + spell_penetration + hit * 1 + crit * 0.7 + haste * 1; + } + else if ((cls == CLASS_PALADIN && tab == 0) || // holy + (cls == CLASS_PRIEST && tab != 2) || // discipline / holy + (cls == CLASS_SHAMAN && tab == 2) || // heal + (cls == CLASS_DRUID && tab == 2)) + { // HEALER - score += intellect * 0.5 + spirit * 0.5 + spell_power + mana_regeneration * 0.5 + crit * 0.5 + haste * 1; - } else if (cls == CLASS_ROGUE || (cls == CLASS_DRUID && tab == 2 && !PlayerbotAI::IsTank(bot))) { + score += intellect * 0.5 + spirit * 0.5 + spell_power + mana_regeneration * 0.5 + crit * 0.5 + haste * 1; + } + else if (cls == CLASS_ROGUE || (cls == CLASS_DRUID && tab == 2 && !PlayerbotAI::IsTank(bot))) + { // AGILITY mainly (STRENGTH also) - score += agility * 2 + strength + attack_power + armor_penetration * 1 + dps * 5 + hit * 1.5 + crit * 1.5 + haste * 1.5 + expertise * 2.5; - } else if ((cls == CLASS_PALADIN && tab == 2) || // retribution - (cls == CLASS_WARRIOR && tab != 2) || // arm / fury - (cls == CLASS_DEATH_KNIGHT && tab != 0) // ice / unholy - ) { + score += agility * 2 + strength + attack_power + armor_penetration * 1 + dps * 5 + hit * 1.5 + crit * 1.5 + + haste * 1.5 + expertise * 2.5; + } + else if ((cls == CLASS_PALADIN && tab == 2) || // retribution + (cls == CLASS_WARRIOR && tab != 2) || // arm / fury + (cls == CLASS_DEATH_KNIGHT && tab != 0) // ice / unholy + ) + { // STRENGTH mainly (AGILITY also) - score += strength * 2 + agility + attack_power + armor_penetration + dps * 5 + hit * 1.5 + crit * 1.5 + haste * 1.5 + expertise * 2; - } else if ((cls == CLASS_SHAMAN && tab == 1)) { // enhancement + score += strength * 2 + agility + attack_power + armor_penetration + dps * 5 + hit * 1.5 + crit * 1.5 + + haste * 1.5 + expertise * 2; + } + else if ((cls == CLASS_SHAMAN && tab == 1)) + { // enhancement // STRENGTH mainly (AGILITY, INTELLECT also) - score += strength * 1 + agility * 1.5 + intellect * 1.5 + attack_power + spell_power * 1.5 + armor_penetration * 0.5 + dps * 5 - + hit * 1.5 + crit * 1.5 + haste * 1.5 + expertise * 2; - } else if ((cls == CLASS_WARRIOR && tab == 2) || - (cls == CLASS_PALADIN && tab == 1)) { + score += strength * 1 + agility * 1.5 + intellect * 1.5 + attack_power + spell_power * 1.5 + + armor_penetration * 0.5 + dps * 5 + hit * 1.5 + crit * 1.5 + haste * 1.5 + expertise * 2; + } + else if ((cls == CLASS_WARRIOR && tab == 2) || (cls == CLASS_PALADIN && tab == 1)) + { // TANK WITH SHIELD - score += strength * 1 + agility * 2 + attack_power * 0.2 - + defense * 2.5 + parry * 2 + dodge * 2 + resilience * 2 + block * 2 + armor * 0.3 + stamina * 3 - + hit * 0.5 + crit * 0.2 + haste * 0.5 + expertise * 3; - } else if (cls == CLASS_DEATH_KNIGHT && tab == 0){ + score += strength * 1 + agility * 2 + attack_power * 0.2 + defense * 2.5 + parry * 2 + dodge * 2 + + resilience * 2 + block * 2 + armor * 0.3 + stamina * 3 + hit * 0.5 + crit * 0.2 + haste * 0.5 + + expertise * 3; + } + else if (cls == CLASS_DEATH_KNIGHT && tab == 0) + { // BLOOD DK TANK - score += strength * 1 + agility * 2 + attack_power * 0.2 - + defense * 3.5 + parry * 2 + dodge * 2 + resilience * 2 + armor * 0.3 + stamina * 2.5 - + hit * 0.5 + crit * 0.5 + haste * 0.5 + expertise * 3.5; - } else { + score += strength * 1 + agility * 2 + attack_power * 0.2 + defense * 3.5 + parry * 2 + dodge * 2 + + resilience * 2 + armor * 0.3 + stamina * 2.5 + hit * 0.5 + crit * 0.5 + haste * 0.5 + expertise * 3.5; + } + else + { // BEAR DRUID TANK - score += agility * 1.5 + strength * 1 + attack_power * 0.5 + armor_penetration * 0.5 + dps * 2 - + defense * 0.25 + dodge * 0.25 + armor * 0.3 + stamina * 1.5 - + hit * 1 + crit * 1 + haste * 0.5 + expertise * 3; + score += agility * 1.5 + strength * 1 + attack_power * 0.5 + armor_penetration * 0.5 + dps * 2 + + defense * 0.25 + dodge * 0.25 + armor * 0.3 + stamina * 1.5 + hit * 1 + crit * 1 + haste * 0.5 + + expertise * 3; } return score; } @@ -4417,7 +4635,7 @@ float PlayerbotFactory::CalculateSpellScore(uint32 spell_id, Player* bot, uint32 bool isMelee = PlayerbotAI::IsMelee(bot); bool isRanged = PlayerbotAI::IsRanged(bot); bool isCaster = PlayerbotAI::IsCaster(bot); - for (int i = 0; i < MAX_SPELL_EFFECTS; i++) + for (int i = 0; i < MAX_SPELL_EFFECTS; i++) { float multiplier = trigger == ITEM_SPELLTRIGGER_ON_EQUIP ? 1.0f : 0.2f; if (spellInfo->Effects[i].Effect == SPELL_EFFECT_APPLY_AURA) @@ -4426,7 +4644,7 @@ float PlayerbotFactory::CalculateSpellScore(uint32 spell_id, Player* bot, uint32 switch (spellInfo->Effects[i].ApplyAuraName) { case SPELL_AURA_MOD_DAMAGE_DONE: - // case SPELL_AURA_MOD_HEALING_DONE: duplicated + // case SPELL_AURA_MOD_HEALING_DONE: duplicated spell_power += val * multiplier; break; case SPELL_AURA_MOD_ATTACK_POWER: @@ -4456,47 +4674,56 @@ float PlayerbotFactory::CalculateSpellScore(uint32 spell_id, Player* bot, uint32 block += val * multiplier; break; case CR_HIT_MELEE: - if (isMelee) { + if (isMelee) + { hit += val * multiplier; } break; case CR_HIT_RANGED: - if (isRanged && !isCaster) { + if (isRanged && !isCaster) + { hit += val * multiplier; } break; case CR_HIT_SPELL: - if (isCaster) { + if (isCaster) + { hit += val * multiplier; } break; case CR_CRIT_MELEE: - if (isMelee) { + if (isMelee) + { crit += val * multiplier; } break; case CR_CRIT_RANGED: - if (isRanged && !isCaster) { + if (isRanged && !isCaster) + { crit += val * multiplier; } break; case CR_CRIT_SPELL: - if (isCaster) { + if (isCaster) + { crit += val * multiplier; } break; case CR_HASTE_MELEE: - if (isMelee) { + if (isMelee) + { haste += val * multiplier; } break; case CR_HASTE_RANGED: - if (isRanged && !isCaster) { + if (isRanged && !isCaster) + { haste += val * multiplier; } break; case CR_HASTE_SPELL: - if (isCaster) { + if (isCaster) + { haste += val * multiplier; } break; @@ -4516,7 +4743,8 @@ float PlayerbotFactory::CalculateSpellScore(uint32 spell_id, Player* bot, uint32 case SPELL_AURA_PROC_TRIGGER_SPELL: { multiplier = 0.2f; - if (spellInfo->Effects[i].TriggerSpell) { + if (spellInfo->Effects[i].TriggerSpell) + { SpellInfo const* triggerSpellInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[i].TriggerSpell); if (!triggerSpellInfo) continue; @@ -4527,7 +4755,7 @@ float PlayerbotFactory::CalculateSpellScore(uint32 spell_id, Player* bot, uint32 switch (triggerSpellInfo->Effects[k].ApplyAuraName) { case SPELL_AURA_MOD_DAMAGE_DONE: - // case SPELL_AURA_MOD_HEALING_DONE: duplicated + // case SPELL_AURA_MOD_HEALING_DONE: duplicated spell_power += val * multiplier; break; case SPELL_AURA_MOD_ATTACK_POWER: @@ -4557,47 +4785,56 @@ float PlayerbotFactory::CalculateSpellScore(uint32 spell_id, Player* bot, uint32 block += val * multiplier; break; case CR_HIT_MELEE: - if (isMelee) { + if (isMelee) + { hit += val * multiplier; } break; case CR_HIT_RANGED: - if (isRanged && !isCaster) { + if (isRanged && !isCaster) + { hit += val * multiplier; } break; case CR_HIT_SPELL: - if (isCaster) { + if (isCaster) + { hit += val * multiplier; } break; case CR_CRIT_MELEE: - if (isMelee) { + if (isMelee) + { crit += val * multiplier; } break; case CR_CRIT_RANGED: - if (isRanged && !isCaster) { + if (isRanged && !isCaster) + { crit += val * multiplier; } break; case CR_CRIT_SPELL: - if (isCaster) { + if (isCaster) + { crit += val * multiplier; } break; case CR_HASTE_MELEE: - if (isMelee) { + if (isMelee) + { haste += val * multiplier; } break; case CR_HASTE_RANGED: - if (isRanged && !isCaster) { + if (isRanged && !isCaster) + { haste += val * multiplier; } break; case CR_HASTE_SPELL: - if (isCaster) { + if (isCaster) + { haste += val * multiplier; } break; @@ -4629,73 +4866,92 @@ float PlayerbotFactory::CalculateSpellScore(uint32 spell_id, Player* bot, uint32 } float score = 0; // todo: remove duplicate code - if (cls == CLASS_HUNTER) { + if (cls == CLASS_HUNTER) + { // AGILITY only - score += agility * 2.5 + attack_power + armor_penetration * 2 + rangeDps * 5 + hit * 2 + crit * 2 + haste * 2.5 + intellect; - } else if (cls == CLASS_WARLOCK || - cls == CLASS_MAGE || - (cls == CLASS_PRIEST && tab == 2) || // shadow - (cls == CLASS_SHAMAN && tab == 0) || // element - (cls == CLASS_DRUID && tab == 0) // balance - ) { + score += agility * 2.5 + attack_power + armor_penetration * 2 + rangeDps * 5 + hit * 2 + crit * 2 + + haste * 2.5 + intellect; + } + else if (cls == CLASS_WARLOCK || cls == CLASS_MAGE || (cls == CLASS_PRIEST && tab == 2) || // shadow + (cls == CLASS_SHAMAN && tab == 0) || // element + (cls == CLASS_DRUID && tab == 0) // balance + ) + { // SPELL DPS - score += intellect * 0.5 + spirit * 0.5 + spell_power + spell_penetration - + hit * 1 + crit * 0.7 + haste * 1 + rangeDps; - } else if ((cls == CLASS_PALADIN && tab == 0) || // holy - (cls == CLASS_PRIEST && tab != 2) || // discipline / holy - (cls == CLASS_SHAMAN && tab == 2) || // heal - (cls == CLASS_DRUID && tab == 2) - ) { + score += intellect * 0.5 + spirit * 0.5 + spell_power + spell_penetration + hit * 1 + crit * 0.7 + haste * 1 + + rangeDps; + } + else if ((cls == CLASS_PALADIN && tab == 0) || // holy + (cls == CLASS_PRIEST && tab != 2) || // discipline / holy + (cls == CLASS_SHAMAN && tab == 2) || // heal + (cls == CLASS_DRUID && tab == 2)) + { // HEALER - score += intellect * 0.5 + spirit * 0.5 + spell_power + mana_regeneration * 0.5 + crit * 0.5 + haste * 1 + rangeDps; - } else if (cls == CLASS_ROGUE || (cls == CLASS_DRUID && tab == 2 && !PlayerbotAI::IsTank(bot))) { + score += + intellect * 0.5 + spirit * 0.5 + spell_power + mana_regeneration * 0.5 + crit * 0.5 + haste * 1 + rangeDps; + } + else if (cls == CLASS_ROGUE || (cls == CLASS_DRUID && tab == 2 && !PlayerbotAI::IsTank(bot))) + { // AGILITY mainly (STRENGTH also) - score += agility * 2 + strength + attack_power + armor_penetration * 1 + meleeDps * 5 + hit * 1.5 + crit * 1.5 + haste * 1.5 + expertise * 2.5; - } else if ((cls == CLASS_PALADIN && tab == 2) || // retribution - (cls == CLASS_WARRIOR && tab != 2) || // arm / fury - (cls == CLASS_DEATH_KNIGHT && tab != 0) // ice / unholy - ) { + score += agility * 2 + strength + attack_power + armor_penetration * 1 + meleeDps * 5 + hit * 1.5 + crit * 1.5 + + haste * 1.5 + expertise * 2.5; + } + else if ((cls == CLASS_PALADIN && tab == 2) || // retribution + (cls == CLASS_WARRIOR && tab != 2) || // arm / fury + (cls == CLASS_DEATH_KNIGHT && tab != 0) // ice / unholy + ) + { // STRENGTH mainly (AGILITY also) - score += strength * 2 + agility + attack_power + armor_penetration + meleeDps * 5 + hit * 1.5 + crit * 1.5 + haste * 1.5 + expertise * 2; - } else if ((cls == CLASS_SHAMAN && tab == 1)) { // enhancement + score += strength * 2 + agility + attack_power + armor_penetration + meleeDps * 5 + hit * 1.5 + crit * 1.5 + + haste * 1.5 + expertise * 2; + } + else if ((cls == CLASS_SHAMAN && tab == 1)) + { // enhancement // STRENGTH mainly (AGILITY, INTELLECT also) - score += strength * 1 + agility * 1.5 + intellect * 1.5 + attack_power + spell_power * 1.5 + armor_penetration * 0.5 + meleeDps * 5 - + hit * 1.5 + crit * 1.5 + haste * 1.5 + expertise * 2; - } else if ((cls == CLASS_WARRIOR && tab == 2) || - (cls == CLASS_PALADIN && tab == 1)) { + score += strength * 1 + agility * 1.5 + intellect * 1.5 + attack_power + spell_power * 1.5 + + armor_penetration * 0.5 + meleeDps * 5 + hit * 1.5 + crit * 1.5 + haste * 1.5 + expertise * 2; + } + else if ((cls == CLASS_WARRIOR && tab == 2) || (cls == CLASS_PALADIN && tab == 1)) + { // TANK WITH SHIELD - score += strength * 1 + agility * 2 + attack_power * 0.2 - + defense * 2.5 + parry * 2 + dodge * 2 + resilience * 2 + block * 2 + armor * 0.3 + stamina * 3 - + hit * 0.5 + crit * 0.2 + haste * 0.5 + expertise * 3; - } else if (cls == CLASS_DEATH_KNIGHT && tab == 0){ + score += strength * 1 + agility * 2 + attack_power * 0.2 + defense * 2.5 + parry * 2 + dodge * 2 + + resilience * 2 + block * 2 + armor * 0.3 + stamina * 3 + hit * 0.5 + crit * 0.2 + haste * 0.5 + + expertise * 3; + } + else if (cls == CLASS_DEATH_KNIGHT && tab == 0) + { // BLOOD DK TANK - score += strength * 1 + agility * 2 + attack_power * 0.2 - + defense * 3.5 + parry * 2 + dodge * 2 + resilience * 2 + armor * 0.3 + stamina * 2.5 - + hit * 0.5 + crit * 0.5 + haste * 0.5 + expertise * 3.5; - } else { + score += strength * 1 + agility * 2 + attack_power * 0.2 + defense * 3.5 + parry * 2 + dodge * 2 + + resilience * 2 + armor * 0.3 + stamina * 2.5 + hit * 0.5 + crit * 0.5 + haste * 0.5 + expertise * 3.5; + } + else + { // BEAR DRUID TANK - score += agility * 1.5 + strength * 1 + attack_power * 0.5 + armor_penetration * 0.5 + meleeDps * 2 - + defense * 0.25 + dodge * 0.25 + armor * 0.3 + stamina * 1.5 - + hit * 1 + crit * 1 + haste * 0.5 + expertise * 3; + score += agility * 1.5 + strength * 1 + attack_power * 0.5 + armor_penetration * 0.5 + meleeDps * 2 + + defense * 0.25 + dodge * 0.25 + armor * 0.3 + stamina * 1.5 + hit * 1 + crit * 1 + haste * 0.5 + + expertise * 3; } return score; } -bool PlayerbotFactory::IsShieldTank(Player* bot) +bool PlayerbotFactory::IsShieldTank(Player* bot) { int tab = AiFactory::GetPlayerSpecTab(bot); - return (bot->getClass() == CLASS_WARRIOR && tab == 2) || (bot->getClass() == CLASS_PALADIN && tab == 1); + return (bot->getClass() == CLASS_WARRIOR && tab == 2) || (bot->getClass() == CLASS_PALADIN && tab == 1); } -bool PlayerbotFactory::NotSameArmorType(uint32 item_subclass_armor, Player* bot) +bool PlayerbotFactory::NotSameArmorType(uint32 item_subclass_armor, Player* bot) { - if (bot->HasSkill(SKILL_PLATE_MAIL)) { + if (bot->HasSkill(SKILL_PLATE_MAIL)) + { return item_subclass_armor != ITEM_SUBCLASS_ARMOR_PLATE; } - if (bot->HasSkill(SKILL_MAIL)) { + if (bot->HasSkill(SKILL_MAIL)) + { return item_subclass_armor != ITEM_SUBCLASS_ARMOR_MAIL; } - if (bot->HasSkill(SKILL_LEATHER)) { + if (bot->HasSkill(SKILL_LEATHER)) + { return item_subclass_armor != ITEM_SUBCLASS_ARMOR_LEATHER; } return false; @@ -4716,18 +4972,18 @@ void PlayerbotFactory::IterateItems(IterateItemsVisitor* visitor, IterateItemsMa void PlayerbotFactory::IterateItemsInBags(IterateItemsVisitor* visitor) { for (uint32 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) - if (Item *pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + if (Item* pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (!visitor->Visit(pItem)) return; for (uint32 i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; ++i) - if (Item *pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + if (Item* pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (!visitor->Visit(pItem)) return; for (uint32 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - if (Bag *pBag = (Bag*)bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + if (Bag* pBag = (Bag*)bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) if (Item* pItem = pBag->GetItemByPos(j)) if (!visitor->Visit(pItem)) return; @@ -4751,7 +5007,7 @@ void PlayerbotFactory::IterateItemsInBank(IterateItemsVisitor* visitor) for (uint8 slot = BANK_SLOT_ITEM_START; slot < BANK_SLOT_ITEM_END; slot++) { Item* const pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if(!pItem) + if (!pItem) continue; if (!visitor->Visit(pItem)) @@ -4768,7 +5024,7 @@ void PlayerbotFactory::IterateItemsInBank(IterateItemsVisitor* visitor) { if (Item* pItem = pBag->GetItemByPos(j)) { - if(!pItem) + if (!pItem) continue; if (!visitor->Visit(pItem)) diff --git a/src/PlayerbotFactory.h b/src/PlayerbotFactory.h index 1e4f6d51..841c5afb 100644 --- a/src/PlayerbotFactory.h +++ b/src/PlayerbotFactory.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PLAYERBOTFACTORY_H @@ -15,15 +16,15 @@ struct ItemTemplate; struct EnchantTemplate { - uint8 ClassId; - uint8 SpecId; - uint32 SpellId; - uint8 SlotId; + uint8 ClassId; + uint8 SpecId; + uint32 SpellId; + uint8 SlotId; }; typedef std::vector EnchantContainer; -//TODO: more spec/role +// TODO: more spec/role /* classid+talenttree enum spec : uint8 { @@ -46,158 +47,160 @@ enum spec : uint8 enum PriorizedConsumables { - CONSUM_ID_ROUGH_WEIGHTSTONE = 3239, - CONSUM_ID_COARSE_WEIGHTSTONE = 3239, - CONSUM_ID_HEAVY_WEIGHTSTONE = 3241, - CONSUM_ID_SOLID_WEIGHTSTONE = 7965, - CONSUM_ID_DENSE_WEIGHTSTONE = 12643, - CONSUM_ID_FEL_WEIGHTSTONE = 28420, - CONSUM_ID_ADAMANTITE_WEIGHTSTONE = 28421, - CONSUM_ID_ROUGH_SHARPENING_STONE = 2862, - CONSUM_ID_COARSE_SHARPENING_STONE = 2863, - CONSUM_ID_HEAVY_SHARPENING_STONE = 2871, - CONSUM_ID_SOL_SHARPENING_STONE = 7964, - CONSUM_ID_DENSE_SHARPENING_STONE = 12404, - CONSUM_ID_ELEMENTAL_SHARPENING_STONE = 18262, - CONSUM_ID_CONSECRATED_SHARPENING_STONE = 23122, - CONSUM_ID_FEL_SHARPENING_STONE = 23528, - CONSUM_ID_ADAMANTITE_SHARPENING_STONE = 23529, - CONSUM_ID_LINEN_BANDAGE = 1251, - CONSUM_ID_HEAVY_LINEN_BANDAGE = 2581, - CONSUM_ID_WOOL_BANDAGE = 3530, - CONSUM_ID_HEAVY_WOOL_BANDAGE = 3531, - CONSUM_ID_SILK_BANDAGE = 6450, - CONSUM_ID_HEAVY_SILK_BANDAGE = 6451, - CONSUM_ID_MAGEWEAVE_BANDAGE = 8544, - CONSUM_ID_HEAVY_MAGEWEAVE_BANDAGE = 8545, - CONSUM_ID_RUNECLOTH_BANDAGE = 14529, - CONSUM_ID_HEAVY_RUNECLOTH_BANDAGE = 14530, - CONSUM_ID_NETHERWEAVE_BANDAGE = 21990, - CONSUM_ID_HEAVY_NETHERWEAVE_BANDAGE = 21991, - CONSUM_ID_BRILLIANT_MANA_OIL = 20748, - CONSUM_ID_MINOR_MANA_OIL = 20745, - CONSUM_ID_SUPERIOR_MANA_OIL = 22521, - CONSUM_ID_LESSER_MANA_OIL = 20747, - CONSUM_ID_BRILLIANT_WIZARD_OIL = 20749, - CONSUM_ID_MINOR_WIZARD_OIL = 20744, - CONSUM_ID_SUPERIOR_WIZARD_OIL = 22522, - CONSUM_ID_WIZARD_OIL = 20750, - CONSUM_ID_LESSER_WIZARD_OIL = 20746, - CONSUM_ID_INSTANT_POISON = 6947, - CONSUM_ID_INSTANT_POISON_II = 6949, - CONSUM_ID_INSTANT_POISON_III = 6950, - CONSUM_ID_INSTANT_POISON_IV = 8926, - CONSUM_ID_INSTANT_POISON_V = 8927, - CONSUM_ID_INSTANT_POISON_VI = 8928, - CONSUM_ID_INSTANT_POISON_VII = 21927, - CONSUM_ID_DEADLY_POISON = 2892, - CONSUM_ID_DEADLY_POISON_II = 2893, - CONSUM_ID_DEADLY_POISON_III = 8984, - CONSUM_ID_DEADLY_POISON_IV = 8985, - CONSUM_ID_DEADLY_POISON_V = 20844, - CONSUM_ID_DEADLY_POISON_VI = 22053, - CONSUM_ID_DEADLY_POISON_VII = 22054 + CONSUM_ID_ROUGH_WEIGHTSTONE = 3239, + CONSUM_ID_COARSE_WEIGHTSTONE = 3239, + CONSUM_ID_HEAVY_WEIGHTSTONE = 3241, + CONSUM_ID_SOLID_WEIGHTSTONE = 7965, + CONSUM_ID_DENSE_WEIGHTSTONE = 12643, + CONSUM_ID_FEL_WEIGHTSTONE = 28420, + CONSUM_ID_ADAMANTITE_WEIGHTSTONE = 28421, + CONSUM_ID_ROUGH_SHARPENING_STONE = 2862, + CONSUM_ID_COARSE_SHARPENING_STONE = 2863, + CONSUM_ID_HEAVY_SHARPENING_STONE = 2871, + CONSUM_ID_SOL_SHARPENING_STONE = 7964, + CONSUM_ID_DENSE_SHARPENING_STONE = 12404, + CONSUM_ID_ELEMENTAL_SHARPENING_STONE = 18262, + CONSUM_ID_CONSECRATED_SHARPENING_STONE = 23122, + CONSUM_ID_FEL_SHARPENING_STONE = 23528, + CONSUM_ID_ADAMANTITE_SHARPENING_STONE = 23529, + CONSUM_ID_LINEN_BANDAGE = 1251, + CONSUM_ID_HEAVY_LINEN_BANDAGE = 2581, + CONSUM_ID_WOOL_BANDAGE = 3530, + CONSUM_ID_HEAVY_WOOL_BANDAGE = 3531, + CONSUM_ID_SILK_BANDAGE = 6450, + CONSUM_ID_HEAVY_SILK_BANDAGE = 6451, + CONSUM_ID_MAGEWEAVE_BANDAGE = 8544, + CONSUM_ID_HEAVY_MAGEWEAVE_BANDAGE = 8545, + CONSUM_ID_RUNECLOTH_BANDAGE = 14529, + CONSUM_ID_HEAVY_RUNECLOTH_BANDAGE = 14530, + CONSUM_ID_NETHERWEAVE_BANDAGE = 21990, + CONSUM_ID_HEAVY_NETHERWEAVE_BANDAGE = 21991, + CONSUM_ID_BRILLIANT_MANA_OIL = 20748, + CONSUM_ID_MINOR_MANA_OIL = 20745, + CONSUM_ID_SUPERIOR_MANA_OIL = 22521, + CONSUM_ID_LESSER_MANA_OIL = 20747, + CONSUM_ID_BRILLIANT_WIZARD_OIL = 20749, + CONSUM_ID_MINOR_WIZARD_OIL = 20744, + CONSUM_ID_SUPERIOR_WIZARD_OIL = 22522, + CONSUM_ID_WIZARD_OIL = 20750, + CONSUM_ID_LESSER_WIZARD_OIL = 20746, + CONSUM_ID_INSTANT_POISON = 6947, + CONSUM_ID_INSTANT_POISON_II = 6949, + CONSUM_ID_INSTANT_POISON_III = 6950, + CONSUM_ID_INSTANT_POISON_IV = 8926, + CONSUM_ID_INSTANT_POISON_V = 8927, + CONSUM_ID_INSTANT_POISON_VI = 8928, + CONSUM_ID_INSTANT_POISON_VII = 21927, + CONSUM_ID_DEADLY_POISON = 2892, + CONSUM_ID_DEADLY_POISON_II = 2893, + CONSUM_ID_DEADLY_POISON_III = 8984, + CONSUM_ID_DEADLY_POISON_IV = 8985, + CONSUM_ID_DEADLY_POISON_V = 20844, + CONSUM_ID_DEADLY_POISON_VI = 22053, + CONSUM_ID_DEADLY_POISON_VII = 22054 }; #define MAX_CONSUM_ID 28 class PlayerbotFactory { - public: - PlayerbotFactory(Player* bot, uint32 level, uint32 itemQuality = 0, uint32 gearScoreLimit = 0); +public: + PlayerbotFactory(Player* bot, uint32 level, uint32 itemQuality = 0, uint32 gearScoreLimit = 0); - static ObjectGuid GetRandomBot(); - static void Init(); - void Refresh(); - void Randomize(bool incremental); - static std::list classQuestIds; - void ClearEverything(); - void InitSkills(); + static ObjectGuid GetRandomBot(); + static void Init(); + void Refresh(); + void Randomize(bool incremental); + static std::list classQuestIds; + void ClearEverything(); + void InitSkills(); - static uint32 tradeSkills[]; - static float CalculateItemScore(uint32 item_id, Player* bot); - static float CalculateEnchantScore(uint32 enchant_id, Player* bot); - static float CalculateSpellScore(uint32 spell_id, Player* bot, uint32 trigger = ITEM_SPELLTRIGGER_ON_EQUIP); - void InitTalentsTree(bool incremental = false, bool use_template = true, bool reset = false); - static void InitTalentsBySpecNo(Player* bot, int specNo, bool reset); - static void InitTalentsByParsedSpecLink(Player* bot, std::vector> parsedSpecLink, bool reset); - void InitAvailableSpells(); - void InitClassSpells(); - void InitEquipment(bool incremental); - void InitPet(); - void InitAmmo(); - static uint32 CalcMixedGearScore(uint32 gs, uint32 quality); - void InitPetTalents(); - - void InitReagents(); - void InitGlyphs(bool increment = false); - void InitFood(); - void InitMounts(); - void InitBags(bool destroyOld = true); - void ApplyEnchantAndGemsNew(bool destoryOld = true); - void InitInstanceQuests(); - void UnbindInstance(); - private: - void Prepare(); - // void InitSecondEquipmentSet(); - // void InitEquipmentNew(bool incremental); - bool CanEquipItem(ItemTemplate const* proto, uint32 desiredQuality); - bool CanEquipUnseenItem(uint8 slot, uint16& dest, uint32 item); - void InitTradeSkills(); - void UpdateTradeSkills(); - void SetRandomSkill(uint16 id); - void InitSpells(); - void ClearSpells(); - void ClearSkills(); - void InitSpecialSpells(); - void InitTalents(uint32 specNo); - void InitTalentsByTemplate(uint32 specNo); - void InitQuests(std::list& questMap); - void ClearInventory(); - void ClearAllItems(); - void ResetQuests(); - void InitPotions(); - - bool CanEquipArmor(ItemTemplate const* proto); - bool CanEquipWeapon(ItemTemplate const* proto); - void EnchantItem(Item* item); - void AddItemStats(uint32 mod, uint8& sp, uint8& ap, uint8& tank); - bool CheckItemStats(uint8 sp, uint8 ap, uint8 tank); - void CancelAuras(); - bool IsDesiredReplacement(Item* item); - void InitInventory(); - void InitInventoryTrade(); - void InitInventoryEquip(); - void InitInventorySkill(); - Item* StoreItem(uint32 itemId, uint32 count); - void InitGuild(); - void InitArenaTeam(); - void InitImmersive(); - void AddConsumables(); - static void AddPrevQuests(uint32 questId, std::list& questIds); - void LoadEnchantContainer(); - void ApplyEnchantTemplate(); - void ApplyEnchantTemplate(uint8 spec); - std::vector GetPossibleInventoryTypeListBySlot(EquipmentSlots slot); - static bool IsShieldTank(Player* bot); - static bool NotSameArmorType(uint32 item_subclass_armor, Player* bot); - void IterateItems(IterateItemsVisitor* visitor, IterateItemsMask mask = ITERATE_ITEMS_IN_BAGS); - void IterateItemsInBags(IterateItemsVisitor* visitor); - void IterateItemsInEquip(IterateItemsVisitor* visitor); - void IterateItemsInBank(IterateItemsVisitor* visitor); - EnchantContainer::const_iterator GetEnchantContainerBegin() { return m_EnchantContainer.begin(); } - EnchantContainer::const_iterator GetEnchantContainerEnd() { return m_EnchantContainer.end(); } - uint32 level; - uint32 itemQuality; - uint32 gearScoreLimit; - static std::list specialQuestIds; - std::vector trainerIdCache; - static std::vector enchantSpellIdCache; - static std::vector enchantGemIdCache; - protected: - EnchantContainer m_EnchantContainer; - Player* bot; - PlayerbotAI* botAI; + static uint32 tradeSkills[]; + static float CalculateItemScore(uint32 item_id, Player* bot); + static float CalculateEnchantScore(uint32 enchant_id, Player* bot); + static float CalculateSpellScore(uint32 spell_id, Player* bot, uint32 trigger = ITEM_SPELLTRIGGER_ON_EQUIP); + void InitTalentsTree(bool incremental = false, bool use_template = true, bool reset = false); + static void InitTalentsBySpecNo(Player* bot, int specNo, bool reset); + static void InitTalentsByParsedSpecLink(Player* bot, std::vector> parsedSpecLink, bool reset); + void InitAvailableSpells(); + void InitClassSpells(); + void InitEquipment(bool incremental); + void InitPet(); + void InitAmmo(); + static uint32 CalcMixedGearScore(uint32 gs, uint32 quality); + void InitPetTalents(); + + void InitReagents(); + void InitGlyphs(bool increment = false); + void InitFood(); + void InitMounts(); + void InitBags(bool destroyOld = true); + void ApplyEnchantAndGemsNew(bool destoryOld = true); + void InitInstanceQuests(); + void UnbindInstance(); + +private: + void Prepare(); + // void InitSecondEquipmentSet(); + // void InitEquipmentNew(bool incremental); + bool CanEquipItem(ItemTemplate const* proto, uint32 desiredQuality); + bool CanEquipUnseenItem(uint8 slot, uint16& dest, uint32 item); + void InitTradeSkills(); + void UpdateTradeSkills(); + void SetRandomSkill(uint16 id); + void InitSpells(); + void ClearSpells(); + void ClearSkills(); + void InitSpecialSpells(); + void InitTalents(uint32 specNo); + void InitTalentsByTemplate(uint32 specNo); + void InitQuests(std::list& questMap); + void ClearInventory(); + void ClearAllItems(); + void ResetQuests(); + void InitPotions(); + + bool CanEquipArmor(ItemTemplate const* proto); + bool CanEquipWeapon(ItemTemplate const* proto); + void EnchantItem(Item* item); + void AddItemStats(uint32 mod, uint8& sp, uint8& ap, uint8& tank); + bool CheckItemStats(uint8 sp, uint8 ap, uint8 tank); + void CancelAuras(); + bool IsDesiredReplacement(Item* item); + void InitInventory(); + void InitInventoryTrade(); + void InitInventoryEquip(); + void InitInventorySkill(); + Item* StoreItem(uint32 itemId, uint32 count); + void InitGuild(); + void InitArenaTeam(); + void InitImmersive(); + void AddConsumables(); + static void AddPrevQuests(uint32 questId, std::list& questIds); + void LoadEnchantContainer(); + void ApplyEnchantTemplate(); + void ApplyEnchantTemplate(uint8 spec); + std::vector GetPossibleInventoryTypeListBySlot(EquipmentSlots slot); + static bool IsShieldTank(Player* bot); + static bool NotSameArmorType(uint32 item_subclass_armor, Player* bot); + void IterateItems(IterateItemsVisitor* visitor, IterateItemsMask mask = ITERATE_ITEMS_IN_BAGS); + void IterateItemsInBags(IterateItemsVisitor* visitor); + void IterateItemsInEquip(IterateItemsVisitor* visitor); + void IterateItemsInBank(IterateItemsVisitor* visitor); + EnchantContainer::const_iterator GetEnchantContainerBegin() { return m_EnchantContainer.begin(); } + EnchantContainer::const_iterator GetEnchantContainerEnd() { return m_EnchantContainer.end(); } + uint32 level; + uint32 itemQuality; + uint32 gearScoreLimit; + static std::list specialQuestIds; + std::vector trainerIdCache; + static std::vector enchantSpellIdCache; + static std::vector enchantGemIdCache; + +protected: + EnchantContainer m_EnchantContainer; + Player* bot; + PlayerbotAI* botAI; }; #endif diff --git a/src/PlayerbotMgr.cpp b/src/PlayerbotMgr.cpp index 1774b93e..503d6a20 100644 --- a/src/PlayerbotMgr.cpp +++ b/src/PlayerbotMgr.cpp @@ -1,7 +1,16 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ +#include "PlayerbotMgr.h" + +#include +#include +#include +#include + +#include "ChannelMgr.h" #include "CharacterCache.h" #include "CharacterPackets.h" #include "Common.h" @@ -11,35 +20,29 @@ #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "PlayerbotAIConfig.h" -#include "PlayerbotMgr.h" -#include "PlayerbotSecurity.h" -#include "Playerbots.h" #include "PlayerbotDbStore.h" #include "PlayerbotFactory.h" +#include "PlayerbotSecurity.h" +#include "Playerbots.h" #include "SharedDefines.h" #include "WorldSession.h" -#include "ChannelMgr.h" -#include -#include -#include -#include -PlayerbotHolder::PlayerbotHolder() : PlayerbotAIBase(false) -{ -} +PlayerbotHolder::PlayerbotHolder() : PlayerbotAIBase(false) {} class PlayerbotLoginQueryHolder : public LoginQueryHolder { - private: - uint32 masterAccountId; - PlayerbotHolder* playerbotHolder; +private: + uint32 masterAccountId; + PlayerbotHolder* playerbotHolder; - public: - PlayerbotLoginQueryHolder(PlayerbotHolder* playerbotHolder, uint32 masterAccount, uint32 accountId, ObjectGuid guid) - : LoginQueryHolder(accountId, guid), masterAccountId(masterAccount), playerbotHolder(playerbotHolder) { } +public: + PlayerbotLoginQueryHolder(PlayerbotHolder* playerbotHolder, uint32 masterAccount, uint32 accountId, ObjectGuid guid) + : LoginQueryHolder(accountId, guid), masterAccountId(masterAccount), playerbotHolder(playerbotHolder) + { + } - uint32 GetMasterAccountId() const { return masterAccountId; } - PlayerbotHolder* GetPlayerbotHolder() { return playerbotHolder; } + uint32 GetMasterAccountId() const { return masterAccountId; } + PlayerbotHolder* GetPlayerbotHolder() { return playerbotHolder; } }; void PlayerbotHolder::AddPlayerBot(ObjectGuid playerGuid, uint32 masterAccountId) @@ -53,7 +56,8 @@ void PlayerbotHolder::AddPlayerBot(ObjectGuid playerGuid, uint32 masterAccountId if (!accountId) return; - std::shared_ptr holder = std::make_shared(this, masterAccountId, accountId, playerGuid); + std::shared_ptr holder = + std::make_shared(this, masterAccountId, accountId, playerGuid); if (!holder->Initialize()) { return; @@ -61,17 +65,15 @@ void PlayerbotHolder::AddPlayerBot(ObjectGuid playerGuid, uint32 masterAccountId if (WorldSession* masterSession = sWorld->FindSession(masterAccountId)) { - masterSession->AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(holder)).AfterComplete([this](SQLQueryHolderBase const& holder) - { - HandlePlayerBotLoginCallback(static_cast(holder)); - }); + masterSession->AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(holder)) + .AfterComplete([this](SQLQueryHolderBase const& holder) + { HandlePlayerBotLoginCallback(static_cast(holder)); }); } else { - sWorld->AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(holder)).AfterComplete([this](SQLQueryHolderBase const& holder) - { - HandlePlayerBotLoginCallback(static_cast(holder)); - }); + sWorld->AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(holder)) + .AfterComplete([this](SQLQueryHolderBase const& holder) + { HandlePlayerBotLoginCallback(static_cast(holder)); }); } } @@ -79,23 +81,27 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con { // has bot already been added? Player* loginBot = ObjectAccessor::FindConnectedPlayer(holder.GetGuid()); - if (loginBot && loginBot->IsInWorld()) { + if (loginBot && loginBot->IsInWorld()) + { return; } uint32 botAccountId = holder.GetAccountId(); - // At login DBC locale should be what the server is set to use by default (as spells etc are hardcoded to ENUS this allows channels to work as intended) - WorldSession* botSession = new WorldSession(botAccountId, "", nullptr, SEC_PLAYER, EXPANSION_WRATH_OF_THE_LICH_KING, time_t(0), sWorld->GetDefaultDbcLocale(), 0, false, false, 0, true); + // At login DBC locale should be what the server is set to use by default (as spells etc are hardcoded to ENUS this + // allows channels to work as intended) + WorldSession* botSession = new WorldSession(botAccountId, "", nullptr, SEC_PLAYER, EXPANSION_WRATH_OF_THE_LICH_KING, + time_t(0), sWorld->GetDefaultDbcLocale(), 0, false, false, 0, true); - botSession->HandlePlayerLoginFromDB(holder); // will delete lqh + botSession->HandlePlayerLoginFromDB(holder); // will delete lqh Player* bot = botSession->GetPlayer(); if (!bot) { botSession->LogoutPlayer(true); delete botSession; - // LOG_ERROR("playerbots", "Error logging in bot {}, please try to reset all random bots", holder.GetGuid().ToString().c_str()); + // LOG_ERROR("playerbots", "Error logging in bot {}, please try to reset all random bots", + // holder.GetGuid().ToString().c_str()); return; } @@ -103,25 +109,37 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con WorldSession* masterSession = masterAccount ? sWorld->FindSession(masterAccount) : nullptr; std::ostringstream out; bool allowed = false; - if (botAccountId == masterAccount) { + if (botAccountId == masterAccount) + { allowed = true; - } else if (masterSession && sPlayerbotAIConfig->allowGuildBots && bot->GetGuildId() != 0 && bot->GetGuildId() == masterSession->GetPlayer()->GetGuildId()) { + } + else if (masterSession && sPlayerbotAIConfig->allowGuildBots && bot->GetGuildId() != 0 && + bot->GetGuildId() == masterSession->GetPlayer()->GetGuildId()) + { allowed = true; - } else if (sPlayerbotAIConfig->IsInRandomAccountList(botAccountId)) { + } + else if (sPlayerbotAIConfig->IsInRandomAccountList(botAccountId)) + { allowed = true; - } else { + } + else + { allowed = false; out << "Failure: You are not allowed to control bot " << bot->GetName().c_str(); } - if (allowed && masterSession) { + if (allowed && masterSession) + { Player* player = masterSession->GetPlayer(); - PlayerbotMgr *mgr = GET_PLAYERBOT_MGR(player); + PlayerbotMgr* mgr = GET_PLAYERBOT_MGR(player); uint32 count = mgr->GetPlayerbotsCount(); uint32 cls_count = mgr->GetPlayerbotsCountByClass(bot->getClass()); - if (count >= sPlayerbotAIConfig->maxAddedBots) { + if (count >= sPlayerbotAIConfig->maxAddedBots) + { allowed = false; out << "Failure: You have added too many bots"; - } else if (cls_count >= sPlayerbotAIConfig->maxAddedBotsPerClass) { + } + else if (cls_count >= sPlayerbotAIConfig->maxAddedBotsPerClass) + { allowed = false; out << "Failure: You have added too many bots for this class"; } @@ -143,7 +161,8 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con // OnBotLogin(bot); // LogoutPlayerBot(bot->GetGUID()); - // LOG_ERROR("playerbots", "Attempt to add not allowed bot {}, please try to reset all random bots", bot->GetName()); + // LOG_ERROR("playerbots", "Attempt to add not allowed bot {}, please try to reset all random bots", + // bot->GetName()); } } @@ -155,7 +174,8 @@ void PlayerbotHolder::UpdateSessions() if (bot->IsBeingTeleported()) { PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - if (botAI) { + if (botAI) + { botAI->HandleTeleportAck(); } } @@ -229,7 +249,8 @@ void PlayerbotMgr::CancelLogout() } } - for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr->GetPlayerBotsBegin(); it != sRandomPlayerbotMgr->GetPlayerBotsEnd(); ++it) + for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr->GetPlayerBotsBegin(); + it != sRandomPlayerbotMgr->GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); @@ -289,14 +310,16 @@ void PlayerbotHolder::LogoutPlayerBot(ObjectGuid guid) logout = true; } - if (master && (master->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || master->HasUnitState(UNIT_STATE_IN_FLIGHT) || - (masterWorldSessionPtr && masterWorldSessionPtr->GetSecurity() >= (AccountTypes)sWorld->getIntConfig(CONFIG_INSTANT_LOGOUT)))) + if (master && + (master->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || master->HasUnitState(UNIT_STATE_IN_FLIGHT) || + (masterWorldSessionPtr && + masterWorldSessionPtr->GetSecurity() >= (AccountTypes)sWorld->getIntConfig(CONFIG_INSTANT_LOGOUT)))) { logout = true; } TravelTarget* target = nullptr; - if (botAI->GetAiObjectContext()) //Maybe some day re-write to delate all pointer values. + if (botAI->GetAiObjectContext()) // Maybe some day re-write to delate all pointer values. { target = botAI->GetAiObjectContext()->GetValue("travel target")->Get(); } @@ -325,19 +348,19 @@ void PlayerbotHolder::LogoutPlayerBot(ObjectGuid guid) } else { - playerBots.erase(guid); // deletes bot player ptr inside this WorldSession PlayerBotMap + playerBots.erase(guid); // deletes bot player ptr inside this WorldSession PlayerBotMap delete botWorldSessionPtr; // finally delete the bot's WorldSession if (target) delete target; } return; - } // if instant logout possible, do it + } // if instant logout possible, do it else if (bot && (logout || !botWorldSessionPtr->isLogingOut())) { botAI->TellMaster("Goodbye!"); - playerBots.erase(guid); // deletes bot player ptr inside this WorldSession PlayerBotMap - botWorldSessionPtr->LogoutPlayer(true); // this will delete the bot Player object and PlayerbotAI object - delete botWorldSessionPtr; // finally delete the bot's WorldSession + playerBots.erase(guid); // deletes bot player ptr inside this WorldSession PlayerBotMap + botWorldSessionPtr->LogoutPlayer(true); // this will delete the bot Player object and PlayerbotAI object + delete botWorldSessionPtr; // finally delete the bot's WorldSession } } } @@ -347,7 +370,8 @@ void PlayerbotHolder::DisablePlayerBot(ObjectGuid guid) if (Player* bot = GetPlayerBot(guid)) { PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - if (!botAI) { + if (!botAI) + { return; } botAI->TellMaster("Goodbye!"); @@ -364,14 +388,14 @@ void PlayerbotHolder::DisablePlayerBot(ObjectGuid guid) bot->SaveToDB(false, false); - if (botAI->GetAiObjectContext()) //Maybe some day re-write to delate all pointer values. + if (botAI->GetAiObjectContext()) // Maybe some day re-write to delate all pointer values. { TravelTarget* target = botAI->GetAiObjectContext()->GetValue("travel target")->Get(); if (target) delete target; } - playerBots.erase(guid); // deletes bot player ptr inside this WorldSession PlayerBotMap + playerBots.erase(guid); // deletes bot player ptr inside this WorldSession PlayerBotMap delete botAI; } @@ -393,7 +417,8 @@ Player* PlayerbotHolder::GetPlayerBot(ObjectGuid::LowType lowGuid) const void PlayerbotHolder::OnBotLogin(Player* const bot) { // Prevent duplicate login - if (playerBots.find(bot->GetGUID()) != playerBots.end()) { + if (playerBots.find(bot->GetGUID()) != playerBots.end()) + { return; } @@ -401,16 +426,16 @@ void PlayerbotHolder::OnBotLogin(Player* const bot) playerBots[bot->GetGUID()] = bot; OnBotLoginInternal(bot); - PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - if (!botAI) { + if (!botAI) + { return; } Player* master = botAI->GetMaster(); if (master) { ObjectGuid masterGuid = master->GetGUID(); - if (master->GetGroup() && ! master->GetGroup()->IsLeader(masterGuid)) + if (master->GetGroup() && !master->GetGroup()->IsLeader(masterGuid)) master->GetGroup()->ChangeLeader(masterGuid); } @@ -475,19 +500,27 @@ void PlayerbotHolder::OnBotLogin(Player* const bot) botAI->TellMaster("Hello!", PLAYERBOT_SECURITY_TALK); - if (master && master->GetGroup() && !group) { + if (master && master->GetGroup() && !group) + { Group* mgroup = master->GetGroup(); - if (mgroup->GetMembersCount() >= 5) { - if (!mgroup->isRaidGroup() && !mgroup->isLFGGroup() && !mgroup->isBGGroup() && !mgroup->isBFGroup()) { + if (mgroup->GetMembersCount() >= 5) + { + if (!mgroup->isRaidGroup() && !mgroup->isLFGGroup() && !mgroup->isBGGroup() && !mgroup->isBFGroup()) + { mgroup->ConvertToRaid(); } - if (mgroup->isRaidGroup()) { + if (mgroup->isRaidGroup()) + { mgroup->AddMember(bot); } - } else { + } + else + { mgroup->AddMember(bot); } - } else if (master && !group) { + } + else if (master && !group) + { Group* newGroup = new Group(); newGroup->Create(master); sGroupMgr->AddGroup(newGroup); @@ -497,30 +530,36 @@ void PlayerbotHolder::OnBotLogin(Player* const bot) uint32 accountId = bot->GetSession()->GetAccountId(); bool isRandomAccount = sPlayerbotAIConfig->IsInRandomAccountList(accountId); - if (isRandomAccount && sPlayerbotAIConfig->randomBotFixedLevel) { + if (isRandomAccount && sPlayerbotAIConfig->randomBotFixedLevel) + { bot->SetPlayerFlag(PLAYER_FLAGS_NO_XP_GAIN); - } else if (isRandomAccount && !sPlayerbotAIConfig->randomBotFixedLevel) { + } + else if (isRandomAccount && !sPlayerbotAIConfig->randomBotFixedLevel) + { bot->RemovePlayerFlag(PLAYER_FLAGS_NO_XP_GAIN); } bot->SaveToDB(false, false); - if (master && isRandomAccount && master->GetLevel() < bot->GetLevel()) { + if (master && isRandomAccount && master->GetLevel() < bot->GetLevel()) + { // PlayerbotFactory factory(bot, master->GetLevel()); // factory.Randomize(false); - uint32 mixedGearScore = PlayerbotAI::GetMixedGearScore(master, true, false, 12) * sPlayerbotAIConfig->autoInitEquipLevelLimitRatio; + uint32 mixedGearScore = + PlayerbotAI::GetMixedGearScore(master, true, false, 12) * sPlayerbotAIConfig->autoInitEquipLevelLimitRatio; PlayerbotFactory factory(bot, master->GetLevel(), ITEM_QUALITY_LEGENDARY, mixedGearScore); factory.Randomize(false); } // bots join World chat if not solo oriented - if (bot->GetLevel() >= 10 && sRandomPlayerbotMgr->IsRandomBot(bot) && GET_PLAYERBOT_AI(bot) && GET_PLAYERBOT_AI(bot)->GetGrouperType() != GrouperType::SOLO) + if (bot->GetLevel() >= 10 && sRandomPlayerbotMgr->IsRandomBot(bot) && GET_PLAYERBOT_AI(bot) && + GET_PLAYERBOT_AI(bot)->GetGrouperType() != GrouperType::SOLO) { // TODO make action/config // Make the bot join the world channel for chat WorldPacket pkt(CMSG_JOIN_CHANNEL); pkt << uint32(0) << uint8(0) << uint8(0); pkt << std::string("World"); - pkt << ""; // Pass + pkt << ""; // Pass bot->GetSession()->HandleJoinChannel(pkt); } // join standard channels @@ -533,7 +572,8 @@ void PlayerbotHolder::OnBotLogin(Player* const bot) for (uint32 i = 0; i < sChatChannelsStore.GetNumRows(); ++i) { ChatChannelsEntry const* channel = sChatChannelsStore.LookupEntry(i); - if (!channel) continue; + if (!channel) + continue; bool isLfg = (channel->flags & CHANNEL_DBC_FLAG_LFG) != 0; @@ -551,7 +591,8 @@ void PlayerbotHolder::OnBotLogin(Player* const bot) else { char new_channel_name_buf[100]; - snprintf(new_channel_name_buf, 100, channel->pattern[sWorld->GetDefaultDbcLocale()], current_zone_name.c_str()); + snprintf(new_channel_name_buf, 100, channel->pattern[sWorld->GetDefaultDbcLocale()], + current_zone_name.c_str()); new_channel = cMgr->GetJoinChannel(new_channel_name_buf, channel->ChannelID); } if (new_channel && new_channel->GetName().length() > 0) @@ -560,7 +601,8 @@ void PlayerbotHolder::OnBotLogin(Player* const bot) } } -std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, ObjectGuid guid, ObjectGuid masterguid, bool admin, uint32 masterAccountId, uint32 masterGuildId) +std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, ObjectGuid guid, ObjectGuid masterguid, + bool admin, uint32 masterAccountId, uint32 masterGuildId) { if (!sPlayerbotAIConfig->enabled || guid.IsEmpty()) return "bot system is disabled"; @@ -573,7 +615,8 @@ std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, Obje if (!isRandomAccount && !isMasterAccount && !admin && masterguid) { Player* master = ObjectAccessor::FindConnectedPlayer(masterguid); - if (master && (!sPlayerbotAIConfig->allowGuildBots || !masterGuildId || (masterGuildId && sCharacterCache->GetCharacterGuildIdByGuid(guid) != masterGuildId))) + if (master && (!sPlayerbotAIConfig->allowGuildBots || !masterGuildId || + (masterGuildId && sCharacterCache->GetCharacterGuildIdByGuid(guid) != masterGuildId))) return "not in your guild or account"; } @@ -609,21 +652,27 @@ std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, Obje if (!bot) return "bot not found"; - if (!isRandomAccount || isRandomBot) { + if (!isRandomAccount || isRandomBot) + { return "ERROR: You can not use this command on non-summoned random bot."; } - if (!admin) { + if (!admin) + { Player* master = ObjectAccessor::FindConnectedPlayer(masterguid); - if (master && (master->IsInCombat() || bot->IsInCombat())) { + if (master && (master->IsInCombat() || bot->IsInCombat())) + { return "ERROR: You can not use this command during combat."; } } - - if (GET_PLAYERBOT_AI(bot)) { + + if (GET_PLAYERBOT_AI(bot)) + { if (Player* master = GET_PLAYERBOT_AI(bot)->GetMaster()) { - if (master->GetSession()->GetSecurity() <= SEC_PLAYER && sPlayerbotAIConfig->autoInitOnly && cmd != "init=auto") { + if (master->GetSession()->GetSecurity() <= SEC_PLAYER && sPlayerbotAIConfig->autoInitOnly && + cmd != "init=auto") + { return "The command is not allowed, use init=auto instead."; } int gs; @@ -659,10 +708,12 @@ std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, Obje } else if (cmd == "init=auto") { - uint32 mixedGearScore = PlayerbotAI::GetMixedGearScore(master, true, false, 12) * sPlayerbotAIConfig->autoInitEquipLevelLimitRatio; + uint32 mixedGearScore = PlayerbotAI::GetMixedGearScore(master, true, false, 12) * + sPlayerbotAIConfig->autoInitEquipLevelLimitRatio; PlayerbotFactory factory(bot, master->GetLevel(), ITEM_QUALITY_LEGENDARY, mixedGearScore); factory.Randomize(false); - return "ok, gear score limit: " + std::to_string(mixedGearScore / (ITEM_QUALITY_EPIC + 1)) + "(for epic)"; + return "ok, gear score limit: " + std::to_string(mixedGearScore / (ITEM_QUALITY_EPIC + 1)) + + "(for epic)"; } else if (cmd.starts_with("init=") && sscanf(cmd.c_str(), "init=%d", &gs) != -1) { @@ -673,7 +724,7 @@ std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, Obje } if (cmd == "refresh=raid") - { // TODO: This function is not perfect yet. If you are already in a raid, + { // TODO: This function is not perfect yet. If you are already in a raid, // after the command is executed, the AI ​​needs to go back online or exit the raid and re-enter. PlayerbotFactory factory(bot, bot->GetLevel()); factory.UnbindInstance(); @@ -698,7 +749,8 @@ std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, Obje sRandomPlayerbotMgr->Randomize(bot); return "ok"; } - else if (cmd == "quests"){ + else if (cmd == "quests") + { PlayerbotFactory factory(bot, bot->GetLevel()); factory.InitInstanceQuests(); return "Initialization quests"; @@ -754,61 +806,78 @@ std::vector PlayerbotHolder::HandlePlayerbotCommand(char const* arg return messages; } - char* cmd = strtok ((char*)args, " "); - char* charname = strtok (nullptr, " "); + char* cmd = strtok((char*)args, " "); + char* charname = strtok(nullptr, " "); if (!cmd) { messages.push_back("usage: list/reload/tweak/self or add/init/remove PLAYERNAME or addclass CLASSNAME"); return messages; } - if (!strcmp(cmd, "initself")) { - if (master->GetSession()->GetSecurity() >= SEC_GAMEMASTER) { + if (!strcmp(cmd, "initself")) + { + if (master->GetSession()->GetSecurity() >= SEC_GAMEMASTER) + { // OnBotLogin(master); PlayerbotFactory factory(master, master->GetLevel(), ITEM_QUALITY_EPIC); factory.Randomize(false); messages.push_back("initself ok"); return messages; - } else { + } + else + { messages.push_back("ERROR: Only GM can use this command."); return messages; } } - if (!strncmp(cmd, "initself=", 9)) { - if (!strcmp(cmd, "initself=rare")) { - if (master->GetSession()->GetSecurity() >= SEC_GAMEMASTER) { + if (!strncmp(cmd, "initself=", 9)) + { + if (!strcmp(cmd, "initself=rare")) + { + if (master->GetSession()->GetSecurity() >= SEC_GAMEMASTER) + { // OnBotLogin(master); PlayerbotFactory factory(master, master->GetLevel(), ITEM_QUALITY_RARE); factory.Randomize(false); messages.push_back("initself ok"); return messages; - } else { + } + else + { messages.push_back("ERROR: Only GM can use this command."); return messages; } } - if (!strcmp(cmd, "initself=epic")) { - if (master->GetSession()->GetSecurity() >= SEC_GAMEMASTER) { + if (!strcmp(cmd, "initself=epic")) + { + if (master->GetSession()->GetSecurity() >= SEC_GAMEMASTER) + { // OnBotLogin(master); PlayerbotFactory factory(master, master->GetLevel(), ITEM_QUALITY_EPIC); factory.Randomize(false); messages.push_back("initself ok"); return messages; - } else { + } + else + { messages.push_back("ERROR: Only GM can use this command."); return messages; } } int32 gs; - if (sscanf(cmd, "initself=%d", &gs) != -1) { - if (master->GetSession()->GetSecurity() >= SEC_GAMEMASTER) { + if (sscanf(cmd, "initself=%d", &gs) != -1) + { + if (master->GetSession()->GetSecurity() >= SEC_GAMEMASTER) + { // OnBotLogin(master); PlayerbotFactory factory(master, master->GetLevel(), ITEM_QUALITY_LEGENDARY, gs); factory.Randomize(false); messages.push_back("initself ok, gs = " + std::to_string(gs)); return messages; - } else { + } + else + { messages.push_back("ERROR: Only GM can use this command."); return messages; } @@ -867,12 +936,15 @@ std::vector PlayerbotHolder::HandlePlayerbotCommand(char const* arg if (!strcmp(cmd, "addclass")) { - if (sPlayerbotAIConfig->addClassCommand == 0 && master->GetSession()->GetSecurity() < SEC_GAMEMASTER) { + if (sPlayerbotAIConfig->addClassCommand == 0 && master->GetSession()->GetSecurity() < SEC_GAMEMASTER) + { messages.push_back("You do not have permission to create bot by addclass command"); return messages; } - if (!charname) { - messages.push_back("addclass: invalid CLASSNAME(warrior/paladin/hunter/rogue/priest/shaman/mage/warlock/druid/dk)"); + if (!charname) + { + messages.push_back( + "addclass: invalid CLASSNAME(warrior/paladin/hunter/rogue/priest/shaman/mage/warlock/druid/dk)"); return messages; } uint8 claz; @@ -942,10 +1014,13 @@ std::vector PlayerbotHolder::HandlePlayerbotCommand(char const* arg } uint32 maxAccountId = sPlayerbotAIConfig->randomBotAccounts.back(); // find a bot fit conditions and not in any guild - QueryResult results = CharacterDatabase.Query("SELECT guid FROM characters " - "WHERE name IN (SELECT name FROM playerbots_names) AND class = '{}' AND online = 0 AND race IN ({}) AND guid NOT IN ( SELECT guid FROM guild_member ) " + QueryResult results = CharacterDatabase.Query( + "SELECT guid FROM characters " + "WHERE name IN (SELECT name FROM playerbots_names) AND class = '{}' AND online = 0 AND race IN ({}) AND " + "guid NOT IN ( SELECT guid FROM guild_member ) " "AND account <= {} " - "ORDER BY account DESC LIMIT 1", claz, race_limit, maxAccountId); + "ORDER BY account DESC LIMIT 1", + claz, race_limit, maxAccountId); if (results) { Field* fields = results->Fetch(); @@ -966,13 +1041,18 @@ std::vector PlayerbotHolder::HandlePlayerbotCommand(char const* arg std::string name; bool isPlayer = sCharacterCache->GetCharacterNameByGuid(master->GetTarget(), name); // Player* tPlayer = ObjectAccessor::FindConnectedPlayer(master->GetTarget()); - if (isPlayer) { + if (isPlayer) + { charnameStr = name; - } else { + } + else + { messages.push_back("usage: list/reload/tweak/self or add/init/remove PLAYERNAME"); return messages; } - } else { + } + else + { charnameStr = charname; } @@ -1050,7 +1130,9 @@ std::vector PlayerbotHolder::HandlePlayerbotCommand(char const* arg } else if (master && member != master->GetGUID()) { - out << ProcessBotCommand(cmdStr, member, master->GetGUID(), master->GetSession()->GetSecurity() >= SEC_GAMEMASTER, master->GetSession()->GetAccountId(), master->GetGuildId()); + out << ProcessBotCommand(cmdStr, member, master->GetGUID(), + master->GetSession()->GetSecurity() >= SEC_GAMEMASTER, + master->GetSession()->GetAccountId(), master->GetGuildId()); } else if (!master) { @@ -1063,10 +1145,7 @@ std::vector PlayerbotHolder::HandlePlayerbotCommand(char const* arg return messages; } -uint32 PlayerbotHolder::GetAccountId(std::string const name) -{ - return AccountMgr::GetId(name); -} +uint32 PlayerbotHolder::GetAccountId(std::string const name) { return AccountMgr::GetId(name); } uint32 PlayerbotHolder::GetAccountId(ObjectGuid guid) { @@ -1122,7 +1201,8 @@ std::string const PlayerbotHolder::ListBots(Player* master) if (master) { - QueryResult results = CharacterDatabase.Query("SELECT class, name FROM characters WHERE account = {}", master->GetSession()->GetAccountId()); + QueryResult results = CharacterDatabase.Query("SELECT class, name FROM characters WHERE account = {}", + master->GetSession()->GetAccountId()); if (results) { do @@ -1147,7 +1227,7 @@ std::string const PlayerbotHolder::ListBots(Player* master) Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) { - Player *member = ObjectAccessor::FindPlayer(itr->guid); + Player* member = ObjectAccessor::FindPlayer(itr->guid); if (member && sRandomPlayerbotMgr->IsRandomBot(member)) { std::string const name = member->GetName(); @@ -1192,7 +1272,8 @@ std::string const PlayerbotHolder::LookupBots(Player* master) messages.push_back("DK"); messages.push_back("(Usage: .bot lookup CLASS)"); std::string ret_msg; - for (std::string msg: messages) { + for (std::string msg : messages) + { ret_msg += msg + "\n"; } return ret_msg; @@ -1204,16 +1285,15 @@ uint32 PlayerbotHolder::GetPlayerbotsCountByClass(uint32 cls) for (PlayerBotMap::const_iterator it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; - if (bot->getClass() == cls) { + if (bot->getClass() == cls) + { count++; } } return count; } -PlayerbotMgr::PlayerbotMgr(Player* const master) : PlayerbotHolder(), master(master), lastErrorTell(0) -{ -} +PlayerbotMgr::PlayerbotMgr(Player* const master) : PlayerbotHolder(), master(master), lastErrorTell(0) {} PlayerbotMgr::~PlayerbotMgr() { @@ -1253,7 +1333,8 @@ void PlayerbotMgr::HandleCommand(uint32 type, std::string const text) botAI->HandleCommand(type, text, master); } - for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr->GetPlayerBotsBegin(); it != sRandomPlayerbotMgr->GetPlayerBotsEnd(); ++it) + for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr->GetPlayerBotsBegin(); + it != sRandomPlayerbotMgr->GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); @@ -1274,7 +1355,8 @@ void PlayerbotMgr::HandleMasterIncomingPacket(WorldPacket const& packet) botAI->HandleMasterIncomingPacket(packet); } - for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr->GetPlayerBotsBegin(); it != sRandomPlayerbotMgr->GetPlayerBotsEnd(); ++it) + for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr->GetPlayerBotsBegin(); + it != sRandomPlayerbotMgr->GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); @@ -1309,7 +1391,8 @@ void PlayerbotMgr::HandleMasterOutgoingPacket(WorldPacket const& packet) botAI->HandleMasterOutgoingPacket(packet); } - for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr->GetPlayerBotsBegin(); it != sRandomPlayerbotMgr->GetPlayerBotsEnd(); ++it) + for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr->GetPlayerBotsBegin(); + it != sRandomPlayerbotMgr->GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); @@ -1326,7 +1409,8 @@ void PlayerbotMgr::SaveToDB() bot->SaveToDB(false, false); } - for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr->GetPlayerBotsBegin(); it != sRandomPlayerbotMgr->GetPlayerBotsEnd(); ++it) + for (PlayerBotMap::const_iterator it = sRandomPlayerbotMgr->GetPlayerBotsBegin(); + it != sRandomPlayerbotMgr->GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; if (GET_PLAYERBOT_AI(bot) && GET_PLAYERBOT_AI(bot)->GetMaster() == GetMaster()) @@ -1334,10 +1418,11 @@ void PlayerbotMgr::SaveToDB() } } -void PlayerbotMgr::OnBotLoginInternal(Player * const bot) +void PlayerbotMgr::OnBotLoginInternal(Player* const bot) { PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - if (!botAI) { + if (!botAI) + { return; } botAI->SetMaster(master); @@ -1431,7 +1516,7 @@ void PlayerbotsMgr::AddPlayerbotData(Player* player, bool isBotAI) return; } // If the guid already exists in the map, remove it - + if (!isBotAI) { std::unordered_map::iterator itr = _playerbotsMgrMap.find(player->GetGUID()); @@ -1458,13 +1543,16 @@ void PlayerbotsMgr::AddPlayerbotData(Player* player, bool isBotAI) void PlayerbotsMgr::RemovePlayerBotData(ObjectGuid const& guid, bool is_AI) { - if (is_AI) { + if (is_AI) + { std::unordered_map::iterator itr = _playerbotsAIMap.find(guid); if (itr != _playerbotsAIMap.end()) { _playerbotsAIMap.erase(itr); } - } else { + } + else + { std::unordered_map::iterator itr = _playerbotsMgrMap.find(guid); if (itr != _playerbotsMgrMap.end()) { diff --git a/src/PlayerbotMgr.h b/src/PlayerbotMgr.h index c8297c0a..ce746e07 100644 --- a/src/PlayerbotMgr.h +++ b/src/PlayerbotMgr.h @@ -1,15 +1,16 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PLAYERBOTMGR_H #define _PLAYERBOT_PLAYERBOTMGR_H #include "Common.h" -#include "QueryHolder.h" -#include "QueryResult.h" #include "Player.h" #include "PlayerbotAIBase.h" +#include "QueryHolder.h" +#include "QueryResult.h" class ChatHandler; class PlayerbotAI; @@ -21,92 +22,94 @@ typedef std::map > PlayerBotErrorMap; class PlayerbotHolder : public PlayerbotAIBase { - public: - PlayerbotHolder(); - virtual ~PlayerbotHolder() { }; +public: + PlayerbotHolder(); + virtual ~PlayerbotHolder(){}; - void AddPlayerBot(ObjectGuid guid, uint32 masterAccountId); - void HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder const& holder); + void AddPlayerBot(ObjectGuid guid, uint32 masterAccountId); + void HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder const& holder); - void LogoutPlayerBot(ObjectGuid guid); - void DisablePlayerBot(ObjectGuid guid); - Player* GetPlayerBot(ObjectGuid guid) const; - Player* GetPlayerBot(ObjectGuid::LowType lowGuid) const; - PlayerBotMap::const_iterator GetPlayerBotsBegin() const { return playerBots.begin(); } - PlayerBotMap::const_iterator GetPlayerBotsEnd() const { return playerBots.end(); } + void LogoutPlayerBot(ObjectGuid guid); + void DisablePlayerBot(ObjectGuid guid); + Player* GetPlayerBot(ObjectGuid guid) const; + Player* GetPlayerBot(ObjectGuid::LowType lowGuid) const; + PlayerBotMap::const_iterator GetPlayerBotsBegin() const { return playerBots.begin(); } + PlayerBotMap::const_iterator GetPlayerBotsEnd() const { return playerBots.end(); } - void UpdateAIInternal([[maybe_unused]] uint32 elapsed, [[maybe_unused]] bool minimal = false) override { }; - void UpdateSessions(); - void HandleBotPackets(WorldSession* session); + void UpdateAIInternal([[maybe_unused]] uint32 elapsed, [[maybe_unused]] bool minimal = false) override{}; + void UpdateSessions(); + void HandleBotPackets(WorldSession* session); - void LogoutAllBots(); - void OnBotLogin(Player* const bot); + void LogoutAllBots(); + void OnBotLogin(Player* const bot); - std::vector HandlePlayerbotCommand(char const* args, Player* master = nullptr); - std::string const ProcessBotCommand(std::string const cmd, ObjectGuid guid, ObjectGuid masterguid, bool admin, uint32 masterAccountId, uint32 masterGuildId); - uint32 GetAccountId(std::string const name); - uint32 GetAccountId(ObjectGuid guid); - std::string const ListBots(Player* master); - std::string const LookupBots(Player* master); - uint32 GetPlayerbotsCount() { return playerBots.size(); } - uint32 GetPlayerbotsCountByClass(uint32 cls); - protected: - virtual void OnBotLoginInternal(Player* const bot) = 0; + std::vector HandlePlayerbotCommand(char const* args, Player* master = nullptr); + std::string const ProcessBotCommand(std::string const cmd, ObjectGuid guid, ObjectGuid masterguid, bool admin, + uint32 masterAccountId, uint32 masterGuildId); + uint32 GetAccountId(std::string const name); + uint32 GetAccountId(ObjectGuid guid); + std::string const ListBots(Player* master); + std::string const LookupBots(Player* master); + uint32 GetPlayerbotsCount() { return playerBots.size(); } + uint32 GetPlayerbotsCountByClass(uint32 cls); - PlayerBotMap playerBots; +protected: + virtual void OnBotLoginInternal(Player* const bot) = 0; + + PlayerBotMap playerBots; }; class PlayerbotMgr : public PlayerbotHolder { - public: - PlayerbotMgr(Player* const master); - virtual ~PlayerbotMgr(); +public: + PlayerbotMgr(Player* const master); + virtual ~PlayerbotMgr(); - static bool HandlePlayerbotMgrCommand(ChatHandler* handler, char const* args); - void HandleMasterIncomingPacket(WorldPacket const& packet); - void HandleMasterOutgoingPacket(WorldPacket const& packet); - void HandleCommand(uint32 type, std::string const text); - void OnPlayerLogin(Player* player); - void CancelLogout(); + static bool HandlePlayerbotMgrCommand(ChatHandler* handler, char const* args); + void HandleMasterIncomingPacket(WorldPacket const& packet); + void HandleMasterOutgoingPacket(WorldPacket const& packet); + void HandleCommand(uint32 type, std::string const text); + void OnPlayerLogin(Player* player); + void CancelLogout(); - void UpdateAIInternal(uint32 elapsed, bool minimal = false) override; - void TellError(std::string const botName, std::string const text); + void UpdateAIInternal(uint32 elapsed, bool minimal = false) override; + void TellError(std::string const botName, std::string const text); - Player* GetMaster() const { return master; }; + Player* GetMaster() const { return master; }; - void SaveToDB(); + void SaveToDB(); - protected: - void OnBotLoginInternal(Player* const bot) override; - void CheckTellErrors(uint32 elapsed); +protected: + void OnBotLoginInternal(Player* const bot) override; + void CheckTellErrors(uint32 elapsed); - private: - Player* const master; - PlayerBotErrorMap errors; - time_t lastErrorTell; +private: + Player* const master; + PlayerBotErrorMap errors; + time_t lastErrorTell; }; class PlayerbotsMgr { - public: - PlayerbotsMgr() { } - ~PlayerbotsMgr() { } +public: + PlayerbotsMgr() {} + ~PlayerbotsMgr() {} - static PlayerbotsMgr* instance() - { - static PlayerbotsMgr instance; - return &instance; - } + static PlayerbotsMgr* instance() + { + static PlayerbotsMgr instance; + return &instance; + } - void AddPlayerbotData(Player* player, bool isBotAI); - void RemovePlayerBotData(ObjectGuid const& guid, bool is_AI); + void AddPlayerbotData(Player* player, bool isBotAI); + void RemovePlayerBotData(ObjectGuid const& guid, bool is_AI); - PlayerbotAI* GetPlayerbotAI(Player* player); - PlayerbotMgr* GetPlayerbotMgr(Player* player); + PlayerbotAI* GetPlayerbotAI(Player* player); + PlayerbotMgr* GetPlayerbotMgr(Player* player); - private: - std::unordered_map _playerbotsAIMap; - std::unordered_map _playerbotsMgrMap; +private: + std::unordered_map _playerbotsAIMap; + std::unordered_map _playerbotsMgrMap; }; #define sPlayerbotsMgr PlayerbotsMgr::instance() diff --git a/src/PlayerbotSecurity.cpp b/src/PlayerbotSecurity.cpp index da8a54a9..e7241004 100644 --- a/src/PlayerbotSecurity.cpp +++ b/src/PlayerbotSecurity.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PlayerbotSecurity.h" + #include "LFGMgr.h" #include "PlayerbotAIConfig.h" #include "Playerbots.h" @@ -19,7 +21,8 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea return PLAYERBOT_SECURITY_ALLOW_ALL; PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - if (!botAI) { + if (!botAI) + { return PLAYERBOT_SECURITY_DENY_ALL; } if (botAI->IsOpposing(from)) @@ -62,7 +65,8 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea } } - if (sPlayerbotAIConfig->groupInvitationPermission <= 0) { + if (sPlayerbotAIConfig->groupInvitationPermission <= 0) + { if (reason) *reason = PLAYERBOT_DENY_NONE; @@ -85,9 +89,11 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea if (sPlayerbotAIConfig->gearscorecheck) { if (botGS && bot->GetLevel() > 15 && botGS > fromGS && - static_cast(100 * (botGS - fromGS) / botGS) >= static_cast(12 * sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) / from->GetLevel())) + static_cast(100 * (botGS - fromGS) / botGS) >= + static_cast(12 * sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) / from->GetLevel())) { - if (reason) *reason = PLAYERBOT_DENY_GEARSCORE; + if (reason) + *reason = PLAYERBOT_DENY_GEARSCORE; return PLAYERBOT_SECURITY_TALK; } } @@ -195,37 +201,39 @@ bool PlayerbotSecurity::CheckLevelFor(PlayerbotSecurityLevel level, bool silent, case PLAYERBOT_SECURITY_TALK: switch (reason) { - case PLAYERBOT_DENY_NONE: - out << "I'll do it later"; - break; - case PLAYERBOT_DENY_LOW_LEVEL: - out << "You are too low level: |cffff0000" << (uint32)from->GetLevel() << "|cffffffff/|cff00ff00" << (uint32)bot->GetLevel(); - break; - case PLAYERBOT_DENY_GEARSCORE: + case PLAYERBOT_DENY_NONE: + out << "I'll do it later"; + break; + case PLAYERBOT_DENY_LOW_LEVEL: + out << "You are too low level: |cffff0000" << (uint32)from->GetLevel() << "|cffffffff/|cff00ff00" + << (uint32)bot->GetLevel(); + break; + case PLAYERBOT_DENY_GEARSCORE: { int botGS = (int)botAI->GetEquipGearScore(bot, false, false); int fromGS = (int)botAI->GetEquipGearScore(from, false, false); int diff = (100 * (botGS - fromGS) / botGS); int req = 12 * sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) / from->GetLevel(); - out << "Your gearscore is too low: |cffff0000" << fromGS << "|cffffffff/|cff00ff00" << botGS << " |cffff0000" << diff << "%|cffffffff/|cff00ff00" << req << "%"; + out << "Your gearscore is too low: |cffff0000" << fromGS << "|cffffffff/|cff00ff00" << botGS + << " |cffff0000" << diff << "%|cffffffff/|cff00ff00" << req << "%"; } break; - case PLAYERBOT_DENY_NOT_YOURS: - out << "I have a master already"; - break; - case PLAYERBOT_DENY_IS_BOT: - out << "You are a bot"; - break; - case PLAYERBOT_DENY_OPPOSING: - out << "You are the enemy"; - break; - case PLAYERBOT_DENY_DEAD: - out << "I'm dead. Will do it later"; - break; - case PLAYERBOT_DENY_INVITE: - out << "Invite me to your group first"; - break; - case PLAYERBOT_DENY_FAR: + case PLAYERBOT_DENY_NOT_YOURS: + out << "I have a master already"; + break; + case PLAYERBOT_DENY_IS_BOT: + out << "You are a bot"; + break; + case PLAYERBOT_DENY_OPPOSING: + out << "You are the enemy"; + break; + case PLAYERBOT_DENY_DEAD: + out << "I'm dead. Will do it later"; + break; + case PLAYERBOT_DENY_INVITE: + out << "Invite me to your group first"; + break; + case PLAYERBOT_DENY_FAR: { out << "You must be closer to invite me to your group. I am in "; @@ -235,31 +243,32 @@ bool PlayerbotSecurity::CheckLevelFor(PlayerbotSecurityLevel level, bool silent, } } break; - case PLAYERBOT_DENY_FULL_GROUP: - out << "I am in a full group. Will do it later"; - break; - case PLAYERBOT_DENY_IS_LEADER: - out << "I am currently leading a group. I can invite you if you want."; - break; - case PLAYERBOT_DENY_NOT_LEADER: - if (botAI->GetGroupMaster()) - { - out << "I am in a group with " << botAI->GetGroupMaster()->GetName() << ". You can ask him for invite."; - } - else - { - out << "I am in a group with someone else. You can ask him for invite."; - } - break; - case PLAYERBOT_DENY_BG: - out << "I am in a queue for BG. Will do it later"; - break; - case PLAYERBOT_DENY_LFG: - out << "I am in a queue for dungeon. Will do it later"; - break; - default: - out << "I can't do that"; - break; + case PLAYERBOT_DENY_FULL_GROUP: + out << "I am in a full group. Will do it later"; + break; + case PLAYERBOT_DENY_IS_LEADER: + out << "I am currently leading a group. I can invite you if you want."; + break; + case PLAYERBOT_DENY_NOT_LEADER: + if (botAI->GetGroupMaster()) + { + out << "I am in a group with " << botAI->GetGroupMaster()->GetName() + << ". You can ask him for invite."; + } + else + { + out << "I am in a group with someone else. You can ask him for invite."; + } + break; + case PLAYERBOT_DENY_BG: + out << "I am in a queue for BG. Will do it later"; + break; + case PLAYERBOT_DENY_LFG: + out << "I am in a queue for dungeon. Will do it later"; + break; + default: + out << "I can't do that"; + break; } break; case PLAYERBOT_SECURITY_INVITE: diff --git a/src/PlayerbotSecurity.h b/src/PlayerbotSecurity.h index 4239ee61..f2947595 100644 --- a/src/PlayerbotSecurity.h +++ b/src/PlayerbotSecurity.h @@ -1,23 +1,24 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PLAYERBOTSECURITY_H #define _PLAYERBOT_PLAYERBOTSECURITY_H +#include + #include "Common.h" #include "ObjectGuid.h" -#include - class Player; enum PlayerbotSecurityLevel : uint32 { - PLAYERBOT_SECURITY_DENY_ALL = 0, - PLAYERBOT_SECURITY_TALK = 1, - PLAYERBOT_SECURITY_INVITE = 2, - PLAYERBOT_SECURITY_ALLOW_ALL = 3 + PLAYERBOT_SECURITY_DENY_ALL = 0, + PLAYERBOT_SECURITY_TALK = 1, + PLAYERBOT_SECURITY_INVITE = 2, + PLAYERBOT_SECURITY_ALLOW_ALL = 3 }; enum DenyReason @@ -40,16 +41,16 @@ enum DenyReason class PlayerbotSecurity { - public: - PlayerbotSecurity(Player* const bot); +public: + PlayerbotSecurity(Player* const bot); - PlayerbotSecurityLevel LevelFor(Player* from, DenyReason* reason = nullptr, bool ignoreGroup = false); - bool CheckLevelFor(PlayerbotSecurityLevel level, bool silent, Player* from, bool ignoreGroup = false); + PlayerbotSecurityLevel LevelFor(Player* from, DenyReason* reason = nullptr, bool ignoreGroup = false); + bool CheckLevelFor(PlayerbotSecurityLevel level, bool silent, Player* from, bool ignoreGroup = false); - private: - Player* const bot; - uint32 account; - std::map > whispers; +private: + Player* const bot; + uint32 account; + std::map > whispers; }; #endif diff --git a/src/PlayerbotTextMgr.cpp b/src/PlayerbotTextMgr.cpp index 7041185c..e78236d9 100644 --- a/src/PlayerbotTextMgr.cpp +++ b/src/PlayerbotTextMgr.cpp @@ -1,17 +1,21 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PlayerbotTextMgr.h" + #include "Playerbots.h" -void PlayerbotTextMgr::replaceAll(std::string & str, const std::string & from, const std::string & to) { +void PlayerbotTextMgr::replaceAll(std::string& str, const std::string& from, const std::string& to) +{ if (from.empty()) return; size_t start_pos = 0; - while ((start_pos = str.find(from, start_pos)) != std::string::npos) { + while ((start_pos = str.find(from, start_pos)) != std::string::npos) + { str.replace(start_pos, from.length(), to); - start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx' + start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx' } } @@ -20,7 +24,8 @@ void PlayerbotTextMgr::LoadBotTexts() LOG_INFO("playerbots", "Loading playerbots texts..."); uint32 count = 0; - if (PreparedQueryResult result = PlayerbotsDatabase.Query(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_TEXT))) + if (PreparedQueryResult result = + PlayerbotsDatabase.Query(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_TEXT))) { do { @@ -37,8 +42,7 @@ void PlayerbotTextMgr::LoadBotTexts() botTexts[name].push_back(BotTextEntry(name, text, sayType, replyType)); ++count; - } - while (result->NextRow()); + } while (result->NextRow()); } LOG_INFO("playerbots", "{} playerbots texts loaded", count); @@ -123,14 +127,14 @@ std::string PlayerbotTextMgr::GetBotText(ChatReplyType replyType, std::map placeholders; @@ -149,7 +153,7 @@ bool PlayerbotTextMgr::rollTextChance(std::string name) return urand(0, 100) < botTextChance[name]; } -bool PlayerbotTextMgr::GetBotText(std::string name, std::string &text) +bool PlayerbotTextMgr::GetBotText(std::string name, std::string& text) { if (!rollTextChance(name)) return false; @@ -167,7 +171,6 @@ bool PlayerbotTextMgr::GetBotText(std::string name, std::string& text, std::map< return !text.empty(); } - void PlayerbotTextMgr::AddLocalePriority(uint32 locale) { if (!locale) diff --git a/src/PlayerbotTextMgr.h b/src/PlayerbotTextMgr.h index f5dcfd84..5ec3aaa6 100644 --- a/src/PlayerbotTextMgr.h +++ b/src/PlayerbotTextMgr.h @@ -1,21 +1,25 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PLAYERBOTTEXTMGR_H #define _PLAYERBOT_PLAYERBOTTEXTMGR_H -#include "Common.h" - #include #include +#include "Common.h" + #define BOT_TEXT1(name) sPlayerbotTextMgr->GetBotText(name) #define BOT_TEXT2(name, replace) sPlayerbotTextMgr->GetBotText(name, replace) struct BotTextEntry { - BotTextEntry(std::string name, std::map text, uint32 say_type, uint32 reply_type) : m_name(name), m_text(text), m_sayType(say_type), m_replyType(reply_type) {} + BotTextEntry(std::string name, std::map text, uint32 say_type, uint32 reply_type) + : m_name(name), m_text(text), m_sayType(say_type), m_replyType(reply_type) + { + } std::string m_name; std::map m_text; uint32 m_sayType; @@ -31,7 +35,11 @@ struct ChatReplyData struct ChatQueuedReply { - ChatQueuedReply(uint32 type, uint32 guid1, uint32 guid2, std::string msg, std::string chanName, std::string name, time_t time) : m_type(type), m_guid1(guid1), m_guid2(guid2), m_msg(msg), m_chanName(chanName), m_name(name), m_time(time) {} + ChatQueuedReply(uint32 type, uint32 guid1, uint32 guid2, std::string msg, std::string chanName, std::string name, + time_t time) + : m_type(type), m_guid1(guid1), m_guid2(guid2), m_msg(msg), m_chanName(chanName), m_name(name), m_time(time) + { + } uint32 m_type; uint32 m_guid1; uint32 m_guid2; @@ -54,39 +62,40 @@ enum ChatReplyType class PlayerbotTextMgr { - public: - PlayerbotTextMgr() { - for (uint8 i = 0; i < MAX_LOCALES; ++i) - { - botTextLocalePriority[i] = 0; - } - }; - virtual ~PlayerbotTextMgr() { }; - static PlayerbotTextMgr* instance() +public: + PlayerbotTextMgr() + { + for (uint8 i = 0; i < MAX_LOCALES; ++i) { - static PlayerbotTextMgr instance; - return &instance; + botTextLocalePriority[i] = 0; } + }; + virtual ~PlayerbotTextMgr(){}; + static PlayerbotTextMgr* instance() + { + static PlayerbotTextMgr instance; + return &instance; + } - std::string GetBotText(std::string name, std::map placeholders); - std::string GetBotText(std::string name); - std::string GetBotText(ChatReplyType replyType, std::map placeholders); - std::string GetBotText(ChatReplyType replyType, std::string name); - bool GetBotText(std::string name, std::string& text); - bool GetBotText(std::string name, std::string& text, std::map placeholders); - void LoadBotTexts(); - void LoadBotTextChance(); - static void replaceAll(std::string& str, const std::string& from, const std::string& to); - bool rollTextChance(std::string text); + std::string GetBotText(std::string name, std::map placeholders); + std::string GetBotText(std::string name); + std::string GetBotText(ChatReplyType replyType, std::map placeholders); + std::string GetBotText(ChatReplyType replyType, std::string name); + bool GetBotText(std::string name, std::string& text); + bool GetBotText(std::string name, std::string& text, std::map placeholders); + void LoadBotTexts(); + void LoadBotTextChance(); + static void replaceAll(std::string& str, const std::string& from, const std::string& to); + bool rollTextChance(std::string text); - uint32 GetLocalePriority(); - void AddLocalePriority(uint32 locale); - void ResetLocalePriority(); + uint32 GetLocalePriority(); + void AddLocalePriority(uint32 locale); + void ResetLocalePriority(); - private: - std::map> botTexts; - std::map botTextChance; - uint32 botTextLocalePriority[MAX_LOCALES]; +private: + std::map> botTexts; + std::map botTextChance; + uint32 botTextLocalePriority[MAX_LOCALES]; }; #define sPlayerbotTextMgr PlayerbotTextMgr::instance() diff --git a/src/Playerbots.cpp b/src/Playerbots.cpp index ad519e13..eeacb85a 100644 --- a/src/Playerbots.cpp +++ b/src/Playerbots.cpp @@ -15,327 +15,320 @@ * with this program. If not, see . */ -#include "cs_playerbots.h" +#include "Playerbots.h" + #include "Channel.h" #include "Config.h" #include "DatabaseEnv.h" #include "DatabaseLoader.h" #include "GuildTaskMgr.h" #include "Metric.h" -#include "Playerbots.h" #include "RandomPlayerbotMgr.h" #include "ScriptMgr.h" +#include "cs_playerbots.h" class PlayerbotsDatabaseScript : public DatabaseScript { - public: - PlayerbotsDatabaseScript() : DatabaseScript("PlayerbotsDatabaseScript") { } +public: + PlayerbotsDatabaseScript() : DatabaseScript("PlayerbotsDatabaseScript") {} - bool OnDatabasesLoading() override + bool OnDatabasesLoading() override + { + DatabaseLoader playerbotLoader("server.playerbots"); + playerbotLoader.SetUpdateFlags(sConfigMgr->GetOption("Playerbots.Updates.EnableDatabases", true) + ? DatabaseLoader::DATABASE_PLAYERBOTS + : 0); + playerbotLoader.AddDatabase(PlayerbotsDatabase, "Playerbots"); + + return playerbotLoader.Load(); + } + + void OnDatabasesKeepAlive() override { PlayerbotsDatabase.KeepAlive(); } + + void OnDatabasesClosing() override { PlayerbotsDatabase.Close(); } + + void OnDatabaseWarnAboutSyncQueries(bool apply) override { PlayerbotsDatabase.WarnAboutSyncQueries(apply); } + + void OnDatabaseSelectIndexLogout(Player* player, uint32& statementIndex, uint32& statementParam) override + { + statementIndex = CHAR_UPD_CHAR_ONLINE; + statementParam = player->GetGUID().GetCounter(); + } + + void OnDatabaseGetDBRevision(std::string& revision) override + { + if (QueryResult resultPlayerbot = + PlayerbotsDatabase.Query("SELECT date FROM version_db_playerbots ORDER BY date DESC LIMIT 1")) { - DatabaseLoader playerbotLoader("server.playerbots"); - playerbotLoader.SetUpdateFlags(sConfigMgr->GetOption("Playerbots.Updates.EnableDatabases", true) ? DatabaseLoader::DATABASE_PLAYERBOTS : 0); - playerbotLoader.AddDatabase(PlayerbotsDatabase, "Playerbots"); - - return playerbotLoader.Load(); + Field* fields = resultPlayerbot->Fetch(); + revision = fields[0].Get(); } - void OnDatabasesKeepAlive() override + if (revision.empty()) { - PlayerbotsDatabase.KeepAlive(); - } - - void OnDatabasesClosing() override - { - PlayerbotsDatabase.Close(); - } - - void OnDatabaseWarnAboutSyncQueries(bool apply) override - { - PlayerbotsDatabase.WarnAboutSyncQueries(apply); - } - - void OnDatabaseSelectIndexLogout(Player* player, uint32& statementIndex, uint32& statementParam) override - { - statementIndex = CHAR_UPD_CHAR_ONLINE; - statementParam = player->GetGUID().GetCounter(); - } - - void OnDatabaseGetDBRevision(std::string& revision) override - { - if (QueryResult resultPlayerbot = PlayerbotsDatabase.Query("SELECT date FROM version_db_playerbots ORDER BY date DESC LIMIT 1")) - { - Field* fields = resultPlayerbot->Fetch(); - revision = fields[0].Get(); - } - - if (revision.empty()) - { - revision = "Unknown Playerbots Database Revision"; - } + revision = "Unknown Playerbots Database Revision"; } + } }; class PlayerbotsMetricScript : public MetricScript { - public: - PlayerbotsMetricScript() : MetricScript("PlayerbotsMetricScript") { } +public: + PlayerbotsMetricScript() : MetricScript("PlayerbotsMetricScript") {} - void OnMetricLogging() override + void OnMetricLogging() override + { + if (sMetric->IsEnabled()) { - if (sMetric->IsEnabled()) - { - sMetric->LogValue("db_queue_playerbots", uint64(PlayerbotsDatabase.QueueSize()), {}); - } + sMetric->LogValue("db_queue_playerbots", uint64(PlayerbotsDatabase.QueueSize()), {}); } + } }; class PlayerbotsPlayerScript : public PlayerScript { - public: - PlayerbotsPlayerScript() : PlayerScript("PlayerbotsPlayerScript") { } +public: + PlayerbotsPlayerScript() : PlayerScript("PlayerbotsPlayerScript") {} - void OnLogin(Player* player) override + void OnLogin(Player* player) override + { + if (!player->GetSession()->IsBot()) { - if (!player->GetSession()->IsBot()) + sPlayerbotsMgr->AddPlayerbotData(player, false); + sRandomPlayerbotMgr->OnPlayerLogin(player); + } + } + + void OnAfterUpdate(Player* player, uint32 diff) override + { + if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(player)) + { + botAI->UpdateAI(diff); + } + + if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) + { + playerbotMgr->UpdateAI(diff); + } + } + + bool CanPlayerUseChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg, Player* receiver) override + { + if (type == CHAT_MSG_WHISPER) + { + if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(receiver)) { - sPlayerbotsMgr->AddPlayerbotData(player, false); - sRandomPlayerbotMgr->OnPlayerLogin(player); + botAI->HandleCommand(type, msg, player); + + return false; } } - void OnAfterUpdate(Player* player, uint32 diff) override - { - if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(player)) - { - botAI->UpdateAI(diff); - } + return true; + } - if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) - { - playerbotMgr->UpdateAI(diff); - } - } - - bool CanPlayerUseChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg, Player* receiver) override + void OnChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg, Group* group) override + { + for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next()) { - if (type == CHAT_MSG_WHISPER) + if (Player* member = itr->GetSource()) { - if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(receiver)) + if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(member)) { botAI->HandleCommand(type, msg, player); - - return false; - } - } - - return true; - } - - void OnChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg, Group* group) override - { - for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next()) - { - if (Player* member = itr->GetSource()) - { - if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(member)) - { - botAI->HandleCommand(type, msg, player); - } } } } + } - void OnChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg) override + void OnChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg) override + { + if (type == CHAT_MSG_GUILD) { - if (type == CHAT_MSG_GUILD) + if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) { - if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) + for (PlayerBotMap::const_iterator it = playerbotMgr->GetPlayerBotsBegin(); + it != playerbotMgr->GetPlayerBotsEnd(); ++it) { - for (PlayerBotMap::const_iterator it = playerbotMgr->GetPlayerBotsBegin(); it != playerbotMgr->GetPlayerBotsEnd(); ++it) + if (Player* const bot = it->second) { - if (Player* const bot = it->second) + if (bot->GetGuildId() == player->GetGuildId()) { - if (bot->GetGuildId() == player->GetGuildId()) - { - GET_PLAYERBOT_AI(bot)->HandleCommand(type, msg, player); - } + GET_PLAYERBOT_AI(bot)->HandleCommand(type, msg, player); } } } } } + } - void OnChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg, Channel* channel) override + void OnChat(Player* player, uint32 type, uint32 /*lang*/, std::string& msg, Channel* channel) override + { + if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) { - if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) + if (channel->GetFlags() & 0x18) { - if (channel->GetFlags() & 0x18) - { - playerbotMgr->HandleCommand(type, msg); - } + playerbotMgr->HandleCommand(type, msg); } - - sRandomPlayerbotMgr->HandleCommand(type, msg, player); } - bool OnBeforeCriteriaProgress(Player* player, AchievementCriteriaEntry const* /*criteria*/) override - { - if (sRandomPlayerbotMgr->IsRandomBot(player)) - { - return false; - } - return true; - } + sRandomPlayerbotMgr->HandleCommand(type, msg, player); + } - bool OnBeforeAchiComplete(Player* player, AchievementEntry const* /*achievement*/) override + bool OnBeforeCriteriaProgress(Player* player, AchievementCriteriaEntry const* /*criteria*/) override + { + if (sRandomPlayerbotMgr->IsRandomBot(player)) { - if (sRandomPlayerbotMgr->IsRandomBot(player)) - { - return false; - } - return true; + return false; } + return true; + } + + bool OnBeforeAchiComplete(Player* player, AchievementEntry const* /*achievement*/) override + { + if (sRandomPlayerbotMgr->IsRandomBot(player)) + { + return false; + } + return true; + } }; class PlayerbotsMiscScript : public MiscScript { - public: - PlayerbotsMiscScript() : MiscScript("PlayerbotsMiscScript", {MISCHOOK_ON_DESTRUCT_PLAYER}) { } +public: + PlayerbotsMiscScript() : MiscScript("PlayerbotsMiscScript", {MISCHOOK_ON_DESTRUCT_PLAYER}) {} - void OnDestructPlayer(Player* player) override + void OnDestructPlayer(Player* player) override + { + if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(player)) { - if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(player)) - { - delete botAI; - } - - if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) - { - delete playerbotMgr; - } + delete botAI; } + + if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) + { + delete playerbotMgr; + } + } }; class PlayerbotsServerScript : public ServerScript { - public: - PlayerbotsServerScript() : ServerScript("PlayerbotsServerScript") { } +public: + PlayerbotsServerScript() : ServerScript("PlayerbotsServerScript") {} - void OnPacketReceived(WorldSession* session, WorldPacket const& packet) override - { - if (Player* player = session->GetPlayer()) - if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) - playerbotMgr->HandleMasterIncomingPacket(packet); - } + void OnPacketReceived(WorldSession* session, WorldPacket const& packet) override + { + if (Player* player = session->GetPlayer()) + if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) + playerbotMgr->HandleMasterIncomingPacket(packet); + } }; class PlayerbotsWorldScript : public WorldScript { - public: - PlayerbotsWorldScript() : WorldScript("PlayerbotsWorldScript") { } +public: + PlayerbotsWorldScript() : WorldScript("PlayerbotsWorldScript") {} - void OnBeforeWorldInitialized() override - { - uint32 oldMSTime = getMSTime(); + void OnBeforeWorldInitialized() override + { + uint32 oldMSTime = getMSTime(); - LOG_INFO("server.loading", " "); - LOG_INFO("server.loading", "Load Playerbots Config..."); + LOG_INFO("server.loading", " "); + LOG_INFO("server.loading", "Load Playerbots Config..."); - sPlayerbotAIConfig->Initialize(); + sPlayerbotAIConfig->Initialize(); - LOG_INFO("server.loading", ">> Loaded playerbots config in {} ms", GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - } + LOG_INFO("server.loading", ">> Loaded playerbots config in {} ms", GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); + } }; class PlayerbotsScript : public PlayerbotScript { - public: - PlayerbotsScript() : PlayerbotScript("PlayerbotsScript") { } +public: + PlayerbotsScript() : PlayerbotScript("PlayerbotsScript") {} - bool OnPlayerbotCheckLFGQueue(lfg::Lfg5Guids const& guidsList) override + bool OnPlayerbotCheckLFGQueue(lfg::Lfg5Guids const& guidsList) override + { + bool nonBotFound = false; + for (ObjectGuid const& guid : guidsList.guids) { - bool nonBotFound = false; - for (ObjectGuid const& guid : guidsList.guids) + Player* player = ObjectAccessor::FindPlayer(guid); + if (guid.IsGroup() || (player && !GET_PLAYERBOT_AI(player))) { - Player* player = ObjectAccessor::FindPlayer(guid); - if (guid.IsGroup() || (player && !GET_PLAYERBOT_AI(player))) - { - nonBotFound = true; - break; - } + nonBotFound = true; + break; } - - return nonBotFound; } - void OnPlayerbotCheckKillTask(Player* player, Unit* victim) override + return nonBotFound; + } + + void OnPlayerbotCheckKillTask(Player* player, Unit* victim) override + { + if (player) + sGuildTaskMgr->CheckKillTask(player, victim); + } + + void OnPlayerbotCheckPetitionAccount(Player* player, bool& found) override + { + if (found && GET_PLAYERBOT_AI(player)) + found = false; + } + + bool OnPlayerbotCheckUpdatesToSend(Player* player) override + { + if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(player)) + return botAI->IsRealPlayer(); + + return true; + } + + void OnPlayerbotPacketSent(Player* player, WorldPacket const* packet) override + { + if (!player) + return; + + if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(player)) { - if (player) - sGuildTaskMgr->CheckKillTask(player, victim); + botAI->HandleBotOutgoingPacket(*packet); } - - void OnPlayerbotCheckPetitionAccount(Player* player, bool& found) override + if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) { - if (found && GET_PLAYERBOT_AI(player)) - found = false; + playerbotMgr->HandleMasterOutgoingPacket(*packet); } + } - bool OnPlayerbotCheckUpdatesToSend(Player* player) override - { - if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(player)) - return botAI->IsRealPlayer(); + void OnPlayerbotUpdate(uint32 diff) override + { + sRandomPlayerbotMgr->UpdateAI(diff); + sRandomPlayerbotMgr->UpdateSessions(); + } - return true; - } - - void OnPlayerbotPacketSent(Player* player, WorldPacket const* packet) override - { - if (!player) - return; - - if (PlayerbotAI* botAI = GET_PLAYERBOT_AI(player)) - { - botAI->HandleBotOutgoingPacket(*packet); - } + void OnPlayerbotUpdateSessions(Player* player) override + { + if (player) if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) + playerbotMgr->UpdateSessions(); + } + + void OnPlayerbotLogout(Player* player) override + { + if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) + { + PlayerbotAI* botAI = GET_PLAYERBOT_AI(player); + if (!botAI || botAI->IsRealPlayer()) { - playerbotMgr->HandleMasterOutgoingPacket(*packet); + playerbotMgr->LogoutAllBots(); } } - void OnPlayerbotUpdate(uint32 diff) override - { - sRandomPlayerbotMgr->UpdateAI(diff); - sRandomPlayerbotMgr->UpdateSessions(); - } + sRandomPlayerbotMgr->OnPlayerLogout(player); + } - void OnPlayerbotUpdateSessions(Player* player) override - { - if (player) - if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) - playerbotMgr->UpdateSessions(); - } - - void OnPlayerbotLogout(Player* player) override - { - if (PlayerbotMgr* playerbotMgr = GET_PLAYERBOT_MGR(player)) - { - PlayerbotAI* botAI = GET_PLAYERBOT_AI(player); - if (!botAI || botAI->IsRealPlayer()) - { - playerbotMgr->LogoutAllBots(); - } - } - - sRandomPlayerbotMgr->OnPlayerLogout(player); - } - - void OnPlayerbotLogoutBots() override - { - sRandomPlayerbotMgr->LogoutAllBots(); - } + void OnPlayerbotLogoutBots() override { sRandomPlayerbotMgr->LogoutAllBots(); } }; void AddPlayerbotsScripts() diff --git a/src/Playerbots.h b/src/Playerbots.h index 2b467366..5b82771b 100644 --- a/src/Playerbots.h +++ b/src/Playerbots.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_H @@ -43,7 +44,8 @@ int strcmpi(char const* s1, char const* s2); #define RESET_AI_VALUE2(type, name, param) context->GetValue(name, param)->Reset() #define PAI_VALUE(type, name) sPlayerbotsMgr->GetPlayerbotAI(player)->GetAiObjectContext()->GetValue(name)->Get() -#define PAI_VALUE2(type, name, param) sPlayerbotsMgr->GetPlayerbotAI(player)->GetAiObjectContext()->GetValue(name, param)->Get() +#define PAI_VALUE2(type, name, param) \ + sPlayerbotsMgr->GetPlayerbotAI(player)->GetAiObjectContext()->GetValue(name, param)->Get() #define GAI_VALUE(type, name) sSharedValueContext->getGlobalValue(name)->Get() #define GAI_VALUE2(type, name, param) sSharedValueContext->getGlobalValue(name, param)->Get() diff --git a/src/RandomItemMgr.cpp b/src/RandomItemMgr.cpp index 1e1a18ab..415ccb15 100644 --- a/src/RandomItemMgr.cpp +++ b/src/RandomItemMgr.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RandomItemMgr.h" + #include "ItemTemplate.h" #include "LootValues.h" #include "Playerbots.h" @@ -10,70 +12,70 @@ char* strstri(char const* str1, char const* str2); std::set RandomItemMgr::itemCache; -uint64 BotEquipKey::GetKey() -{ - return level + 100 * clazz + 10000 * slot + 1000000 * quality; -} +uint64 BotEquipKey::GetKey() { return level + 100 * clazz + 10000 * slot + 1000000 * quality; } class RandomItemGuildTaskPredicate : public RandomItemPredicate { - public: - bool Apply(ItemTemplate const* proto) override - { - if (proto->Bonding == BIND_WHEN_PICKED_UP || proto->Bonding == BIND_QUEST_ITEM || proto->Bonding == BIND_WHEN_USE) - return false; - - if (proto->Quality < ITEM_QUALITY_NORMAL) - return false; - - if ((proto->Class == ITEM_CLASS_ARMOR || proto->Class == ITEM_CLASS_WEAPON) && proto->Quality >= ITEM_QUALITY_RARE) - return true; - - if (proto->Class == ITEM_CLASS_TRADE_GOODS || proto->Class == ITEM_CLASS_CONSUMABLE) - return true; - +public: + bool Apply(ItemTemplate const* proto) override + { + if (proto->Bonding == BIND_WHEN_PICKED_UP || proto->Bonding == BIND_QUEST_ITEM || + proto->Bonding == BIND_WHEN_USE) return false; - } + + if (proto->Quality < ITEM_QUALITY_NORMAL) + return false; + + if ((proto->Class == ITEM_CLASS_ARMOR || proto->Class == ITEM_CLASS_WEAPON) && + proto->Quality >= ITEM_QUALITY_RARE) + return true; + + if (proto->Class == ITEM_CLASS_TRADE_GOODS || proto->Class == ITEM_CLASS_CONSUMABLE) + return true; + + return false; + } }; class RandomItemGuildTaskRewardPredicate : public RandomItemPredicate { - public: - RandomItemGuildTaskRewardPredicate(bool equip, bool rare) : equip(equip), rare(rare) { } - - bool Apply(ItemTemplate const* proto) override - { - if (proto->Bonding == BIND_WHEN_PICKED_UP || proto->Bonding == BIND_QUEST_ITEM || proto->Bonding == BIND_WHEN_USE) - return false; - - if (proto->Class == ITEM_CLASS_QUEST) - return false; - - if (equip) - { - uint32 desiredQuality = rare ? ITEM_QUALITY_RARE : ITEM_QUALITY_UNCOMMON; - if (proto->Quality < desiredQuality || proto->Quality >= ITEM_QUALITY_EPIC) - return false; - - if (proto->Class == ITEM_CLASS_ARMOR || proto->Class == ITEM_CLASS_WEAPON) - return true; - } - else - { - uint32 desiredQuality = rare ? ITEM_QUALITY_UNCOMMON : ITEM_QUALITY_NORMAL; - if (proto->Quality < desiredQuality || proto->Quality >= ITEM_QUALITY_RARE) - return false; - - if (proto->Class == ITEM_CLASS_TRADE_GOODS || proto->Class == ITEM_CLASS_CONSUMABLE) - return true; - } +public: + RandomItemGuildTaskRewardPredicate(bool equip, bool rare) : equip(equip), rare(rare) {} + bool Apply(ItemTemplate const* proto) override + { + if (proto->Bonding == BIND_WHEN_PICKED_UP || proto->Bonding == BIND_QUEST_ITEM || + proto->Bonding == BIND_WHEN_USE) return false; + + if (proto->Class == ITEM_CLASS_QUEST) + return false; + + if (equip) + { + uint32 desiredQuality = rare ? ITEM_QUALITY_RARE : ITEM_QUALITY_UNCOMMON; + if (proto->Quality < desiredQuality || proto->Quality >= ITEM_QUALITY_EPIC) + return false; + + if (proto->Class == ITEM_CLASS_ARMOR || proto->Class == ITEM_CLASS_WEAPON) + return true; + } + else + { + uint32 desiredQuality = rare ? ITEM_QUALITY_UNCOMMON : ITEM_QUALITY_NORMAL; + if (proto->Quality < desiredQuality || proto->Quality >= ITEM_QUALITY_RARE) + return false; + + if (proto->Class == ITEM_CLASS_TRADE_GOODS || proto->Class == ITEM_CLASS_CONSUMABLE) + return true; } - private: - bool equip; - bool rare; + return false; + } + +private: + bool equip; + bool rare; }; RandomItemMgr::RandomItemMgr() @@ -147,7 +149,6 @@ RandomItemMgr::RandomItemMgr() weightRatingLink["dodgertng"] = CR_DODGE; weightRatingLink["blockrtng"] = CR_BLOCK; weightRatingLink["parryrtng"] = CR_PARRY; - } void RandomItemMgr::Init() @@ -164,7 +165,7 @@ void RandomItemMgr::Init() void RandomItemMgr::InitAfterAhBot() { BuildRandomItemCache(); - //BuildRarityCache(); + // BuildRarityCache(); } RandomItemMgr::~RandomItemMgr() @@ -179,7 +180,7 @@ bool RandomItemMgr::HandleConsoleCommand(ChatHandler* handler, char const* args) { if (!args || !*args) { - LOG_ERROR("playerbots", "Usage: rnditem"); + LOG_ERROR("playerbots", "Usage: rnditem"); return false; } @@ -209,7 +210,8 @@ RandomItemList RandomItemMgr::Query(uint32 level, RandomItemType type, RandomIte void RandomItemMgr::BuildRandomItemCache() { - if (PreparedQueryResult result = PlayerbotsDatabase.Query(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_RNDITEM_CACHE))) + if (PreparedQueryResult result = + PlayerbotsDatabase.Query(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_RNDITEM_CACHE))) { LOG_INFO("server.loading", "Loading random item cache"); uint32 count = 0; @@ -224,8 +226,7 @@ void RandomItemMgr::BuildRandomItemCache() randomItemCache[level][rit].push_back(itemId); ++count; - } - while (result->NextRow()); + } while (result->NextRow()); LOG_INFO("server.loading", "Equipment cache loaded from {} records", count); } @@ -243,7 +244,8 @@ void RandomItemMgr::BuildRandomItemCache() if (proto->Duration & 0x80000000) continue; - if (strstri(proto->Name1.c_str(), "qa") || strstri(proto->Name1.c_str(), "test") || strstri(proto->Name1.c_str(), "deprecated")) + if (strstri(proto->Name1.c_str(), "qa") || strstri(proto->Name1.c_str(), "test") || + strstri(proto->Name1.c_str(), "deprecated")) continue; if (!proto->ItemLevel) @@ -261,7 +263,8 @@ void RandomItemMgr::BuildRandomItemCache() randomItemCache[level / 10][rit].push_back(itr.first); - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_INS_RNDITEM_CACHE); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_INS_RNDITEM_CACHE); stmt->SetData(0, level / 10); stmt->SetData(1, type); stmt->SetData(2, itr.first); @@ -278,7 +281,8 @@ void RandomItemMgr::BuildRandomItemCache() for (uint32 type = RANDOM_ITEM_GUILD_TASK; type <= RANDOM_ITEM_GUILD_TASK_REWARD_TRADE_RARE; type++) { RandomItemList list = randomItemCache[level][(RandomItemType)type]; - LOG_INFO("playerbots", " Level {}..{} Type {} - {} random items cached", level * 10, level * 10 + 9, type, list.size()); + LOG_INFO("playerbots", " Level {}..{} Type {} - {} random items cached", level * 10, level * 10 + 9, + type, list.size()); for (RandomItemList::iterator i = list.begin(); i != list.end(); ++i) { @@ -334,20 +338,20 @@ bool RandomItemMgr::CanEquipItem(BotEquipKey key, ItemTemplate const* proto) requiredLevel = key.level; uint32 level = key.level; - + uint32 delta = 2; if (level < 15) delta = 15; else if (level < 40) - delta = 10; //urand(5, 10); + delta = 10; // urand(5, 10); else if (level < 60) - delta = 6; // urand(3, 7); + delta = 6; // urand(3, 7); else if (level < 70) - delta = 9; // urand(2, 5); + delta = 9; // urand(2, 5); else if (level < 80) - delta = 9; // urand(2, 4); + delta = 9; // urand(2, 4); else if (level == 80) - delta = 9; // urand(2, 4); + delta = 9; // urand(2, 4); if (key.quality > ITEM_QUALITY_NORMAL && (requiredLevel > level || requiredLevel < level - delta)) return false; @@ -373,7 +377,8 @@ bool RandomItemMgr::CanEquipItemNew(ItemTemplate const* proto) return false; bool properSlot = false; - for (std::map >::iterator i = viableSlots.begin(); i != viableSlots.end(); ++i) + for (std::map >::iterator i = viableSlots.begin(); i != viableSlots.end(); + ++i) { std::set const& slots = viableSlots[(EquipmentSlots)i->first]; if (slots.find((InventoryType)proto->InventoryType) != slots.end()) @@ -455,7 +460,7 @@ bool RandomItemMgr::ShouldEquipArmorForSpec(uint8 playerclass, uint8 spec, ItemT if (!m_weightScales[playerclass][spec].info.id) return false; - std::unordered_set resultArmorSubClass = { ITEM_SUBCLASS_ARMOR_CLOTH }; + std::unordered_set resultArmorSubClass = {ITEM_SUBCLASS_ARMOR_CLOTH}; switch (playerclass) { @@ -464,12 +469,14 @@ bool RandomItemMgr::ShouldEquipArmorForSpec(uint8 playerclass, uint8 spec, ItemT if (proto->InventoryType == INVTYPE_HOLDABLE) return false; - if (m_weightScales[playerclass][spec].info.name == "arms" || m_weightScales[playerclass][spec].info.name == "fury") + if (m_weightScales[playerclass][spec].info.name == "arms" || + m_weightScales[playerclass][spec].info.name == "fury") { - resultArmorSubClass = { ITEM_SUBCLASS_ARMOR_LEATHER, ITEM_SUBCLASS_ARMOR_MAIL, ITEM_SUBCLASS_ARMOR_PLATE }; + resultArmorSubClass = {ITEM_SUBCLASS_ARMOR_LEATHER, ITEM_SUBCLASS_ARMOR_MAIL, + ITEM_SUBCLASS_ARMOR_PLATE}; } else - resultArmorSubClass = { ITEM_SUBCLASS_ARMOR_MAIL, ITEM_SUBCLASS_ARMOR_PLATE }; + resultArmorSubClass = {ITEM_SUBCLASS_ARMOR_MAIL, ITEM_SUBCLASS_ARMOR_PLATE}; break; } case CLASS_DEATH_KNIGHT: @@ -477,7 +484,7 @@ bool RandomItemMgr::ShouldEquipArmorForSpec(uint8 playerclass, uint8 spec, ItemT if (proto->InventoryType == INVTYPE_HOLDABLE) return false; - resultArmorSubClass = { ITEM_SUBCLASS_ARMOR_SIGIL, ITEM_SUBCLASS_ARMOR_PLATE }; + resultArmorSubClass = {ITEM_SUBCLASS_ARMOR_SIGIL, ITEM_SUBCLASS_ARMOR_PLATE}; } case CLASS_PALADIN: { @@ -485,9 +492,10 @@ bool RandomItemMgr::ShouldEquipArmorForSpec(uint8 playerclass, uint8 spec, ItemT return false; if (m_weightScales[playerclass][spec].info.name != "holy") - resultArmorSubClass = { ITEM_SUBCLASS_ARMOR_MAIL, ITEM_SUBCLASS_ARMOR_PLATE , ITEM_SUBCLASS_ARMOR_LIBRAM }; + resultArmorSubClass = {ITEM_SUBCLASS_ARMOR_MAIL, ITEM_SUBCLASS_ARMOR_PLATE, ITEM_SUBCLASS_ARMOR_LIBRAM}; else - resultArmorSubClass = { ITEM_SUBCLASS_ARMOR_CLOTH, ITEM_SUBCLASS_ARMOR_LEATHER, ITEM_SUBCLASS_ARMOR_MAIL, ITEM_SUBCLASS_ARMOR_PLATE, ITEM_SUBCLASS_ARMOR_LIBRAM }; + resultArmorSubClass = {ITEM_SUBCLASS_ARMOR_CLOTH, ITEM_SUBCLASS_ARMOR_LEATHER, ITEM_SUBCLASS_ARMOR_MAIL, + ITEM_SUBCLASS_ARMOR_PLATE, ITEM_SUBCLASS_ARMOR_LIBRAM}; break; } case CLASS_HUNTER: @@ -495,7 +503,7 @@ bool RandomItemMgr::ShouldEquipArmorForSpec(uint8 playerclass, uint8 spec, ItemT if (proto->InventoryType == INVTYPE_HOLDABLE) return false; - resultArmorSubClass = { ITEM_SUBCLASS_ARMOR_CLOTH, ITEM_SUBCLASS_ARMOR_LEATHER, ITEM_SUBCLASS_ARMOR_MAIL }; + resultArmorSubClass = {ITEM_SUBCLASS_ARMOR_CLOTH, ITEM_SUBCLASS_ARMOR_LEATHER, ITEM_SUBCLASS_ARMOR_MAIL}; break; } case CLASS_ROGUE: @@ -503,12 +511,12 @@ bool RandomItemMgr::ShouldEquipArmorForSpec(uint8 playerclass, uint8 spec, ItemT if (proto->InventoryType == INVTYPE_HOLDABLE) return false; - resultArmorSubClass = { ITEM_SUBCLASS_ARMOR_CLOTH, ITEM_SUBCLASS_ARMOR_LEATHER }; + resultArmorSubClass = {ITEM_SUBCLASS_ARMOR_CLOTH, ITEM_SUBCLASS_ARMOR_LEATHER}; break; } case CLASS_PRIEST: { - resultArmorSubClass = { ITEM_SUBCLASS_ARMOR_CLOTH }; + resultArmorSubClass = {ITEM_SUBCLASS_ARMOR_CLOTH}; break; } case CLASS_SHAMAN: @@ -516,21 +524,24 @@ bool RandomItemMgr::ShouldEquipArmorForSpec(uint8 playerclass, uint8 spec, ItemT if (m_weightScales[playerclass][spec].info.name == "enhance" && proto->InventoryType == INVTYPE_HOLDABLE) return false; - resultArmorSubClass = { ITEM_SUBCLASS_ARMOR_TOTEM, ITEM_SUBCLASS_ARMOR_CLOTH, ITEM_SUBCLASS_ARMOR_LEATHER, ITEM_SUBCLASS_ARMOR_MAIL }; + resultArmorSubClass = {ITEM_SUBCLASS_ARMOR_TOTEM, ITEM_SUBCLASS_ARMOR_CLOTH, ITEM_SUBCLASS_ARMOR_LEATHER, + ITEM_SUBCLASS_ARMOR_MAIL}; break; } case CLASS_MAGE: case CLASS_WARLOCK: { - resultArmorSubClass = { ITEM_SUBCLASS_ARMOR_CLOTH }; + resultArmorSubClass = {ITEM_SUBCLASS_ARMOR_CLOTH}; break; } case CLASS_DRUID: { - if ((m_weightScales[playerclass][spec].info.name == "feraltank" || m_weightScales[playerclass][spec].info.name == "feraldps") && proto->InventoryType == INVTYPE_HOLDABLE) + if ((m_weightScales[playerclass][spec].info.name == "feraltank" || + m_weightScales[playerclass][spec].info.name == "feraldps") && + proto->InventoryType == INVTYPE_HOLDABLE) return false; - resultArmorSubClass = { ITEM_SUBCLASS_ARMOR_IDOL, ITEM_SUBCLASS_ARMOR_CLOTH, ITEM_SUBCLASS_ARMOR_LEATHER }; + resultArmorSubClass = {ITEM_SUBCLASS_ARMOR_IDOL, ITEM_SUBCLASS_ARMOR_CLOTH, ITEM_SUBCLASS_ARMOR_LEATHER}; break; } } @@ -543,7 +554,8 @@ bool RandomItemMgr::ShouldEquipWeaponForSpec(uint8 playerclass, uint8 spec, Item EquipmentSlots slot_mh = EQUIPMENT_SLOT_START; EquipmentSlots slot_oh = EQUIPMENT_SLOT_START; EquipmentSlots slot_rh = EQUIPMENT_SLOT_START; - for (std::map >::iterator i = viableSlots.begin(); i != viableSlots.end(); ++i) + for (std::map >::iterator i = viableSlots.begin(); i != viableSlots.end(); + ++i) { std::set slots = viableSlots[(EquipmentSlots)i->first]; if (slots.find((InventoryType)proto->InventoryType) != slots.end()) @@ -573,14 +585,16 @@ bool RandomItemMgr::ShouldEquipWeaponForSpec(uint8 playerclass, uint8 spec, Item { if (m_weightScales[playerclass][spec].info.name == "prot") { - mh_weapons = { ITEM_SUBCLASS_WEAPON_SWORD, ITEM_SUBCLASS_WEAPON_AXE, ITEM_SUBCLASS_WEAPON_MACE, ITEM_SUBCLASS_WEAPON_DAGGER, ITEM_SUBCLASS_WEAPON_FIST }; - oh_weapons = { ITEM_SUBCLASS_ARMOR_SHIELD }; - r_weapons = { ITEM_SUBCLASS_WEAPON_BOW, ITEM_SUBCLASS_WEAPON_CROSSBOW, ITEM_SUBCLASS_WEAPON_GUN }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_SWORD, ITEM_SUBCLASS_WEAPON_AXE, ITEM_SUBCLASS_WEAPON_MACE, + ITEM_SUBCLASS_WEAPON_DAGGER, ITEM_SUBCLASS_WEAPON_FIST}; + oh_weapons = {ITEM_SUBCLASS_ARMOR_SHIELD}; + r_weapons = {ITEM_SUBCLASS_WEAPON_BOW, ITEM_SUBCLASS_WEAPON_CROSSBOW, ITEM_SUBCLASS_WEAPON_GUN}; } else { - mh_weapons = { ITEM_SUBCLASS_WEAPON_SWORD2, ITEM_SUBCLASS_WEAPON_AXE2, ITEM_SUBCLASS_WEAPON_MACE2, ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_POLEARM }; - r_weapons = { ITEM_SUBCLASS_WEAPON_BOW, ITEM_SUBCLASS_WEAPON_CROSSBOW, ITEM_SUBCLASS_WEAPON_GUN }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_SWORD2, ITEM_SUBCLASS_WEAPON_AXE2, ITEM_SUBCLASS_WEAPON_MACE2, + ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_POLEARM}; + r_weapons = {ITEM_SUBCLASS_WEAPON_BOW, ITEM_SUBCLASS_WEAPON_CROSSBOW, ITEM_SUBCLASS_WEAPON_GUN}; } break; } @@ -588,94 +602,99 @@ bool RandomItemMgr::ShouldEquipWeaponForSpec(uint8 playerclass, uint8 spec, Item { if (m_weightScales[playerclass][spec].info.name == "prot") { - mh_weapons = { ITEM_SUBCLASS_WEAPON_SWORD, ITEM_SUBCLASS_WEAPON_AXE, ITEM_SUBCLASS_WEAPON_MACE }; - oh_weapons = { ITEM_SUBCLASS_ARMOR_SHIELD }; - r_weapons = { ITEM_SUBCLASS_ARMOR_LIBRAM }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_SWORD, ITEM_SUBCLASS_WEAPON_AXE, ITEM_SUBCLASS_WEAPON_MACE}; + oh_weapons = {ITEM_SUBCLASS_ARMOR_SHIELD}; + r_weapons = {ITEM_SUBCLASS_ARMOR_LIBRAM}; } else if (m_weightScales[playerclass][spec].info.name == "holy") { - mh_weapons = { ITEM_SUBCLASS_WEAPON_SWORD, ITEM_SUBCLASS_WEAPON_AXE, ITEM_SUBCLASS_WEAPON_MACE }; - oh_weapons = { ITEM_SUBCLASS_ARMOR_SHIELD, ITEM_SUBCLASS_ARMOR_MISC }; - r_weapons = { ITEM_SUBCLASS_ARMOR_LIBRAM }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_SWORD, ITEM_SUBCLASS_WEAPON_AXE, ITEM_SUBCLASS_WEAPON_MACE}; + oh_weapons = {ITEM_SUBCLASS_ARMOR_SHIELD, ITEM_SUBCLASS_ARMOR_MISC}; + r_weapons = {ITEM_SUBCLASS_ARMOR_LIBRAM}; } else { - mh_weapons = { ITEM_SUBCLASS_WEAPON_SWORD2, ITEM_SUBCLASS_WEAPON_AXE2, ITEM_SUBCLASS_WEAPON_MACE2, ITEM_SUBCLASS_WEAPON_POLEARM }; - r_weapons = { ITEM_SUBCLASS_ARMOR_LIBRAM }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_SWORD2, ITEM_SUBCLASS_WEAPON_AXE2, ITEM_SUBCLASS_WEAPON_MACE2, + ITEM_SUBCLASS_WEAPON_POLEARM}; + r_weapons = {ITEM_SUBCLASS_ARMOR_LIBRAM}; } break; } case CLASS_HUNTER: { - mh_weapons = { ITEM_SUBCLASS_WEAPON_SWORD2, ITEM_SUBCLASS_WEAPON_AXE2, ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_POLEARM }; - r_weapons = { ITEM_SUBCLASS_WEAPON_BOW, ITEM_SUBCLASS_WEAPON_CROSSBOW, ITEM_SUBCLASS_WEAPON_GUN }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_SWORD2, ITEM_SUBCLASS_WEAPON_AXE2, ITEM_SUBCLASS_WEAPON_STAFF, + ITEM_SUBCLASS_WEAPON_POLEARM}; + r_weapons = {ITEM_SUBCLASS_WEAPON_BOW, ITEM_SUBCLASS_WEAPON_CROSSBOW, ITEM_SUBCLASS_WEAPON_GUN}; break; } case CLASS_ROGUE: { - mh_weapons = { ITEM_SUBCLASS_WEAPON_DAGGER }; - oh_weapons = { ITEM_SUBCLASS_WEAPON_DAGGER }; - r_weapons = { ITEM_SUBCLASS_WEAPON_BOW, ITEM_SUBCLASS_WEAPON_CROSSBOW, ITEM_SUBCLASS_WEAPON_GUN }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_DAGGER}; + oh_weapons = {ITEM_SUBCLASS_WEAPON_DAGGER}; + r_weapons = {ITEM_SUBCLASS_WEAPON_BOW, ITEM_SUBCLASS_WEAPON_CROSSBOW, ITEM_SUBCLASS_WEAPON_GUN}; break; } case CLASS_PRIEST: { - mh_weapons = { ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_DAGGER, ITEM_SUBCLASS_WEAPON_MACE }; - oh_weapons = { ITEM_SUBCLASS_ARMOR_MISC }; - r_weapons = { ITEM_SUBCLASS_WEAPON_WAND }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_DAGGER, ITEM_SUBCLASS_WEAPON_MACE}; + oh_weapons = {ITEM_SUBCLASS_ARMOR_MISC}; + r_weapons = {ITEM_SUBCLASS_WEAPON_WAND}; break; } case CLASS_SHAMAN: { if (m_weightScales[playerclass][spec].info.name == "resto") { - mh_weapons = { ITEM_SUBCLASS_WEAPON_DAGGER, ITEM_SUBCLASS_WEAPON_AXE, ITEM_SUBCLASS_WEAPON_MACE, ITEM_SUBCLASS_WEAPON_FIST }; - oh_weapons = { ITEM_SUBCLASS_ARMOR_MISC, ITEM_SUBCLASS_ARMOR_SHIELD }; - r_weapons = { ITEM_SUBCLASS_ARMOR_TOTEM }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_DAGGER, ITEM_SUBCLASS_WEAPON_AXE, ITEM_SUBCLASS_WEAPON_MACE, + ITEM_SUBCLASS_WEAPON_FIST}; + oh_weapons = {ITEM_SUBCLASS_ARMOR_MISC, ITEM_SUBCLASS_ARMOR_SHIELD}; + r_weapons = {ITEM_SUBCLASS_ARMOR_TOTEM}; } else if (m_weightScales[playerclass][spec].info.name == "enhance") { - mh_weapons = { ITEM_SUBCLASS_WEAPON_MACE2, ITEM_SUBCLASS_WEAPON_AXE2, ITEM_SUBCLASS_WEAPON_DAGGER, ITEM_SUBCLASS_WEAPON_AXE, ITEM_SUBCLASS_WEAPON_MACE, ITEM_SUBCLASS_WEAPON_FIST }; - oh_weapons = { ITEM_SUBCLASS_ARMOR_SHIELD }; - r_weapons = { ITEM_SUBCLASS_ARMOR_TOTEM }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_MACE2, ITEM_SUBCLASS_WEAPON_AXE2, ITEM_SUBCLASS_WEAPON_DAGGER, + ITEM_SUBCLASS_WEAPON_AXE, ITEM_SUBCLASS_WEAPON_MACE, ITEM_SUBCLASS_WEAPON_FIST}; + oh_weapons = {ITEM_SUBCLASS_ARMOR_SHIELD}; + r_weapons = {ITEM_SUBCLASS_ARMOR_TOTEM}; } else { - mh_weapons = { ITEM_SUBCLASS_WEAPON_STAFF }; - r_weapons = { ITEM_SUBCLASS_ARMOR_TOTEM }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_STAFF}; + r_weapons = {ITEM_SUBCLASS_ARMOR_TOTEM}; } break; } case CLASS_MAGE: case CLASS_WARLOCK: { - mh_weapons = { ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_DAGGER, ITEM_SUBCLASS_WEAPON_SWORD }; - oh_weapons = { ITEM_SUBCLASS_ARMOR_MISC }; - r_weapons = { ITEM_SUBCLASS_WEAPON_WAND }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_DAGGER, ITEM_SUBCLASS_WEAPON_SWORD}; + oh_weapons = {ITEM_SUBCLASS_ARMOR_MISC}; + r_weapons = {ITEM_SUBCLASS_WEAPON_WAND}; break; } case CLASS_DRUID: { if (m_weightScales[playerclass][spec].info.name == "feraltank") { - mh_weapons = { ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_MACE2 }; - r_weapons = { ITEM_SUBCLASS_ARMOR_IDOL }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_MACE2}; + r_weapons = {ITEM_SUBCLASS_ARMOR_IDOL}; } else if (m_weightScales[playerclass][spec].info.name == "resto") { - mh_weapons = { ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_DAGGER, ITEM_SUBCLASS_WEAPON_FIST, ITEM_SUBCLASS_WEAPON_MACE }; - oh_weapons = { ITEM_SUBCLASS_ARMOR_MISC }; - r_weapons = { ITEM_SUBCLASS_ARMOR_IDOL }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_DAGGER, ITEM_SUBCLASS_WEAPON_FIST, + ITEM_SUBCLASS_WEAPON_MACE}; + oh_weapons = {ITEM_SUBCLASS_ARMOR_MISC}; + r_weapons = {ITEM_SUBCLASS_ARMOR_IDOL}; } else if (m_weightScales[playerclass][spec].info.name == "feraldps") { - mh_weapons = { ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_MACE2 }; - r_weapons = { ITEM_SUBCLASS_ARMOR_IDOL }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_STAFF, ITEM_SUBCLASS_WEAPON_MACE2}; + r_weapons = {ITEM_SUBCLASS_ARMOR_IDOL}; } else { - mh_weapons = { ITEM_SUBCLASS_WEAPON_STAFF }; - r_weapons = { ITEM_SUBCLASS_ARMOR_IDOL }; + mh_weapons = {ITEM_SUBCLASS_WEAPON_STAFF}; + r_weapons = {ITEM_SUBCLASS_ARMOR_IDOL}; } break; } @@ -704,7 +723,8 @@ bool RandomItemMgr::CanEquipArmor(uint8 clazz, uint32 level, ItemTemplate const* if (proto->InventoryType == INVTYPE_TABARD) return true; - if ((clazz == CLASS_WARRIOR || clazz == CLASS_PALADIN || clazz == CLASS_SHAMAN) && proto->SubClass == ITEM_SUBCLASS_ARMOR_SHIELD) + if ((clazz == CLASS_WARRIOR || clazz == CLASS_PALADIN || clazz == CLASS_SHAMAN) && + proto->SubClass == ITEM_SUBCLASS_ARMOR_SHIELD) return true; if ((clazz == CLASS_WARRIOR || clazz == CLASS_PALADIN) && level >= 40) @@ -713,13 +733,15 @@ bool RandomItemMgr::CanEquipArmor(uint8 clazz, uint32 level, ItemTemplate const* return false; } - if (((clazz == CLASS_WARRIOR || clazz == CLASS_PALADIN) && level < 40) || ((clazz == CLASS_HUNTER || clazz == CLASS_SHAMAN) && level >= 40)) + if (((clazz == CLASS_WARRIOR || clazz == CLASS_PALADIN) && level < 40) || + ((clazz == CLASS_HUNTER || clazz == CLASS_SHAMAN) && level >= 40)) { if (proto->SubClass != ITEM_SUBCLASS_ARMOR_MAIL && proto->InventoryType != INVTYPE_CLOAK) return false; } - if (((clazz == CLASS_HUNTER || clazz == CLASS_SHAMAN) && level < 40) || (clazz == CLASS_DRUID || clazz == CLASS_ROGUE)) + if (((clazz == CLASS_HUNTER || clazz == CLASS_SHAMAN) && level < 40) || + (clazz == CLASS_DRUID || clazz == CLASS_ROGUE)) { if (proto->SubClass != ITEM_SUBCLASS_ARMOR_LEATHER && proto->InventoryType != INVTYPE_CLOAK) return false; @@ -746,43 +768,49 @@ bool RandomItemMgr::CanEquipWeapon(uint8 clazz, ItemTemplate const* proto) switch (clazz) { case CLASS_PRIEST: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF && proto->SubClass != ITEM_SUBCLASS_WEAPON_WAND && proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE) + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF && proto->SubClass != ITEM_SUBCLASS_WEAPON_WAND && + proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE) return false; break; case CLASS_MAGE: case CLASS_WARLOCK: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF && proto->SubClass != ITEM_SUBCLASS_WEAPON_WAND && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD) - return false; - break; - case CLASS_WARRIOR: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && - proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD && proto->SubClass != ITEM_SUBCLASS_WEAPON_GUN && proto->SubClass != ITEM_SUBCLASS_WEAPON_CROSSBOW && - proto->SubClass != ITEM_SUBCLASS_WEAPON_BOW && proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE && proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE2 && - proto->SubClass != ITEM_SUBCLASS_WEAPON_THROWN) - return false; - break; - case CLASS_PALADIN: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF && proto->SubClass != ITEM_SUBCLASS_WEAPON_WAND && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD) return false; break; - case CLASS_SHAMAN: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF) + case CLASS_WARRIOR: + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && + proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD && + proto->SubClass != ITEM_SUBCLASS_WEAPON_GUN && proto->SubClass != ITEM_SUBCLASS_WEAPON_CROSSBOW && + proto->SubClass != ITEM_SUBCLASS_WEAPON_BOW && proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE && + proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_THROWN) return false; break; - case CLASS_DRUID: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER && + case CLASS_PALADIN: + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && + proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD) + return false; + break; + case CLASS_SHAMAN: + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF) return false; break; + case CLASS_DRUID: + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE2 && + proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER && proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF) + return false; + break; case CLASS_HUNTER: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_GUN && - proto->SubClass != ITEM_SUBCLASS_WEAPON_CROSSBOW && proto->SubClass != ITEM_SUBCLASS_WEAPON_BOW) + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_AXE2 && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD2 && + proto->SubClass != ITEM_SUBCLASS_WEAPON_GUN && proto->SubClass != ITEM_SUBCLASS_WEAPON_CROSSBOW && + proto->SubClass != ITEM_SUBCLASS_WEAPON_BOW) return false; break; case CLASS_ROGUE: - if (proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD && proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && - proto->SubClass != ITEM_SUBCLASS_WEAPON_GUN && proto->SubClass != ITEM_SUBCLASS_WEAPON_CROSSBOW && proto->SubClass != ITEM_SUBCLASS_WEAPON_BOW && + if (proto->SubClass != ITEM_SUBCLASS_WEAPON_DAGGER && proto->SubClass != ITEM_SUBCLASS_WEAPON_SWORD && + proto->SubClass != ITEM_SUBCLASS_WEAPON_MACE && proto->SubClass != ITEM_SUBCLASS_WEAPON_GUN && + proto->SubClass != ITEM_SUBCLASS_WEAPON_CROSSBOW && proto->SubClass != ITEM_SUBCLASS_WEAPON_BOW && proto->SubClass != ITEM_SUBCLASS_WEAPON_THROWN) return false; break; @@ -895,7 +923,8 @@ void RandomItemMgr::BuildItemInfoCache() for (CreatureTemplateContainer::const_iterator itr = creatures->begin(); itr != creatures->end(); ++itr) { uint32 sEntry = itr->first; - if (LootTemplateAccess const* lTemplateA = DropMapValue::GetLootTemplate(ObjectGuid::Create(sEntry, uint32(1)), LOOT_CORPSE)) + if (LootTemplateAccess const* lTemplateA = + DropMapValue::GetLootTemplate(ObjectGuid::Create(sEntry, uint32(1)), LOOT_CORPSE)) for (auto const& lItem : lTemplateA->Entries) dropMap->insert(std::make_pair(lItem->itemid, sEntry)); } @@ -906,7 +935,8 @@ void RandomItemMgr::BuildItemInfoCache() for (auto const& itr : *gameobjects) { uint32 sEntry = itr.first; - if (LootTemplateAccess const* lTemplateA = DropMapValue::GetLootTemplate(ObjectGuid::Create(sEntry, uint32(1)), LOOT_CORPSE)) + if (LootTemplateAccess const* lTemplateA = DropMapValue::GetLootTemplate( + ObjectGuid::Create(sEntry, uint32(1)), LOOT_CORPSE)) for (auto const& lItem : lTemplateA->Entries) dropMap->insert(std::make_pair(lItem->itemid, sEntry)); } @@ -927,39 +957,29 @@ void RandomItemMgr::BuildItemInfoCache() continue; // skip non armor/weapon - if (proto->Class != ITEM_CLASS_WEAPON && - proto->Class != ITEM_CLASS_ARMOR && - proto->Class != ITEM_CLASS_CONTAINER && - proto->Class != ITEM_CLASS_PROJECTILE) + if (proto->Class != ITEM_CLASS_WEAPON && proto->Class != ITEM_CLASS_ARMOR && + proto->Class != ITEM_CLASS_CONTAINER && proto->Class != ITEM_CLASS_PROJECTILE) continue; if (!CanEquipItemNew(proto)) continue; // skip test items - if (strstr(proto->Name1.c_str(), "(Test)") || - strstr(proto->Name1.c_str(), "(TEST)") || - strstr(proto->Name1.c_str(), "(test)") || - strstr(proto->Name1.c_str(), "(JEFFTEST)") || - strstr(proto->Name1.c_str(), "Test ") || - strstr(proto->Name1.c_str(), "Test") || - strstr(proto->Name1.c_str(), "TEST") || - strstr(proto->Name1.c_str(), "TEST ") || - strstr(proto->Name1.c_str(), " TEST") || - strstr(proto->Name1.c_str(), "2200 ") || - strstr(proto->Name1.c_str(), "Deprecated ") || - strstr(proto->Name1.c_str(), "Unused ") || - strstr(proto->Name1.c_str(), "Monster ") || - strstr(proto->Name1.c_str(), "[PH]") || - strstr(proto->Name1.c_str(), "(OLD)") || - strstr(proto->Name1.c_str(), "QR") - ) + if (strstr(proto->Name1.c_str(), "(Test)") || strstr(proto->Name1.c_str(), "(TEST)") || + strstr(proto->Name1.c_str(), "(test)") || strstr(proto->Name1.c_str(), "(JEFFTEST)") || + strstr(proto->Name1.c_str(), "Test ") || strstr(proto->Name1.c_str(), "Test") || + strstr(proto->Name1.c_str(), "TEST") || strstr(proto->Name1.c_str(), "TEST ") || + strstr(proto->Name1.c_str(), " TEST") || strstr(proto->Name1.c_str(), "2200 ") || + strstr(proto->Name1.c_str(), "Deprecated ") || strstr(proto->Name1.c_str(), "Unused ") || + strstr(proto->Name1.c_str(), "Monster ") || strstr(proto->Name1.c_str(), "[PH]") || + strstr(proto->Name1.c_str(), "(OLD)") || strstr(proto->Name1.c_str(), "QR")) { itemForTest.insert(proto->ItemId); continue; } - if (proto->Flags & ITEM_FLAG_DEPRECATED) { + if (proto->Flags & ITEM_FLAG_DEPRECATED) + { itemForTest.insert(proto->ItemId); continue; } @@ -970,9 +990,7 @@ void RandomItemMgr::BuildItemInfoCache() proto->RequiredReputationRank > 0) continue;*/ - if (proto->RequiredHonorRank > 0 || - proto->RequiredSkillRank > 0 || - proto->RequiredCityRank > 0) + if (proto->RequiredHonorRank > 0 || proto->RequiredSkillRank > 0 || proto->RequiredCityRank > 0) continue; // skip random enchant items @@ -985,7 +1003,8 @@ void RandomItemMgr::BuildItemInfoCache() // check possible equip slots EquipmentSlots slot = EQUIPMENT_SLOT_START; - for (std::map >::iterator i = viableSlots.begin(); i != viableSlots.end(); ++i) + for (std::map >::iterator i = viableSlots.begin(); + i != viableSlots.end(); ++i) { std::set slots = viableSlots[(EquipmentSlots)i->first]; if (slots.find((InventoryType)proto->InventoryType) != slots.end()) @@ -1028,7 +1047,8 @@ void RandomItemMgr::BuildItemInfoCache() // continue; // // check possible weapon for spec - // if ((proto->Class == ITEM_CLASS_WEAPON || (proto->SubClass == ITEM_SUBCLASS_ARMOR_SHIELD || (proto->SubClass == ITEM_SUBCLASS_ARMOR_MISC && proto->InventoryType == INVTYPE_HOLDABLE))) && + // if ((proto->Class == ITEM_CLASS_WEAPON || (proto->SubClass == ITEM_SUBCLASS_ARMOR_SHIELD || + // (proto->SubClass == ITEM_SUBCLASS_ARMOR_MISC && proto->InventoryType == INVTYPE_HOLDABLE))) && // !ShouldEquipWeaponForSpec(clazz, spec, proto)) // continue; @@ -1040,7 +1060,8 @@ void RandomItemMgr::BuildItemInfoCache() // //statWeight.weight = statW; // // save item statWeight into ItemCache // cacheInfo.weights[statWeight.id] = statWeight.weight; - // LOG_DEBUG("playerbots", "Item: {}, weight: {}, class: {}, spec: {}", proto->ItemId, statWeight.weight, clazz, m_weightScales[clazz][spec].info.name); + // LOG_DEBUG("playerbots", "Item: {}, weight: {}, class: {}, spec: {}", proto->ItemId, + // statWeight.weight, clazz, m_weightScales[clazz][spec].info.name); // } // } @@ -1065,7 +1086,8 @@ void RandomItemMgr::BuildItemInfoCache() // } // if (cacheInfo.team < TEAM_NEUTRAL) - // LOG_DEBUG("playerbots", "Item: {}, team (item): {}", proto->ItemId, cacheInfo.team == TEAM_ALLIANCE ? "Alliance" : "Horde"); + // LOG_DEBUG("playerbots", "Item: {}, team (item): {}", proto->ItemId, cacheInfo.team == TEAM_ALLIANCE ? + // "Alliance" : "Horde"); // // check min level // if (proto->RequiredLevel) @@ -1119,8 +1141,9 @@ void RandomItemMgr::BuildItemInfoCache() // else if (isHorde) // cacheInfo.team = TEAM_HORDE; - // LOG_DEBUG("playerbots", "Item: {}, team (quest): {}", proto->ItemId, cacheInfo.team == TEAM_ALLIANCE ? "Alliance" : cacheInfo.team == TEAM_HORDE ? "Horde" : "Both"); - // LOG_DEBUG("playerbots", "Item: {}, source: quest {}, minlevel: {}", proto->ItemId, cacheInfo.sourceId, cacheInfo.minLevel); + // LOG_DEBUG("playerbots", "Item: {}, team (quest): {}", proto->ItemId, cacheInfo.team == TEAM_ALLIANCE + // ? "Alliance" : cacheInfo.team == TEAM_HORDE ? "Horde" : "Both"); LOG_DEBUG("playerbots", "Item: {}, + // source: quest {}, minlevel: {}", proto->ItemId, cacheInfo.sourceId, cacheInfo.minLevel); // } // } @@ -1163,12 +1186,14 @@ void RandomItemMgr::BuildItemInfoCache() // { // cacheInfo.source = ITEM_SOURCE_DROP; // cacheInfo.sourceId = creatures.front(); - // LOG_DEBUG("playerbots", "Item: {}, source: creature drop, ID: {}", proto->ItemId, creatures.front()); + // LOG_DEBUG("playerbots", "Item: {}, source: creature drop, ID: {}", proto->ItemId, + // creatures.front()); // } // else // { // cacheInfo.source = ITEM_SOURCE_DROP; - // LOG_DEBUG("playerbots", "Item: {}, source: creatures drop, number: {}", proto->ItemId, creatures.size()); + // LOG_DEBUG("playerbots", "Item: {}, source: creatures drop, number: {}", proto->ItemId, + // creatures.size()); // } // } // } @@ -1182,18 +1207,21 @@ void RandomItemMgr::BuildItemInfoCache() // { // cacheInfo.source = ITEM_SOURCE_DROP; // cacheInfo.sourceId = gameobjects.front(); - // LOG_INFO("playerbots", "Item: {}, source: gameobject, ID: {}", proto->ItemId, gameobjects.front()); + // LOG_INFO("playerbots", "Item: {}, source: gameobject, ID: {}", proto->ItemId, + // gameobjects.front()); // } // else // { // cacheInfo.source = ITEM_SOURCE_DROP; - // LOG_INFO("playerbots", "Item: {}, source: gameobjects, number: {}", proto->ItemId, gameobjects.size()); + // LOG_INFO("playerbots", "Item: {}, source: gameobjects, number: {}", proto->ItemId, + // gameobjects.size()); // } // } // } // // check faction - // if (proto->RequiredReputationFaction > 0 && proto->RequiredReputationFaction != 35 && proto->RequiredReputationRank < 15) + // if (proto->RequiredReputationFaction > 0 && proto->RequiredReputationFaction != 35 && + // proto->RequiredReputationRank < 15) // { // cacheInfo.repFaction = proto->RequiredReputationFaction; // cacheInfo.repRank = proto->RequiredReputationRank; @@ -1204,8 +1232,8 @@ void RandomItemMgr::BuildItemInfoCache() // cacheInfo.slot = slot; // // save cache - // PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_DEL_EQUIP_CACHE_NEW); - // stmt->SetData(0, proto->ItemId); + // PlayerbotsDatabasePreparedStatement* stmt = + // PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_DEL_EQUIP_CACHE_NEW); stmt->SetData(0, proto->ItemId); // trans->Append(stmt); // stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_INS_EQUIP_CACHE_NEW); @@ -1240,14 +1268,17 @@ uint32 RandomItemMgr::CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTem uint32 statWeight = 0; bool isCasterItem = false; bool isAttackItem = false; - bool noCaster = (Classes)playerclass == CLASS_WARRIOR || (Classes)playerclass == CLASS_ROGUE || (Classes)playerclass == CLASS_DEATH_KNIGHT || (Classes)playerclass == CLASS_HUNTER; + bool noCaster = (Classes)playerclass == CLASS_WARRIOR || (Classes)playerclass == CLASS_ROGUE || + (Classes)playerclass == CLASS_DEATH_KNIGHT || (Classes)playerclass == CLASS_HUNTER; uint32 spellPower = 0; uint32 spellHeal = 0; uint32 attackPower = 0; bool hasInt = false; - bool hasMana = !((Classes)playerclass == CLASS_WARRIOR || (Classes)playerclass == CLASS_ROGUE || (Classes)playerclass == CLASS_DEATH_KNIGHT); + bool hasMana = !((Classes)playerclass == CLASS_WARRIOR || (Classes)playerclass == CLASS_ROGUE || + (Classes)playerclass == CLASS_DEATH_KNIGHT); - if (proto->SubClass == ITEM_SUBCLASS_ARMOR_LIBRAM || proto->SubClass == ITEM_SUBCLASS_ARMOR_IDOL || proto->SubClass == ITEM_SUBCLASS_ARMOR_TOTEM || proto->SubClass == ITEM_SUBCLASS_ARMOR_SIGIL) + if (proto->SubClass == ITEM_SUBCLASS_ARMOR_LIBRAM || proto->SubClass == ITEM_SUBCLASS_ARMOR_IDOL || + proto->SubClass == ITEM_SUBCLASS_ARMOR_TOTEM || proto->SubClass == ITEM_SUBCLASS_ARMOR_SIGIL) return (uint32)(proto->Quality + proto->ItemLevel); // check basic item stats @@ -1258,8 +1289,8 @@ uint32 RandomItemMgr::CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTem int32 val; std::string weightName; - //if (j >= proto->StatsCount) - // continue; + // if (j >= proto->StatsCount) + // continue; statType = proto->ItemStat[j].ItemStatType; val = proto->ItemStat[j].ItemStatValue; @@ -1267,7 +1298,7 @@ uint32 RandomItemMgr::CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTem if (val == 0) continue; - for (std::map::iterator i = weightStatLink.begin(); i != weightStatLink.end(); ++i) + for (std::map::iterator i = weightStatLink.begin(); i != weightStatLink.end(); ++i) { uint32 modd = i->second; if (modd == statType) @@ -1378,14 +1409,16 @@ uint32 RandomItemMgr::CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTem // SPELL_AURA_MOD_SPELL_HIT_CHANCE if (spellInfo->Effects[j].ApplyAuraName == SPELL_AURA_MOD_SPELL_HIT_CHANCE) { - statWeight += CalculateSingleStatWeight(playerclass, spec, "spellhitrtng", spellInfo->Effects[j].BasePoints + 1); + statWeight += CalculateSingleStatWeight(playerclass, spec, "spellhitrtng", + spellInfo->Effects[j].BasePoints + 1); } // spell crit rating (pre tbc) // SPELL_AURA_MOD_SPELL_CRIT_CHANCE if (spellInfo->Effects[j].ApplyAuraName == SPELL_AURA_MOD_SPELL_CRIT_CHANCE) { - statWeight += CalculateSingleStatWeight(playerclass, spec, "spellcritstrkrtng", spellInfo->Effects[j].BasePoints + 1); + statWeight += CalculateSingleStatWeight(playerclass, spec, "spellcritstrkrtng", + spellInfo->Effects[j].BasePoints + 1); } // spell penetration @@ -1394,14 +1427,16 @@ uint32 RandomItemMgr::CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTem { // check if magic type if (spellInfo->Effects[j].MiscValue == SPELL_SCHOOL_MASK_SPELL) - statWeight += CalculateSingleStatWeight(playerclass, spec, "spellpenrtng", abs(spellInfo->Effects[j].BasePoints + 1)); + statWeight += CalculateSingleStatWeight(playerclass, spec, "spellpenrtng", + abs(spellInfo->Effects[j].BasePoints + 1)); } // check attack power if (spellInfo->Effects[j].ApplyAuraName == SPELL_AURA_MOD_ATTACK_POWER) { isAttackItem = true; - attackPower += CalculateSingleStatWeight(playerclass, spec, "atkpwr", spellInfo->Effects[j].BasePoints + 1); + attackPower += + CalculateSingleStatWeight(playerclass, spec, "atkpwr", spellInfo->Effects[j].BasePoints + 1); } // check ranged ap @@ -1409,20 +1444,23 @@ uint32 RandomItemMgr::CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTem if (spellInfo->Effects[j].ApplyAuraName == SPELL_AURA_MOD_RANGED_ATTACK_POWER) { isAttackItem = true; - attackPower += CalculateSingleStatWeight(playerclass, spec, "atkpwr", spellInfo->Effects[j].BasePoints + 1); + attackPower += + CalculateSingleStatWeight(playerclass, spec, "atkpwr", spellInfo->Effects[j].BasePoints + 1); } // check block if (spellInfo->Effects[j].ApplyAuraName == SPELL_AURA_MOD_SHIELD_BLOCKVALUE) { - statWeight += CalculateSingleStatWeight(playerclass, spec, "block", spellInfo->Effects[j].BasePoints + 1); + statWeight += + CalculateSingleStatWeight(playerclass, spec, "block", spellInfo->Effects[j].BasePoints + 1); } // block chance // SPELL_AURA_MOD_BLOCK_PERCENT if (spellInfo->Effects[j].ApplyAuraName == SPELL_AURA_MOD_BLOCK_PERCENT) { - statWeight += CalculateSingleStatWeight(playerclass, spec, "blockrtng", spellInfo->Effects[j].BasePoints + 1); + statWeight += + CalculateSingleStatWeight(playerclass, spec, "blockrtng", spellInfo->Effects[j].BasePoints + 1); } // armor penetration @@ -1431,31 +1469,34 @@ uint32 RandomItemMgr::CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTem { // check if physical type if (spellInfo->Effects[j].MiscValue == SPELL_SCHOOL_MASK_NORMAL) - statWeight += CalculateSingleStatWeight(playerclass, spec, "armorpenrtng", abs(spellInfo->Effects[j].BasePoints + 1)); + statWeight += CalculateSingleStatWeight(playerclass, spec, "armorpenrtng", + abs(spellInfo->Effects[j].BasePoints + 1)); } // hit rating (pre tbc) // SPELL_AURA_MOD_HIT_CHANCE if (spellInfo->Effects[j].ApplyAuraName == SPELL_AURA_MOD_HIT_CHANCE) { - statWeight += CalculateSingleStatWeight(playerclass, spec, "hitrtng", spellInfo->Effects[j].BasePoints + 1); + statWeight += + CalculateSingleStatWeight(playerclass, spec, "hitrtng", spellInfo->Effects[j].BasePoints + 1); } // crit rating (pre tbc) // SPELL_AURA_MOD_HIT_CHANCE if (spellInfo->Effects[j].ApplyAuraName == SPELL_AURA_MOD_CRIT_PCT) { - statWeight += CalculateSingleStatWeight(playerclass, spec, "critstrkrtng", spellInfo->Effects[j].BasePoints + 1); + statWeight += CalculateSingleStatWeight(playerclass, spec, "critstrkrtng", + spellInfo->Effects[j].BasePoints + 1); } // check defense SPELL_AURA_MOD_SKILL // check block - //if (spellInfo->Effects[j].ApplyAuraName == SPELL_AURA_MOD_SKILL) + // if (spellInfo->Effects[j].ApplyAuraName == SPELL_AURA_MOD_SKILL) //{ - // statWeight += CalculateSingleStatWeight(playerclass, spec, "block", spellInfo->Effects[j].BasePoints + 1); + // statWeight += CalculateSingleStatWeight(playerclass, spec, "block", + // spellInfo->Effects[j].BasePoints + 1); //} - // ratings // enum CombatRating if (spellInfo->Effects[j].ApplyAuraName == SPELL_AURA_MOD_RATING) @@ -1467,7 +1508,8 @@ uint32 RandomItemMgr::CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTem int32 val = spellInfo->Effects[j].BasePoints + 1; std::string weightName; - for (std::map::iterator i = weightRatingLink.begin(); i != weightRatingLink.end(); ++i) + for (std::map::iterator i = weightRatingLink.begin(); + i != weightRatingLink.end(); ++i) { uint32 modd = i->second; if (modd == rating) @@ -1489,7 +1531,8 @@ uint32 RandomItemMgr::CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTem // SPELL_AURA_MOD_POWER_REGEN if (spellInfo->Effects[j].ApplyAuraName == SPELL_AURA_MOD_POWER_REGEN) { - statWeight += CalculateSingleStatWeight(playerclass, spec, "manargn", spellInfo->Effects[j].BasePoints + 1); + statWeight += + CalculateSingleStatWeight(playerclass, spec, "manargn", spellInfo->Effects[j].BasePoints + 1); } } } @@ -1508,7 +1551,8 @@ uint32 RandomItemMgr::CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTem return 0; bool playerCaster = false; - for (std::vector::iterator i = m_weightScales[playerclass][spec].stats.begin(); i != m_weightScales[playerclass][spec].stats.end(); ++i) + for (std::vector::iterator i = m_weightScales[playerclass][spec].stats.begin(); + i != m_weightScales[playerclass][spec].stats.end(); ++i) { if (i->stat == "splpwr" || i->stat == "int" || i->stat == "manargn") { @@ -1525,13 +1569,15 @@ uint32 RandomItemMgr::CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTem { if (hasMana && !noCaster && !(hasInt || spellPower)) return 0; - //if (!noCaster && attackPower) - // return 0; + // if (!noCaster && attackPower) + // return 0; bool playerAttacker = false; - for (std::vector::iterator i = m_weightScales[playerclass][spec].stats.begin(); i != m_weightScales[playerclass][spec].stats.end(); ++i) + for (std::vector::iterator i = m_weightScales[playerclass][spec].stats.begin(); + i != m_weightScales[playerclass][spec].stats.end(); ++i) { - if (i->stat == "str" || i->stat == "agi" || i->stat == "atkpwr" || i->stat == "mledps" || i->stat == "rgddps") + if (i->stat == "str" || i->stat == "agi" || i->stat == "atkpwr" || i->stat == "mledps" || + i->stat == "rgddps") { playerAttacker = true; } @@ -1557,7 +1603,8 @@ uint32 RandomItemMgr::CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTem uint32 RandomItemMgr::CalculateSingleStatWeight(uint8 playerclass, uint8 spec, std::string stat, uint32 value) { uint32 statWeight = 0; - for (std::vector::iterator i = m_weightScales[playerclass][spec].stats.begin(); i != m_weightScales[playerclass][spec].stats.end(); ++i) + for (std::vector::iterator i = m_weightScales[playerclass][spec].stats.begin(); + i != m_weightScales[playerclass][spec].stats.end(); ++i) { if (stat == i->stat) { @@ -1731,11 +1778,8 @@ uint32 RandomItemMgr::GetUpgrade(Player* player, std::string spec, uint8 slot, u } // skip no stats trinkets - if (info.weights[specId] == 1 && - info.slot == EQUIPMENT_SLOT_NECK || - info.slot == EQUIPMENT_SLOT_TRINKET1 || - info.slot == EQUIPMENT_SLOT_TRINKET2 || - info.slot == EQUIPMENT_SLOT_FINGER1 || + if (info.weights[specId] == 1 && info.slot == EQUIPMENT_SLOT_NECK || info.slot == EQUIPMENT_SLOT_TRINKET1 || + info.slot == EQUIPMENT_SLOT_TRINKET2 || info.slot == EQUIPMENT_SLOT_FINGER1 || info.slot == EQUIPMENT_SLOT_FINGER2) continue; @@ -1774,7 +1818,8 @@ uint32 RandomItemMgr::GetUpgrade(Player* player, std::string spec, uint8 slot, u return closestUpgrade; } -std::vector RandomItemMgr::GetUpgradeList(Player* player, std::string spec, uint8 slot, uint32 quality, uint32 itemId, uint32 amount) +std::vector RandomItemMgr::GetUpgradeList(Player* player, std::string spec, uint8 slot, uint32 quality, + uint32 itemId, uint32 amount) { std::vector listItems; if (!player) @@ -1855,34 +1900,31 @@ std::vector RandomItemMgr::GetUpgradeList(Player* player, std::string sp } // skip no stats trinkets - if (info.weights[specId] < 2 && ( - info.slot == EQUIPMENT_SLOT_NECK || - info.slot == EQUIPMENT_SLOT_TRINKET1 || - info.slot == EQUIPMENT_SLOT_TRINKET2 || - info.slot == EQUIPMENT_SLOT_FINGER1 || - info.slot == EQUIPMENT_SLOT_FINGER2)) + if (info.weights[specId] < 2 && (info.slot == EQUIPMENT_SLOT_NECK || info.slot == EQUIPMENT_SLOT_TRINKET1 || + info.slot == EQUIPMENT_SLOT_TRINKET2 || info.slot == EQUIPMENT_SLOT_FINGER1 || + info.slot == EQUIPMENT_SLOT_FINGER2)) continue; - //if (player->GetLevel() >= 40) + // if (player->GetLevel() >= 40) //{ - // // check if item stat score is the best among class specs - // uint32 bestSpecId = 0; - // uint32 bestSpecScore = 0; - // for (vector::iterator i = classspecs.begin(); i != classspecs.end(); ++i) - // { - // if (info->weights[*i] > bestSpecScore) - // { - // bestSpecId = *i; - // bestSpecScore = info->weights[specId]; - // } - // } + // // check if item stat score is the best among class specs + // uint32 bestSpecId = 0; + // uint32 bestSpecScore = 0; + // for (vector::iterator i = classspecs.begin(); i != classspecs.end(); ++i) + // { + // if (info->weights[*i] > bestSpecScore) + // { + // bestSpecId = *i; + // bestSpecScore = info->weights[specId]; + // } + // } // if (bestSpecId && bestSpecId != specId) // continue; //} listItems.push_back(info.itemId); - //continue; + // continue; // pick closest upgrade if (info.weights[specId] > closestUpgradeWeight) @@ -1893,7 +1935,8 @@ std::vector RandomItemMgr::GetUpgradeList(Player* player, std::string sp } if (listItems.size()) - LOG_INFO("playerbots", "New Items: {}, Old item:%d, New items max: {}", listItems.size(), oldStatWeight, closestUpgradeWeight); + LOG_INFO("playerbots", "New Items: {}, Old item:%d, New items max: {}", listItems.size(), oldStatWeight, + closestUpgradeWeight); return std::move(listItems); } @@ -1940,7 +1983,6 @@ uint32 RandomItemMgr::GetStatWeight(Player* player, uint32 itemId) if (m_weightScales[player->getClass()][specNum].info.name == specName) specId = m_weightScales[player->getClass()][specNum].info.id; - if (m_weightScales[player->getClass()][specNum].info.name == specName) { specId = specNum; @@ -1994,7 +2036,7 @@ uint32 RandomItemMgr::GetLiveStatWeight(Player* player, uint32 itemId) return 0; // skip too low level - //if ((int32)info->minLevel < (int32)(player->GetLevel() - 20)) + // if ((int32)info->minLevel < (int32)(player->GetLevel() - 20)) // return 0; // skip wrong team @@ -2016,12 +2058,10 @@ uint32 RandomItemMgr::GetLiveStatWeight(Player* player, uint32 itemId) } // skip no stats trinkets - if (itr->second.weights[specId] == 1 && ( - itr->second.slot == EQUIPMENT_SLOT_NECK || - itr->second.slot == EQUIPMENT_SLOT_TRINKET1 || - itr->second.slot == EQUIPMENT_SLOT_TRINKET2 || - itr->second.slot == EQUIPMENT_SLOT_FINGER1 || - itr->second.slot == EQUIPMENT_SLOT_FINGER2)) + if (itr->second.weights[specId] == 1 && + (itr->second.slot == EQUIPMENT_SLOT_NECK || itr->second.slot == EQUIPMENT_SLOT_TRINKET1 || + itr->second.slot == EQUIPMENT_SLOT_TRINKET2 || itr->second.slot == EQUIPMENT_SLOT_FINGER1 || + itr->second.slot == EQUIPMENT_SLOT_FINGER2)) return 0; // skip items that only fit in slot, but not stats @@ -2057,8 +2097,9 @@ void RandomItemMgr::BuildEquipCache() PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_EQUIP_CACHE); if (PreparedQueryResult result = PlayerbotsDatabase.Query(stmt)) { - LOG_INFO("server.loading", "Loading equipment cache for {} classes, {} levels, {} slots, {} quality from {} items", - MAX_CLASSES, maxLevel, EQUIPMENT_SLOT_END, ITEM_QUALITY_ARTIFACT, itemTemplates->size()); + LOG_INFO("server.loading", + "Loading equipment cache for {} classes, {} levels, {} slots, {} quality from {} items", MAX_CLASSES, + maxLevel, EQUIPMENT_SLOT_END, ITEM_QUALITY_ARTIFACT, itemTemplates->size()); uint32 count = 0; do @@ -2073,16 +2114,16 @@ void RandomItemMgr::BuildEquipCache() BotEquipKey key(level, clazz, slot, quality); equipCache[key].push_back(itemId); ++count; - } - while (result->NextRow()); + } while (result->NextRow()); LOG_INFO("playerbots", "Equipment cache loaded from {} records", count); } else { uint64 total = MAX_CLASSES * maxLevel * EQUIPMENT_SLOT_END * ITEM_QUALITY_ARTIFACT; - LOG_INFO("server.loading", "Building equipment cache for {} classes, {} levels, {} slots, {} quality from {} items ({} total)", - MAX_CLASSES, maxLevel, EQUIPMENT_SLOT_END, ITEM_QUALITY_ARTIFACT, itemTemplates->size(), total); + LOG_INFO("server.loading", + "Building equipment cache for {} classes, {} levels, {} slots, {} quality from {} items ({} total)", + MAX_CLASSES, maxLevel, EQUIPMENT_SLOT_END, ITEM_QUALITY_ARTIFACT, itemTemplates->size(), total); for (uint8 class_ = CLASS_WARRIOR; class_ < MAX_CLASSES; ++class_) { @@ -2105,26 +2146,32 @@ void RandomItemMgr::BuildEquipCache() if (!proto) continue; - if (proto->Class != ITEM_CLASS_WEAPON && proto->Class != ITEM_CLASS_ARMOR && proto->Class != ITEM_CLASS_CONTAINER && proto->Class != ITEM_CLASS_PROJECTILE) + if (proto->Class != ITEM_CLASS_WEAPON && proto->Class != ITEM_CLASS_ARMOR && + proto->Class != ITEM_CLASS_CONTAINER && proto->Class != ITEM_CLASS_PROJECTILE) continue; if (!CanEquipItem(key, proto)) continue; - if (proto->Class == ITEM_CLASS_ARMOR && (slot == EQUIPMENT_SLOT_HEAD || slot == EQUIPMENT_SLOT_SHOULDERS || slot == EQUIPMENT_SLOT_CHEST || - slot == EQUIPMENT_SLOT_WAIST || slot == EQUIPMENT_SLOT_LEGS || slot == EQUIPMENT_SLOT_FEET || slot == EQUIPMENT_SLOT_WRISTS || - slot == EQUIPMENT_SLOT_HANDS) && !CanEquipArmor(key.clazz, key.level, proto)) + if (proto->Class == ITEM_CLASS_ARMOR && + (slot == EQUIPMENT_SLOT_HEAD || slot == EQUIPMENT_SLOT_SHOULDERS || + slot == EQUIPMENT_SLOT_CHEST || slot == EQUIPMENT_SLOT_WAIST || + slot == EQUIPMENT_SLOT_LEGS || slot == EQUIPMENT_SLOT_FEET || + slot == EQUIPMENT_SLOT_WRISTS || slot == EQUIPMENT_SLOT_HANDS) && + !CanEquipArmor(key.clazz, key.level, proto)) continue; if (proto->Class == ITEM_CLASS_WEAPON && !CanEquipWeapon(key.clazz, proto)) continue; - if (slot == EQUIPMENT_SLOT_OFFHAND && key.clazz == CLASS_ROGUE && proto->Class != ITEM_CLASS_WEAPON) + if (slot == EQUIPMENT_SLOT_OFFHAND && key.clazz == CLASS_ROGUE && + proto->Class != ITEM_CLASS_WEAPON) continue; items.push_back(itr.first); - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_INS_EQUIP_CACHE); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_INS_EQUIP_CACHE); stmt->SetData(0, class_); stmt->SetData(1, level); stmt->SetData(2, slot); @@ -2135,8 +2182,9 @@ void RandomItemMgr::BuildEquipCache() equipCache[key] = items; - LOG_DEBUG("playerbots", "Equipment cache for class: {}, level {}, slot {}, quality {}: {} items", - class_, level, slot, quality, items.size()); + LOG_DEBUG("playerbots", + "Equipment cache for class: {}, level {}, slot {}, quality {}: {} items", class_, + level, slot, quality, items.size()); } } } @@ -2156,10 +2204,12 @@ void RandomItemMgr::BuildEquipCacheNew() if (!proto) continue; uint32 itemId = proto->ItemId; - if (IsTestItem(itemId)) { + if (IsTestItem(itemId)) + { continue; } - if (itemId == 22784) { // Sunwell Orb + if (itemId == 22784) + { // Sunwell Orb continue; } equipCacheNew[proto->RequiredLevel][proto->InventoryType].push_back(itemId); @@ -2178,15 +2228,18 @@ RandomItemList RandomItemMgr::Query(uint32 level, uint8 clazz, uint8 slot, uint3 if (!proto) continue; - if (proto->Class != ITEM_CLASS_WEAPON && proto->Class != ITEM_CLASS_ARMOR && proto->Class != ITEM_CLASS_CONTAINER && proto->Class != ITEM_CLASS_PROJECTILE) + if (proto->Class != ITEM_CLASS_WEAPON && proto->Class != ITEM_CLASS_ARMOR && + proto->Class != ITEM_CLASS_CONTAINER && proto->Class != ITEM_CLASS_PROJECTILE) continue; if (!CanEquipItem(key, proto)) continue; - if (proto->Class == ITEM_CLASS_ARMOR && (slot == EQUIPMENT_SLOT_HEAD || slot == EQUIPMENT_SLOT_SHOULDERS || slot == EQUIPMENT_SLOT_CHEST || - slot == EQUIPMENT_SLOT_WAIST || slot == EQUIPMENT_SLOT_LEGS || slot == EQUIPMENT_SLOT_FEET || slot == EQUIPMENT_SLOT_WRISTS || - slot == EQUIPMENT_SLOT_HANDS) && !CanEquipArmor(key.clazz, key.level, proto)) + if (proto->Class == ITEM_CLASS_ARMOR && + (slot == EQUIPMENT_SLOT_HEAD || slot == EQUIPMENT_SLOT_SHOULDERS || slot == EQUIPMENT_SLOT_CHEST || + slot == EQUIPMENT_SLOT_WAIST || slot == EQUIPMENT_SLOT_LEGS || slot == EQUIPMENT_SLOT_FEET || + slot == EQUIPMENT_SLOT_WRISTS || slot == EQUIPMENT_SLOT_HANDS) && + !CanEquipArmor(key.clazz, key.level, proto)) continue; if (proto->Class == ITEM_CLASS_WEAPON && !CanEquipWeapon(key.clazz, proto)) @@ -2211,15 +2264,19 @@ void RandomItemMgr::BuildAmmoCache() { for (uint32 subClass = ITEM_SUBCLASS_ARROW; subClass <= ITEM_SUBCLASS_BULLET; subClass++) { - QueryResult results = WorldDatabase.Query("SELECT entry, Flags FROM item_template WHERE class = {} AND subclass = {} AND RequiredLevel <= {} " - "ORDER BY stackable DESC, RequiredLevel DESC", ITEM_CLASS_PROJECTILE, subClass, level); + QueryResult results = WorldDatabase.Query( + "SELECT entry, Flags FROM item_template WHERE class = {} AND subclass = {} AND RequiredLevel <= {} " + "ORDER BY stackable DESC, RequiredLevel DESC", + ITEM_CLASS_PROJECTILE, subClass, level); if (!results) continue; - do { + do + { Field* fields = results->Fetch(); uint32 entry = fields[0].Get(); uint32 flags = fields[1].Get(); - if (flags & ITEM_FLAG_DEPRECATED) { + if (flags & ITEM_FLAG_DEPRECATED) + { continue; } ammoCache[level][subClass] = entry; @@ -2229,13 +2286,10 @@ void RandomItemMgr::BuildAmmoCache() } } - LOG_INFO("server.loading", "Cached {} types of ammo", counter); // TEST + LOG_INFO("server.loading", "Cached {} types of ammo", counter); // TEST } -uint32 RandomItemMgr::GetAmmo(uint32 level, uint32 subClass) -{ - return ammoCache[level][subClass]; -} +uint32 RandomItemMgr::GetAmmo(uint32 level, uint32 subClass) { return ammoCache[level][subClass]; } void RandomItemMgr::BuildPotionCache() { @@ -2250,7 +2304,7 @@ void RandomItemMgr::BuildPotionCache() uint32 counter = 0; for (uint32 level = 1; level <= maxLevel + 1; level += 10) { - uint32 effects[] = { SPELL_EFFECT_HEAL, SPELL_EFFECT_ENERGIZE }; + uint32 effects[] = {SPELL_EFFECT_HEAL, SPELL_EFFECT_ENERGIZE}; for (uint8 i = 0; i < 2; ++i) { uint32 effect = effects[i]; @@ -2261,7 +2315,9 @@ void RandomItemMgr::BuildPotionCache() if (!proto) continue; - if (proto->Class != ITEM_CLASS_CONSUMABLE || (proto->SubClass != ITEM_SUBCLASS_POTION && proto->SubClass != ITEM_SUBCLASS_FLASK) || proto->Bonding != NO_BIND) + if (proto->Class != ITEM_CLASS_CONSUMABLE || + (proto->SubClass != ITEM_SUBCLASS_POTION && proto->SubClass != ITEM_SUBCLASS_FLASK) || + proto->Bonding != NO_BIND) continue; if (proto->RequiredLevel && (proto->RequiredLevel > level || proto->RequiredLevel < level - 10)) @@ -2282,7 +2338,7 @@ void RandomItemMgr::BuildPotionCache() if (!spellInfo) continue; - for (uint8 i = 0 ; i < 3; i++) + for (uint8 i = 0; i < 3; i++) { if (spellInfo->Effects[i].Effect == effect) { @@ -2297,7 +2353,7 @@ void RandomItemMgr::BuildPotionCache() for (uint32 level = 1; level <= maxLevel + 1; level += 10) { - uint32 effects[] = { SPELL_EFFECT_HEAL, SPELL_EFFECT_ENERGIZE }; + uint32 effects[] = {SPELL_EFFECT_HEAL, SPELL_EFFECT_ENERGIZE}; for (uint8 i = 0; i < 2; ++i) { uint32 effect = effects[i]; @@ -2308,7 +2364,7 @@ void RandomItemMgr::BuildPotionCache() } } - LOG_INFO("server.loading", "Cached {} types of potions", counter); // TEST + LOG_INFO("server.loading", "Cached {} types of potions", counter); // TEST } void RandomItemMgr::BuildFoodCache() @@ -2324,7 +2380,7 @@ void RandomItemMgr::BuildFoodCache() uint32 counter = 0; for (uint32 level = 1; level <= maxLevel + 1; level += 10) { - uint32 categories[] = { 11, 59 }; + uint32 categories[] = {11, 59}; for (int i = 0; i < 2; ++i) { uint32 category = categories[i]; @@ -2335,7 +2391,8 @@ void RandomItemMgr::BuildFoodCache() if (!proto) continue; - if (proto->Class != ITEM_CLASS_CONSUMABLE || (proto->SubClass != ITEM_SUBCLASS_FOOD && proto->SubClass != ITEM_SUBCLASS_CONSUMABLE) || + if (proto->Class != ITEM_CLASS_CONSUMABLE || + (proto->SubClass != ITEM_SUBCLASS_FOOD && proto->SubClass != ITEM_SUBCLASS_CONSUMABLE) || (proto->Spells[0].SpellCategory != category) || proto->Bonding != NO_BIND) continue; @@ -2358,7 +2415,7 @@ void RandomItemMgr::BuildFoodCache() for (uint32 level = 1; level <= maxLevel + 1; level += 10) { - uint32 categories[] = { 11, 59 }; + uint32 categories[] = {11, 59}; for (uint8 i = 0; i < 2; ++i) { uint32 category = categories[i]; @@ -2387,49 +2444,50 @@ uint32 RandomItemMgr::GetFood(uint32 level, uint32 category) if (category == 11) { if (level < 5) - items = { 787, 117, 4540, 2680 }; + items = {787, 117, 4540, 2680}; else if (level < 15) - items = { 2287, 4592, 4541, 21072 }; + items = {2287, 4592, 4541, 21072}; else if (level < 25) - items = { 3770, 16170, 4542, 20074 }; + items = {3770, 16170, 4542, 20074}; else if (level < 35) - items = { 4594, 3771, 1707, 4457 }; + items = {4594, 3771, 1707, 4457}; else if (level < 45) - items = { 4599, 4601, 21552, 17222 /*21030, 16168 */ }; + items = {4599, 4601, 21552, 17222 /*21030, 16168 */}; else if (level < 55) - items = { 8950, 8952, 8957, 21023 /*21033, 21031 */ }; + items = {8950, 8952, 8957, 21023 /*21033, 21031 */}; else if (level < 65) - items = { 29292, 27859, 30458, 27662 }; + items = {29292, 27859, 30458, 27662}; else if (level < 75) - items = { 29450, 29451, 29452 }; + items = {29450, 29451, 29452}; else - items = { 35947 }; + items = {35947}; } if (category == 59) { if (level < 5) - items = { 159, 117 }; + items = {159, 117}; else if (level < 15) - items = { 1179, 21072 }; + items = {1179, 21072}; else if (level < 25) - items = { 1205 }; + items = {1205}; else if (level < 35) - items = { 1708 }; + items = {1708}; else if (level < 45) - items = { 1645 }; + items = {1645}; else if (level < 55) - items = { 8766 }; - else if (level < 65) - items = { 28399 }; + items = {8766}; + else if (level < 65) + items = {28399}; else if (level < 75) - items = { 27860 }; + items = {27860}; else - items = { 33445 }; + items = {33445}; } food.insert(food.end(), items); - if (food.empty()) return 0; + if (food.empty()) + return 0; return food[urand(0, food.size() - 1)]; } @@ -2484,7 +2542,7 @@ void RandomItemMgr::BuildTradeCache() ++counter; } - LOG_INFO("server.loading", "Cached {} trade items", counter); // TEST + LOG_INFO("server.loading", "Cached {} trade items", counter); // TEST } uint32 RandomItemMgr::GetRandomTrade(uint32 level) @@ -2498,7 +2556,8 @@ uint32 RandomItemMgr::GetRandomTrade(uint32 level) void RandomItemMgr::BuildRarityCache() { - if (PreparedQueryResult result = PlayerbotsDatabase.Query(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_RARITY_CACHE))) + if (PreparedQueryResult result = + PlayerbotsDatabase.Query(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_RARITY_CACHE))) { LOG_INFO("playerbots", "Loading item rarity cache"); @@ -2512,8 +2571,7 @@ void RandomItemMgr::BuildRarityCache() rarityCache[itemId] = rarity; ++count; - } - while (result->NextRow()); + } while (result->NextRow()); LOG_INFO("playerbots", "Item rarity cache loaded from {} records", count); } @@ -2534,90 +2592,102 @@ void RandomItemMgr::BuildRarityCache() if (proto->Quality == ITEM_QUALITY_POOR) continue; - if (strstri(proto->Name1.c_str(), "qa") || strstri(proto->Name1.c_str(), "test") || strstri(proto->Name1.c_str(), "deprecated")) + if (strstri(proto->Name1.c_str(), "qa") || strstri(proto->Name1.c_str(), "test") || + strstri(proto->Name1.c_str(), "deprecated")) continue; if (!proto->ItemLevel) continue; QueryResult results = WorldDatabase.Query( - "SELECT MAX(q.chance) FROM ( " - // "-- Creature " - "SELECT " - "AVG ( " - " CASE " - " WHEN lt.groupid = 0 THEN lt.ChanceOrQuestChance " - " WHEN lt.ChanceOrQuestChance > 0 THEN lt.ChanceOrQuestChance " - " ELSE " - " IFNULL(100 - (SELECT SUM(ChanceOrQuestChance) FROM creature_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance > 0), 100) " - " / (SELECT COUNT(*) FROM creature_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance = 0) " - " END " - ") chance, 'creature' type " - "FROM creature_loot_template lt " - "JOIN creature_template ct ON ct.LootId = lt.entry " - "JOIN creature c ON c.id1 = ct.entry " - "WHERE lt.item = {} " - "union all " - // "-- Gameobject " - "SELECT " - "AVG ( " - " CASE " - " WHEN lt.groupid = 0 THEN lt.ChanceOrQuestChance " - " WHEN lt.ChanceOrQuestChance > 0 THEN lt.ChanceOrQuestChance " - " ELSE " - " IFNULL(100 - (SELECT SUM(ChanceOrQuestChance) FROM gameobject_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance > 0), 100) " - " / (SELECT COUNT(*) FROM gameobject_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance = 0) " - " END " - ") chance, 'gameobject' type " - "FROM gameobject_loot_template lt " - "JOIN gameobject_template ct ON ct.data1 = lt.entry " - "JOIN gameobject c ON c.id1 = ct.entry " - "WHERE lt.item = {} " - "union all " - // "-- Disenchant " - "SELECT " - "AVG ( " - " CASE " - " WHEN lt.groupid = 0 THEN lt.ChanceOrQuestChance " - " WHEN lt.ChanceOrQuestChance > 0 THEN lt.ChanceOrQuestChance " - " ELSE " - " IFNULL(100 - (SELECT SUM(ChanceOrQuestChance) FROM disenchant_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance > 0), 100) " - " / (SELECT COUNT(*) FROM disenchant_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance = 0) " - " END " - ") chance, 'disenchant' type " - "FROM disenchant_loot_template lt " - "JOIN item_template ct ON ct.DisenchantID = lt.entry " - "WHERE lt.item = {} " - "union all " - // "-- Fishing " - "SELECT " - "AVG ( " - " CASE " - " WHEN lt.groupid = 0 THEN lt.ChanceOrQuestChance " - " WHEN lt.ChanceOrQuestChance > 0 THEN lt.ChanceOrQuestChance " - " ELSE " - " IFNULL(100 - (SELECT SUM(ChanceOrQuestChance) FROM fishing_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance > 0), 100) " - " / (SELECT COUNT(*) FROM fishing_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance = 0) " - " END " - ") chance, 'fishing' type " - "FROM fishing_loot_template lt " - "WHERE lt.item = {} " - "union all " - // "-- Skinning " - "SELECT " - "AVG ( " - " CASE " - " WHEN lt.groupid = 0 THEN lt.ChanceOrQuestChance " - " WHEN lt.ChanceOrQuestChance > 0 THEN lt.ChanceOrQuestChance " - " ELSE " - " IFNULL(100 - (SELECT SUM(ChanceOrQuestChance) FROM skinning_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance > 0), 100) " - " * IFNULL((SELECT 1/COUNT(*) FROM skinning_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance = 0), 1) " - " END " - ") chance, 'skinning' type " - "FROM skinning_loot_template lt " - "JOIN creature_template ct ON ct.SkinningLootId = lt.entry " - "JOIN creature c ON c.id1 = ct.entry " - "WHERE lt.item = {}) q; ", itr.first, itr.first, itr.first, itr.first, itr.first); + "SELECT MAX(q.chance) FROM ( " + // "-- Creature " + "SELECT " + "AVG ( " + " CASE " + " WHEN lt.groupid = 0 THEN lt.ChanceOrQuestChance " + " WHEN lt.ChanceOrQuestChance > 0 THEN lt.ChanceOrQuestChance " + " ELSE " + " IFNULL(100 - (SELECT SUM(ChanceOrQuestChance) FROM creature_loot_template lt1 WHERE lt1.groupid = " + "lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance > 0), 100) " + " / (SELECT COUNT(*) FROM creature_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry = " + "lt.entry AND lt1.ChanceOrQuestChance = 0) " + " END " + ") chance, 'creature' type " + "FROM creature_loot_template lt " + "JOIN creature_template ct ON ct.LootId = lt.entry " + "JOIN creature c ON c.id1 = ct.entry " + "WHERE lt.item = {} " + "union all " + // "-- Gameobject " + "SELECT " + "AVG ( " + " CASE " + " WHEN lt.groupid = 0 THEN lt.ChanceOrQuestChance " + " WHEN lt.ChanceOrQuestChance > 0 THEN lt.ChanceOrQuestChance " + " ELSE " + " IFNULL(100 - (SELECT SUM(ChanceOrQuestChance) FROM gameobject_loot_template lt1 WHERE lt1.groupid " + "= lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance > 0), 100) " + " / (SELECT COUNT(*) FROM gameobject_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry " + "= lt.entry AND lt1.ChanceOrQuestChance = 0) " + " END " + ") chance, 'gameobject' type " + "FROM gameobject_loot_template lt " + "JOIN gameobject_template ct ON ct.data1 = lt.entry " + "JOIN gameobject c ON c.id1 = ct.entry " + "WHERE lt.item = {} " + "union all " + // "-- Disenchant " + "SELECT " + "AVG ( " + " CASE " + " WHEN lt.groupid = 0 THEN lt.ChanceOrQuestChance " + " WHEN lt.ChanceOrQuestChance > 0 THEN lt.ChanceOrQuestChance " + " ELSE " + " IFNULL(100 - (SELECT SUM(ChanceOrQuestChance) FROM disenchant_loot_template lt1 WHERE lt1.groupid " + "= lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance > 0), 100) " + " / (SELECT COUNT(*) FROM disenchant_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry " + "= lt.entry AND lt1.ChanceOrQuestChance = 0) " + " END " + ") chance, 'disenchant' type " + "FROM disenchant_loot_template lt " + "JOIN item_template ct ON ct.DisenchantID = lt.entry " + "WHERE lt.item = {} " + "union all " + // "-- Fishing " + "SELECT " + "AVG ( " + " CASE " + " WHEN lt.groupid = 0 THEN lt.ChanceOrQuestChance " + " WHEN lt.ChanceOrQuestChance > 0 THEN lt.ChanceOrQuestChance " + " ELSE " + " IFNULL(100 - (SELECT SUM(ChanceOrQuestChance) FROM fishing_loot_template lt1 WHERE lt1.groupid = " + "lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance > 0), 100) " + " / (SELECT COUNT(*) FROM fishing_loot_template lt1 WHERE lt1.groupid = lt.groupid AND lt1.entry = " + "lt.entry AND lt1.ChanceOrQuestChance = 0) " + " END " + ") chance, 'fishing' type " + "FROM fishing_loot_template lt " + "WHERE lt.item = {} " + "union all " + // "-- Skinning " + "SELECT " + "AVG ( " + " CASE " + " WHEN lt.groupid = 0 THEN lt.ChanceOrQuestChance " + " WHEN lt.ChanceOrQuestChance > 0 THEN lt.ChanceOrQuestChance " + " ELSE " + " IFNULL(100 - (SELECT SUM(ChanceOrQuestChance) FROM skinning_loot_template lt1 WHERE lt1.groupid = " + "lt.groupid AND lt1.entry = lt.entry AND lt1.ChanceOrQuestChance > 0), 100) " + " * IFNULL((SELECT 1/COUNT(*) FROM skinning_loot_template lt1 WHERE lt1.groupid = lt.groupid AND " + "lt1.entry = lt.entry AND lt1.ChanceOrQuestChance = 0), 1) " + " END " + ") chance, 'skinning' type " + "FROM skinning_loot_template lt " + "JOIN creature_template ct ON ct.SkinningLootId = lt.entry " + "JOIN creature c ON c.id1 = ct.entry " + "WHERE lt.item = {}) q; ", + itr.first, itr.first, itr.first, itr.first, itr.first); if (results) { @@ -2627,7 +2697,8 @@ void RandomItemMgr::BuildRarityCache() { rarityCache[itr.first] = rarity; - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_INS_RARITY_CACHE); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_INS_RARITY_CACHE); stmt->SetData(0, itr.first); stmt->SetData(1, rarity); PlayerbotsDatabase.Execute(stmt); @@ -2639,10 +2710,7 @@ void RandomItemMgr::BuildRarityCache() } } -float RandomItemMgr::GetItemRarity(uint32 itemId) -{ - return rarityCache[itemId]; -} +float RandomItemMgr::GetItemRarity(uint32 itemId) { return rarityCache[itemId]; } inline bool IsCraftedBySpellInfo(ItemTemplate const* proto, SpellInfo const* spellInfo) { @@ -2728,7 +2796,8 @@ inline bool ContainsInternal(ItemTemplate const* proto, uint32 skillId) if (!trainer_spells) continue; - for (TrainerSpellMap::const_iterator iter = trainer_spells->spellList.begin(); iter != trainer_spells->spellList.end(); ++iter) + for (TrainerSpellMap::const_iterator iter = trainer_spells->spellList.begin(); + iter != trainer_spells->spellList.end(); ++iter) { TrainerSpell const* tSpell = &iter->second; if (!tSpell || tSpell->reqSkill != skillId) @@ -2745,18 +2814,17 @@ inline bool ContainsInternal(ItemTemplate const* proto, uint32 skillId) if (!recipe) continue; - if (recipe->Class == ITEM_CLASS_RECIPE && ( - (recipe->SubClass == ITEM_SUBCLASS_LEATHERWORKING_PATTERN && skillId == SKILL_LEATHERWORKING) || - (recipe->SubClass == ITEM_SUBCLASS_TAILORING_PATTERN && skillId == SKILL_TAILORING) || - (recipe->SubClass == ITEM_SUBCLASS_ENGINEERING_SCHEMATIC && skillId == SKILL_ENGINEERING) || - (recipe->SubClass == ITEM_SUBCLASS_BLACKSMITHING && skillId == SKILL_BLACKSMITHING) || - (recipe->SubClass == ITEM_SUBCLASS_COOKING_RECIPE && skillId == SKILL_COOKING) || - (recipe->SubClass == ITEM_SUBCLASS_ALCHEMY_RECIPE && skillId == SKILL_ALCHEMY) || - (recipe->SubClass == ITEM_SUBCLASS_FIRST_AID_MANUAL && skillId == SKILL_FIRST_AID) || - (recipe->SubClass == ITEM_SUBCLASS_ENCHANTING_FORMULA && skillId == SKILL_ENCHANTING) || - (recipe->SubClass == ITEM_SUBCLASS_JEWELCRAFTING_RECIPE && skillId == SKILL_JEWELCRAFTING) || - (recipe->SubClass == ITEM_SUBCLASS_FISHING_MANUAL && skillId == SKILL_FISHING) - )) + if (recipe->Class == ITEM_CLASS_RECIPE && + ((recipe->SubClass == ITEM_SUBCLASS_LEATHERWORKING_PATTERN && skillId == SKILL_LEATHERWORKING) || + (recipe->SubClass == ITEM_SUBCLASS_TAILORING_PATTERN && skillId == SKILL_TAILORING) || + (recipe->SubClass == ITEM_SUBCLASS_ENGINEERING_SCHEMATIC && skillId == SKILL_ENGINEERING) || + (recipe->SubClass == ITEM_SUBCLASS_BLACKSMITHING && skillId == SKILL_BLACKSMITHING) || + (recipe->SubClass == ITEM_SUBCLASS_COOKING_RECIPE && skillId == SKILL_COOKING) || + (recipe->SubClass == ITEM_SUBCLASS_ALCHEMY_RECIPE && skillId == SKILL_ALCHEMY) || + (recipe->SubClass == ITEM_SUBCLASS_FIRST_AID_MANUAL && skillId == SKILL_FIRST_AID) || + (recipe->SubClass == ITEM_SUBCLASS_ENCHANTING_FORMULA && skillId == SKILL_ENCHANTING) || + (recipe->SubClass == ITEM_SUBCLASS_JEWELCRAFTING_RECIPE && skillId == SKILL_JEWELCRAFTING) || + (recipe->SubClass == ITEM_SUBCLASS_FISHING_MANUAL && skillId == SKILL_FISHING))) { for (uint32 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { diff --git a/src/RandomItemMgr.h b/src/RandomItemMgr.h index 4fedb4ac..8ce7dc88 100644 --- a/src/RandomItemMgr.h +++ b/src/RandomItemMgr.h @@ -1,18 +1,19 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RANDOMITEMMGR_H #define _PLAYERBOT_RANDOMITEMMGR_H -#include "AiFactory.h" -#include "Common.h" -#include "ItemTemplate.h" - #include #include #include +#include "AiFactory.h" +#include "Common.h" +#include "ItemTemplate.h" + class ChatHandler; struct ItemTemplate; @@ -60,7 +61,8 @@ struct StatWeight struct ItemInfoEntry { - ItemInfoEntry() : minLevel(0), source(0), sourceId(0), team(0), repRank(0), repFaction(0), quality(0), slot(0), itemId(0) + ItemInfoEntry() + : minLevel(0), source(0), sourceId(0), team(0), repRank(0), repFaction(0), quality(0), slot(0), itemId(0) { for (uint8 i = 1; i <= MAX_STAT_SCALES; ++i) { @@ -81,7 +83,7 @@ struct ItemInfoEntry }; typedef std::vector WeightScaleStats; -//typedef std::map WeightScaleList; +// typedef std::map WeightScaleList; struct WeightScale { @@ -89,14 +91,14 @@ struct WeightScale WeightScaleStats stats; }; -//typedef map WeightScales; +// typedef map WeightScales; class RandomItemPredicate { - public: - virtual ~RandomItemPredicate() { }; +public: + virtual ~RandomItemPredicate(){}; - virtual bool Apply(ItemTemplate const* proto) = 0; + virtual bool Apply(ItemTemplate const* proto) = 0; }; typedef std::vector RandomItemList; @@ -104,102 +106,107 @@ typedef std::map RandomItemCache; class BotEquipKey { - public: - BotEquipKey() : level(0), clazz(0), slot(0), quality(0), key(GetKey()) { } - BotEquipKey(uint32 level, uint8 clazz, uint8 slot, uint32 quality) : level(level), clazz(clazz), slot(slot), quality(quality), key(GetKey()) { } - BotEquipKey(BotEquipKey const& other) : level(other.level), clazz(other.clazz), slot(other.slot), quality(other.quality), key(GetKey()) { } +public: + BotEquipKey() : level(0), clazz(0), slot(0), quality(0), key(GetKey()) {} + BotEquipKey(uint32 level, uint8 clazz, uint8 slot, uint32 quality) + : level(level), clazz(clazz), slot(slot), quality(quality), key(GetKey()) + { + } + BotEquipKey(BotEquipKey const& other) + : level(other.level), clazz(other.clazz), slot(other.slot), quality(other.quality), key(GetKey()) + { + } - bool operator<(BotEquipKey const& other) const - { - return other.key < this->key; - } + bool operator<(BotEquipKey const& other) const { return other.key < this->key; } - uint32 level; - uint8 clazz; - uint8 slot; - uint32 quality; - uint64 key; + uint32 level; + uint8 clazz; + uint8 slot; + uint32 quality; + uint64 key; - private: - uint64 GetKey(); +private: + uint64 GetKey(); }; typedef std::map BotEquipCache; class RandomItemMgr { - public: - RandomItemMgr(); - virtual ~RandomItemMgr(); - static RandomItemMgr* instance() - { - static RandomItemMgr instance; - return &instance; - } +public: + RandomItemMgr(); + virtual ~RandomItemMgr(); + static RandomItemMgr* instance() + { + static RandomItemMgr instance; + return &instance; + } - public: - void Init(); - void InitAfterAhBot(); - static bool HandleConsoleCommand(ChatHandler* handler, char const* args); - RandomItemList Query(uint32 level, RandomItemType type, RandomItemPredicate* predicate); - RandomItemList Query(uint32 level, uint8 clazz, uint8 slot, uint32 quality); - uint32 GetUpgrade(Player* player, std::string spec, uint8 slot, uint32 quality, uint32 itemId); - std::vector GetUpgradeList(Player* player, std::string spec, uint8 slot, uint32 quality, uint32 itemId, uint32 amount = 1); - bool HasStatWeight(uint32 itemId); - uint32 GetMinLevelFromCache(uint32 itemId); - uint32 GetStatWeight(Player* player, uint32 itemId); - uint32 GetLiveStatWeight(Player* player, uint32 itemId); - uint32 GetRandomItem(uint32 level, RandomItemType type, RandomItemPredicate* predicate = nullptr); - uint32 GetAmmo(uint32 level, uint32 subClass); - uint32 GetRandomPotion(uint32 level, uint32 effect); - uint32 GetRandomFood(uint32 level, uint32 category); - uint32 GetFood(uint32 level, uint32 category); - uint32 GetRandomTrade(uint32 level); - uint32 CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTemplate const* proto); - uint32 CalculateSingleStatWeight(uint8 playerclass, uint8 spec, std::string stat, uint32 value); - bool CanEquipArmor(uint8 clazz, uint32 level, ItemTemplate const* proto); - bool ShouldEquipArmorForSpec(uint8 playerclass, uint8 spec, ItemTemplate const* proto); - bool CanEquipWeapon(uint8 clazz, ItemTemplate const* proto); - bool ShouldEquipWeaponForSpec(uint8 playerclass, uint8 spec, ItemTemplate const* proto); - float GetItemRarity(uint32 itemId); - uint32 GetQuestIdForItem(uint32 itemId); - std::vector GetQuestIdsForItem(uint32 itemId); - static bool IsUsedBySkill(ItemTemplate const* proto, uint32 skillId); - bool IsTestItem(uint32 itemId) { return itemForTest.find(itemId) != itemForTest.end(); } - std::vector GetCachedEquipments(uint32 requiredLevel, uint32 inventoryType); +public: + void Init(); + void InitAfterAhBot(); + static bool HandleConsoleCommand(ChatHandler* handler, char const* args); + RandomItemList Query(uint32 level, RandomItemType type, RandomItemPredicate* predicate); + RandomItemList Query(uint32 level, uint8 clazz, uint8 slot, uint32 quality); + uint32 GetUpgrade(Player* player, std::string spec, uint8 slot, uint32 quality, uint32 itemId); + std::vector GetUpgradeList(Player* player, std::string spec, uint8 slot, uint32 quality, uint32 itemId, + uint32 amount = 1); + bool HasStatWeight(uint32 itemId); + uint32 GetMinLevelFromCache(uint32 itemId); + uint32 GetStatWeight(Player* player, uint32 itemId); + uint32 GetLiveStatWeight(Player* player, uint32 itemId); + uint32 GetRandomItem(uint32 level, RandomItemType type, RandomItemPredicate* predicate = nullptr); + uint32 GetAmmo(uint32 level, uint32 subClass); + uint32 GetRandomPotion(uint32 level, uint32 effect); + uint32 GetRandomFood(uint32 level, uint32 category); + uint32 GetFood(uint32 level, uint32 category); + uint32 GetRandomTrade(uint32 level); + uint32 CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTemplate const* proto); + uint32 CalculateSingleStatWeight(uint8 playerclass, uint8 spec, std::string stat, uint32 value); + bool CanEquipArmor(uint8 clazz, uint32 level, ItemTemplate const* proto); + bool ShouldEquipArmorForSpec(uint8 playerclass, uint8 spec, ItemTemplate const* proto); + bool CanEquipWeapon(uint8 clazz, ItemTemplate const* proto); + bool ShouldEquipWeaponForSpec(uint8 playerclass, uint8 spec, ItemTemplate const* proto); + float GetItemRarity(uint32 itemId); + uint32 GetQuestIdForItem(uint32 itemId); + std::vector GetQuestIdsForItem(uint32 itemId); + static bool IsUsedBySkill(ItemTemplate const* proto, uint32 skillId); + bool IsTestItem(uint32 itemId) { return itemForTest.find(itemId) != itemForTest.end(); } + std::vector GetCachedEquipments(uint32 requiredLevel, uint32 inventoryType); - private: - void BuildRandomItemCache(); - void BuildEquipCache(); - void BuildEquipCacheNew(); - void BuildItemInfoCache(); - void BuildAmmoCache(); - void BuildFoodCache(); - void BuildPotionCache(); - void BuildTradeCache(); - void BuildRarityCache(); - bool CanEquipItem(BotEquipKey key, ItemTemplate const* proto); - bool CanEquipItemNew(ItemTemplate const* proto); - void AddItemStats(uint32 mod, uint8& sp, uint8& ap, uint8& tank); - bool CheckItemStats(uint8 clazz, uint8 sp, uint8 ap, uint8 tank); - private: - std::map randomItemCache; - std::map predicates; - BotEquipCache equipCache; - std::map> viableSlots; - std::map > ammoCache; - std::map > > potionCache; - std::map > > foodCache; - std::map > tradeCache; - std::map rarityCache; - std::map m_weightScales[MAX_CLASSES]; - std::map weightStatLink; - std::map weightRatingLink; - std::map itemInfoCache; - std::set itemForTest; - static std::set itemCache; - // equipCacheNew[RequiredLevel][InventoryType] - std::map>> equipCacheNew; +private: + void BuildRandomItemCache(); + void BuildEquipCache(); + void BuildEquipCacheNew(); + void BuildItemInfoCache(); + void BuildAmmoCache(); + void BuildFoodCache(); + void BuildPotionCache(); + void BuildTradeCache(); + void BuildRarityCache(); + bool CanEquipItem(BotEquipKey key, ItemTemplate const* proto); + bool CanEquipItemNew(ItemTemplate const* proto); + void AddItemStats(uint32 mod, uint8& sp, uint8& ap, uint8& tank); + bool CheckItemStats(uint8 clazz, uint8 sp, uint8 ap, uint8 tank); + +private: + std::map randomItemCache; + std::map predicates; + BotEquipCache equipCache; + std::map> viableSlots; + std::map> ammoCache; + std::map>> potionCache; + std::map>> foodCache; + std::map> tradeCache; + std::map rarityCache; + std::map m_weightScales[MAX_CLASSES]; + std::map weightStatLink; + std::map weightRatingLink; + std::map itemInfoCache; + std::set itemForTest; + static std::set itemCache; + // equipCacheNew[RequiredLevel][InventoryType] + std::map>> equipCacheNew; }; #define sRandomItemMgr RandomItemMgr::instance() diff --git a/src/RandomPlayerbotFactory.cpp b/src/RandomPlayerbotFactory.cpp index 5e44f14b..0b614004 100644 --- a/src/RandomPlayerbotFactory.cpp +++ b/src/RandomPlayerbotFactory.cpp @@ -1,14 +1,16 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RandomPlayerbotFactory.h" -#include "ArenaTeamMgr.h" + #include "AccountMgr.h" +#include "ArenaTeamMgr.h" #include "DatabaseEnv.h" #include "GuildMgr.h" -#include "Playerbots.h" #include "PlayerbotFactory.h" +#include "Playerbots.h" #include "ScriptMgr.h" #include "SocialMgr.h" @@ -26,14 +28,14 @@ RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(acc availableRaces[CLASS_WARRIOR].push_back(RACE_UNDEAD_PLAYER); availableRaces[CLASS_WARRIOR].push_back(RACE_TAUREN); availableRaces[CLASS_WARRIOR].push_back(RACE_TROLL); - if(expansion >= EXPANSION_THE_BURNING_CRUSADE) + if (expansion >= EXPANSION_THE_BURNING_CRUSADE) { availableRaces[CLASS_WARRIOR].push_back(RACE_DRAENEI); } availableRaces[CLASS_PALADIN].push_back(RACE_HUMAN); availableRaces[CLASS_PALADIN].push_back(RACE_DWARF); - if(expansion >= EXPANSION_THE_BURNING_CRUSADE) + if (expansion >= EXPANSION_THE_BURNING_CRUSADE) { availableRaces[CLASS_PALADIN].push_back(RACE_DRAENEI); availableRaces[CLASS_PALADIN].push_back(RACE_BLOODELF); @@ -45,7 +47,7 @@ RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(acc availableRaces[CLASS_ROGUE].push_back(RACE_GNOME); availableRaces[CLASS_ROGUE].push_back(RACE_ORC); availableRaces[CLASS_ROGUE].push_back(RACE_TROLL); - if(expansion >= EXPANSION_THE_BURNING_CRUSADE) + if (expansion >= EXPANSION_THE_BURNING_CRUSADE) { availableRaces[CLASS_ROGUE].push_back(RACE_BLOODELF); } @@ -55,7 +57,7 @@ RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(acc availableRaces[CLASS_PRIEST].push_back(RACE_NIGHTELF); availableRaces[CLASS_PRIEST].push_back(RACE_TROLL); availableRaces[CLASS_PRIEST].push_back(RACE_UNDEAD_PLAYER); - if(expansion >= EXPANSION_THE_BURNING_CRUSADE) + if (expansion >= EXPANSION_THE_BURNING_CRUSADE) { availableRaces[CLASS_PRIEST].push_back(RACE_DRAENEI); availableRaces[CLASS_PRIEST].push_back(RACE_BLOODELF); @@ -65,7 +67,7 @@ RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(acc availableRaces[CLASS_MAGE].push_back(RACE_GNOME); availableRaces[CLASS_MAGE].push_back(RACE_UNDEAD_PLAYER); availableRaces[CLASS_MAGE].push_back(RACE_TROLL); - if(expansion >= EXPANSION_THE_BURNING_CRUSADE) + if (expansion >= EXPANSION_THE_BURNING_CRUSADE) { availableRaces[CLASS_MAGE].push_back(RACE_DRAENEI); availableRaces[CLASS_MAGE].push_back(RACE_BLOODELF); @@ -75,7 +77,7 @@ RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(acc availableRaces[CLASS_WARLOCK].push_back(RACE_GNOME); availableRaces[CLASS_WARLOCK].push_back(RACE_UNDEAD_PLAYER); availableRaces[CLASS_WARLOCK].push_back(RACE_ORC); - if(expansion >= EXPANSION_THE_BURNING_CRUSADE) + if (expansion >= EXPANSION_THE_BURNING_CRUSADE) { availableRaces[CLASS_WARLOCK].push_back(RACE_BLOODELF); } @@ -83,7 +85,7 @@ RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(acc availableRaces[CLASS_SHAMAN].push_back(RACE_ORC); availableRaces[CLASS_SHAMAN].push_back(RACE_TAUREN); availableRaces[CLASS_SHAMAN].push_back(RACE_TROLL); - if(expansion >= EXPANSION_THE_BURNING_CRUSADE) + if (expansion >= EXPANSION_THE_BURNING_CRUSADE) { availableRaces[CLASS_SHAMAN].push_back(RACE_DRAENEI); } @@ -93,7 +95,7 @@ RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(acc availableRaces[CLASS_HUNTER].push_back(RACE_ORC); availableRaces[CLASS_HUNTER].push_back(RACE_TAUREN); availableRaces[CLASS_HUNTER].push_back(RACE_TROLL); - if(expansion >= EXPANSION_THE_BURNING_CRUSADE) + if (expansion >= EXPANSION_THE_BURNING_CRUSADE) { availableRaces[CLASS_HUNTER].push_back(RACE_DRAENEI); availableRaces[CLASS_HUNTER].push_back(RACE_BLOODELF); @@ -119,27 +121,30 @@ RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(acc Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls) { - LOG_DEBUG("playerbots", "Creating new random bot for class {}", cls); + LOG_DEBUG("playerbots", "Creating new random bot for class {}", cls); uint8 gender = rand() % 2 ? GENDER_MALE : GENDER_FEMALE; uint8 alliance = rand() % 2; uint8 race; - for (int attempt = 0; attempt < 15; attempt++) { + for (int attempt = 0; attempt < 15; attempt++) + { race = availableRaces[cls][urand(0, availableRaces[cls].size() - 1)]; - if ((alliance && IsAlliance(race)) || (!alliance && !IsAlliance(race))) { + if ((alliance && IsAlliance(race)) || (!alliance && !IsAlliance(race))) + { break; } } std::string name = CreateRandomBotName(gender); - if (name.empty()) { + if (name.empty()) + { LOG_ERROR("playerbots", "Unable to get random bot name!"); return nullptr; } CharacterDatabase.DirectExecute("UPDATE playerbots_names SET in_use=1 WHERE name='{}'", name); std::vector skinColors, facialHairTypes; - std::vector> faces, hairs; + std::vector> faces, hairs; for (CharSectionsEntry const* charSection : sCharSectionsStore) { if (charSection->Race != race || charSection->Gender != gender) @@ -166,19 +171,22 @@ Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls std::pair face = faces[urand(0, faces.size() - 1)]; std::pair hair = hairs[urand(0, hairs.size() - 1)]; - bool excludeCheck = (race == RACE_TAUREN) || (race == RACE_DRAENEI) || (gender == GENDER_FEMALE && race != RACE_NIGHTELF && race != RACE_UNDEAD_PLAYER); - uint8 facialHair = excludeCheck ? 0 : facialHairTypes[urand(0, facialHairTypes.size() - 1)]; + bool excludeCheck = (race == RACE_TAUREN) || (race == RACE_DRAENEI) || + (gender == GENDER_FEMALE && race != RACE_NIGHTELF && race != RACE_UNDEAD_PLAYER); + uint8 facialHair = excludeCheck ? 0 : facialHairTypes[urand(0, facialHairTypes.size() - 1)]; - std::unique_ptr characterInfo = std::make_unique(name, race, cls, gender, face.second, face.first, hair.first, hair.second, facialHair); + std::unique_ptr characterInfo = std::make_unique( + name, race, cls, gender, face.second, face.first, hair.first, hair.second, facialHair); Player* player = new Player(session); player->GetMotionMaster()->Initialize(); - if (!player->Create(sObjectMgr->GetGenerator().Generate(), characterInfo.get())) + if (!player->Create(sObjectMgr->GetGenerator().Generate(), characterInfo.get())) { player->CleanupsBeforeDelete(); delete player; - LOG_ERROR("playerbots", "Unable to create random bot for account {} - name: \"{}\"; race: {}; class: {}", accountId, name.c_str(), race, cls); + LOG_ERROR("playerbots", "Unable to create random bot for account {} - name: \"{}\"; race: {}; class: {}", + accountId, name.c_str(), race, cls); return nullptr; } @@ -186,23 +194,27 @@ Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls player->SetAtLoginFlag(AT_LOGIN_NONE); if (player->getClass() == CLASS_DEATH_KNIGHT) - { - player->learnSpell(50977, false); - } + { + player->learnSpell(50977, false); + } // player->SaveToDB(true, false); // player->RewardQuest(const Quest *quest, uint32 reward, Object *questGiver) - LOG_DEBUG("playerbots", "Random bot created for account {} - name: \"{}\"; race: {}; class: {}", accountId, name.c_str(), race, cls); + LOG_DEBUG("playerbots", "Random bot created for account {} - name: \"{}\"; race: {}; class: {}", accountId, + name.c_str(), race, cls); return player; } std::string const RandomPlayerbotFactory::CreateRandomBotName(uint8 gender) { - std::string botName = ""; + std::string botName = ""; int tries = 10; - while(--tries) { - QueryResult result = CharacterDatabase.Query("SELECT name FROM playerbots_names " - "WHERE in_use = 0 AND gender = {} ORDER BY RAND() LIMIT 1", gender); + while (--tries) + { + QueryResult result = CharacterDatabase.Query( + "SELECT name FROM playerbots_names " + "WHERE in_use = 0 AND gender = {} ORDER BY RAND() LIMIT 1", + gender); if (!result) { break; @@ -215,66 +227,57 @@ std::string const RandomPlayerbotFactory::CreateRandomBotName(uint8 gender) } } - //CONLANG NAME GENERATION + // CONLANG NAME GENERATION LOG_ERROR("playerbots", "No more names left for random bots. Attempting conlang name generation."); const std::string groupCategory = "SCVKRU"; - const std::string groupFormStart[2][4] = { - {"SV","SV","VK","RV"}, - {"V" ,"SU","VS","RV"} - }; - const std::string groupFormMid[2][6] = { - {"CV","CVC","CVC","CVK","VC","VK"}, - {"CV","CVC","CVK","KVC","VC","KV"} - }; - const std::string groupFormEnd[2][4] = { - {"CV","VC","VK","CV"}, - {"RU","UR","VR","V" } - }; + const std::string groupFormStart[2][4] = {{"SV", "SV", "VK", "RV"}, {"V", "SU", "VS", "RV"}}; + const std::string groupFormMid[2][6] = {{"CV", "CVC", "CVC", "CVK", "VC", "VK"}, + {"CV", "CVC", "CVK", "KVC", "VC", "KV"}}; + const std::string groupFormEnd[2][4] = {{"CV", "VC", "VK", "CV"}, {"RU", "UR", "VR", "V"}}; const std::string groupLetter[2][6] = { - //S C V K R U - {"dtspkThfS","bcCdfghjkmnNqqrrlsStTvwxyz","aaeeiouA" ,"ppttkkbdg","lmmnrr" ,"AEO" }, - {"dtskThfS" ,"bcCdfghjkmmnNqrrlssStTvwyz","aaaeeiiuAAEIO","ppttkbbdg","lmmnrrr","AEOy"} - }; + // S C V K R U + {"dtspkThfS", "bcCdfghjkmnNqqrrlsStTvwxyz", "aaeeiouA", "ppttkkbdg", "lmmnrr", "AEO"}, + {"dtskThfS", "bcCdfghjkmmnNqrrlssStTvwyz", "aaaeeiiuAAEIO", "ppttkbbdg", "lmmnrrr", "AEOy"}}; const std::string replaceRule[2][17] = { - {"ST" ,"ka","ko","ku","kr","S" ,"T" ,"C" ,"N" ,"jj","AA","AI" ,"A" ,"E" ,"O" ,"I" ,"aa"}, - {"sth","ca","co","cu","cr","sh","th","ch","ng","dg","A" ,"ayu","ai","ei","ou","iu","ae"} - }; - + {"ST", "ka", "ko", "ku", "kr", "S", "T", "C", "N", "jj", "AA", "AI", "A", "E", "O", "I", "aa"}, + {"sth", "ca", "co", "cu", "cr", "sh", "th", "ch", "ng", "dg", "A", "ayu", "ai", "ei", "ou", "iu", "ae"}}; + tries = 10; while (--tries) { botName.clear(); - //Build name from groupForms - //Pick random start group - botName = groupFormStart[gender][rand()%4]; - //Pick up to 2 and then up to 1 additional middle group - for (int i = 0; i < rand()%3 + rand()%2; i++) + // Build name from groupForms + // Pick random start group + botName = groupFormStart[gender][rand() % 4]; + // Pick up to 2 and then up to 1 additional middle group + for (int i = 0; i < rand() % 3 + rand() % 2; i++) { - botName += groupFormMid[gender][rand()%6]; - } - //Pick up to 1 end group - botName += rand()%2 ? groupFormEnd[gender][rand()%4] : ""; - //If name is single letter add random end group - botName += (botName.size() < 2) ? groupFormEnd[gender][rand()%4] : ""; - - //Replace Catagory value with random Letter from that Catagory's Letter string for a given bot gender - for (int i=0; i < botName.size(); i++) + botName += groupFormMid[gender][rand() % 6]; + } + // Pick up to 1 end group + botName += rand() % 2 ? groupFormEnd[gender][rand() % 4] : ""; + // If name is single letter add random end group + botName += (botName.size() < 2) ? groupFormEnd[gender][rand() % 4] : ""; + + // Replace Catagory value with random Letter from that Catagory's Letter string for a given bot gender + for (int i = 0; i < botName.size(); i++) { - botName[i] = groupLetter[gender][groupCategory.find(botName[i])][rand()%groupLetter[gender][groupCategory.find(botName[i])].size()]; - } - - //Itterate over replace rules + botName[i] = groupLetter[gender][groupCategory.find(botName[i])] + [rand() % groupLetter[gender][groupCategory.find(botName[i])].size()]; + } + + // Itterate over replace rules for (int i = 0; i < 17; i++) { int j = botName.find(replaceRule[0][i]); - while ( j > -1) + while (j > -1) { - botName.replace(j,replaceRule[0][i].size(),replaceRule[1][i]); + botName.replace(j, replaceRule[0][i].size(), replaceRule[1][i]); j = botName.find(replaceRule[0][i]); - } + } } - - //Capitalize first letter + + // Capitalize first letter botName[0] -= 32; if (ObjectMgr::CheckPlayerName(botName) != CHAR_NAME_SUCCESS || @@ -286,11 +289,13 @@ std::string const RandomPlayerbotFactory::CreateRandomBotName(uint8 gender) return std::move(botName); } - //TRUE RANDOM NAME GENERATION + // TRUE RANDOM NAME GENERATION LOG_ERROR("playerbots", "Con​lang name generation failed. True random name fallback."); tries = 10; - while(--tries) { - for (uint8 i = 0; i < 10; i++) { + while (--tries) + { + for (uint8 i = 0; i < 10; i++) + { botName += (i == 0 ? 'A' : 'a') + rand() % 26; } if (ObjectMgr::CheckPlayerName(botName) != CHAR_NAME_SUCCESS || @@ -325,7 +330,8 @@ void RandomPlayerbotFactory::CreateRandomBots() } LOG_INFO("playerbots", "Deleting all random bot characters, {} accounts collected...", botAccounts.size()); - QueryResult results = LoginDatabase.Query("SELECT id FROM account WHERE username LIKE '{}%%'", sPlayerbotAIConfig->randomBotAccountPrefix.c_str()); + QueryResult results = LoginDatabase.Query("SELECT id FROM account WHERE username LIKE '{}%%'", + sPlayerbotAIConfig->randomBotAccountPrefix.c_str()); int32 deletion_count = 0; if (results) { @@ -340,15 +346,15 @@ void RandomPlayerbotFactory::CreateRandomBots() PlayerbotsDatabase.Execute(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_DEL_RANDOM_BOTS)); CharacterDatabase.DirectExecute("UPDATE playerbots_names SET in_use = 0 WHERE in_use = 1"); - /* TODO(yunfan): we need to sleep here to wait for async account deleted, or the newly account won't be created correctly - the better way is turning the async db operation to sync db operation */ + /* TODO(yunfan): we need to sleep here to wait for async account deleted, or the newly account won't be created + correctly the better way is turning the async db operation to sync db operation */ std::this_thread::sleep_for(10ms * sPlayerbotAIConfig->randomBotAccountCount); LOG_INFO("playerbots", "Random bot characters deleted."); LOG_INFO("playerbots", "Please reset the AiPlayerbot.DeleteRandomBotAccounts to 0 and restart the server..."); World::StopNow(SHUTDOWN_EXIT_CODE); return; } - + uint32 totalAccCount = sPlayerbotAIConfig->randomBotAccountCount; LOG_INFO("playerbots", "Creating random bot accounts..."); @@ -374,7 +380,7 @@ void RandomPlayerbotFactory::CreateRandomBots() { for (int i = 0; i < 10; i++) { - password += (char) urand('!', 'z'); + password += (char)urand('!', 'z'); } } else @@ -385,7 +391,8 @@ void RandomPlayerbotFactory::CreateRandomBots() LOG_DEBUG("playerbots", "Account {} created for random bots", accountName.c_str()); } - if (account_creation) { + if (account_creation) + { /* wait for async accounts create to make character create correctly, same as account delete */ LOG_INFO("playerbots", "Waiting for {} accounts loading into database...", account_creation); std::this_thread::sleep_for(10ms * sPlayerbotAIConfig->randomBotAccountCount); @@ -420,10 +427,12 @@ void RandomPlayerbotFactory::CreateRandomBots() { continue; } - LOG_INFO("playerbots", "Creating random bot characters for account: [{}/{}]", accountNumber + 1, sPlayerbotAIConfig->randomBotAccountCount); + LOG_INFO("playerbots", "Creating random bot characters for account: [{}/{}]", accountNumber + 1, + sPlayerbotAIConfig->randomBotAccountCount); RandomPlayerbotFactory factory(accountId); - WorldSession* session = new WorldSession(accountId, "", nullptr, SEC_PLAYER, EXPANSION_WRATH_OF_THE_LICH_KING, time_t(0), LOCALE_enUS, 0, false, false, 0, true); + WorldSession* session = new WorldSession(accountId, "", nullptr, SEC_PLAYER, EXPANSION_WRATH_OF_THE_LICH_KING, + time_t(0), LOCALE_enUS, 0, false, false, 0, true); sessionBots.push_back(session); for (uint8 cls = CLASS_WARRIOR; cls < MAX_CLASSES - count; ++cls) @@ -433,29 +442,33 @@ void RandomPlayerbotFactory::CreateRandomBots() continue; if (bool const isClassDeathKnight = cls == CLASS_DEATH_KNIGHT; - isClassDeathKnight && - sWorld->getIntConfig(CONFIG_EXPANSION) != - EXPANSION_WRATH_OF_THE_LICH_KING) + isClassDeathKnight && sWorld->getIntConfig(CONFIG_EXPANSION) != EXPANSION_WRATH_OF_THE_LICH_KING) { continue; } - if (cls != 10) { - if (Player* playerBot = factory.CreateRandomBot(session, cls)) { + if (cls != 10) + { + if (Player* playerBot = factory.CreateRandomBot(session, cls)) + { playerBot->SaveToDB(true, false); - sCharacterCache->AddCharacterCacheEntry(playerBot->GetGUID(), accountId, playerBot->GetName(), - playerBot->getGender(), playerBot->getRace(), playerBot->getClass(), playerBot->GetLevel()); + sCharacterCache->AddCharacterCacheEntry(playerBot->GetGUID(), accountId, playerBot->GetName(), + playerBot->getGender(), playerBot->getRace(), + playerBot->getClass(), playerBot->GetLevel()); playerBot->CleanupsBeforeDelete(); delete playerBot; bot_creation++; - } else { + } + else + { LOG_ERROR("playerbots", "Fail to create character for account {}", accountId); } } } } - if (bot_creation) { + if (bot_creation) + { LOG_INFO("playerbots", "Waiting for {} characters loading into database...", bot_creation); /* wait for characters load into database, or characters will fail to loggin */ std::this_thread::sleep_for(10s); @@ -463,12 +476,14 @@ void RandomPlayerbotFactory::CreateRandomBots() for (WorldSession* session : sessionBots) delete session; - - for (uint32 accountId : sPlayerbotAIConfig->randomBotAccounts) { + + for (uint32 accountId : sPlayerbotAIConfig->randomBotAccounts) + { totalRandomBotChars += AccountMgr::GetCharactersCount(accountId); } - LOG_INFO("server.loading", "{} random bot accounts with {} characters available", sPlayerbotAIConfig->randomBotAccounts.size(), totalRandomBotChars); + LOG_INFO("server.loading", "{} random bot accounts with {} characters available", + sPlayerbotAIConfig->randomBotAccounts.size(), totalRandomBotChars); } void RandomPlayerbotFactory::CreateRandomGuilds() @@ -484,8 +499,7 @@ void RandomPlayerbotFactory::CreateRandomGuilds() Field* fields = result->Fetch(); uint32 bot = fields[0].Get(); randomBots.push_back(bot); - } - while (result->NextRow()); + } while (result->NextRow()); } if (sPlayerbotAIConfig->deleteRandomBotGuilds) @@ -538,7 +552,8 @@ void RandomPlayerbotFactory::CreateRandomGuilds() Player* player = ObjectAccessor::FindPlayer(leader); if (!player) { - LOG_ERROR("playerbots", "ObjectAccessor Cannot find player to set leader for guild {} . Skipped...", guildName.c_str()); + LOG_ERROR("playerbots", "ObjectAccessor Cannot find player to set leader for guild {} . Skipped...", + guildName.c_str()); continue; } @@ -548,7 +563,8 @@ void RandomPlayerbotFactory::CreateRandomGuilds() Guild* guild = new Guild(); if (!guild->Create(player, guildName)) { - LOG_ERROR("playerbots", "Error creating guild [ {} ] with leader [ {} ]", guildName.c_str(), player->GetName().c_str()); + LOG_ERROR("playerbots", "Error creating guild [ {} ] with leader [ {} ]", guildName.c_str(), + player->GetName().c_str()); delete guild; continue; } @@ -586,8 +602,10 @@ std::string const RandomPlayerbotFactory::CreateRandomGuildName() uint32 maxId = fields[0].Get(); uint32 id = urand(0, maxId); - result = CharacterDatabase.Query("SELECT n.name FROM playerbots_guild_names n " - "LEFT OUTER JOIN guild e ON e.name = n.name WHERE e.guildid IS NULL AND n.name_id >= {} LIMIT 1", id); + result = CharacterDatabase.Query( + "SELECT n.name FROM playerbots_guild_names n " + "LEFT OUTER JOIN guild e ON e.name = n.name WHERE e.guildid IS NULL AND n.name_id >= {} LIMIT 1", + id); if (!result) { LOG_ERROR("playerbots", "No more names left for random guilds"); @@ -613,8 +631,7 @@ void RandomPlayerbotFactory::CreateRandomArenaTeams(ArenaType type, uint32 count Field* fields = result->Fetch(); uint32 bot = fields[0].Get(); randomBots.push_back(bot); - } - while (result->NextRow()); + } while (result->NextRow()); } uint32 arenaTeamNumber = 0; @@ -664,10 +681,10 @@ void RandomPlayerbotFactory::CreateRandomArenaTeams(ArenaType type, uint32 count continue; } - // Below query no longer required as now user has control over the number of each type of arena team they want to create. - // Keeping commented for potential future reference. - // QueryResult results = CharacterDatabase.Query("SELECT `type` FROM playerbots_arena_team_names WHERE name = '{}'", arenaTeamName.c_str()); - // if (!results) + // Below query no longer required as now user has control over the number of each type of arena team they want + // to create. Keeping commented for potential future reference. QueryResult results = + // CharacterDatabase.Query("SELECT `type` FROM playerbots_arena_team_names WHERE name = '{}'", + // arenaTeamName.c_str()); if (!results) // { // LOG_ERROR("playerbots", "No valid types for arena teams"); // return; @@ -686,7 +703,8 @@ void RandomPlayerbotFactory::CreateRandomArenaTeams(ArenaType type, uint32 count arenateam->SetCaptain(player->GetGUID()); // set random rating - arenateam->SetRatingForAll(urand(sPlayerbotAIConfig->randomBotArenaTeamMinRating, sPlayerbotAIConfig->randomBotArenaTeamMaxRating)); + arenateam->SetRatingForAll( + urand(sPlayerbotAIConfig->randomBotArenaTeamMinRating, sPlayerbotAIConfig->randomBotArenaTeamMaxRating)); // set random emblem uint32 backgroundColor = urand(0xFF000000, 0xFFFFFFFF); @@ -697,10 +715,11 @@ void RandomPlayerbotFactory::CreateRandomArenaTeams(ArenaType type, uint32 count arenateam->SetEmblem(backgroundColor, emblemStyle, emblemColor, borderStyle, borderColor); // set random kills (wip) - //arenateam->SetStats(STAT_TYPE_GAMES_WEEK, urand(0, 30)); - //arenateam->SetStats(STAT_TYPE_WINS_WEEK, urand(0, arenateam->GetStats().games_week)); - //arenateam->SetStats(STAT_TYPE_GAMES_SEASON, urand(arenateam->GetStats().games_week, arenateam->GetStats().games_week * 5)); - //arenateam->SetStats(STAT_TYPE_WINS_SEASON, urand(arenateam->GetStats().wins_week, arenateam->GetStats().games + // arenateam->SetStats(STAT_TYPE_GAMES_WEEK, urand(0, 30)); + // arenateam->SetStats(STAT_TYPE_WINS_WEEK, urand(0, arenateam->GetStats().games_week)); + // arenateam->SetStats(STAT_TYPE_GAMES_SEASON, urand(arenateam->GetStats().games_week, + // arenateam->GetStats().games_week * 5)); arenateam->SetStats(STAT_TYPE_WINS_SEASON, + // urand(arenateam->GetStats().wins_week, arenateam->GetStats().games arenateam->SaveToDB(); sArenaTeamMgr->AddArenaTeam(arenateam); @@ -725,8 +744,10 @@ std::string const RandomPlayerbotFactory::CreateRandomArenaTeamName() uint32 maxId = fields[0].Get(); uint32 id = urand(0, maxId); - result = CharacterDatabase.Query("SELECT n.name FROM playerbots_arena_team_names n LEFT OUTER JOIN arena_team e ON e.name = n.name " - "WHERE e.arenateamid IS NULL AND n.name_id >= {} LIMIT 1", id); + result = CharacterDatabase.Query( + "SELECT n.name FROM playerbots_arena_team_names n LEFT OUTER JOIN arena_team e ON e.name = n.name " + "WHERE e.arenateamid IS NULL AND n.name_id >= {} LIMIT 1", + id); if (!result) { diff --git a/src/RandomPlayerbotFactory.h b/src/RandomPlayerbotFactory.h index 0d338d88..4e532307 100644 --- a/src/RandomPlayerbotFactory.h +++ b/src/RandomPlayerbotFactory.h @@ -1,15 +1,16 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RANDOMPLAYERBOTFACTORY_H #define _PLAYERBOT_RANDOMPLAYERBOTFACTORY_H -#include "Common.h" - #include #include #include + +#include "Common.h" #include "DBCEnums.h" class Player; @@ -19,22 +20,22 @@ enum ArenaType : uint8; class RandomPlayerbotFactory { - public: - RandomPlayerbotFactory(uint32 accountId); - virtual ~RandomPlayerbotFactory() { } +public: + RandomPlayerbotFactory(uint32 accountId); + virtual ~RandomPlayerbotFactory() {} - Player* CreateRandomBot(WorldSession* session, uint8 cls); - static void CreateRandomBots(); - static void CreateRandomGuilds(); - static void CreateRandomArenaTeams(ArenaType slot, uint32 count); - static std::string const CreateRandomGuildName(); + Player* CreateRandomBot(WorldSession* session, uint8 cls); + static void CreateRandomBots(); + static void CreateRandomGuilds(); + static void CreateRandomArenaTeams(ArenaType slot, uint32 count); + static std::string const CreateRandomGuildName(); - private: - std::string const CreateRandomBotName(uint8 gender); - static std::string const CreateRandomArenaTeamName(); +private: + std::string const CreateRandomBotName(uint8 gender); + static std::string const CreateRandomArenaTeamName(); - uint32 accountId; - static std::map> availableRaces; + uint32 accountId; + static std::map> availableRaces; }; #endif diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 658e2d2a..e6704884 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -1,47 +1,46 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RandomPlayerbotMgr.h" + +#include +#include +#include +#include +#include + #include "AccountMgr.h" #include "AiFactory.h" #include "ArenaTeamMgr.h" #include "Battleground.h" #include "BattlegroundMgr.h" #include "CellImpl.h" +#include "ChannelMgr.h" #include "DatabaseEnv.h" #include "Define.h" #include "FleeManager.h" #include "GameTime.h" -#include "GuildMgr.h" -#include "GuildTaskMgr.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" +#include "GuildMgr.h" +#include "GuildTaskMgr.h" #include "LFGMgr.h" #include "MapMgr.h" #include "PerformanceMonitor.h" #include "PlayerbotAIConfig.h" -#include "Playerbots.h" #include "PlayerbotCommandServer.h" #include "PlayerbotFactory.h" +#include "Playerbots.h" #include "Random.h" #include "ServerFacade.h" -#include "ChannelMgr.h" #include "SharedDefines.h" #include "Unit.h" -#include "World.h" #include "UpdateTime.h" +#include "World.h" -#include -#include -#include -#include -#include - -void PrintStatsThread() -{ - sRandomPlayerbotMgr->PrintStats(); -} +void PrintStatsThread() { sRandomPlayerbotMgr->PrintStats(); } void activatePrintStatsThread() { @@ -49,10 +48,7 @@ void activatePrintStatsThread() t.detach(); } -void CheckBgQueueThread() -{ - sRandomPlayerbotMgr->CheckBgQueue(); -} +void CheckBgQueueThread() { sRandomPlayerbotMgr->CheckBgQueue(); } void activateCheckBgQueueThread() { @@ -60,10 +56,7 @@ void activateCheckBgQueueThread() t.detach(); } -void CheckLfgQueueThread() -{ - sRandomPlayerbotMgr->CheckLfgQueue(); -} +void CheckLfgQueueThread() { sRandomPlayerbotMgr->CheckLfgQueue(); } void activateCheckLfgQueueThread() { @@ -71,10 +64,7 @@ void activateCheckLfgQueueThread() t.detach(); } -void CheckPlayersThread() -{ - sRandomPlayerbotMgr->CheckPlayers(); -} +void CheckPlayersThread() { sRandomPlayerbotMgr->CheckPlayers(); } void activateCheckPlayersThread() { @@ -88,7 +78,12 @@ public: botPIDImpl(double dt, double max, double min, double Kp, double Ki, double Kd); ~botPIDImpl(); double calculate(double setpoint, double pv); - void adjust(double Kp, double Ki, double Kd) { _Kp = Kp; _Ki = Ki; _Kd = Kd; } + void adjust(double Kp, double Ki, double Kd) + { + _Kp = Kp; + _Ki = Ki; + _Kd = Kd; + } void reset() { _integral = 0; } private: @@ -102,47 +97,25 @@ private: double _integral; }; - botPID::botPID(double dt, double max, double min, double Kp, double Ki, double Kd) { pimpl = new botPIDImpl(dt, max, min, Kp, Ki, Kd); } -void botPID::adjust(double Kp, double Ki, double Kd) -{ - pimpl->adjust(Kp, Ki, Kd); -} -void botPID::reset() -{ - pimpl->reset(); -} -double botPID::calculate(double setpoint, double pv) -{ - return pimpl->calculate(setpoint, pv); -} -botPID::~botPID() -{ - delete pimpl; -} - +void botPID::adjust(double Kp, double Ki, double Kd) { pimpl->adjust(Kp, Ki, Kd); } +void botPID::reset() { pimpl->reset(); } +double botPID::calculate(double setpoint, double pv) { return pimpl->calculate(setpoint, pv); } +botPID::~botPID() { delete pimpl; } /** * Implementation */ -botPIDImpl::botPIDImpl(double dt, double max, double min, double Kp, double Ki, double Kd) : - _dt(dt), - _max(max), - _min(min), - _Kp(Kp), - _Ki(Ki), - _Kd(Kd), - _pre_error(0), - _integral(0) +botPIDImpl::botPIDImpl(double dt, double max, double min, double Kp, double Ki, double Kd) + : _dt(dt), _max(max), _min(min), _Kp(Kp), _Ki(Ki), _Kd(Kd), _pre_error(0), _integral(0) { } double botPIDImpl::calculate(double setpoint, double pv) { - // Calculate error double error = setpoint - pv; @@ -164,12 +137,12 @@ double botPIDImpl::calculate(double setpoint, double pv) if (output > _max) { output = _max; - _integral -= error * _dt; //Stop integral buildup at max + _integral -= error * _dt; // Stop integral buildup at max } else if (output < _min) { output = _min; - _integral -= error * _dt; //Stop integral buildup at min + _integral -= error * _dt; // Stop integral buildup at min } // Save error to previous error @@ -178,9 +151,7 @@ double botPIDImpl::calculate(double setpoint, double pv) return output; } -botPIDImpl::~botPIDImpl() -{ -} +botPIDImpl::~botPIDImpl() {} RandomPlayerbotMgr::RandomPlayerbotMgr() : PlayerbotHolder(), processTicks(0), totalPmo(nullptr) { @@ -199,14 +170,9 @@ RandomPlayerbotMgr::RandomPlayerbotMgr() : PlayerbotHolder(), processTicks(0), t PlayersCheckTimer = 0; } -RandomPlayerbotMgr::~RandomPlayerbotMgr() -{ -} +RandomPlayerbotMgr::~RandomPlayerbotMgr() {} -uint32 RandomPlayerbotMgr::GetMaxAllowedBotCount() -{ - return GetEventValue(0, "bot_count"); -} +uint32 RandomPlayerbotMgr::GetMaxAllowedBotCount() { return GetEventValue(0, "bot_count"); } void RandomPlayerbotMgr::LogPlayerLocation() { @@ -270,7 +236,8 @@ void RandomPlayerbotMgr::LogPlayerLocation() std::ostringstream out; out << sPlayerbotAIConfig->GetTimestampStr() << "+00,"; - out << "PLR" << ","; + out << "PLR" + << ","; out << bot->GetName() << ","; out << std::fixed << std::setprecision(2); WorldPosition(bot).printWKT(out); @@ -326,17 +293,21 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/) if (sPlayerbotAIConfig->enablePrototypePerformanceDiff) { - LOG_INFO("playerbots", "---------------------------------------"); - LOG_INFO("playerbots", "PROTOTYPE: Playerbot performance enhancements are active. Issues and instability may occur."); - LOG_INFO("playerbots", "---------------------------------------"); + LOG_INFO("playerbots", "---------------------------------------"); + LOG_INFO("playerbots", + "PROTOTYPE: Playerbot performance enhancements are active. Issues and instability may occur."); + LOG_INFO("playerbots", "---------------------------------------"); ScaleBotActivity(); } uint32 maxAllowedBotCount = GetEventValue(0, "bot_count"); - if (!maxAllowedBotCount || (maxAllowedBotCount < sPlayerbotAIConfig->minRandomBots || maxAllowedBotCount > sPlayerbotAIConfig->maxRandomBots)) + if (!maxAllowedBotCount || (maxAllowedBotCount < sPlayerbotAIConfig->minRandomBots || + maxAllowedBotCount > sPlayerbotAIConfig->maxRandomBots)) { maxAllowedBotCount = urand(sPlayerbotAIConfig->minRandomBots, sPlayerbotAIConfig->maxRandomBots); - SetEventValue(0, "bot_count", maxAllowedBotCount, urand(sPlayerbotAIConfig->randomBotCountChangeMinInterval, sPlayerbotAIConfig->randomBotCountChangeMaxInterval)); + SetEventValue(0, "bot_count", maxAllowedBotCount, + urand(sPlayerbotAIConfig->randomBotCountChangeMinInterval, + sPlayerbotAIConfig->randomBotCountChangeMaxInterval)); } GetBots(); @@ -350,7 +321,9 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/) SetNextCheckDelay(sPlayerbotAIConfig->randomBotUpdateInterval * (onlineBotFocus + 25) * 10); - PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_TOTAL, onlineBotCount < maxAllowedBotCount ? "RandomPlayerbotMgr::Login" : "RandomPlayerbotMgr::UpdateAIInternal"); + PerformanceMonitorOperation* pmo = sPerformanceMonitor->start( + PERF_MON_TOTAL, + onlineBotCount < maxAllowedBotCount ? "RandomPlayerbotMgr::Login" : "RandomPlayerbotMgr::UpdateAIInternal"); if (availableBotCount < maxAllowedBotCount) { @@ -362,14 +335,14 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/) if (time(nullptr) > (PlayersCheckTimer + 60)) activateCheckPlayersThread(); } - - if (sPlayerbotAIConfig->randomBotJoinBG/* && !players.empty()*/) + + if (sPlayerbotAIConfig->randomBotJoinBG /* && !players.empty()*/) { if (time(nullptr) > (BgCheckTimer + 30)) activateCheckBgQueueThread(); } - if (sPlayerbotAIConfig->randomBotJoinLfg/* && !players.empty()*/) + if (sPlayerbotAIConfig->randomBotJoinLfg /* && !players.empty()*/) { if (time(nullptr) > (LfgCheckTimer + 30)) activateCheckLfgQueueThread(); @@ -389,7 +362,7 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/) if (ProcessBot(bot)) { - updateBots--; + updateBots--; } if (!updateBots) @@ -403,7 +376,7 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/) LOG_INFO("playerbots", "{} new bots", loginBots); - //Log in bots + // Log in bots for (auto bot : availableBots) { if (GetPlayerBot(bot)) @@ -433,14 +406,17 @@ void RandomPlayerbotMgr::ScaleBotActivity() { float activityPercentage = getActivityPercentage(); - //if (activityPercentage >= 100.0f || activityPercentage <= 0.0f) pid.reset(); //Stop integer buildup during max/min activity + // if (activityPercentage >= 100.0f || activityPercentage <= 0.0f) pid.reset(); //Stop integer buildup during + // max/min activity // % increase/decrease wanted diff , avg diff - float activityPercentageMod = pid.calculate(sRandomPlayerbotMgr->GetPlayers().empty() ? sPlayerbotAIConfig->diffEmpty : sPlayerbotAIConfig->diffWithPlayer, sWorldUpdateTime.GetAverageUpdateTime()); + float activityPercentageMod = pid.calculate( + sRandomPlayerbotMgr->GetPlayers().empty() ? sPlayerbotAIConfig->diffEmpty : sPlayerbotAIConfig->diffWithPlayer, + sWorldUpdateTime.GetAverageUpdateTime()); activityPercentage = activityPercentageMod + 50; - //Cap the percentage between 0 and 100. + // Cap the percentage between 0 and 100. activityPercentage = std::max(0.0f, std::min(100.0f, activityPercentage)); setActivityPercentage(activityPercentage); @@ -455,15 +431,19 @@ uint32 RandomPlayerbotMgr::AddRandomBots() maxAllowedBotCount -= currentBots.size(); maxAllowedBotCount = std::min(sPlayerbotAIConfig->randomBotsPerInterval, maxAllowedBotCount); - for (std::vector::iterator i = sPlayerbotAIConfig->randomBotAccounts.begin(); i != sPlayerbotAIConfig->randomBotAccounts.end(); i++) + for (std::vector::iterator i = sPlayerbotAIConfig->randomBotAccounts.begin(); + i != sPlayerbotAIConfig->randomBotAccounts.end(); i++) { uint32 accountId = *i; - if (sPlayerbotAIConfig->enableRotation) { - uint32 limit = std::min((uint32)sPlayerbotAIConfig->randomBotAccounts.size(), sPlayerbotAIConfig->rotationPoolSize / 10 + 1); + if (sPlayerbotAIConfig->enableRotation) + { + uint32 limit = std::min((uint32)sPlayerbotAIConfig->randomBotAccounts.size(), + sPlayerbotAIConfig->rotationPoolSize / 10 + 1); uint32 index = urand(0, limit); accountId = sPlayerbotAIConfig->randomBotAccounts[index]; } - CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID); + CharacterDatabasePreparedStatement* stmt = + CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID); stmt->SetData(0, accountId); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) @@ -484,15 +464,18 @@ uint32 RandomPlayerbotMgr::AddRandomBots() if (std::find(currentBots.begin(), currentBots.end(), guid) != currentBots.end()) continue; - - if (sPlayerbotAIConfig->disableDeathKnightLogin) { + + if (sPlayerbotAIConfig->disableDeathKnightLogin) + { QueryResult result = CharacterDatabase.Query("Select class from characters where guid = {}", guid); - if (!result) { + if (!result) + { continue; } Field* fields = result->Fetch(); uint32 rClass = fields[0].Get(); - if (rClass == CLASS_DEATH_KNIGHT) { + if (rClass == CLASS_DEATH_KNIGHT) + { continue; } } @@ -502,11 +485,13 @@ uint32 RandomPlayerbotMgr::AddRandomBots() std::mt19937 rnd(time(0)); std::shuffle(guids.begin(), guids.end(), rnd); - for (uint32 &guid : guids) { - uint32 add_time = sPlayerbotAIConfig->enableRotation ? - urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime) : - sPlayerbotAIConfig->randomBotInWorldWithRotationDisabled; - + for (uint32& guid : guids) + { + uint32 add_time = sPlayerbotAIConfig->enableRotation + ? urand(sPlayerbotAIConfig->minRandomBotInWorldTime, + sPlayerbotAIConfig->maxRandomBotInWorldTime) + : sPlayerbotAIConfig->randomBotInWorldWithRotationDisabled; + SetEventValue(guid, "add", 1, add_time); SetEventValue(guid, "logout", 0, 0); currentBots.push_back(guid); @@ -521,7 +506,8 @@ uint32 RandomPlayerbotMgr::AddRandomBots() } if (maxAllowedBotCount) - LOG_ERROR("playerbots", "Not enough random bot accounts available. Need {} more!!", ceil(maxAllowedBotCount / 10)); + LOG_ERROR("playerbots", "Not enough random bot accounts available. Need {} more!!", + ceil(maxAllowedBotCount / 10)); } return currentBots.size(); @@ -574,8 +560,12 @@ void RandomPlayerbotMgr::LoadBattleMastersCache() if (bmFactionId == 66) bmTeam = TEAM_HORDE; - BattleMastersCache[bmTeam][BattlegroundTypeId(bgTypeId)].insert(BattleMastersCache[bmTeam][BattlegroundTypeId(bgTypeId)].end(), entry); - LOG_DEBUG("playerbots", "Cached Battmemaster #{} for BG Type {} ({})", entry, bgTypeId, bmTeam == TEAM_ALLIANCE ? "Alliance" : bmTeam == TEAM_HORDE ? "Horde" : "Neutral"); + BattleMastersCache[bmTeam][BattlegroundTypeId(bgTypeId)].insert( + BattleMastersCache[bmTeam][BattlegroundTypeId(bgTypeId)].end(), entry); + LOG_DEBUG("playerbots", "Cached Battmemaster #{} for BG Type {} ({})", entry, bgTypeId, + bmTeam == TEAM_ALLIANCE ? "Alliance" + : bmTeam == TEAM_HORDE ? "Horde" + : "Neutral"); } while (result->NextRow()); @@ -643,7 +633,8 @@ void RandomPlayerbotMgr::CheckBgQueue() isRated = true; } - if (bgQueue.IsPlayerInvitedToRatedArena(player->GetGUID()) || (player->InArena() && player->GetBattleground()->isRated())) + if (bgQueue.IsPlayerInvitedToRatedArena(player->GetGUID()) || + (player->InArena() && player->GetBattleground()->isRated())) isRated = true; if (isRated) @@ -733,7 +724,8 @@ void RandomPlayerbotMgr::CheckBgQueue() isRated = true; } - if (bgQueue.IsPlayerInvitedToRatedArena(bot->GetGUID()) || (bot->InArena() && bot->GetBattleground()->isRated())) + if (bgQueue.IsPlayerInvitedToRatedArena(bot->GetGUID()) || + (bot->InArena() && bot->GetBattleground()->isRated())) isRated = true; if (isRated) @@ -749,17 +741,17 @@ void RandomPlayerbotMgr::CheckBgQueue() BattlegroundData[queueTypeId][bracketId].bgHordeBotCount++; } - if(bot->InBattleground()) + if (bot->InBattleground()) { std::vector* instanceIds = nullptr; uint32 instanceId = bot->GetBattleground()->GetInstanceID(); bool isArena = false; bool isRated = false; - if(bot->InArena()) + if (bot->InArena()) { isArena = true; - if(bot->GetBattleground()->isRated()) + if (bot->GetBattleground()->isRated()) { isRated = true; instanceIds = &BattlegroundData[queueTypeId][bracketId].ratedArenaInstances; @@ -806,36 +798,28 @@ void RandomPlayerbotMgr::CheckBgQueue() uint32 randomBotAutoJoinBGWarsongCount = sPlayerbotAIConfig->randomBotAutoJoinBGWarsongCount; BattlegroundData[BATTLEGROUND_QUEUE_2v2][randomBotAutoJoinArenaBracket].ratedArenaInstanceCount = - std::max( - randomBotAutoJoinBGRatedArena2v2Count, - (BattlegroundData[BATTLEGROUND_QUEUE_2v2][randomBotAutoJoinArenaBracket].ratedArenaInstanceCount - - randomBotAutoJoinBGRatedArena2v2Count) + - randomBotAutoJoinBGRatedArena2v2Count - ); + std::max(randomBotAutoJoinBGRatedArena2v2Count, + (BattlegroundData[BATTLEGROUND_QUEUE_2v2][randomBotAutoJoinArenaBracket].ratedArenaInstanceCount - + randomBotAutoJoinBGRatedArena2v2Count) + + randomBotAutoJoinBGRatedArena2v2Count); BattlegroundData[BATTLEGROUND_QUEUE_3v3][randomBotAutoJoinArenaBracket].ratedArenaInstanceCount = - std::max( - randomBotAutoJoinBGRatedArena3v3Count, - (BattlegroundData[BATTLEGROUND_QUEUE_3v3][randomBotAutoJoinArenaBracket].ratedArenaInstanceCount - - randomBotAutoJoinBGRatedArena3v3Count) + - randomBotAutoJoinBGRatedArena3v3Count - ); + std::max(randomBotAutoJoinBGRatedArena3v3Count, + (BattlegroundData[BATTLEGROUND_QUEUE_3v3][randomBotAutoJoinArenaBracket].ratedArenaInstanceCount - + randomBotAutoJoinBGRatedArena3v3Count) + + randomBotAutoJoinBGRatedArena3v3Count); BattlegroundData[BATTLEGROUND_QUEUE_5v5][randomBotAutoJoinArenaBracket].ratedArenaInstanceCount = - std::max( - randomBotAutoJoinBGRatedArena5v5Count, - (BattlegroundData[BATTLEGROUND_QUEUE_5v5][randomBotAutoJoinArenaBracket].ratedArenaInstanceCount - - randomBotAutoJoinBGRatedArena5v5Count) + - randomBotAutoJoinBGRatedArena5v5Count - ); + std::max(randomBotAutoJoinBGRatedArena5v5Count, + (BattlegroundData[BATTLEGROUND_QUEUE_5v5][randomBotAutoJoinArenaBracket].ratedArenaInstanceCount - + randomBotAutoJoinBGRatedArena5v5Count) + + randomBotAutoJoinBGRatedArena5v5Count); BattlegroundData[BATTLEGROUND_QUEUE_WS][randomBotAutoJoinWarsongBracket].bgInstanceCount = - std::max( - randomBotAutoJoinBGWarsongCount, - (BattlegroundData[BATTLEGROUND_QUEUE_WS][randomBotAutoJoinWarsongBracket].bgInstanceCount - - randomBotAutoJoinBGWarsongCount) + - randomBotAutoJoinBGWarsongCount - ); + std::max(randomBotAutoJoinBGWarsongCount, + (BattlegroundData[BATTLEGROUND_QUEUE_WS][randomBotAutoJoinWarsongBracket].bgInstanceCount - + randomBotAutoJoinBGWarsongCount) + + randomBotAutoJoinBGWarsongCount); } LogBattlegroundInfo(); @@ -855,11 +839,17 @@ void RandomPlayerbotMgr::LogBattlegroundInfo() { auto& bgInfo = bracketIdPair.second; - LOG_INFO("playerbots", "ARENA:{} {}: Player (Skirmish:{}, Rated:{}) Bots (Skirmish:{}, Rated:{}) Total (Skirmish:{} Rated:{}), Instances (Skirmish:{} Rated:{})", - type == ARENA_TYPE_2v2 ? "2v2" : type == ARENA_TYPE_3v3 ? "3v3" : "5v5", std::to_string(bgInfo.minLevel) + "-" + std::to_string(bgInfo.maxLevel), - bgInfo.skirmishArenaPlayerCount, bgInfo.ratedArenaPlayerCount, bgInfo.skirmishArenaBotCount, bgInfo.ratedArenaBotCount, - bgInfo.skirmishArenaPlayerCount + bgInfo.skirmishArenaBotCount, bgInfo.ratedArenaPlayerCount + bgInfo.ratedArenaBotCount, - bgInfo.skirmishArenaInstanceCount, bgInfo.ratedArenaInstanceCount); + LOG_INFO("playerbots", + "ARENA:{} {}: Player (Skirmish:{}, Rated:{}) Bots (Skirmish:{}, Rated:{}) Total (Skirmish:{} " + "Rated:{}), Instances (Skirmish:{} Rated:{})", + type == ARENA_TYPE_2v2 ? "2v2" + : type == ARENA_TYPE_3v3 ? "3v3" + : "5v5", + std::to_string(bgInfo.minLevel) + "-" + std::to_string(bgInfo.maxLevel), + bgInfo.skirmishArenaPlayerCount, bgInfo.ratedArenaPlayerCount, bgInfo.skirmishArenaBotCount, + bgInfo.ratedArenaBotCount, bgInfo.skirmishArenaPlayerCount + bgInfo.skirmishArenaBotCount, + bgInfo.ratedArenaPlayerCount + bgInfo.ratedArenaBotCount, bgInfo.skirmishArenaInstanceCount, + bgInfo.ratedArenaInstanceCount); } continue; } @@ -898,11 +888,11 @@ void RandomPlayerbotMgr::LogBattlegroundInfo() { auto& bgInfo = bracketIdPair.second; - LOG_INFO("playerbots", "BG:{} {}: Player ({}:{}) Bot ({}:{}) Total (A:{} H:{}), Instances {}", - _bgType, std::to_string(bgInfo.minLevel) + "-" + std::to_string(bgInfo.maxLevel), - bgInfo.bgAlliancePlayerCount, bgInfo.bgHordePlayerCount, bgInfo.bgAllianceBotCount, bgInfo.bgHordeBotCount, - bgInfo.bgAlliancePlayerCount + bgInfo.bgAllianceBotCount, bgInfo.bgHordePlayerCount + bgInfo.bgHordeBotCount, - bgInfo.bgInstanceCount); + LOG_INFO("playerbots", "BG:{} {}: Player ({}:{}) Bot ({}:{}) Total (A:{} H:{}), Instances {}", _bgType, + std::to_string(bgInfo.minLevel) + "-" + std::to_string(bgInfo.maxLevel), + bgInfo.bgAlliancePlayerCount, bgInfo.bgHordePlayerCount, bgInfo.bgAllianceBotCount, + bgInfo.bgHordeBotCount, bgInfo.bgAlliancePlayerCount + bgInfo.bgAllianceBotCount, + bgInfo.bgHordePlayerCount + bgInfo.bgHordeBotCount, bgInfo.bgInstanceCount); } } LOG_INFO("playerbots", "BG Queue check finished"); @@ -963,8 +953,8 @@ void RandomPlayerbotMgr::CheckPlayers() if (player->IsGameMaster()) continue; - //if (player->GetSession()->GetSecurity() > SEC_PLAYER) - // continue; + // if (player->GetSession()->GetSecurity() > SEC_PLAYER) + // continue; if (player->GetLevel() > playersLevel) playersLevel = player->GetLevel() + 3; @@ -976,7 +966,8 @@ void RandomPlayerbotMgr::CheckPlayers() void RandomPlayerbotMgr::ScheduleRandomize(uint32 bot, uint32 time) { SetEventValue(bot, "randomize", 1, time); - //SetEventValue(bot, "logout", 1, time + 30 + urand(sPlayerbotAIConfig->randomBotUpdateInterval, sPlayerbotAIConfig->randomBotUpdateInterval * 3)); + // SetEventValue(bot, "logout", 1, time + 30 + urand(sPlayerbotAIConfig->randomBotUpdateInterval, + // sPlayerbotAIConfig->randomBotUpdateInterval * 3)); } void RandomPlayerbotMgr::ScheduleTeleport(uint32 bot, uint32 time) @@ -990,7 +981,8 @@ void RandomPlayerbotMgr::ScheduleTeleport(uint32 bot, uint32 time) void RandomPlayerbotMgr::ScheduleChangeStrategy(uint32 bot, uint32 time) { if (!time) - time = urand(sPlayerbotAIConfig->minRandomBotChangeStrategyTime, sPlayerbotAIConfig->maxRandomBotChangeStrategyTime); + time = urand(sPlayerbotAIConfig->minRandomBotChangeStrategyTime, + sPlayerbotAIConfig->maxRandomBotChangeStrategyTime); SetEventValue(bot, "change_strategy", 1, time); } @@ -1005,19 +997,20 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot) uint32 isValid = GetEventValue(bot, "add"); if (!isValid) { - if (!player || !player->GetGroup()) - { + if (!player || !player->GetGroup()) + { if (player) - LOG_INFO("playerbots", "Bot #{} {}:{} <{}>: log out", bot, IsAlliance(player->getRace()) ? "A" : "H", player->GetLevel(), player->GetName().c_str()); + LOG_INFO("playerbots", "Bot #{} {}:{} <{}>: log out", bot, IsAlliance(player->getRace()) ? "A" : "H", + player->GetLevel(), player->GetName().c_str()); else LOG_INFO("playerbots", "Bot #{}: log out", bot); - SetEventValue(bot, "add", 0, 0); - currentBots.erase(std::remove(currentBots.begin(), currentBots.end(), bot), currentBots.end()); + SetEventValue(bot, "add", 0, 0); + currentBots.erase(std::remove(currentBots.begin(), currentBots.end(), bot), currentBots.end()); - if (player) + if (player) LogoutPlayerBot(botGUID); - } + } return false; } @@ -1031,16 +1024,21 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot) AddPlayerBot(botGUID, 0); SetEventValue(bot, "login", 1, sPlayerbotAIConfig->randomBotUpdateInterval); - uint32 randomTime = urand(sPlayerbotAIConfig->minRandomBotReviveTime, sPlayerbotAIConfig->maxRandomBotReviveTime); + uint32 randomTime = + urand(sPlayerbotAIConfig->minRandomBotReviveTime, sPlayerbotAIConfig->maxRandomBotReviveTime); SetEventValue(bot, "update", 1, randomTime); // do not randomize or teleport immediately after server start (prevent lagging) - if (!GetEventValue(bot, "randomize")) { - randomTime = urand(sPlayerbotAIConfig->randomBotUpdateInterval * 5, sPlayerbotAIConfig->randomBotUpdateInterval * 20); + if (!GetEventValue(bot, "randomize")) + { + randomTime = urand(sPlayerbotAIConfig->randomBotUpdateInterval * 5, + sPlayerbotAIConfig->randomBotUpdateInterval * 20); ScheduleRandomize(bot, randomTime); } - if (!GetEventValue(bot, "teleport")) { - randomTime = urand(sPlayerbotAIConfig->randomBotUpdateInterval * 5, sPlayerbotAIConfig->randomBotUpdateInterval * 20); + if (!GetEventValue(bot, "teleport")) + { + randomTime = urand(sPlayerbotAIConfig->randomBotUpdateInterval * 5, + sPlayerbotAIConfig->randomBotUpdateInterval * 20); ScheduleTeleport(bot, randomTime); } return true; @@ -1060,7 +1058,7 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot) bool update = true; if (botAI) { - //botAI->GetAiObjectContext()->GetValue("random bot update")->Set(true); + // botAI->GetAiObjectContext()->GetValue("random bot update")->Set(true); if (!sRandomPlayerbotMgr->IsRandomBot(player)) update = false; @@ -1080,7 +1078,8 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot) if (update) ProcessBot(player); - uint32 randomTime = urand(sPlayerbotAIConfig->minRandomBotReviveTime, sPlayerbotAIConfig->maxRandomBotReviveTime); + uint32 randomTime = + urand(sPlayerbotAIConfig->minRandomBotReviveTime, sPlayerbotAIConfig->maxRandomBotReviveTime); SetEventValue(bot, "update", 1, randomTime); return true; @@ -1089,10 +1088,12 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot) uint32 logout = GetEventValue(bot, "logout"); if (player && !logout && !isValid) { - LOG_INFO("playerbots", "Bot #{} {}:{} <{}>: log out", bot, IsAlliance(player->getRace()) ? "A" : "H", player->GetLevel(), player->GetName().c_str()); + LOG_INFO("playerbots", "Bot #{} {}:{} <{}>: log out", bot, IsAlliance(player->getRace()) ? "A" : "H", + player->GetLevel(), player->GetName().c_str()); LogoutPlayerBot(botGUID); currentBots.remove(bot); - SetEventValue(bot, "logout", 1, urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime)); + SetEventValue(bot, "logout", 1, + urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime)); return true; } @@ -1109,14 +1110,16 @@ bool RandomPlayerbotMgr::ProcessBot(Player* player) if (player->InBattlegroundQueue()) return false; - //if (player->isDead()) - //return false; + // if (player->isDead()) + // return false; if (player->isDead()) { if (!GetEventValue(bot, "dead")) { - uint32 randomTime = urand(sPlayerbotAIConfig->minRandomBotReviveTime, sPlayerbotAIConfig->maxRandomBotReviveTime); - // LOG_INFO("playerbots", "Mark bot {} as dead, will be revived in {}s.", player->GetName().c_str(), randomTime); + uint32 randomTime = + urand(sPlayerbotAIConfig->minRandomBotReviveTime, sPlayerbotAIConfig->maxRandomBotReviveTime); + // LOG_INFO("playerbots", "Mark bot {} as dead, will be revived in {}s.", player->GetName().c_str(), + // randomTime); SetEventValue(bot, "dead", 1, sPlayerbotAIConfig->maxRandomBotInWorldTime); SetEventValue(bot, "revive", 1, randomTime); return false; @@ -1124,19 +1127,20 @@ bool RandomPlayerbotMgr::ProcessBot(Player* player) if (!GetEventValue(bot, "revive")) { - Revive(player); - return true; + Revive(player); + return true; } return false; } Group* group = player->GetGroup(); - if (group && !group->isLFGGroup() && IsRandomBot(group->GetLeader())) { + if (group && !group->isLFGGroup() && IsRandomBot(group->GetLeader())) + { player->RemoveFromGroup(); LOG_INFO("playerbots", "Bot {} remove from group since leader is random bot.", player->GetName().c_str()); } - //GET_PLAYERBOT_AI(player)->GetAiObjectContext()->GetValue("random bot update")->Set(false); + // GET_PLAYERBOT_AI(player)->GetAiObjectContext()->GetValue("random bot update")->Set(false); // bool randomiser = true; // if (player->GetGuildId()) @@ -1162,8 +1166,10 @@ bool RandomPlayerbotMgr::ProcessBot(Player* player) if (!randomize) { Randomize(player); - LOG_INFO("playerbots", "Bot #{} {}:{} <{}>: randomized", bot, player->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", player->GetLevel(), player->GetName()); - uint32 randomTime = urand(sPlayerbotAIConfig->minRandomBotRandomizeTime, sPlayerbotAIConfig->maxRandomBotRandomizeTime); + LOG_INFO("playerbots", "Bot #{} {}:{} <{}>: randomized", bot, player->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", + player->GetLevel(), player->GetName()); + uint32 randomTime = + urand(sPlayerbotAIConfig->minRandomBotRandomizeTime, sPlayerbotAIConfig->maxRandomBotRandomizeTime); ScheduleRandomize(bot, randomTime); return true; } @@ -1177,7 +1183,8 @@ bool RandomPlayerbotMgr::ProcessBot(Player* player) LOG_INFO("playerbots", "Bot #{} <{}>: teleport for level and refresh", bot, player->GetName()); Refresh(player); RandomTeleportForLevel(player); - uint32 time = urand(sPlayerbotAIConfig->minRandomBotTeleportInterval, sPlayerbotAIConfig->maxRandomBotTeleportInterval); + uint32 time = + urand(sPlayerbotAIConfig->minRandomBotTeleportInterval, sPlayerbotAIConfig->maxRandomBotTeleportInterval); ScheduleTeleport(bot, time); return true; } @@ -1202,7 +1209,6 @@ void RandomPlayerbotMgr::Revive(Player* player) SetEventValue(bot, "dead", 0, 0); SetEventValue(bot, "revive", 0, 0); - Refresh(player); RandomTeleportGrindForLevel(player); } @@ -1234,11 +1240,15 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector& for (auto& loc : locs) tlocs.push_back(WorldPosition(loc)); // Do not teleport to maps disabled in config - tlocs.erase(std::remove_if(tlocs.begin(), tlocs.end(), [bot](WorldPosition l) - { - std::vector::iterator i = find(sPlayerbotAIConfig->randomBotMaps.begin(), sPlayerbotAIConfig->randomBotMaps.end(), l.getMapId()); - return i == sPlayerbotAIConfig->randomBotMaps.end(); - }), tlocs.end()); + tlocs.erase(std::remove_if(tlocs.begin(), tlocs.end(), + [bot](WorldPosition l) + { + std::vector::iterator i = + find(sPlayerbotAIConfig->randomBotMaps.begin(), + sPlayerbotAIConfig->randomBotMaps.end(), l.getMapId()); + return i == sPlayerbotAIConfig->randomBotMaps.end(); + }), + tlocs.end()); if (tlocs.empty()) { LOG_DEBUG("playerbots", "Cannot teleport bot {} - all locations removed by filter", bot->GetName().c_str()); @@ -1258,18 +1268,20 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector& { WorldLocation loc = tlocs[i]; - float x = loc.GetPositionX(); // + (attemtps > 0 ? urand(0, sPlayerbotAIConfig->grindDistance) - sPlayerbotAIConfig->grindDistance / 2 : 0); - float y = loc.GetPositionY(); // + (attemtps > 0 ? urand(0, sPlayerbotAIConfig->grindDistance) - sPlayerbotAIConfig->grindDistance / 2 : 0); + float x = loc.GetPositionX(); // + (attemtps > 0 ? urand(0, sPlayerbotAIConfig->grindDistance) - + // sPlayerbotAIConfig->grindDistance / 2 : 0); + float y = loc.GetPositionY(); // + (attemtps > 0 ? urand(0, sPlayerbotAIConfig->grindDistance) - + // sPlayerbotAIConfig->grindDistance / 2 : 0); float z = loc.GetPositionZ(); Map* map = sMapMgr->FindMap(loc.GetMapId(), 0); if (!map) continue; - + AreaTableEntry const* zone = sAreaTableStore.LookupEntry(map->GetZoneId(bot->GetPhaseMask(), x, y, z)); if (!zone) continue; - + AreaTableEntry const* area = sAreaTableStore.LookupEntry(map->GetAreaId(bot->GetPhaseMask(), x, y, z)); if (!area) continue; @@ -1292,23 +1304,25 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector& PlayerInfo const* pInfo = sObjectMgr->GetPlayerInfo(bot->getRace(true), bot->getClass()); float dis = loc.GetExactDist(pInfo->positionX, pInfo->positionY, pInfo->positionZ); // yunfan: distance check for low level - if (bot->GetLevel() <= 4 && (loc.GetMapId() != pInfo->mapId || dis > 500.0f)) { + if (bot->GetLevel() <= 4 && (loc.GetMapId() != pInfo->mapId || dis > 500.0f)) + { continue; } - if (bot->GetLevel() <= 10 && (loc.GetMapId() != pInfo->mapId || dis > 2500.0f)) { + if (bot->GetLevel() <= 10 && (loc.GetMapId() != pInfo->mapId || dis > 2500.0f)) + { continue; } - if (bot->GetLevel() <= 18 && (loc.GetMapId() != pInfo->mapId || dis > 10000.0f)) { + if (bot->GetLevel() <= 18 && (loc.GetMapId() != pInfo->mapId || dis > 10000.0f)) + { continue; } const LocaleConstant& locale = sWorld->GetDefaultDbcLocale(); - LOG_INFO("playerbots", "Random teleporting bot {} (level {}) to Map: {} ({}) Zone: {} ({}) Area: {} ({}) {},{},{} ({}/{} locations)", - bot->GetName().c_str(), bot->GetLevel(), - map->GetId(), map->GetMapName(), - zone->ID, zone->area_name[locale], - area->ID, area->area_name[locale], - x, y, z, i + 1, tlocs.size()); + LOG_INFO("playerbots", + "Random teleporting bot {} (level {}) to Map: {} ({}) Zone: {} ({}) Area: {} ({}) {},{},{} ({}/{} " + "locations)", + bot->GetName().c_str(), bot->GetLevel(), map->GetId(), map->GetMapName(), zone->ID, + zone->area_name[locale], area->ID, area->area_name[locale], x, y, z, i + 1, tlocs.size()); if (hearth) { @@ -1331,7 +1345,8 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector& if (pmo) pmo->finish(); - LOG_ERROR("playerbots", "Cannot teleport bot {} - no locations available ({} locations)", bot->GetName().c_str(), tlocs.size()); + LOG_ERROR("playerbots", "Cannot teleport bot {} - no locations available ({} locations)", bot->GetName().c_str(), + tlocs.size()); } void RandomPlayerbotMgr::PrepareTeleportCache() @@ -1341,41 +1356,42 @@ void RandomPlayerbotMgr::PrepareTeleportCache() LOG_INFO("playerbots", "Preparing random teleport caches for {} levels...", maxLevel); QueryResult results = WorldDatabase.Query( - "SELECT " - "g.map, " - "position_x, " - "position_y, " - "position_z, " - "t.minlevel " + "SELECT " + "g.map, " + "position_x, " + "position_y, " + "position_z, " + "t.minlevel " "FROM " - "(SELECT " - "map, " - "MIN( c.guid ) guid, " - "t.entry " - "FROM " - "creature c " - "INNER JOIN creature_template t ON c.id1 = t.entry " - "WHERE " - "t.npcflag = 0 " - "AND t.lootid != 0 " - "AND t.unit_flags != 768 " - "AND t.maxlevel - t.minlevel < 3 " - "AND map IN ({}) " - "AND c.id1 != 32820 " - "AND c.spawntimesecs < 1000 " - "AND t.faction != 188 " - "GROUP BY " - "map, " - "ROUND( position_x / 500 ), " - "ROUND( position_y / 500 ), " - "ROUND( position_z / 50), " - "t.entry " - "HAVING " - "count(*) > 7) AS g " - "INNER JOIN creature c ON g.guid = c.guid " - "INNER JOIN creature_template t on c.id1 = t.entry " + "(SELECT " + "map, " + "MIN( c.guid ) guid, " + "t.entry " + "FROM " + "creature c " + "INNER JOIN creature_template t ON c.id1 = t.entry " + "WHERE " + "t.npcflag = 0 " + "AND t.lootid != 0 " + "AND t.unit_flags != 768 " + "AND t.maxlevel - t.minlevel < 3 " + "AND map IN ({}) " + "AND c.id1 != 32820 " + "AND c.spawntimesecs < 1000 " + "AND t.faction != 188 " + "GROUP BY " + "map, " + "ROUND( position_x / 500 ), " + "ROUND( position_y / 500 ), " + "ROUND( position_z / 50), " + "t.entry " + "HAVING " + "count(*) > 7) AS g " + "INNER JOIN creature c ON g.guid = c.guid " + "INNER JOIN creature_template t on c.id1 = t.entry " "ORDER BY " - "t.minlevel;", sPlayerbotAIConfig->randomBotMapsAsString.c_str()); + "t.minlevel;", + sPlayerbotAIConfig->randomBotMapsAsString.c_str()); uint32 collected_locs = 0; if (results) { @@ -1389,8 +1405,11 @@ void RandomPlayerbotMgr::PrepareTeleportCache() uint32 level = fields[4].Get(); WorldLocation loc(mapId, x, y, z, 0); collected_locs++; - for (int32 l = (int32)level - (int32)sPlayerbotAIConfig->randomBotTeleHigherLevel; l <= (int32)level + (int32)sPlayerbotAIConfig->randomBotTeleLowerLevel; l++) { - if (l < 1 || l > maxLevel) { + for (int32 l = (int32)level - (int32)sPlayerbotAIConfig->randomBotTeleHigherLevel; + l <= (int32)level + (int32)sPlayerbotAIConfig->randomBotTeleLowerLevel; l++) + { + if (l < 1 || l > maxLevel) + { continue; } locsPerLevelCache[(uint8)l].push_back(loc); @@ -1398,32 +1417,33 @@ void RandomPlayerbotMgr::PrepareTeleportCache() } while (results->NextRow()); } LOG_INFO("playerbots", "{} locations for level collected.", collected_locs); - + results = WorldDatabase.Query( - "SELECT " - "map, " - "position_x, " - "position_y, " - "position_z, " - "orientation, " - "t.minlevel " + "SELECT " + "map, " + "position_x, " + "position_y, " + "position_z, " + "orientation, " + "t.minlevel " "FROM " - "creature c " - "INNER JOIN creature_template t on c.id1 = t.entry " + "creature c " + "INNER JOIN creature_template t on c.id1 = t.entry " "WHERE " - "t.npcflag & 131072 " - "AND t.npcflag != 135298 " - "AND t.minlevel != 55 " - "AND t.minlevel != 65 " - "AND t.faction != 35 " - "AND t.faction != 474 " - "AND t.faction != 69 " - "AND t.entry != 30606 " - "AND t.entry != 30608 " - "AND t.faction != 69 " - "AND map IN ({}) " + "t.npcflag & 131072 " + "AND t.npcflag != 135298 " + "AND t.minlevel != 55 " + "AND t.minlevel != 65 " + "AND t.faction != 35 " + "AND t.faction != 474 " + "AND t.faction != 69 " + "AND t.entry != 30606 " + "AND t.entry != 30608 " + "AND t.faction != 69 " + "AND map IN ({}) " "ORDER BY " - "t.minlevel;", sPlayerbotAIConfig->randomBotMapsAsString.c_str()); + "t.minlevel;", + sPlayerbotAIConfig->randomBotMapsAsString.c_str()); collected_locs = 0; if (results) { @@ -1438,17 +1458,22 @@ void RandomPlayerbotMgr::PrepareTeleportCache() uint32 level = fields[5].Get(); WorldLocation loc(mapId, x + cos(orient) * 6.0f, y + sin(orient) * 6.0f, z + 2.0f, orient + M_PI); collected_locs++; - for (int32 l = 1; l <= maxLevel; l++) { - if (l <= 60 && level >= 60) { + for (int32 l = 1; l <= maxLevel; l++) + { + if (l <= 60 && level >= 60) + { continue; } - if (l <= 70 && level >= 70) { + if (l <= 70 && level >= 70) + { continue; } - if (l >= 70 && level >= 60 && level <= 70) { + if (l >= 70 && level >= 60 && level <= 70) + { continue; } - if (l >= 30 && level <= 30) { + if (l >= 30 && level <= 30) + { continue; } bankerLocsPerLevelCache[(uint8)l].push_back(loc); @@ -1460,7 +1485,8 @@ void RandomPlayerbotMgr::PrepareTeleportCache() // temporary only use locsPerLevelCache, so disable rpgLocsCacheLevel cache // LOG_INFO("playerbots", "Preparing RPG teleport caches for {} factions...", sFactionTemplateStore.GetNumRows()); - // results = WorldDatabase.Query("SELECT map, position_x, position_y, position_z, r.race, r.minl, r.maxl FROM creature c INNER JOIN playerbots_rpg_races r ON c.id1 = r.entry " + // results = WorldDatabase.Query("SELECT map, position_x, position_y, position_z, r.race, r.minl, r.maxl FROM + // creature c INNER JOIN playerbots_rpg_races r ON c.id1 = r.entry " // "WHERE r.race < 15"); // if (results) // { @@ -1498,10 +1524,14 @@ void RandomPlayerbotMgr::RandomTeleportForLevel(Player* bot) uint32 level = bot->GetLevel(); uint8 race = bot->getRace(); - LOG_DEBUG("playerbots", "Random teleporting bot {} for level {} ({} locations available)", bot->GetName().c_str(), bot->GetLevel(), locsPerLevelCache[level].size()); - if (level > 10 && urand(0, 100) < sPlayerbotAIConfig->probTeleToBankers * 100) { + LOG_DEBUG("playerbots", "Random teleporting bot {} for level {} ({} locations available)", bot->GetName().c_str(), + bot->GetLevel(), locsPerLevelCache[level].size()); + if (level > 10 && urand(0, 100) < sPlayerbotAIConfig->probTeleToBankers * 100) + { RandomTeleport(bot, bankerLocsPerLevelCache[level], true); - } else { + } + else + { RandomTeleport(bot, locsPerLevelCache[level]); } } @@ -1513,7 +1543,8 @@ void RandomPlayerbotMgr::RandomTeleportGrindForLevel(Player* bot) uint32 level = bot->GetLevel(); uint8 race = bot->getRace(); - LOG_DEBUG("playerbots", "Random teleporting bot {} for level {} ({} locations available)", bot->GetName().c_str(), bot->GetLevel(), locsPerLevelCache[level].size()); + LOG_DEBUG("playerbots", "Random teleporting bot {} for level {} ({} locations available)", bot->GetName().c_str(), + bot->GetLevel(), locsPerLevelCache[level].size()); RandomTeleport(bot, locsPerLevelCache[level]); } @@ -1562,37 +1593,41 @@ void RandomPlayerbotMgr::Randomize(Player* bot) if (bot->InBattleground()) return; - if (bot->GetLevel() < 3 || (bot->GetLevel() < 56 && bot->getClass() == CLASS_DEATH_KNIGHT)) { + if (bot->GetLevel() < 3 || (bot->GetLevel() < 56 && bot->getClass() == CLASS_DEATH_KNIGHT)) + { RandomizeFirst(bot); } - else if (bot->GetLevel() < sPlayerbotAIConfig->randomBotMaxLevel || !sPlayerbotAIConfig->downgradeMaxLevelBot) { + else if (bot->GetLevel() < sPlayerbotAIConfig->randomBotMaxLevel || !sPlayerbotAIConfig->downgradeMaxLevelBot) + { uint8 level = bot->GetLevel(); PlayerbotFactory factory(bot, level); factory.Randomize(true); // IncreaseLevel(bot); } - else { + else + { RandomizeFirst(bot); } } void RandomPlayerbotMgr::IncreaseLevel(Player* bot) { - uint32 maxLevel = sPlayerbotAIConfig->randomBotMaxLevel; - if (maxLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) - maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); + uint32 maxLevel = sPlayerbotAIConfig->randomBotMaxLevel; + if (maxLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) + maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); - PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "IncreaseLevel"); - uint32 lastLevel = GetValue(bot, "level"); - uint8 level = bot->GetLevel() + 1; - if (level > maxLevel) { + PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "IncreaseLevel"); + uint32 lastLevel = GetValue(bot, "level"); + uint8 level = bot->GetLevel() + 1; + if (level > maxLevel) + { level = maxLevel; } - if (lastLevel != level) - { + if (lastLevel != level) + { PlayerbotFactory factory(bot, level); factory.Randomize(true); - } + } if (pmo) pmo->finish(); @@ -1600,37 +1635,47 @@ void RandomPlayerbotMgr::IncreaseLevel(Player* bot) void RandomPlayerbotMgr::RandomizeFirst(Player* bot) { - uint32 maxLevel = sPlayerbotAIConfig->randomBotMaxLevel; - if (maxLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) - maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); + uint32 maxLevel = sPlayerbotAIConfig->randomBotMaxLevel; + if (maxLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) + maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); // if lvl sync is enabled, max level is limited by online players lvl if (sPlayerbotAIConfig->syncLevelWithPlayers) - maxLevel = std::max(sPlayerbotAIConfig->randomBotMinLevel, std::min(playersLevel, sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))); + maxLevel = std::max(sPlayerbotAIConfig->randomBotMinLevel, + std::min(playersLevel, sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))); + + PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "RandomizeFirst"); - PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "RandomizeFirst"); - uint32 level; - if (sPlayerbotAIConfig->downgradeMaxLevelBot && bot->GetLevel() >= sPlayerbotAIConfig->randomBotMaxLevel) { - if (bot->getClass() == CLASS_DEATH_KNIGHT) { + if (sPlayerbotAIConfig->downgradeMaxLevelBot && bot->GetLevel() >= sPlayerbotAIConfig->randomBotMaxLevel) + { + if (bot->getClass() == CLASS_DEATH_KNIGHT) + { level = sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL); - } else { + } + else + { level = sPlayerbotAIConfig->randomBotMinLevel; } - } else { + } + else + { level = urand(sPlayerbotAIConfig->randomBotMinLevel, maxLevel); if (urand(1, 100) < 100 * sPlayerbotAIConfig->randomBotMaxLevelChance) level = maxLevel; if (bot->getClass() == CLASS_DEATH_KNIGHT) - level = urand(std::max(sPlayerbotAIConfig->randomBotMinLevel, sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL)), std::max(sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL), maxLevel)); + level = urand( + std::max(sPlayerbotAIConfig->randomBotMinLevel, sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL)), + std::max(sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL), maxLevel)); } - if (sPlayerbotAIConfig->disableRandomLevels) { - level = bot->getClass() == CLASS_DEATH_KNIGHT ? - std::max(sPlayerbotAIConfig->randombotStartingLevel, sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL)) : - sPlayerbotAIConfig->randombotStartingLevel; + if (sPlayerbotAIConfig->disableRandomLevels) + { + level = bot->getClass() == CLASS_DEATH_KNIGHT ? std::max(sPlayerbotAIConfig->randombotStartingLevel, + sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL)) + : sPlayerbotAIConfig->randombotStartingLevel; } SetValue(bot, "level", level); @@ -1638,8 +1683,10 @@ void RandomPlayerbotMgr::RandomizeFirst(Player* bot) PlayerbotFactory factory(bot, level); factory.Randomize(false); - uint32 randomTime = urand(sPlayerbotAIConfig->minRandomBotRandomizeTime, sPlayerbotAIConfig->maxRandomBotRandomizeTime); - uint32 inworldTime = urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime); + uint32 randomTime = + urand(sPlayerbotAIConfig->minRandomBotRandomizeTime, sPlayerbotAIConfig->maxRandomBotRandomizeTime); + uint32 inworldTime = + urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime); PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_UPD_RANDOM_BOTS); stmt->SetData(0, randomTime); @@ -1660,7 +1707,7 @@ void RandomPlayerbotMgr::RandomizeFirst(Player* bot) if (bot->GetGroup()) bot->RemoveFromGroup(); - if (pmo) + if (pmo) pmo->finish(); RandomTeleportForLevel(bot); @@ -1668,8 +1715,8 @@ void RandomPlayerbotMgr::RandomizeFirst(Player* bot) void RandomPlayerbotMgr::RandomizeMin(Player* bot) { - PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "RandomizeMin"); - + PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "RandomizeMin"); + uint32 level = sPlayerbotAIConfig->randomBotMinLevel; SetValue(bot, "level", level); @@ -1677,8 +1724,10 @@ void RandomPlayerbotMgr::RandomizeMin(Player* bot) PlayerbotFactory factory(bot, level); factory.Randomize(false); - uint32 randomTime = urand(sPlayerbotAIConfig->minRandomBotRandomizeTime, sPlayerbotAIConfig->maxRandomBotRandomizeTime); - uint32 inworldTime = urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime); + uint32 randomTime = + urand(sPlayerbotAIConfig->minRandomBotRandomizeTime, sPlayerbotAIConfig->maxRandomBotRandomizeTime); + uint32 inworldTime = + urand(sPlayerbotAIConfig->minRandomBotInWorldTime, sPlayerbotAIConfig->maxRandomBotInWorldTime); PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_UPD_RANDOM_BOTS); stmt->SetData(0, randomTime); @@ -1699,7 +1748,7 @@ void RandomPlayerbotMgr::RandomizeMin(Player* bot) if (bot->GetGroup()) bot->RemoveFromGroup(); - if (pmo) + if (pmo) pmo->finish(); } @@ -1711,12 +1760,15 @@ void RandomPlayerbotMgr::Clear(Player* bot) uint32 RandomPlayerbotMgr::GetZoneLevel(uint16 mapId, float teleX, float teleY, float teleZ) { - uint32 maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); + uint32 maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); uint32 level = 0; - QueryResult results = WorldDatabase.Query("SELECT AVG(t.minlevel) minlevel, AVG(t.maxlevel) maxlevel FROM creature c " - "INNER JOIN creature_template t ON c.id1 = t.entry WHERE map = {} AND minlevel > 1 AND ABS(position_x - {}) < {} AND ABS(position_y - {}) < {}", - mapId, teleX, sPlayerbotAIConfig->randomBotTeleportDistance / 2, teleY, sPlayerbotAIConfig->randomBotTeleportDistance / 2); + QueryResult results = WorldDatabase.Query( + "SELECT AVG(t.minlevel) minlevel, AVG(t.maxlevel) maxlevel FROM creature c " + "INNER JOIN creature_template t ON c.id1 = t.entry WHERE map = {} AND minlevel > 1 AND ABS(position_x - {}) < " + "{} AND ABS(position_y - {}) < {}", + mapId, teleX, sPlayerbotAIConfig->randomBotTeleportDistance / 2, teleY, + sPlayerbotAIConfig->randomBotTeleportDistance / 2); if (results) { @@ -1761,8 +1813,8 @@ void RandomPlayerbotMgr::Refresh(Player* bot) botAI->Reset(); bot->DurabilityRepairAll(false, 1.0f, false); - bot->SetFullHealth(); - bot->SetPvP(true); + bot->SetFullHealth(); + bot->SetPvP(true); PlayerbotFactory factory(bot, bot->GetLevel(), ITEM_QUALITY_RARE); factory.Refresh(); @@ -1813,7 +1865,8 @@ void RandomPlayerbotMgr::GetBots() if (!currentBots.empty()) return; - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_RANDOM_BOTS_BY_OWNER_AND_EVENT); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_RANDOM_BOTS_BY_OWNER_AND_EVENT); stmt->SetData(0, 0); stmt->SetData(1, "add"); if (PreparedQueryResult result = PlayerbotsDatabase.Query(stmt)) @@ -1824,18 +1877,18 @@ void RandomPlayerbotMgr::GetBots() uint32 bot = fields[0].Get(); if (GetEventValue(bot, "add")) currentBots.push_back(bot); - } - while (result->NextRow()); + } while (result->NextRow()); } } std::vector RandomPlayerbotMgr::GetBgBots(uint32 bracket) { - //if (!currentBgBots.empty()) return currentBgBots; + // if (!currentBgBots.empty()) return currentBgBots; std::vector BgBots; - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_RANDOM_BOTS_BY_EVENT_AND_VALUE); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_RANDOM_BOTS_BY_EVENT_AND_VALUE); stmt->SetData(0, "bg"); stmt->SetData(1, bracket); if (PreparedQueryResult result = PlayerbotsDatabase.Query(stmt)) @@ -1845,8 +1898,7 @@ std::vector RandomPlayerbotMgr::GetBgBots(uint32 bracket) Field* fields = result->Fetch(); uint32 bot = fields[0].Get(); BgBots.push_back(bot); - } - while (result->NextRow()); + } while (result->NextRow()); } return std::move(BgBots); @@ -1857,7 +1909,8 @@ uint32 RandomPlayerbotMgr::GetEventValue(uint32 bot, std::string const event) // load all events at once on first event load if (eventCache[bot].empty()) { - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_RANDOM_BOTS_BY_OWNER_AND_BOT); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_RANDOM_BOTS_BY_OWNER_AND_BOT); stmt->SetData(0, 0); stmt->SetData(1, bot); if (PreparedQueryResult result = PlayerbotsDatabase.Query(stmt)) @@ -1873,16 +1926,15 @@ uint32 RandomPlayerbotMgr::GetEventValue(uint32 bot, std::string const event) e.validIn = fields[3].Get(); e.data = fields[4].Get(); eventCache[bot][eventName] = std::move(e); - } - while (result->NextRow()); + } while (result->NextRow()); } } CachedEvent& e = eventCache[bot][event]; /*if (e.IsEmpty()) { - QueryResult results = PlayerbotsDatabase.Query("SELECT `value`, `time`, validIn, `data` FROM playerbots_random_bots WHERE owner = 0 AND bot = {} AND event = {}", - bot, event.c_str()); + QueryResult results = PlayerbotsDatabase.Query("SELECT `value`, `time`, validIn, `data` FROM + playerbots_random_bots WHERE owner = 0 AND bot = {} AND event = {}", bot, event.c_str()); if (results) { @@ -1913,11 +1965,13 @@ std::string const RandomPlayerbotMgr::GetEventData(uint32 bot, std::string const return data; } -uint32 RandomPlayerbotMgr::SetEventValue(uint32 bot, std::string const event, uint32 value, uint32 validIn, std::string const data) +uint32 RandomPlayerbotMgr::SetEventValue(uint32 bot, std::string const event, uint32 value, uint32 validIn, + std::string const data) { PlayerbotsDatabaseTransaction trans = PlayerbotsDatabase.BeginTransaction(); - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_DEL_RANDOM_BOTS_BY_OWNER_AND_EVENT); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_DEL_RANDOM_BOTS_BY_OWNER_AND_EVENT); stmt->SetData(0, 0); stmt->SetData(1, bot); stmt->SetData(2, event.c_str()); @@ -1950,20 +2004,14 @@ uint32 RandomPlayerbotMgr::SetEventValue(uint32 bot, std::string const event, ui return value; } -uint32 RandomPlayerbotMgr::GetValue(uint32 bot, std::string const type) -{ - return GetEventValue(bot, type); -} +uint32 RandomPlayerbotMgr::GetValue(uint32 bot, std::string const type) { return GetEventValue(bot, type); } uint32 RandomPlayerbotMgr::GetValue(Player* bot, std::string const type) { return GetValue(bot->GetGUID().GetCounter(), type); } -std::string const RandomPlayerbotMgr::GetData(uint32 bot, std::string const type) -{ - return GetEventData(bot, type); -} +std::string const RandomPlayerbotMgr::GetData(uint32 bot, std::string const type) { return GetEventData(bot, type); } void RandomPlayerbotMgr::SetValue(uint32 bot, std::string const type, uint32 value, std::string const data) { @@ -2038,10 +2086,12 @@ bool RandomPlayerbotMgr::HandlePlayerbotConsoleCommand(ChatHandler* handler, cha std::string const name = cmd.size() > prefix.size() + 1 ? cmd.substr(1 + prefix.size()) : "%"; std::vector botIds; - for (std::vector::iterator i = sPlayerbotAIConfig->randomBotAccounts.begin(); i != sPlayerbotAIConfig->randomBotAccounts.end(); ++i) + for (std::vector::iterator i = sPlayerbotAIConfig->randomBotAccounts.begin(); + i != sPlayerbotAIConfig->randomBotAccounts.end(); ++i) { uint32 account = *i; - if (QueryResult results = CharacterDatabase.Query("SELECT guid FROM characters WHERE account = {} AND name like '{}'", account, name.c_str())) + if (QueryResult results = CharacterDatabase.Query( + "SELECT guid FROM characters WHERE account = {} AND name like '{}'", account, name.c_str())) { do { @@ -2049,7 +2099,8 @@ bool RandomPlayerbotMgr::HandlePlayerbotConsoleCommand(ChatHandler* handler, cha uint32 botId = fields[0].Get(); ObjectGuid guid = ObjectGuid::Create(botId); - if (!sRandomPlayerbotMgr->IsRandomBot(guid.GetCounter())) { + if (!sRandomPlayerbotMgr->IsRandomBot(guid.GetCounter())) + { continue; } Player* bot = ObjectAccessor::FindPlayer(guid); @@ -2058,7 +2109,7 @@ bool RandomPlayerbotMgr::HandlePlayerbotConsoleCommand(ChatHandler* handler, cha botIds.push_back(botId); } while (results->NextRow()); - } + } } if (botIds.empty()) @@ -2075,7 +2126,8 @@ bool RandomPlayerbotMgr::HandlePlayerbotConsoleCommand(ChatHandler* handler, cha if (!bot) continue; - LOG_INFO("playerbots", "[{}/{}] Processing command {} for bot {}", processed++, botIds.size(), cmd.c_str(), bot->GetName().c_str()); + LOG_INFO("playerbots", "[{}/{}] Processing command {} for bot {}", processed++, botIds.size(), cmd.c_str(), + bot->GetName().c_str()); ConsoleCommandHandler handler = j->second; (sRandomPlayerbotMgr->*handler)(bot); @@ -2137,9 +2189,10 @@ void RandomPlayerbotMgr::OnPlayerLogout(Player* player) players.erase(i); } -void RandomPlayerbotMgr::OnBotLoginInternal(Player * const bot) +void RandomPlayerbotMgr::OnBotLoginInternal(Player* const bot) { - LOG_INFO("playerbots", "{}/{} Bot {} logged in", playerBots.size(), sRandomPlayerbotMgr->GetMaxAllowedBotCount(), bot->GetName().c_str()); + LOG_INFO("playerbots", "{}/{} Bot {} logged in", playerBots.size(), sRandomPlayerbotMgr->GetMaxAllowedBotCount(), + bot->GetName().c_str()); } void RandomPlayerbotMgr::OnPlayerLogin(Player* player) @@ -2149,14 +2202,14 @@ void RandomPlayerbotMgr::OnPlayerLogin(Player* player) for (PlayerBotMap::const_iterator it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; - if (player == bot/* || GET_PLAYERBOT_AI(player)*/) // TEST + if (player == bot /* || GET_PLAYERBOT_AI(player)*/) // TEST continue; Cell playerCell(player->GetPositionX(), player->GetPositionY()); Cell botCell(bot->GetPositionX(), bot->GetPositionY()); - //if (playerCell == botCell) - //botsNearby++; + // if (playerCell == botCell) + // botsNearby++; Group* group = bot->GetGroup(); if (!group) @@ -2184,10 +2237,10 @@ void RandomPlayerbotMgr::OnPlayerLogin(Player* player) { WorldPosition botPos(player); - //botPos.GetReachableRandomPointOnGround(player, sPlayerbotAIConfig->reactDistance * 2, true); + // botPos.GetReachableRandomPointOnGround(player, sPlayerbotAIConfig->reactDistance * 2, true); - //player->TeleportTo(botPos); - //player->Relocate(botPos.coord_x, botPos.coord_y, botPos.coord_z, botPos.orientation); + // player->TeleportTo(botPos); + // player->Relocate(botPos.coord_x, botPos.coord_y, botPos.coord_z, botPos.orientation); if (!player->GetFactionTemplateEntry()) { @@ -2284,7 +2337,7 @@ void RandomPlayerbotMgr::PrintStats() uint32 taxi = 0; uint32 moving = 0; uint32 mounted = 0; - uint32 stateCount[MAX_TRAVEL_STATE + 1] = { 0 }; + uint32 stateCount[MAX_TRAVEL_STATE + 1] = {0}; std::vector> questCount; for (PlayerBotMap::iterator i = playerBots.begin(); i != playerBots.end(); ++i) { @@ -2317,8 +2370,8 @@ void RandomPlayerbotMgr::PrintStats() if (bot->isDead()) { ++dead; - //if (!GetEventValue(botId, "dead")) - //++revive; + // if (!GetEventValue(botId, "dead")) + //++revive; } uint8 spec = AiFactory::GetPlayerSpecTab(bot); @@ -2396,13 +2449,13 @@ void RandomPlayerbotMgr::PrintStats() } LOG_INFO("playerbots", "Bots level:"); - uint32 maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); - for (uint8 i = 0; i < 10; ++i) + uint32 maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); + for (uint8 i = 0; i < 10; ++i) { if (!alliance[i] && !horde[i]) continue; - uint32 from = i*10; + uint32 from = i * 10; uint32 to = std::min(from + 9, maxLevel); if (!from) from = 1; @@ -2431,12 +2484,12 @@ void RandomPlayerbotMgr::PrintStats() LOG_INFO("playerbots", " Active: {}", active); LOG_INFO("playerbots", " Moving: {}", moving); - //LOG_INFO("playerbots", "Bots to:"); - //LOG_INFO("playerbots", " update: {}", update); - //LOG_INFO("playerbots", " randomize: {}", randomize); - //LOG_INFO("playerbots", " teleport: {}", teleport); - //LOG_INFO("playerbots", " change_strategy: {}", changeStrategy); - //LOG_INFO("playerbots", " revive: {}", revive); + // LOG_INFO("playerbots", "Bots to:"); + // LOG_INFO("playerbots", " update: {}", update); + // LOG_INFO("playerbots", " randomize: {}", randomize); + // LOG_INFO("playerbots", " teleport: {}", teleport); + // LOG_INFO("playerbots", " change_strategy: {}", changeStrategy); + // LOG_INFO("playerbots", " revive: {}", revive); LOG_INFO("playerbots", " On taxi: {}", taxi); LOG_INFO("playerbots", " On mount: {}", mounted); @@ -2444,22 +2497,24 @@ void RandomPlayerbotMgr::PrintStats() LOG_INFO("playerbots", " Dead: {}", dead); LOG_INFO("playerbots", "Bots questing:"); - LOG_INFO("playerbots", " Picking quests: {}", stateCount[TRAVEL_STATE_TRAVEL_PICK_UP_QUEST] + stateCount[TRAVEL_STATE_WORK_PICK_UP_QUEST]); - LOG_INFO("playerbots", " Doing quests: {}", stateCount[TRAVEL_STATE_TRAVEL_DO_QUEST] + stateCount[TRAVEL_STATE_WORK_DO_QUEST]); - LOG_INFO("playerbots", " Completing quests: {}", stateCount[TRAVEL_STATE_TRAVEL_HAND_IN_QUEST] + stateCount[TRAVEL_STATE_WORK_HAND_IN_QUEST]); + LOG_INFO("playerbots", " Picking quests: {}", + stateCount[TRAVEL_STATE_TRAVEL_PICK_UP_QUEST] + stateCount[TRAVEL_STATE_WORK_PICK_UP_QUEST]); + LOG_INFO("playerbots", " Doing quests: {}", + stateCount[TRAVEL_STATE_TRAVEL_DO_QUEST] + stateCount[TRAVEL_STATE_WORK_DO_QUEST]); + LOG_INFO("playerbots", " Completing quests: {}", + stateCount[TRAVEL_STATE_TRAVEL_HAND_IN_QUEST] + stateCount[TRAVEL_STATE_WORK_HAND_IN_QUEST]); LOG_INFO("playerbots", " Idling: {}", stateCount[TRAVEL_STATE_IDLE]); - /*sort(questCount.begin(), questCount.end(), [](std::pair i, std::pair j) {return i.second > j.second; }); + /*sort(questCount.begin(), questCount.end(), [](std::pair i, std::pair j) + {return i.second > j.second; }); LOG_INFO("playerbots", "Bots top quests:"); uint32 cnt = 0; for (auto& quest : questCount) { - LOG_INFO("playerbots", " [{}]: {} ({})", quest.second, quest.first->GetTitle().c_str(), quest.first->GetQuestLevel()); - cnt++; - if (cnt > 25) - break; + LOG_INFO("playerbots", " [{}]: {} ({})", quest.second, quest.first->GetTitle().c_str(), + quest.first->GetQuestLevel()); cnt++; if (cnt > 25) break; } */ } @@ -2471,7 +2526,8 @@ double RandomPlayerbotMgr::GetBuyMultiplier(Player* bot) if (!value) { value = urand(50, 120); - uint32 validIn = urand(sPlayerbotAIConfig->minRandomBotsPriceChangeInterval, sPlayerbotAIConfig->maxRandomBotsPriceChangeInterval); + uint32 validIn = urand(sPlayerbotAIConfig->minRandomBotsPriceChangeInterval, + sPlayerbotAIConfig->maxRandomBotsPriceChangeInterval); SetEventValue(id, "buymultiplier", value, validIn); } @@ -2485,7 +2541,8 @@ double RandomPlayerbotMgr::GetSellMultiplier(Player* bot) if (!value) { value = urand(80, 250); - uint32 validIn = urand(sPlayerbotAIConfig->minRandomBotsPriceChangeInterval, sPlayerbotAIConfig->maxRandomBotsPriceChangeInterval); + uint32 validIn = urand(sPlayerbotAIConfig->minRandomBotsPriceChangeInterval, + sPlayerbotAIConfig->maxRandomBotsPriceChangeInterval); SetEventValue(id, "sellmultiplier", value, validIn); } @@ -2509,8 +2566,8 @@ void RandomPlayerbotMgr::SetTradeDiscount(Player* bot, Player* master, uint32 va if (!master) return; - uint32 botId = bot->GetGUID().GetCounter(); - uint32 masterId = master->GetGUID().GetCounter(); + uint32 botId = bot->GetGUID().GetCounter(); + uint32 masterId = master->GetGUID().GetCounter(); std::ostringstream name; name << "trade_discount_" << masterId; @@ -2522,7 +2579,7 @@ uint32 RandomPlayerbotMgr::GetTradeDiscount(Player* bot, Player* master) if (!master) return 0; - uint32 botId = bot->GetGUID().GetCounter(); + uint32 botId = bot->GetGUID().GetCounter(); uint32 masterId = master->GetGUID().GetCounter(); std::ostringstream name; @@ -2577,7 +2634,7 @@ void RandomPlayerbotMgr::ChangeStrategyOnce(Player* player) { uint32 bot = player->GetGUID().GetCounter(); - if (frand(0.f, 100.f) > sPlayerbotAIConfig->randomBotRpgChance) // select grind / pvp + if (frand(0.f, 100.f) > sPlayerbotAIConfig->randomBotRpgChance) // select grind / pvp { LOG_INFO("playerbots", "Bot #{} <{}>: sent to grind spot", bot, player->GetName().c_str()); RandomTeleportForLevel(player); @@ -2594,7 +2651,8 @@ void RandomPlayerbotMgr::RandomTeleportForRpg(Player* bot) { uint32 race = bot->getRace(); uint32 level = bot->GetLevel(); - LOG_DEBUG("playerbots", "Random teleporting bot {} for RPG ({} locations available)", bot->GetName().c_str(), rpgLocsCacheLevel[race].size()); + LOG_DEBUG("playerbots", "Random teleporting bot {} for RPG ({} locations available)", bot->GetName().c_str(), + rpgLocsCacheLevel[race].size()); RandomTeleport(bot, rpgLocsCacheLevel[race][level], true); } @@ -2602,7 +2660,8 @@ void RandomPlayerbotMgr::Remove(Player* bot) { ObjectGuid owner = bot->GetGUID(); - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_DEL_RANDOM_BOTS_BY_OWNER); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_DEL_RANDOM_BOTS_BY_OWNER); stmt->SetData(0, 0); stmt->SetData(1, owner.GetCounter()); PlayerbotsDatabase.Execute(stmt); @@ -2631,12 +2690,14 @@ ObjectGuid const RandomPlayerbotMgr::GetBattleMasterGUID(Player* bot, Battlegrou TeamId team = bot->GetTeamId(); std::vector Bms; - for (auto i = std::begin(BattleMastersCache[team][bgTypeId]); i != std::end(BattleMastersCache[team][bgTypeId]); ++i) + for (auto i = std::begin(BattleMastersCache[team][bgTypeId]); i != std::end(BattleMastersCache[team][bgTypeId]); + ++i) { Bms.insert(Bms.end(), *i); } - for (auto i = std::begin(BattleMastersCache[TEAM_NEUTRAL][bgTypeId]); i != std::end(BattleMastersCache[TEAM_NEUTRAL][bgTypeId]); ++i) + for (auto i = std::begin(BattleMastersCache[TEAM_NEUTRAL][bgTypeId]); + i != std::end(BattleMastersCache[TEAM_NEUTRAL][bgTypeId]); ++i) { Bms.insert(Bms.end(), *i); } diff --git a/src/RandomPlayerbotMgr.h b/src/RandomPlayerbotMgr.h index 5c33c609..cfc82dfb 100644 --- a/src/RandomPlayerbotMgr.h +++ b/src/RandomPlayerbotMgr.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RANDOMPLAYERBOTMGR_H @@ -7,7 +8,8 @@ #include "PlayerbotMgr.h" -struct BattlegroundInfo { +struct BattlegroundInfo +{ std::vector bgInstances; std::vector ratedArenaInstances; std::vector skirmishArenaInstances; @@ -16,9 +18,9 @@ struct BattlegroundInfo { uint32 skirmishArenaInstanceCount = 0; uint32 minLevel = 0; uint32 maxLevel = 0; - uint32 activeRatedArenaQueue = 0; // 0 = Inactive, 1 = Active - uint32 activeSkirmishArenaQueue = 0; // 0 = Inactive, 1 = Active - uint32 activeBgQueue = 0; // 0 = Inactive, 1 = Active + uint32 activeRatedArenaQueue = 0; // 0 = Inactive, 1 = Active + uint32 activeSkirmishArenaQueue = 0; // 0 = Inactive, 1 = Active + uint32 activeBgQueue = 0; // 0 = Inactive, 1 = Active // Bots (Arena) uint32 ratedArenaBotCount = 0; @@ -43,21 +45,27 @@ class WorldLocation; class CachedEvent { - public: - CachedEvent() : value(0), lastChangeTime(0), validIn(0), data("") { } - CachedEvent(const CachedEvent& other) : value(other.value), lastChangeTime(other.lastChangeTime), validIn(other.validIn), data(other.data) { } - CachedEvent(uint32 value, uint32 lastChangeTime, uint32 validIn, std::string const data = "") : value(value), lastChangeTime(lastChangeTime), validIn(validIn), data(data) { } +public: + CachedEvent() : value(0), lastChangeTime(0), validIn(0), data("") {} + CachedEvent(const CachedEvent& other) + : value(other.value), lastChangeTime(other.lastChangeTime), validIn(other.validIn), data(other.data) + { + } + CachedEvent(uint32 value, uint32 lastChangeTime, uint32 validIn, std::string const data = "") + : value(value), lastChangeTime(lastChangeTime), validIn(validIn), data(data) + { + } - bool IsEmpty() { return !lastChangeTime; } + bool IsEmpty() { return !lastChangeTime; } - public: - uint32 value; - uint32 lastChangeTime; - uint32 validIn; - std::string data; +public: + uint32 value; + uint32 lastChangeTime; + uint32 validIn; + std::string data; }; -//https://gist.github.com/bradley219/5373998 +// https://gist.github.com/bradley219/5373998 class botPIDImpl; class botPID @@ -82,117 +90,121 @@ private: class RandomPlayerbotMgr : public PlayerbotHolder { - public: - RandomPlayerbotMgr(); - virtual ~RandomPlayerbotMgr(); - static RandomPlayerbotMgr* instance() - { - static RandomPlayerbotMgr instance; - return &instance; - } +public: + RandomPlayerbotMgr(); + virtual ~RandomPlayerbotMgr(); + static RandomPlayerbotMgr* instance() + { + static RandomPlayerbotMgr instance; + return &instance; + } - void LogPlayerLocation(); - void UpdateAIInternal(uint32 elapsed, bool minimal = false) override; + void LogPlayerLocation(); + void UpdateAIInternal(uint32 elapsed, bool minimal = false) override; - private: - void ScaleBotActivity(); +private: + void ScaleBotActivity(); - public: - uint32 activeBots = 0; - static bool HandlePlayerbotConsoleCommand(ChatHandler* handler, char const* args); - bool IsRandomBot(Player* bot); - bool IsRandomBot(ObjectGuid::LowType bot); - void Randomize(Player* bot); - void Clear(Player* bot); - void RandomizeFirst(Player* bot); - void RandomizeMin(Player* bot); - void IncreaseLevel(Player* bot); - void ScheduleTeleport(uint32 bot, uint32 time = 0); - void ScheduleChangeStrategy(uint32 bot, uint32 time = 0); - void HandleCommand(uint32 type, std::string const text, Player* fromPlayer, std::string channelName = ""); - std::string const HandleRemoteCommand(std::string const request); - void OnPlayerLogout(Player* player); - void OnPlayerLogin(Player* player); - void OnPlayerLoginError(uint32 bot); - Player* GetRandomPlayer(); - std::vector GetPlayers() { return players; }; - PlayerBotMap GetAllBots() { return playerBots; }; - void PrintStats(); - double GetBuyMultiplier(Player* bot); - double GetSellMultiplier(Player* bot); - void AddTradeDiscount(Player* bot, Player* master, int32 value); - void SetTradeDiscount(Player* bot, Player* master, uint32 value); - uint32 GetTradeDiscount(Player* bot, Player* master); - void Refresh(Player* bot); - void RandomTeleportForLevel(Player* bot); - void RandomTeleportGrindForLevel(Player* bot); - void RandomTeleportForRpg(Player* bot); - uint32 GetMaxAllowedBotCount(); - bool ProcessBot(Player* player); - void Revive(Player* player); - void ChangeStrategy(Player* player); - void ChangeStrategyOnce(Player* player); +public: + uint32 activeBots = 0; + static bool HandlePlayerbotConsoleCommand(ChatHandler* handler, char const* args); + bool IsRandomBot(Player* bot); + bool IsRandomBot(ObjectGuid::LowType bot); + void Randomize(Player* bot); + void Clear(Player* bot); + void RandomizeFirst(Player* bot); + void RandomizeMin(Player* bot); + void IncreaseLevel(Player* bot); + void ScheduleTeleport(uint32 bot, uint32 time = 0); + void ScheduleChangeStrategy(uint32 bot, uint32 time = 0); + void HandleCommand(uint32 type, std::string const text, Player* fromPlayer, std::string channelName = ""); + std::string const HandleRemoteCommand(std::string const request); + void OnPlayerLogout(Player* player); + void OnPlayerLogin(Player* player); + void OnPlayerLoginError(uint32 bot); + Player* GetRandomPlayer(); + std::vector GetPlayers() { return players; }; + PlayerBotMap GetAllBots() { return playerBots; }; + void PrintStats(); + double GetBuyMultiplier(Player* bot); + double GetSellMultiplier(Player* bot); + void AddTradeDiscount(Player* bot, Player* master, int32 value); + void SetTradeDiscount(Player* bot, Player* master, uint32 value); + uint32 GetTradeDiscount(Player* bot, Player* master); + void Refresh(Player* bot); + void RandomTeleportForLevel(Player* bot); + void RandomTeleportGrindForLevel(Player* bot); + void RandomTeleportForRpg(Player* bot); + uint32 GetMaxAllowedBotCount(); + bool ProcessBot(Player* player); + void Revive(Player* player); + void ChangeStrategy(Player* player); + void ChangeStrategyOnce(Player* player); uint32 GetValue(Player* bot, std::string const type); - uint32 GetValue(uint32 bot, std::string const type); - std::string const GetData(uint32 bot, std::string const type); - void SetValue(uint32 bot, std::string const type, uint32 value, std::string const data = ""); - void SetValue(Player* bot, std::string const type, uint32 value, std::string const data = ""); - void Remove(Player* bot); - ObjectGuid const GetBattleMasterGUID(Player* bot, BattlegroundTypeId bgTypeId); - CreatureData const* GetCreatureDataByEntry(uint32 entry); - void LoadBattleMastersCache(); - std::map> BattlegroundData; - std::map>> VisualBots; - std::map>> Supporters; - std::map> LfgDungeons; - void CheckBgQueue(); - void CheckLfgQueue(); - void CheckPlayers(); - void LogBattlegroundInfo(); + uint32 GetValue(uint32 bot, std::string const type); + std::string const GetData(uint32 bot, std::string const type); + void SetValue(uint32 bot, std::string const type, uint32 value, std::string const data = ""); + void SetValue(Player* bot, std::string const type, uint32 value, std::string const data = ""); + void Remove(Player* bot); + ObjectGuid const GetBattleMasterGUID(Player* bot, BattlegroundTypeId bgTypeId); + CreatureData const* GetCreatureDataByEntry(uint32 entry); + void LoadBattleMastersCache(); + std::map> BattlegroundData; + std::map>> VisualBots; + std::map>> Supporters; + std::map> LfgDungeons; + void CheckBgQueue(); + void CheckLfgQueue(); + void CheckPlayers(); + void LogBattlegroundInfo(); - std::map>> getBattleMastersCache() { return BattleMastersCache; } + std::map>> getBattleMastersCache() + { + return BattleMastersCache; + } - float getActivityMod() { return activityMod; } - float getActivityPercentage() { return activityMod * 100.0f; } - void setActivityPercentage(float percentage) { activityMod = percentage / 100.0f; } + float getActivityMod() { return activityMod; } + float getActivityPercentage() { return activityMod * 100.0f; } + void setActivityPercentage(float percentage) { activityMod = percentage / 100.0f; } - protected: - void OnBotLoginInternal(Player* const bot) override; +protected: + void OnBotLoginInternal(Player* const bot) override; - private: - //pid values are set in constructor - botPID pid = botPID(1, 50, -50, 0, 0, 0); - float activityMod = 0.25; - uint32 GetEventValue(uint32 bot, std::string const event); - std::string const GetEventData(uint32 bot, std::string const event); - uint32 SetEventValue(uint32 bot, std::string const event, uint32 value, uint32 validIn, std::string const data = ""); - void GetBots(); - std::vector GetBgBots(uint32 bracket); - time_t BgCheckTimer; - time_t LfgCheckTimer; - time_t PlayersCheckTimer; - uint32 AddRandomBots(); - bool ProcessBot(uint32 bot); - void ScheduleRandomize(uint32 bot, uint32 time); - void RandomTeleport(Player* bot); - void RandomTeleport(Player* bot, std::vector& locs, bool hearth = false); - uint32 GetZoneLevel(uint16 mapId, float teleX, float teleY, float teleZ); - void PrepareTeleportCache(); - typedef void(RandomPlayerbotMgr::*ConsoleCommandHandler)(Player*); +private: + // pid values are set in constructor + botPID pid = botPID(1, 50, -50, 0, 0, 0); + float activityMod = 0.25; + uint32 GetEventValue(uint32 bot, std::string const event); + std::string const GetEventData(uint32 bot, std::string const event); + uint32 SetEventValue(uint32 bot, std::string const event, uint32 value, uint32 validIn, + std::string const data = ""); + void GetBots(); + std::vector GetBgBots(uint32 bracket); + time_t BgCheckTimer; + time_t LfgCheckTimer; + time_t PlayersCheckTimer; + uint32 AddRandomBots(); + bool ProcessBot(uint32 bot); + void ScheduleRandomize(uint32 bot, uint32 time); + void RandomTeleport(Player* bot); + void RandomTeleport(Player* bot, std::vector& locs, bool hearth = false); + uint32 GetZoneLevel(uint16 mapId, float teleX, float teleY, float teleZ); + void PrepareTeleportCache(); + typedef void (RandomPlayerbotMgr::*ConsoleCommandHandler)(Player*); - std::vector players; - uint32 processTicks; - std::map> locsPerLevelCache; - std::map> bankerLocsPerLevelCache; + std::vector players; + uint32 processTicks; + std::map> locsPerLevelCache; + std::map> bankerLocsPerLevelCache; - // std::map> rpgLocsCache; - std::map>> rpgLocsCacheLevel; - std::map>> BattleMastersCache; - std::map> eventCache; - std::list currentBots; - uint32 bgBotsCount; - uint32 playersLevel; - PerformanceMonitorOperation* totalPmo; + // std::map> rpgLocsCache; + std::map>> rpgLocsCacheLevel; + std::map>> BattleMastersCache; + std::map> eventCache; + std::list currentBots; + uint32 bgBotsCount; + uint32 playersLevel; + PerformanceMonitorOperation* totalPmo; }; #define sRandomPlayerbotMgr RandomPlayerbotMgr::instance() diff --git a/src/ServerFacade.cpp b/src/ServerFacade.cpp index 2c41edfc..65e5af0a 100644 --- a/src/ServerFacade.cpp +++ b/src/ServerFacade.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ServerFacade.h" + #include "Playerbots.h" #include "TargetedMovementGenerator.h" @@ -15,7 +17,7 @@ float ServerFacade::GetDistance2d(Unit* unit, WorldObject* wo) return std::round(dist * 10.0f) / 10.0f; } -float ServerFacade::GetDistance2d(Unit *unit, float x, float y) +float ServerFacade::GetDistance2d(Unit* unit, float x, float y) { float dist = unit->GetDistance2d(x, y); return std::round(dist * 10.0f) / 10.0f; @@ -23,25 +25,19 @@ float ServerFacade::GetDistance2d(Unit *unit, float x, float y) bool ServerFacade::IsDistanceLessThan(float dist1, float dist2) { - //return dist1 - dist2 < sPlayerbotAIConfig->targetPosRecalcDistance; + // return dist1 - dist2 < sPlayerbotAIConfig->targetPosRecalcDistance; return dist1 < dist2; } bool ServerFacade::IsDistanceGreaterThan(float dist1, float dist2) { - //return dist1 - dist2 > sPlayerbotAIConfig->targetPosRecalcDistance; + // return dist1 - dist2 > sPlayerbotAIConfig->targetPosRecalcDistance; return dist1 > dist2; } -bool ServerFacade::IsDistanceGreaterOrEqualThan(float dist1, float dist2) -{ - return !IsDistanceLessThan(dist1, dist2); -} +bool ServerFacade::IsDistanceGreaterOrEqualThan(float dist1, float dist2) { return !IsDistanceLessThan(dist1, dist2); } -bool ServerFacade::IsDistanceLessOrEqualThan(float dist1, float dist2) -{ - return !IsDistanceGreaterThan(dist1, dist2); -} +bool ServerFacade::IsDistanceLessOrEqualThan(float dist1, float dist2) { return !IsDistanceGreaterThan(dist1, dist2); } void ServerFacade::SetFacingTo(Player* bot, WorldObject* wo, bool force) { @@ -50,8 +46,8 @@ void ServerFacade::SetFacingTo(Player* bot, WorldObject* wo, bool force) // bot->SetFacingTo(bot->GetAngle(wo)); // else // { - bot->SetOrientation(angle); - bot->SendMovementFlagUpdate(); + bot->SetOrientation(angle); + bot->SendMovementFlagUpdate(); // } } diff --git a/src/ServerFacade.h b/src/ServerFacade.h index 92f2aaf5..169e941f 100644 --- a/src/ServerFacade.h +++ b/src/ServerFacade.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SERVERFACADE_H @@ -13,26 +14,26 @@ class WorldObject; class ServerFacade { - public: - ServerFacade() { }; - virtual ~ServerFacade() { }; - static ServerFacade* instance() - { - static ServerFacade instance; - return &instance; - } +public: + ServerFacade(){}; + virtual ~ServerFacade(){}; + static ServerFacade* instance() + { + static ServerFacade instance; + return &instance; + } - public: - float GetDistance2d(Unit* unit, WorldObject* wo); - float GetDistance2d(Unit* unit, float x, float y); - bool IsDistanceLessThan(float dist1, float dist2); - bool IsDistanceGreaterThan(float dist1, float dist2); - bool IsDistanceGreaterOrEqualThan(float dist1, float dist2); - bool IsDistanceLessOrEqualThan(float dist1, float dist2); +public: + float GetDistance2d(Unit* unit, WorldObject* wo); + float GetDistance2d(Unit* unit, float x, float y); + bool IsDistanceLessThan(float dist1, float dist2); + bool IsDistanceGreaterThan(float dist1, float dist2); + bool IsDistanceGreaterOrEqualThan(float dist1, float dist2); + bool IsDistanceLessOrEqualThan(float dist1, float dist2); - void SetFacingTo(Player* bot, WorldObject* wo, bool force = false); + void SetFacingTo(Player* bot, WorldObject* wo, bool force = false); - Unit* GetChaseTarget(Unit* target); + Unit* GetChaseTarget(Unit* target); }; #define sServerFacade ServerFacade::instance() diff --git a/src/Talentspec.cpp b/src/Talentspec.cpp index fcf08445..39a75702 100644 --- a/src/Talentspec.cpp +++ b/src/Talentspec.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "Talentspec.h" + #include "Event.h" #include "Playerbots.h" @@ -11,7 +13,7 @@ uint32 TalentSpec::TalentListEntry::tabPage() const return talentTabInfo->TalentTabID == 41 ? 1 : talentTabInfo->tabpage; } -//Checks a talent link on basic validity. +// Checks a talent link on basic validity. bool TalentSpec::CheckTalentLink(std::string const link, std::ostringstream* out) { std::string const validChar = "-"; @@ -50,10 +52,7 @@ uint32 TalentSpec::PointstoLevel(uint32 points) const return uint32(ceil(points / sWorld->getRate(RATE_TALENT))) + 9; } -TalentSpec::TalentSpec(uint32 classMask) -{ - GetTalents(classMask); -} +TalentSpec::TalentSpec(uint32 classMask) { GetTalents(classMask); } TalentSpec::TalentSpec(TalentSpec* base, std::string const link) { @@ -73,7 +72,7 @@ TalentSpec::TalentSpec(Player* bot, std::string const link) ReadTalents(link); } -//Check the talentspec for errors. +// Check the talentspec for errors. bool TalentSpec::CheckTalents(uint32 level, std::ostringstream* out) { for (auto& entry : talents) @@ -81,7 +80,8 @@ bool TalentSpec::CheckTalents(uint32 level, std::ostringstream* out) if (entry.rank > entry.maxRank) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(entry.talentInfo->RankID[0]); - *out << "spec is not for this class. " << spellInfo->SpellName[0] << " has " << (entry.rank - entry.maxRank) << " points above max rank."; + *out << "spec is not for this class. " << spellInfo->SpellName[0] << " has " << (entry.rank - entry.maxRank) + << " points above max rank."; return false; } @@ -103,7 +103,8 @@ bool TalentSpec::CheckTalents(uint32 level, std::ostringstream* out) if (!found) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(entry.talentInfo->RankID[0]); - *out << "spec is invalid. Talent:" << spellInfo->SpellName[0] << " needs: " << spellInfodep->SpellName[0] << " at rank: " << entry.talentInfo->DependsOnRank; + *out << "spec is invalid. Talent:" << spellInfo->SpellName[0] + << " needs: " << spellInfodep->SpellName[0] << " at rank: " << entry.talentInfo->DependsOnRank; return false; } } @@ -120,7 +121,8 @@ bool TalentSpec::CheckTalents(uint32 level, std::ostringstream* out) if (entry.rank > 0 && entry.talentInfo->Row * 5 > points) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(entry.talentInfo->RankID[0]); - *out << "spec is is invalid. Talent " << spellInfo->SpellName[0] << " is selected with only " << points << " in row below it."; + *out << "spec is is invalid. Talent " << spellInfo->SpellName[0] << " is selected with only " << points + << " in row below it."; return false; } @@ -137,17 +139,18 @@ bool TalentSpec::CheckTalents(uint32 level, std::ostringstream* out) return true; } -//Set the talents for the bots to the current spec. +// Set the talents for the bots to the current spec. void TalentSpec::ApplyTalents(Player* bot, std::ostringstream* out) { - for (auto& entry : talents) { + for (auto& entry : talents) + { if (entry.rank == 0) continue; bot->LearnTalent(entry.talentInfo->TalentID, entry.rank - 1); } } -//Returns a base talentlist for a class. +// Returns a base talentlist for a class. void TalentSpec::GetTalents(uint32 classMask) { TalentListEntry entry; @@ -185,7 +188,7 @@ void TalentSpec::GetTalents(uint32 classMask) SortTalents(talents, SORT_BY_DEFAULT); } -//Sorts a talent list by page, row, column. +// Sorts a talent list by page, row, column. bool sortTalentMap(TalentSpec::TalentListEntry i, TalentSpec::TalentListEntry j, uint32* tabSort) { uint32 itab = i.tabPage(); @@ -208,38 +211,35 @@ bool sortTalentMap(TalentSpec::TalentListEntry i, TalentSpec::TalentListEntry j, return false; } -void TalentSpec::SortTalents(uint32 sortBy) -{ - SortTalents(talents, sortBy); -} +void TalentSpec::SortTalents(uint32 sortBy) { SortTalents(talents, sortBy); } -//Sort the talents. +// Sort the talents. void TalentSpec::SortTalents(std::vector& talents, uint32 sortBy) { switch (sortBy) { case SORT_BY_DEFAULT: { - uint32 tabSort[] = { 0, 1, 2 }; - std::sort(talents.begin(), talents.end(), [&tabSort](TalentSpec::TalentListEntry i, TalentSpec::TalentListEntry j) - { - return sortTalentMap(i, j, tabSort); - }); + uint32 tabSort[] = {0, 1, 2}; + std::sort(talents.begin(), talents.end(), + [&tabSort](TalentSpec::TalentListEntry i, TalentSpec::TalentListEntry j) + { return sortTalentMap(i, j, tabSort); }); break; } case SORT_BY_POINTS_TREE: { - uint32 tabSort[] = { GetTalentPoints(talents, 0) * 100 - urand(0, 99), GetTalentPoints(talents, 1) * 100 - urand(0, 99), GetTalentPoints(talents, 2) * 100 - urand(0, 99) }; - std::sort(talents.begin(), talents.end(), [&tabSort](TalentSpec::TalentListEntry i, TalentSpec::TalentListEntry j) - { - return sortTalentMap(i, j, tabSort); - }); + uint32 tabSort[] = {GetTalentPoints(talents, 0) * 100 - urand(0, 99), + GetTalentPoints(talents, 1) * 100 - urand(0, 99), + GetTalentPoints(talents, 2) * 100 - urand(0, 99)}; + std::sort(talents.begin(), talents.end(), + [&tabSort](TalentSpec::TalentListEntry i, TalentSpec::TalentListEntry j) + { return sortTalentMap(i, j, tabSort); }); break; } } } -//Set the talent ranks to the current rank of the player. +// Set the talent ranks to the current rank of the player. void TalentSpec::ReadTalents(Player* bot) { for (auto& entry : talents) @@ -257,7 +257,7 @@ void TalentSpec::ReadTalents(Player* bot) } } -//Set the talent ranks to the ranks of the link. +// Set the talent ranks to the ranks of the link. void TalentSpec::ReadTalents(std::string const link) { uint32 rank = 0; @@ -308,7 +308,7 @@ void TalentSpec::ReadTalents(std::string const link) } } -//Returns only a specific tree from a talent list. +// Returns only a specific tree from a talent list. std::vector TalentSpec::GetTalentTree(uint32 tabpage) { std::vector retList; @@ -320,12 +320,9 @@ std::vector TalentSpec::GetTalentTree(uint32 tabpag return std::move(retList); } -uint32 TalentSpec::GetTalentPoints(int32 tabpage) -{ - return GetTalentPoints(talents, tabpage); -}; +uint32 TalentSpec::GetTalentPoints(int32 tabpage) { return GetTalentPoints(talents, tabpage); }; -//Counts the point in a talent list. +// Counts the point in a talent list. uint32 TalentSpec::GetTalentPoints(std::vector& talents, int32 tabpage) { if (tabpage == -1) @@ -339,7 +336,7 @@ uint32 TalentSpec::GetTalentPoints(std::vector& talents, int32 return tPoints; } -//Generates a wow-head link from a talent list. +// Generates a wow-head link from a talent list. std::string const TalentSpec::GetTalentLink() { std::string link = ""; @@ -403,7 +400,7 @@ std::string const TalentSpec::FormatSpec(Player* bot) uint8 cls = bot->getClass(); std::ostringstream out; - //out << chathelper:: specs[cls][highestTree()] << " ("; + // out << chathelper:: specs[cls][highestTree()] << " ("; uint32 c0 = GetTalentPoints(0); uint32 c1 = GetTalentPoints(1); @@ -416,7 +413,7 @@ std::string const TalentSpec::FormatSpec(Player* bot) return out.str(); } -//Removes talentpoints to match the level +// Removes talentpoints to match the level void TalentSpec::CropTalents(uint32 level) { if (points <= LeveltoPoints(level)) @@ -436,8 +433,10 @@ void TalentSpec::CropTalents(uint32 level) SortTalents(talents, SORT_BY_DEFAULT); } -//Substracts ranks. Follows the sorting of the newList. -std::vector TalentSpec::SubTalentList(std::vector& oldList, std::vector& newList, uint32 reverse = SUBSTRACT_OLD_NEW) +// Substracts ranks. Follows the sorting of the newList. +std::vector TalentSpec::SubTalentList(std::vector& oldList, + std::vector& newList, + uint32 reverse = SUBSTRACT_OLD_NEW) { std::vector deltaList = newList; @@ -466,35 +465,35 @@ bool TalentSpec::isEarlierVersionOf(TalentSpec& newSpec) return true; } -//Modifies current talents towards new talents up to a maxium of points. +// Modifies current talents towards new talents up to a maxium of points. void TalentSpec::ShiftTalents(TalentSpec* currentSpec, uint32 level) { uint32 currentPoints = currentSpec->GetTalentPoints(); - if (points >= LeveltoPoints(level)) //We have no more points to spend. Better reset and crop + if (points >= LeveltoPoints(level)) // We have no more points to spend. Better reset and crop { CropTalents(level); return; } - SortTalents(SORT_BY_POINTS_TREE); //Apply points first to the largest new tree. + SortTalents(SORT_BY_POINTS_TREE); // Apply points first to the largest new tree. std::vector deltaList = SubTalentList(currentSpec->talents, talents); for (auto& entry : deltaList) { - if (entry.rank < 0) //We have to remove talents. Might as well reset and crop the new list. + if (entry.rank < 0) // We have to remove talents. Might as well reset and crop the new list. { CropTalents(level); return; } } - //Start from the current spec. + // Start from the current spec. talents = currentSpec->talents; for (auto& entry : deltaList) { - if (entry.rank + points > LeveltoPoints(level)) //Running out of points. Only apply what we have left. + if (entry.rank + points > LeveltoPoints(level)) // Running out of points. Only apply what we have left. entry.rank = std::max(0, std::abs(int32(LeveltoPoints(level) - points))); for (auto& subentry : talents) diff --git a/src/Talentspec.h b/src/Talentspec.h index 382fc6d8..aba39059 100644 --- a/src/Talentspec.h +++ b/src/Talentspec.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TALENTSPEC_H @@ -21,85 +22,86 @@ struct TalentTabEntry; // unused currently class TalentSpec { - public: - struct TalentListEntry - { - uint32 entry; - uint32 rank; - uint32 maxRank; - TalentEntry const* talentInfo; - TalentTabEntry const* talentTabInfo; - uint32 tabPage() const; - }; +public: + struct TalentListEntry + { + uint32 entry; + uint32 rank; + uint32 maxRank; + TalentEntry const* talentInfo; + TalentTabEntry const* talentTabInfo; + uint32 tabPage() const; + }; - TalentSpec() { }; - virtual ~TalentSpec() { } - TalentSpec(uint32 classMask); - TalentSpec(TalentSpec* base, std::string const link); - TalentSpec(Player* bot); - TalentSpec(Player* bot, std::string const link); + TalentSpec(){}; + virtual ~TalentSpec() {} + TalentSpec(uint32 classMask); + TalentSpec(TalentSpec* base, std::string const link); + TalentSpec(Player* bot); + TalentSpec(Player* bot, std::string const link); - uint32 points = 0; - std::vector talents; + uint32 points = 0; + std::vector talents; - bool CheckTalentLink(std::string const link, std::ostringstream* out); - virtual bool CheckTalents(uint32 maxPoints, std::ostringstream* out); - void CropTalents(uint32 level); - void ShiftTalents(TalentSpec* oldTalents, uint32 level); - void ApplyTalents(Player* bot, std::ostringstream* out); + bool CheckTalentLink(std::string const link, std::ostringstream* out); + virtual bool CheckTalents(uint32 maxPoints, std::ostringstream* out); + void CropTalents(uint32 level); + void ShiftTalents(TalentSpec* oldTalents, uint32 level); + void ApplyTalents(Player* bot, std::ostringstream* out); - uint32 GetTalentPoints(std::vector& talents, int32 tabpage = -1); - uint32 GetTalentPoints(int32 tabpage = -1); - bool isEarlierVersionOf(TalentSpec& newSpec); + uint32 GetTalentPoints(std::vector& talents, int32 tabpage = -1); + uint32 GetTalentPoints(int32 tabpage = -1); + bool isEarlierVersionOf(TalentSpec& newSpec); - std::string const GetTalentLink(); - uint32 highestTree(); - std::string const FormatSpec(Player* bot); + std::string const GetTalentLink(); + uint32 highestTree(); + std::string const FormatSpec(Player* bot); - protected: - uint32 LeveltoPoints(uint32 level) const; - uint32 PointstoLevel(uint32 points) const; - void GetTalents(uint32 classMask); - void SortTalents(std::vector& talents, uint32 sortBy); - void SortTalents(uint32 sortBy); +protected: + uint32 LeveltoPoints(uint32 level) const; + uint32 PointstoLevel(uint32 points) const; + void GetTalents(uint32 classMask); + void SortTalents(std::vector& talents, uint32 sortBy); + void SortTalents(uint32 sortBy); - void ReadTalents(Player* bot); - void ReadTalents(std::string const link); + void ReadTalents(Player* bot); + void ReadTalents(std::string const link); - std::vector GetTalentTree(uint32 tabpage); - std::vector SubTalentList(std::vector& oldList, std::vector& newList, uint32 reverse); + std::vector GetTalentTree(uint32 tabpage); + std::vector SubTalentList(std::vector& oldList, + std::vector& newList, uint32 reverse); }; class TalentPath { - public: - TalentPath(uint32 pathId, std::string const pathName, uint32 pathProbability) - { - id = pathId; - name = pathName; - probability = pathProbability; - }; +public: + TalentPath(uint32 pathId, std::string const pathName, uint32 pathProbability) + { + id = pathId; + name = pathName; + probability = pathProbability; + }; - uint32 id = 0; - std::string name = ""; - uint32 probability = 100; - std::vector talentSpec; + uint32 id = 0; + std::string name = ""; + uint32 probability = 100; + std::vector talentSpec; }; class ClassSpecs { - public: - ClassSpecs() { }; - ClassSpecs(uint32 specsClassMask) - { - classMask = specsClassMask; - baseSpec = TalentSpec(specsClassMask); - } +public: + ClassSpecs(){}; + ClassSpecs(uint32 specsClassMask) + { + classMask = specsClassMask; + baseSpec = TalentSpec(specsClassMask); + } - uint32 classMask = 0; - TalentSpec baseSpec; + uint32 classMask = 0; + TalentSpec baseSpec; - std::vector talentPath; + std::vector talentPath; }; #endif diff --git a/src/TravelMgr.cpp b/src/TravelMgr.cpp index a60a59cd..c64a6d1f 100644 --- a/src/TravelMgr.cpp +++ b/src/TravelMgr.cpp @@ -1,12 +1,17 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TravelMgr.h" + +#include +#include + #include "CellImpl.h" #include "ChatHelper.h" -#include "MapMgr.h" #include "MMapFactory.h" +#include "MapMgr.h" #include "PathGenerator.h" #include "Playerbots.h" #include "StrategyContext.h" @@ -14,9 +19,6 @@ #include "VMapFactory.h" #include "VMapMgr2.h" -#include -#include - WorldPosition::WorldPosition(std::string const str) { std::stringstream out(str); @@ -27,7 +29,8 @@ WorldPosition::WorldPosition(std::string const str) out >> this->m_orientation; } -WorldPosition::WorldPosition(uint32 mapId, const Position& pos) : WorldLocation(mapId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()) +WorldPosition::WorldPosition(uint32 mapId, const Position& pos) + : WorldLocation(mapId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()) { } @@ -35,7 +38,8 @@ WorldPosition::WorldPosition(WorldObject const* wo) { if (wo) { - set(WorldLocation(wo->GetMapId(), wo->GetPositionX(), wo->GetPositionY(), wo->GetPositionZ(), wo->GetOrientation())); + set(WorldLocation(wo->GetMapId(), wo->GetPositionX(), wo->GetPositionY(), wo->GetPositionZ(), + wo->GetOrientation())); } } @@ -51,14 +55,15 @@ WorldPosition::WorldPosition(std::vector list, WorldPositionCons set(*list[urand(0, size - 1)]); else if (conType == WP_CENTROID) { - set(std::accumulate(list.begin(), list.end(), WorldLocation(list[0]->getMapId(), 0, 0, 0, 0), [size](WorldLocation i, WorldPosition* j) - { - i.m_positionX += j->getX() / size; - i.m_positionY += j->getY() / size; - i.m_positionZ += j->getZ() / size; - i.NormalizeOrientation(i.m_orientation += j->getO() / size); - return i; - })); + set(std::accumulate(list.begin(), list.end(), WorldLocation(list[0]->getMapId(), 0, 0, 0, 0), + [size](WorldLocation i, WorldPosition* j) + { + i.m_positionX += j->getX() / size; + i.m_positionY += j->getY() / size; + i.m_positionZ += j->getZ() / size; + i.NormalizeOrientation(i.m_orientation += j->getO() / size); + return i; + })); } else if (conType == WP_MEAN_CENTROID) { @@ -79,14 +84,15 @@ WorldPosition::WorldPosition(std::vector list, WorldPositionConst set(list[urand(0, size - 1)]); else if (conType == WP_CENTROID) { - set(std::accumulate(list.begin(), list.end(), WorldLocation(list[0].getMapId(), 0, 0, 0, 0), [size](WorldLocation i, WorldPosition& j) - { - i.m_positionX += j.getX() / size; - i.m_positionY += j.getY() / size; - i.m_positionZ += j.getZ() / size; - i.NormalizeOrientation(i.m_orientation += j.getO() / size); - return i; - })); + set(std::accumulate(list.begin(), list.end(), WorldLocation(list[0].getMapId(), 0, 0, 0, 0), + [size](WorldLocation i, WorldPosition& j) + { + i.m_positionX += j.getX() / size; + i.m_positionY += j.getY() / size; + i.m_positionZ += j.getZ() / size; + i.NormalizeOrientation(i.m_orientation += j.getO() / size); + return i; + })); } else if (conType == WP_MEAN_CENTROID) { @@ -95,65 +101,49 @@ WorldPosition::WorldPosition(std::vector list, WorldPositionConst } } -WorldPosition::WorldPosition(uint32 mapid, GridCoord grid) : WorldLocation(mapid, (int32(grid.x_coord) - CENTER_GRID_ID - 0.5) * SIZE_OF_GRIDS + CENTER_GRID_OFFSET, - (int32(grid.y_coord) - CENTER_GRID_ID - 0.5) * SIZE_OF_GRIDS + CENTER_GRID_OFFSET, 0, 0) +WorldPosition::WorldPosition(uint32 mapid, GridCoord grid) + : WorldLocation(mapid, (int32(grid.x_coord) - CENTER_GRID_ID - 0.5) * SIZE_OF_GRIDS + CENTER_GRID_OFFSET, + (int32(grid.y_coord) - CENTER_GRID_ID - 0.5) * SIZE_OF_GRIDS + CENTER_GRID_OFFSET, 0, 0) { } -WorldPosition::WorldPosition(uint32 mapid, CellCoord cell) : WorldLocation(mapid, (int32(cell.x_coord) - CENTER_GRID_CELL_ID - 0.5) * SIZE_OF_GRID_CELL + CENTER_GRID_CELL_OFFSET, - (int32(cell.y_coord) - CENTER_GRID_CELL_ID - 0.5) * SIZE_OF_GRID_CELL + CENTER_GRID_CELL_OFFSET, 0, 0) +WorldPosition::WorldPosition(uint32 mapid, CellCoord cell) + : WorldLocation( + mapid, (int32(cell.x_coord) - CENTER_GRID_CELL_ID - 0.5) * SIZE_OF_GRID_CELL + CENTER_GRID_CELL_OFFSET, + (int32(cell.y_coord) - CENTER_GRID_CELL_ID - 0.5) * SIZE_OF_GRID_CELL + CENTER_GRID_CELL_OFFSET, 0, 0) { } -WorldPosition::WorldPosition(uint32 mapid, mGridCoord grid) : WorldLocation(mapid, (32 - grid.first) * SIZE_OF_GRIDS, (32 - grid.second) * SIZE_OF_GRIDS, 0, 0) +WorldPosition::WorldPosition(uint32 mapid, mGridCoord grid) + : WorldLocation(mapid, (32 - grid.first) * SIZE_OF_GRIDS, (32 - grid.second) * SIZE_OF_GRIDS, 0, 0) { } -void WorldPosition::set(const WorldLocation& pos) -{ - WorldRelocate(pos); -} +void WorldPosition::set(const WorldLocation& pos) { WorldRelocate(pos); } -void WorldPosition::setMapId(uint32 id) -{ - m_mapId = id; -} +void WorldPosition::setMapId(uint32 id) { m_mapId = id; } -void WorldPosition::setX(float x) -{ - m_positionX = x; -} +void WorldPosition::setX(float x) { m_positionX = x; } -void WorldPosition::setY(float y) -{ - m_positionY = y; -} +void WorldPosition::setY(float y) { m_positionY = y; } -void WorldPosition::setZ(float z) -{ - m_positionZ = z; -} +void WorldPosition::setZ(float z) { m_positionZ = z; } -void WorldPosition::setO(float o) -{ - m_orientation = o; -} +void WorldPosition::setO(float o) { m_orientation = o; } WorldPosition::operator bool() const { return GetMapId() != 0 || GetPositionX() != 0 || GetPositionY() != 0 || GetPositionZ() != 0; } -bool operator==(WorldPosition const& p1, const WorldPosition &p2) +bool operator==(WorldPosition const& p1, const WorldPosition& p2) { return p1.GetMapId() == p2.GetMapId() && p2.GetPositionX() == p1.GetPositionX() && - p2.GetPositionY() == p1.GetPositionY() && p2.GetPositionZ() == p1.GetPositionZ() && p2.GetOrientation() == p1.GetOrientation(); + p2.GetPositionY() == p1.GetPositionY() && p2.GetPositionZ() == p1.GetPositionZ() && + p2.GetOrientation() == p1.GetOrientation(); } -bool operator!=(WorldPosition const& p1, const WorldPosition &p2) -{ - return !(p1 == p2); -} +bool operator!=(WorldPosition const& p1, const WorldPosition& p2) { return !(p1 == p2); } WorldPosition& WorldPosition::operator+=(WorldPosition const& p1) { @@ -171,30 +161,15 @@ WorldPosition& WorldPosition::operator-=(WorldPosition const& p1) return *this; } -uint32 WorldPosition::getMapId() -{ - return GetMapId(); -} +uint32 WorldPosition::getMapId() { return GetMapId(); } -float WorldPosition::getX() -{ - return GetPositionX(); -} +float WorldPosition::getX() { return GetPositionX(); } -float WorldPosition::getY() -{ - return GetPositionY(); -} +float WorldPosition::getY() { return GetPositionY(); } -float WorldPosition::getZ() -{ - return GetPositionZ(); -} +float WorldPosition::getZ() { return GetPositionZ(); } -float WorldPosition::getO() -{ - return GetOrientation(); -} +float WorldPosition::getO() { return GetOrientation(); } bool WorldPosition::isOverworld() { @@ -203,24 +178,28 @@ bool WorldPosition::isOverworld() bool WorldPosition::isInWater() { - return getMap() ? getMap()->IsInWater(PHASEMASK_NORMAL, GetPositionX(), GetPositionY(), GetPositionZ(), DEFAULT_COLLISION_HEIGHT) : false; + return getMap() ? getMap()->IsInWater(PHASEMASK_NORMAL, GetPositionX(), GetPositionY(), GetPositionZ(), + DEFAULT_COLLISION_HEIGHT) + : false; }; bool WorldPosition::isUnderWater() { - return getMap() ? getMap()->IsUnderWater(PHASEMASK_NORMAL, GetPositionX(), GetPositionY(), GetPositionZ(), DEFAULT_COLLISION_HEIGHT) : false; + return getMap() ? getMap()->IsUnderWater(PHASEMASK_NORMAL, GetPositionX(), GetPositionY(), GetPositionZ(), + DEFAULT_COLLISION_HEIGHT) + : false; }; WorldPosition WorldPosition::relPoint(WorldPosition* center) { - return WorldPosition(GetMapId(), GetPositionX() - center->GetPositionX(), - GetPositionY() - center->GetPositionY(), GetPositionZ() - center->GetPositionZ(), GetOrientation()); + return WorldPosition(GetMapId(), GetPositionX() - center->GetPositionX(), GetPositionY() - center->GetPositionY(), + GetPositionZ() - center->GetPositionZ(), GetOrientation()); } WorldPosition WorldPosition::offset(WorldPosition* center) { - return WorldPosition(GetMapId(), GetPositionX() + center->GetPositionX(), - GetPositionY() + center->GetPositionY(), GetPositionZ() + center->GetPositionZ(), GetOrientation()); + return WorldPosition(GetMapId(), GetPositionX() + center->GetPositionX(), GetPositionY() + center->GetPositionY(), + GetPositionZ() + center->GetPositionZ(), GetOrientation()); } float WorldPosition::size() @@ -230,10 +209,10 @@ float WorldPosition::size() float WorldPosition::distance(WorldPosition* center) { - if(GetMapId() == center->getMapId()) + if (GetMapId() == center->getMapId()) return relPoint(center).size(); - //this -> mapTransfer | mapTransfer -> center + // this -> mapTransfer | mapTransfer -> center return sTravelMgr->mapTransDistance(*this, *center); }; @@ -251,15 +230,15 @@ float mapTransfer::fDist(WorldPosition start, WorldPosition end) return start.fDist(pointFrom) + portalLength + pointTo.fDist(end); } -//When moving from this along list return last point that falls within range. -//Distance is move distance along path. +// When moving from this along list return last point that falls within range. +// Distance is move distance along path. WorldPosition WorldPosition::lastInRange(std::vector list, float minDist, float maxDist) { WorldPosition rPoint; float startDist = 0.0f; - //Enter the path at the closest point. + // Enter the path at the closest point. for (auto& p : list) { float curDist = distance(p); @@ -269,23 +248,23 @@ WorldPosition WorldPosition::lastInRange(std::vector list, float float totalDist = 0.0f; - //Follow the path from the last nearest point - //Return last point in range. + // Follow the path from the last nearest point + // Return last point in range. for (auto& p : list) { float curDist = distance(p); - if (totalDist > 0) //We have started the path. Keep counting. + if (totalDist > 0) // We have started the path. Keep counting. totalDist += p.distance(std::prev(&p, 1)); - if (curDist == startDist) //Start the path here. + if (curDist == startDist) // Start the path here. totalDist = startDist; if (minDist > 0 && totalDist < minDist) continue; if (maxDist > 0 && totalDist > maxDist) - continue; //We do not break here because the path may loop back and have a second startDist point. + continue; // We do not break here because the path may loop back and have a second startDist point. rPoint = p; } @@ -293,7 +272,7 @@ WorldPosition WorldPosition::lastInRange(std::vector list, float return rPoint; }; -//Todo: remove or adjust to above standard. +// Todo: remove or adjust to above standard. WorldPosition WorldPosition::firstOutRange(std::vector list, float minDist, float maxDist) { WorldPosition rPoint; @@ -312,7 +291,7 @@ WorldPosition WorldPosition::firstOutRange(std::vector list, floa return rPoint; } -//Returns true if (on the x-y plane) the position is inside the three points. +// Returns true if (on the x-y plane) the position is inside the three points. bool WorldPosition::isInside(WorldPosition* p1, WorldPosition* p2, WorldPosition* p3) { if (getMapId() != p1->getMapId() != p2->getMapId() != p3->getMapId()) @@ -331,10 +310,7 @@ bool WorldPosition::isInside(WorldPosition* p1, WorldPosition* p2, WorldPosition return !(has_neg && has_pos); } -MapEntry const* WorldPosition::getMapEntry() -{ - return sMapStore.LookupEntry(GetMapId()); -}; +MapEntry const* WorldPosition::getMapEntry() { return sMapStore.LookupEntry(GetMapId()); }; uint32 WorldPosition::getInstanceId() { @@ -349,15 +325,12 @@ Map* WorldPosition::getMap() return sMapMgr->FindMap(GetMapId(), getMapEntry()->Instanceable() ? getInstanceId() : 0); } -float WorldPosition::getHeight() // remove const - whipowill +float WorldPosition::getHeight() // remove const - whipowill { return getMap()->GetHeight(getX(), getY(), getZ()); } -G3D::Vector3 WorldPosition::getVector3() -{ - return G3D::Vector3(GetPositionX(), GetPositionY(), GetPositionZ()); -} +G3D::Vector3 WorldPosition::getVector3() { return G3D::Vector3(GetPositionX(), GetPositionY(), GetPositionZ()); } std::string const WorldPosition::print() { @@ -387,7 +360,7 @@ void WorldPosition::printWKT(std::vector points, std::ostringstre switch (dim) { case 0: - if(points.size() == 1) + if (points.size() == 1) out << "\"POINT("; else out << "\"MULTIPOINT("; @@ -414,10 +387,7 @@ WorldPosition WorldPosition::getDisplayLocation() return offset(const_cast(&pos)); } -uint16 WorldPosition::getAreaId() -{ - return sMapMgr->GetAreaId(PHASEMASK_NORMAL, getMapId(), getX(), getY(), getZ()); -} +uint16 WorldPosition::getAreaId() { return sMapMgr->GetAreaId(PHASEMASK_NORMAL, getMapId(), getX(), getY(), getZ()); } AreaTableEntry const* WorldPosition::getArea() { @@ -475,15 +445,15 @@ std::set WorldPosition::getTransports(uint32 entry) else { */ - std::set transports; - /* - for (auto transport : getMap()->m_transports) - if(transport->GetEntry() == entry) - transports.insert(transport); + std::set transports; + /* + for (auto transport : getMap()->m_transports) + if(transport->GetEntry() == entry) + transports.insert(transport); - return transports; - } - */ + return transports; +} +*/ return transports; } @@ -572,10 +542,10 @@ std::vector> WorldPosition::getmGridCoords(WorldPosition int uy = std::max(getmGridCoord().second, secondPos.getmGridCoord().second); int border = 1; - //lx = std::min(std::max(border, lx), MAX_NUMBER_OF_GRIDS - border); - //ly = std::min(std::max(border, ly), MAX_NUMBER_OF_GRIDS - border); - //ux = std::min(std::max(border, ux), MAX_NUMBER_OF_GRIDS - border); - //uy = std::min(std::max(border, uy), MAX_NUMBER_OF_GRIDS - border); + // lx = std::min(std::max(border, lx), MAX_NUMBER_OF_GRIDS - border); + // ly = std::min(std::max(border, ly), MAX_NUMBER_OF_GRIDS - border); + // ux = std::min(std::max(border, ux), MAX_NUMBER_OF_GRIDS - border); + // uy = std::min(std::max(border, uy), MAX_NUMBER_OF_GRIDS - border); for (int x = lx - border; x <= ux + border; x++) { @@ -619,15 +589,16 @@ void WorldPosition::loadMapAndVMap(uint32 mapId, uint8 x, uint8 y) { std::ostringstream out; out << sPlayerbotAIConfig->GetTimestampStr(); - out << "+00,\"mmap\", " << x << "," << y << "," << (sTravelMgr->isBadMmap(mapId, x, y) ? "0" : "1") << ","; + out << "+00,\"mmap\", " << x << "," << y << "," << (sTravelMgr->isBadMmap(mapId, x, y) ? "0" : "1") + << ","; printWKT(fromGridCoord(GridCoord(x, y)), out, 1, true); sPlayerbotAIConfig->log(fileName, out.str().c_str()); } } else { - //This needs to be disabled or maps will not load. - //Needs more testing to check for impact on movement. + // This needs to be disabled or maps will not load. + // Needs more testing to check for impact on movement. if (false) if (!sTravelMgr->isBadVmap(mapId, x, y)) { @@ -635,19 +606,23 @@ void WorldPosition::loadMapAndVMap(uint32 mapId, uint8 x, uint8 y) const MapEntry* i_mapEntry = sMapStore.LookupEntry(mapId); const char* mapName = i_mapEntry ? i_mapEntry->name[sWorld->GetDefaultDbcLocale()] : "UNNAMEDMAP\x0"; - int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapMgr()->loadMap((sWorld->GetDataPath() + "vmaps").c_str(), mapId, x, y); + int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapMgr()->loadMap( + (sWorld->GetDataPath() + "vmaps").c_str(), mapId, x, y); switch (vmapLoadResult) { case VMAP::VMAP_LOAD_RESULT_OK: - //LOG_ERROR("playerbots", "VMAP loaded name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", mapName, mapId, x, y, x, y); + // LOG_ERROR("playerbots", "VMAP loaded name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", + // mapName, mapId, x, y, x, y); break; case VMAP::VMAP_LOAD_RESULT_ERROR: - //LOG_ERROR("playerbots", "Could not load VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", mapName, mapId, x, y, x, y); + // LOG_ERROR("playerbots", "Could not load VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, + // y:{})", mapName, mapId, x, y, x, y); sTravelMgr->addBadVmap(mapId, x, y); break; case VMAP::VMAP_LOAD_RESULT_IGNORED: sTravelMgr->addBadVmap(mapId, x, y); - //LOG_INFO("playerbots", "Ignored VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", mapName, mapId, x, y, x, y); + // LOG_INFO("playerbots", "Ignored VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", + // mapName, mapId, x, y, x, y); break; } @@ -655,7 +630,8 @@ void WorldPosition::loadMapAndVMap(uint32 mapId, uint8 x, uint8 y) { std::ostringstream out; out << sPlayerbotAIConfig->GetTimestampStr(); - out << "+00,\"vmap\", " << x << "," << y << ", " << (sTravelMgr->isBadVmap(mapId, x, y) ? "0" : "1") << ","; + out << "+00,\"vmap\", " << x << "," << y << ", " << (sTravelMgr->isBadVmap(mapId, x, y) ? "0" : "1") + << ","; printWKT(frommGridCoord(mGridCoord(x, y)), out, 1, true); sPlayerbotAIConfig->log(fileName, out.str().c_str()); } @@ -671,7 +647,8 @@ void WorldPosition::loadMapAndVMap(uint32 mapId, uint8 x, uint8 y) { std::ostringstream out; out << sPlayerbotAIConfig->GetTimestampStr(); - out << "+00,\"mmap\", " << x << "," << y << "," << (sTravelMgr->isBadMmap(mapId, x, y) ? "0" : "1") << ","; + out << "+00,\"mmap\", " << x << "," << y << "," << (sTravelMgr->isBadMmap(mapId, x, y) ? "0" : "1") + << ","; printWKT(fromGridCoord(GridCoord(x, y)), out, 1, true); sPlayerbotAIConfig->log(fileName, out.str().c_str()); } @@ -696,13 +673,13 @@ std::vector WorldPosition::fromPointsArray(std::vector WorldPosition::getPathStepFrom(WorldPosition startPos, Unit* bot) { if (!bot) return {}; - //Load mmaps and vmaps between the two points. + // Load mmaps and vmaps between the two points. loadMapAndVMaps(startPos); PathGenerator path(bot); @@ -711,12 +688,11 @@ std::vector WorldPosition::getPathStepFrom(WorldPosition startPos Movement::PointsArray points = path.GetPath(); PathType type = path.GetPathType(); - if (sPlayerbotAIConfig->hasLog("pathfind_attempt_point.csv")) { std::ostringstream out; out << std::fixed << std::setprecision(1); - printWKT({ startPos, *this }, out); + printWKT({startPos, *this}, out); sPlayerbotAIConfig->log("pathfind_attempt_point.csv", out.str().c_str()); } @@ -740,7 +716,9 @@ bool WorldPosition::cropPathTo(std::vector& path, float maxDistan if (path.empty()) return false; - auto bestPos = std::min_element(path.begin(), path.end(), [this](WorldPosition i, WorldPosition j) {return this->sqDistance(i) < this->sqDistance(j); }); + auto bestPos = std::min_element(path.begin(), path.end(), + [this](WorldPosition i, WorldPosition j) + { return this->sqDistance(i) < this->sqDistance(j); }); bool insRange = this->sqDistance(*bestPos) <= maxDistance * maxDistance; @@ -752,13 +730,15 @@ bool WorldPosition::cropPathTo(std::vector& path, float maxDistan return insRange; } -//A sequential series of pathfinding attempts. Returns the complete path and if the patfinder eventually found a way to the destination. -std::vector WorldPosition::getPathFromPath(std::vector startPath, Unit* bot, uint8 maxAttempt) +// A sequential series of pathfinding attempts. Returns the complete path and if the patfinder eventually found a way to +// the destination. +std::vector WorldPosition::getPathFromPath(std::vector startPath, Unit* bot, + uint8 maxAttempt) { - //We start at the end of the last path. + // We start at the end of the last path. WorldPosition currentPos = startPath.back(); - //No pathfinding across maps. + // No pathfinding across maps. if (getMapId() != currentPos.getMapId()) return {}; @@ -767,21 +747,21 @@ std::vector WorldPosition::getPathFromPath(std::vectortargetPosRecalcDistance) break; - //Append the path excluding the start (this should be the same as the end of the startPath) - fullPath.insert(fullPath.end(), std::next(subPath.begin(),1), subPath.end()); + // Append the path excluding the start (this should be the same as the end of the startPath) + fullPath.insert(fullPath.end(), std::next(subPath.begin(), 1), subPath.end()); - //Are we there yet? + // Are we there yet? if (isPathTo(subPath)) break; - //Continue pathfinding. + // Continue pathfinding. currentPos = subPath.back(); } @@ -800,14 +780,17 @@ bool WorldPosition::GetReachableRandomPointOnGround(Player* bot, float radius, b uint32 WorldPosition::getUnitsAggro(GuidVector& units, Player* bot) { - units.erase(std::remove_if(units.begin(), units.end(), [this, bot](ObjectGuid guid) - { - Creature* creature = ObjectAccessor::GetCreature(*bot, guid); - if (!creature) - return true; + units.erase(std::remove_if(units.begin(), units.end(), + [this, bot](ObjectGuid guid) + { + Creature* creature = ObjectAccessor::GetCreature(*bot, guid); + if (!creature) + return true; - return sqDistance(WorldPosition(creature)) > creature->GetAttackDistance(bot) * creature->GetAttackDistance(bot); - }), units.end()); + return sqDistance(WorldPosition(creature)) > + creature->GetAttackDistance(bot) * creature->GetAttackDistance(bot); + }), + units.end()); return units.size(); } @@ -816,7 +799,8 @@ void FindPointCreatureData::operator()(CreatureData const& creatureData) { if (!entry || creatureData.id1 == entry) if ((!point || creatureData.mapid == point.getMapId()) && - (!radius || point.sqDistance(WorldPosition(creatureData.mapid, creatureData.posX, creatureData.posY, creatureData.posZ)) < radius * radius)) + (!radius || point.sqDistance(WorldPosition(creatureData.mapid, creatureData.posX, creatureData.posY, + creatureData.posZ)) < radius * radius)) { data.push_back(&creatureData); } @@ -826,7 +810,8 @@ void FindPointGameObjectData::operator()(GameObjectData const& gameobjectData) { if (!entry || gameobjectData.id == entry) if ((!point || gameobjectData.mapid == point.getMapId()) && - (!radius || point.sqDistance(WorldPosition(gameobjectData.mapid, gameobjectData.posX, gameobjectData.posY, gameobjectData.posZ)) < radius * radius)) + (!radius || point.sqDistance(WorldPosition(gameobjectData.mapid, gameobjectData.posX, gameobjectData.posY, + gameobjectData.posZ)) < radius * radius)) { data.push_back(&gameobjectData); } @@ -935,16 +920,18 @@ bool GuidPosition::isDead() return true; } -GuidPosition::GuidPosition(WorldObject* wo) : ObjectGuid(wo->GetGUID()), WorldPosition(wo), loadedFromDB(false) -{ -} +GuidPosition::GuidPosition(WorldObject* wo) : ObjectGuid(wo->GetGUID()), WorldPosition(wo), loadedFromDB(false) {} -GuidPosition::GuidPosition(CreatureData const& creData) : ObjectGuid(HighGuid::Unit, creData.id1, creData.spawnId), WorldPosition(creData.mapid, creData.posX, creData.posY, creData.posZ, creData.orientation) +GuidPosition::GuidPosition(CreatureData const& creData) + : ObjectGuid(HighGuid::Unit, creData.id1, creData.spawnId), + WorldPosition(creData.mapid, creData.posX, creData.posY, creData.posZ, creData.orientation) { loadedFromDB = true; } -GuidPosition::GuidPosition(GameObjectData const& goData) : ObjectGuid(HighGuid::GameObject, goData.id), WorldPosition(goData.mapid, goData.posX, goData.posY, goData.posZ, goData.orientation) +GuidPosition::GuidPosition(GameObjectData const& goData) + : ObjectGuid(HighGuid::GameObject, goData.id), + WorldPosition(goData.mapid, goData.posX, goData.posY, goData.posZ, goData.orientation) { loadedFromDB = true; } @@ -988,10 +975,7 @@ WorldObject* GuidPosition::GetWorldObject() return nullptr; } -bool GuidPosition::HasNpcFlag(NPCFlags flag) -{ - return IsCreature() && GetCreatureTemplate()->npcflag & flag; -} +bool GuidPosition::HasNpcFlag(NPCFlags flag) { return IsCreature() && GetCreatureTemplate()->npcflag & flag; } std::vector TravelDestination::getPoints(bool ignoreFull) { @@ -1003,13 +987,15 @@ std::vector TravelDestination::getPoints(bool ignoreFull) return points; std::vector retVec; - std::copy_if(points.begin(), points.end(), std::back_inserter(retVec), [max](WorldPosition* p) { return p->getVisitors() < max; }); + std::copy_if(points.begin(), points.end(), std::back_inserter(retVec), + [max](WorldPosition* p) { return p->getVisitors() < max; }); return retVec; } WorldPosition* TravelDestination::nearestPoint(WorldPosition* pos) { - return *std::min_element(points.begin(), points.end(), [pos](WorldPosition* i, WorldPosition* j) { return i->distance(pos) < j->distance(pos); }); + return *std::min_element(points.begin(), points.end(), + [pos](WorldPosition* i, WorldPosition* j) { return i->distance(pos) < j->distance(pos); }); } std::vector TravelDestination::touchingPoints(WorldPosition* pos) @@ -1033,7 +1019,8 @@ std::vector TravelDestination::touchingPoints(WorldPosition* pos std::vector TravelDestination::sortedPoints(WorldPosition* pos) { std::vector ret_points = points; - std::sort(ret_points.begin(), ret_points.end(), [pos](WorldPosition* i, WorldPosition* j) { return i->distance(pos) < j->distance(pos); }); + std::sort(ret_points.begin(), ret_points.end(), + [pos](WorldPosition* i, WorldPosition* j) { return i->distance(pos) < j->distance(pos); }); return ret_points; }; @@ -1054,10 +1041,7 @@ bool TravelDestination::isFull(bool ignoreFull) return false; } -std::string const QuestTravelDestination::getTitle() -{ - return ChatHelper::FormatQuest(questTemplate); -} +std::string const QuestTravelDestination::getTitle() { return ChatHelper::FormatQuest(questTemplate); } bool QuestRelationTravelDestination::isActive(Player* bot) { @@ -1066,8 +1050,8 @@ bool QuestRelationTravelDestination::isActive(Player* bot) if (questTemplate->GetQuestLevel() >= bot->GetLevel() + 5) return false; - //if (questTemplate->XPValue(bot) == 0) - // return false; + // if (questTemplate->XPValue(bot) == 0) + // return false; if (!bot->GetMap()->GetEntry()->IsWorldMap() || !bot->CanTakeQuest(questTemplate, false)) return false; @@ -1089,7 +1073,8 @@ bool QuestRelationTravelDestination::isActive(Player* bot) } // Do not try to pick up dungeon/elite quests in instances without a group. - if ((questTemplate->GetType() == QUEST_TYPE_ELITE || questTemplate->GetType() == QUEST_TYPE_DUNGEON) && !AI_VALUE(bool, "can fight boss")) + if ((questTemplate->GetType() == QUEST_TYPE_ELITE || questTemplate->GetType() == QUEST_TYPE_DUNGEON) && + !AI_VALUE(bool, "can fight boss")) return false; } else @@ -1102,14 +1087,16 @@ bool QuestRelationTravelDestination::isActive(Player* bot) uint32 dialogStatus = sTravelMgr->getDialogStatus(bot, entry, questTemplate); - if (dialogStatus != DIALOG_STATUS_REWARD2 && dialogStatus != DIALOG_STATUS_REWARD && dialogStatus != DIALOG_STATUS_REWARD_REP) + if (dialogStatus != DIALOG_STATUS_REWARD2 && dialogStatus != DIALOG_STATUS_REWARD && + dialogStatus != DIALOG_STATUS_REWARD_REP) return false; PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); AiObjectContext* context = botAI->GetAiObjectContext(); // Do not try to hand-in dungeon/elite quests in instances without a group. - if ((questTemplate->GetType() == QUEST_TYPE_ELITE || questTemplate->GetType() == QUEST_TYPE_DUNGEON) && !AI_VALUE(bool, "can fight boss")) + if ((questTemplate->GetType() == QUEST_TYPE_ELITE || questTemplate->GetType() == QUEST_TYPE_DUNGEON) && + !AI_VALUE(bool, "can fight boss")) { WorldPosition pos(bot); if (!this->nearestPoint(const_cast(&pos))->isOverworld()) @@ -1143,18 +1130,19 @@ bool QuestObjectiveTravelDestination::isActive(Player* bot) if (questTemplate->GetQuestLevel() + 5 > bot->GetLevel() && !AI_VALUE(bool, "can fight equal")) return false; - //Check mob level + // Check mob level if (getEntry() > 0) { CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(getEntry()); if (cInfo && (int)cInfo->maxlevel - (int)bot->GetLevel() > 4) return false; - // Do not try to hand-in dungeon/elite quests in instances without a group. + // Do not try to hand-in dungeon/elite quests in instances without a group. if (cInfo->rank > CREATURE_ELITE_NORMAL) { WorldPosition pos(bot); - if (!this->nearestPoint(const_cast(&pos))->isOverworld() && !AI_VALUE(bool, "can fight boss")) + if (!this->nearestPoint(const_cast(&pos))->isOverworld() && + !AI_VALUE(bool, "can fight boss")) return false; if (!AI_VALUE(bool, "can fight elite")) @@ -1175,7 +1163,8 @@ bool QuestObjectiveTravelDestination::isActive(Player* bot) GuidVector targets = AI_VALUE(GuidVector, "possible targets"); for (auto& target : targets) - if (target.GetEntry() == getEntry() && target.IsCreature() && botAI->GetCreature(target) && botAI->GetCreature(target)->IsAlive()) + if (target.GetEntry() == getEntry() && target.IsCreature() && botAI->GetCreature(target) && + botAI->GetCreature(target)->IsAlive()) return true; return false; @@ -1221,7 +1210,7 @@ bool RpgTravelDestination::isActive(Player* bot) if (!isUsefull) return false; - //Once the target rpged with it is added to the ignore list. We can now move on. + // Once the target rpged with it is added to the ignore list. We can now move on. GuidSet& ignoreList = GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue("ignore rpg target")->Get(); for (ObjectGuid const guid : ignoreList) @@ -1238,10 +1227,7 @@ bool RpgTravelDestination::isActive(Player* bot) return reaction > REP_NEUTRAL; } -CreatureTemplate const* RpgTravelDestination::GetCreatureTemplate() -{ - return sObjectMgr->GetCreatureTemplate(entry); -} +CreatureTemplate const* RpgTravelDestination::GetCreatureTemplate() { return sObjectMgr->GetCreatureTemplate(entry); } std::string const RpgTravelDestination::getTitle() { @@ -1272,10 +1258,10 @@ bool ExploreTravelDestination::isActive(Player* bot) return !(currFields & val); } -//std::string const ExploreTravelDestination::getTitle() +// std::string const ExploreTravelDestination::getTitle() //{ -// return points[0]->getAreaName(); -//}; +// return points[0]->getAreaName(); +// }; bool GrindTravelDestination::isActive(Player* bot) { @@ -1293,17 +1279,17 @@ bool GrindTravelDestination::isActive(Player* bot) int32 botLevel = bot->GetLevel(); uint8 botPowerLevel = AI_VALUE(uint8, "durability"); - float levelMod = botPowerLevel / 500.0f; //(0-0.2f) - float levelBoost = botPowerLevel / 50.0f; //(0-2.0f) + float levelMod = botPowerLevel / 500.0f; //(0-0.2f) + float levelBoost = botPowerLevel / 50.0f; //(0-2.0f) int32 maxLevel = std::max(botLevel * (0.5f + levelMod), botLevel - 5.0f + levelBoost); - if ((int32)cInfo->maxlevel > maxLevel) //@lvl5 max = 3, @lvl60 max = 57 + if ((int32)cInfo->maxlevel > maxLevel) //@lvl5 max = 3, @lvl60 max = 57 return false; int32 minLevel = std::max(botLevel * (0.4f + levelMod), botLevel - 12.0f + levelBoost); - if ((int32)cInfo->maxlevel < minLevel) //@lvl5 min = 3, @lvl60 max = 50 + if ((int32)cInfo->maxlevel < minLevel) //@lvl5 min = 3, @lvl60 max = 50 return false; if (!cInfo->mingold) @@ -1318,10 +1304,7 @@ bool GrindTravelDestination::isActive(Player* bot) return reaction < REP_NEUTRAL; } -CreatureTemplate const* GrindTravelDestination::GetCreatureTemplate() -{ - return sObjectMgr->GetCreatureTemplate(entry); -} +CreatureTemplate const* GrindTravelDestination::GetCreatureTemplate() { return sObjectMgr->GetCreatureTemplate(entry); } std::string const GrindTravelDestination::getTitle() { @@ -1377,7 +1360,8 @@ bool BossTravelDestination::isActive(Player* bot) GuidVector targets = AI_VALUE(GuidVector, "possible targets"); for (auto& target : targets) - if (target.GetEntry() == getEntry() && target.IsCreature() && botAI->GetCreature(target) && botAI->GetCreature(target)->IsAlive()) + if (target.GetEntry() == getEntry() && target.IsCreature() && botAI->GetCreature(target) && + botAI->GetCreature(target)->IsAlive()) return true; return false; @@ -1389,10 +1373,7 @@ bool BossTravelDestination::isActive(Player* bot) return true; } -CreatureTemplate const* BossTravelDestination::getCreatureTemplate() -{ - return sObjectMgr->GetCreatureTemplate(entry); -} +CreatureTemplate const* BossTravelDestination::getCreatureTemplate() { return sObjectMgr->GetCreatureTemplate(entry); } std::string const BossTravelDestination::getTitle() { @@ -1409,7 +1390,8 @@ TravelTarget::~TravelTarget() return; releaseVisitors(); - //sTravelMgr->botTargets.erase(std::remove(sTravelMgr->botTargets.begin(), sTravelMgr->botTargets.end(), this), sTravelMgr->botTargets.end()); + // sTravelMgr->botTargets.erase(std::remove(sTravelMgr->botTargets.begin(), sTravelMgr->botTargets.end(), this), + // sTravelMgr->botTargets.end()); } void TravelTarget::setTarget(TravelDestination* tDestination1, WorldPosition* wPosition1, bool groupCopy1) @@ -1465,15 +1447,9 @@ float TravelTarget::distance(Player* bot) return wPosition->distance(&pos); } -WorldPosition* TravelTarget::getPosition() -{ - return wPosition; -} +WorldPosition* TravelTarget::getPosition() { return wPosition; } -TravelDestination* TravelTarget::getDestination() -{ - return tDestination; -} +TravelDestination* TravelTarget::getDestination() { return tDestination; } void TravelTarget::setStatus(TravelStatus status) { @@ -1523,7 +1499,7 @@ bool TravelTarget::isActive() if (isWorking()) return true; - if (!tDestination->isActive(bot)) //Target has become invalid. Stop. + if (!tDestination->isActive(bot)) // Target has become invalid. Stop. { setStatus(TRAVEL_STATUS_COOLDOWN); return true; @@ -1532,17 +1508,14 @@ bool TravelTarget::isActive() return true; }; -uint32 TravelTarget::getMaxTravelTime() -{ - return (1000.0 * distance(bot)) / bot->GetSpeed(MOVE_RUN); -} +uint32 TravelTarget::getMaxTravelTime() { return (1000.0 * distance(bot)) / bot->GetSpeed(MOVE_RUN); } bool TravelTarget::isTraveling() { if (m_status != TRAVEL_STATUS_TRAVEL) return false; - if (!tDestination->isActive(bot) && !forced) //Target has become invalid. Stop. + if (!tDestination->isActive(bot) && !forced) // Target has become invalid. Stop. { setStatus(TRAVEL_STATUS_COOLDOWN); return false; @@ -1572,7 +1545,7 @@ bool TravelTarget::isWorking() if (m_status != TRAVEL_STATUS_WORK) return false; - if (!tDestination->isActive(bot)) //Target has become invalid. Stop. + if (!tDestination->isActive(bot)) // Target has become invalid. Stop. { setStatus(TRAVEL_STATUS_COOLDOWN); return false; @@ -1682,7 +1655,7 @@ void TravelMgr::Clear() void TravelMgr::logQuestError(uint32 errorNr, Quest* quest, uint32 objective, uint32 unitId, uint32 itemId) { - bool logQuestErrors = false; //For debugging. + bool logQuestErrors = false; // For debugging. if (!logQuestErrors) return; @@ -1706,26 +1679,31 @@ void TravelMgr::logQuestError(uint32 errorNr, Quest* quest, uint32 objective, ui if (errorNr == 1) { LOG_ERROR("playerbots", "Quest {} [{}] has {} {} [{}] but none is found in the world.", - quest->GetTitle().c_str(), quest->GetQuestId(), objective == 0 ? "quest giver" : "quest taker", unitName.c_str(), unitId); + quest->GetTitle().c_str(), quest->GetQuestId(), objective == 0 ? "quest giver" : "quest taker", + unitName.c_str(), unitId); } else if (errorNr == 2) { LOG_ERROR("playerbots", "Quest {} [{}] needs {} [{}] for objective {} but none is found in the world.", - quest->GetTitle().c_str(), quest->GetQuestId(), unitName.c_str(), unitId, objective); + quest->GetTitle().c_str(), quest->GetQuestId(), unitName.c_str(), unitId, objective); } else if (errorNr == 3) { - LOG_ERROR("playerbots", "Quest {} [{}] needs itemId {} but no such item exists.", quest->GetTitle().c_str(), quest->GetQuestId(), itemId); + LOG_ERROR("playerbots", "Quest {} [{}] needs itemId {} but no such item exists.", quest->GetTitle().c_str(), + quest->GetQuestId(), itemId); } else if (errorNr == 4) { - LOG_ERROR("playerbots", "Quest {} [{}] needs {} [{}] for loot of item {} [{}] for objective {} but none is found in the world.", - quest->GetTitle().c_str(), quest->GetQuestId(), unitName.c_str(), unitId, proto->Name1.c_str(), itemId, objective); + LOG_ERROR( + "playerbots", + "Quest {} [{}] needs {} [{}] for loot of item {} [{}] for objective {} but none is found in the world.", + quest->GetTitle().c_str(), quest->GetQuestId(), unitName.c_str(), unitId, proto->Name1.c_str(), itemId, + objective); } else if (errorNr == 5) { LOG_ERROR("playerbots", "Quest {} [{}] needs item {} [{}] for objective {} but none is found in the world.", - quest->GetTitle().c_str(), quest->GetQuestId(), proto->Name1.c_str(), itemId, objective); + quest->GetTitle().c_str(), quest->GetQuestId(), proto->Name1.c_str(), itemId, objective); } else if (errorNr == 6) { @@ -1737,7 +1715,8 @@ void TravelMgr::logQuestError(uint32 errorNr, Quest* quest, uint32 objective, ui } else if (errorNr == 8) { - LOG_ERROR("playerbots", "Quest {} [{}] has no quest viable quest objective.", quest->GetTitle().c_str(), quest->GetQuestId()); + LOG_ERROR("playerbots", "Quest {} [{}] has no quest viable quest objective.", quest->GetTitle().c_str(), + quest->GetQuestId()); } } @@ -1773,10 +1752,10 @@ void TravelMgr::LoadQuestTravelTable() uint32 type; uint32 entry; uint32 map; - float x; - float y; - float z; - float o; + float x; + float y; + float z; + float o; uint32 c; } t_unit; std::vector units; @@ -1845,7 +1824,10 @@ void TravelMgr::LoadQuestTravelTable() /* // 0 1 2 3 4 5 6 7 8 - std::string const query = "SELECT 0,guid,id,map,position_x,position_y,position_z,orientation, (SELECT COUNT(*) FROM creature k WHERE c.id1 = k.id1) FROM creature c UNION ALL SELECT 1,guid,id,map,position_x,position_y,position_z,orientation, (SELECT COUNT(*) FROM gameobject h WHERE h.id = g.id) FROM gameobject g"; + std::string const query = "SELECT 0,guid,id,map,position_x,position_y,position_z,orientation, (SELECT COUNT(*) FROM + creature k WHERE c.id1 = k.id1) FROM creature c UNION ALL SELECT + 1,guid,id,map,position_x,position_y,position_z,orientation, (SELECT COUNT(*) FROM gameobject h WHERE h.id = g.id) + FROM gameobject g"; QueryResult result = WorldDatabase.Query(query.c_str()); if (result) @@ -1875,8 +1857,9 @@ void TravelMgr::LoadQuestTravelTable() LOG_ERROR("playerbots", ">> Error loading units locations."); } - query = "SELECT 0, 0, id, quest FROM creature_queststarter UNION ALL SELECT 0, 1, id, quest FROM creature_questender UNION ALL SELECT 1, 0, id, quest FROM gameobject_queststarter UNION ALL SELECT 1, 1, id, quest FROM gameobject_questender"; - result = WorldDatabase.Query(query.c_str()); + query = "SELECT 0, 0, id, quest FROM creature_queststarter UNION ALL SELECT 0, 1, id, quest FROM creature_questender + UNION ALL SELECT 1, 0, id, quest FROM gameobject_queststarter UNION ALL SELECT 1, 1, id, quest FROM + gameobject_questender"; result = WorldDatabase.Query(query.c_str()); if (result) { @@ -1900,8 +1883,10 @@ void TravelMgr::LoadQuestTravelTable() LOG_ERROR("playerbots", ">> Error loading relations."); } - query = "SELECT 0, ct.entry, item FROM creature_template ct JOIN creature_loot_template clt ON (ct.lootid = clt.entry) UNION ALL SELECT 0, entry, item FROM npc_vendor UNION ALL SELECT 1, gt.entry, item FROM gameobject_template gt JOIN gameobject_loot_template glt ON (gt.TYPE = 3 AND gt.DATA1 = glt.entry)"; - result = WorldDatabase.Query(query.c_str()); + query = "SELECT 0, ct.entry, item FROM creature_template ct JOIN creature_loot_template clt ON (ct.lootid = + clt.entry) UNION ALL SELECT 0, entry, item FROM npc_vendor UNION ALL SELECT 1, gt.entry, item FROM + gameobject_template gt JOIN gameobject_loot_template glt ON (gt.TYPE = 3 AND gt.DATA1 = glt.entry)"; result = + WorldDatabase.Query(query.c_str()); if (result) { @@ -1951,7 +1936,8 @@ void TravelMgr::LoadQuestTravelTable() if (flag & (uint32)QuestRelationFlag::questGiver) { - loc = new QuestRelationTravelDestination(questId, entry, 0, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance); + loc = new QuestRelationTravelDestination( + questId, entry, 0, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance); loc->setExpireDelay(5 * 60 * 1000); loc->setMaxVisitors(15, 0); container->questGivers.push_back(loc); @@ -1959,7 +1945,8 @@ void TravelMgr::LoadQuestTravelTable() } if (flag & (uint32)QuestRelationFlag::questTaker) { - loc = new QuestRelationTravelDestination(questId, entry, 1, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance); + loc = new QuestRelationTravelDestination( + questId, entry, 1, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance); loc->setExpireDelay(5 * 60 * 1000); loc->setMaxVisitors(15, 0); container->questTakers.push_back(loc); @@ -1977,7 +1964,9 @@ void TravelMgr::LoadQuestTravelTable() else if (flag & (uint32)QuestRelationFlag::objective4) objective = 3; - loc = new QuestObjectiveTravelDestination(questId, entry, objective, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance); + loc = new QuestObjectiveTravelDestination(questId, entry, objective, + sPlayerbotAIConfig->tooCloseDistance, + sPlayerbotAIConfig->sightDistance); loc->setExpireDelay(1 * 60 * 1000); loc->setMaxVisitors(100, 1); container->questObjectives.push_back(loc); @@ -2026,9 +2015,8 @@ void TravelMgr::LoadQuestTravelTable() int32 entry = r.type == 0 ? r.entry : r.entry * -1; - loc = new QuestRelationTravelDestination(r.questId, entry, r.role, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance); - loc->setExpireDelay(5 * 60 * 1000); - loc->setMaxVisitors(15, 0); + loc = new QuestRelationTravelDestination(r.questId, entry, r.role, sPlayerbotAIConfig->tooCloseDistance, + sPlayerbotAIConfig->sightDistance); loc->setExpireDelay(5 * 60 * 1000); loc->setMaxVisitors(15, 0); for (auto& u : units) { @@ -2066,9 +2054,8 @@ void TravelMgr::LoadQuestTravelTable() uint32 reqEntry = quest->RequiredNpcOrGo[i]; - loc = new QuestObjectiveTravelDestination(questId, reqEntry, i, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance); - loc->setExpireDelay(1 * 60 * 1000); - loc->setMaxVisitors(100, 1); + loc = new QuestObjectiveTravelDestination(questId, reqEntry, i, sPlayerbotAIConfig->tooCloseDistance, + sPlayerbotAIConfig->sightDistance); loc->setExpireDelay(1 * 60 * 1000); loc->setMaxVisitors(100, 1); for (auto& u : units) { @@ -2118,9 +2105,8 @@ void TravelMgr::LoadQuestTravelTable() int32 entry = l.type == 0 ? l.entry : l.entry * -1; - loc = new QuestObjectiveTravelDestination(questId, entry, i, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance, l.item); - loc->setExpireDelay(1 * 60 * 1000); - loc->setMaxVisitors(100, 1); + loc = new QuestObjectiveTravelDestination(questId, entry, i, sPlayerbotAIConfig->tooCloseDistance, + sPlayerbotAIConfig->sightDistance, l.item); loc->setExpireDelay(1 * 60 * 1000); loc->setMaxVisitors(100, 1); for (auto& u : units) { @@ -2172,7 +2158,7 @@ void TravelMgr::LoadQuestTravelTable() LOG_INFO("playerbots", "Loading Rpg, Grind and Boss locations."); - //Rpg locations + // Rpg locations for (auto& u : units) { RpgTravelDestination* rLoc; @@ -2208,7 +2194,8 @@ void TravelMgr::LoadQuestTravelTable() { if ((cInfo->npcflag & *i) != 0) { - rLoc = new RpgTravelDestination(u.entry, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance); + rLoc = new RpgTravelDestination(u.entry, sPlayerbotAIConfig->tooCloseDistance, + sPlayerbotAIConfig->sightDistance); rLoc->setExpireDelay(5 * 60 * 1000); rLoc->setMaxVisitors(15, 0); @@ -2220,7 +2207,8 @@ void TravelMgr::LoadQuestTravelTable() if (cInfo->mingold > 0) { - gLoc = new GrindTravelDestination(u.entry, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance); + gLoc = new GrindTravelDestination(u.entry, sPlayerbotAIConfig->tooCloseDistance, + sPlayerbotAIConfig->sightDistance); gLoc->setExpireDelay(5 * 60 * 1000); gLoc->setMaxVisitors(100, 0); @@ -2233,7 +2221,8 @@ void TravelMgr::LoadQuestTravelTable() { std::string const nodeName = cInfo->Name; - bLoc = new BossTravelDestination(u.entry, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance); + bLoc = new BossTravelDestination(u.entry, sPlayerbotAIConfig->tooCloseDistance, + sPlayerbotAIConfig->sightDistance); bLoc->setExpireDelay(5 * 60 * 1000); bLoc->setMaxVisitors(0, 0); @@ -2244,7 +2233,7 @@ void TravelMgr::LoadQuestTravelTable() LOG_INFO("playerbots", "Loading Explore locations."); - //Explore points + // Explore points for (auto& u : units) { ExploreTravelDestination* loc; @@ -2265,7 +2254,8 @@ void TravelMgr::LoadQuestTravelTable() if (iloc == exploreLocs.end()) { - loc = new ExploreTravelDestination(area->ID, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance); + loc = new ExploreTravelDestination(area->ID, sPlayerbotAIConfig->tooCloseDistance, + sPlayerbotAIConfig->sightDistance); loc->setMaxVisitors(1000, 0); loc->setCooldownDelay(1000); loc->setExpireDelay(1000); @@ -2280,7 +2270,7 @@ void TravelMgr::LoadQuestTravelTable() loc->addPoint(&point); } - //Clear these logs files + // Clear these logs files sPlayerbotAIConfig->openLog("zones.csv", "w"); sPlayerbotAIConfig->openLog("creatures.csv", "w"); sPlayerbotAIConfig->openLog("gos.csv", "w"); @@ -2496,7 +2486,8 @@ void TravelMgr::LoadQuestTravelTable() if (pos.distance(&lPos) == 0) { - TravelNode* node = sTravelNodeMap->addNode(&pos, data->name, true, true, true, iter.first); + TravelNode* node = sTravelNodeMap->addNode(&pos, data->name, true, true, true, + iter.first); if (!prevNode) { @@ -2506,9 +2497,8 @@ void TravelMgr::LoadQuestTravelTable() else { float totalTime = (p.second->TimeSeg - timeStart) / 1000.0f; - TravelNodePath travelPath(0.1f, totalTime, (uint8) TravelNodePathType::transport, entry, true); - node->setPathTo(prevNode, travelPath); - ppath.clear(); + TravelNodePath travelPath(0.1f, totalTime, (uint8) + TravelNodePathType::transport, entry, true); node->setPathTo(prevNode, travelPath); ppath.clear(); ppath.push_back(pos); timeStart = p.second->TimeSeg; } @@ -2525,19 +2515,19 @@ void TravelMgr::LoadQuestTravelTable() { float dx = cos(u.o) * p.second->X - sin(u.o) * p.second->Y; float dy = sin(u.o) * p.second->X + cos(u.o) * p.second->Y; - WorldPosition pos = WorldPosition(u.map, u.x + dx, u.y + dy, u.z + p.second->Z, u.o); + WorldPosition pos = WorldPosition(u.map, u.x + dx, u.y + dy, u.z + p.second->Z, + u.o); ppath.push_back(pos); if (pos.distance(&lPos) == 0) { - TravelNode* node = sTravelNodeMap->addNode(&pos, data->name, true, true, true, iter.first); - if (node != prevNode) + TravelNode* node = sTravelNodeMap->addNode(&pos, data->name, true, true, true, + iter.first); if (node != prevNode) { float totalTime = (p.second->TimeSeg - timeStart) / 1000.0f; - TravelNodePath travelPath(0.1f, totalTime, (uint8) TravelNodePathType::transport, entry, true); - travelPath.setPath(ppath); - node->setPathTo(prevNode, travelPath); + TravelNodePath travelPath(0.1f, totalTime, (uint8) + TravelNodePathType::transport, entry, true); travelPath.setPath(ppath); node->setPathTo(prevNode, travelPath); ppath.clear(); ppath.push_back(pos); timeStart = p.second->TimeSeg; @@ -2579,10 +2569,8 @@ void TravelMgr::LoadQuestTravelTable() } else { - TravelNodePath travelPath(0.1f, 0.0, (uint8) TravelNodePathType::transport, entry, true); - travelPath.setPathAndCost(ppath, moveSpeed); - node->setPathTo(prevNode, travelPath); - ppath.clear(); + TravelNodePath travelPath(0.1f, 0.0, (uint8) TravelNodePathType::transport, entry, + true); travelPath.setPathAndCost(ppath, moveSpeed); node->setPathTo(prevNode, travelPath); ppath.clear(); ppath.push_back(pos); } @@ -2609,9 +2597,8 @@ void TravelMgr::LoadQuestTravelTable() TravelNode* node = sTravelNodeMap->getNode(&pos, nullptr, 5.0f); if (node != prevNode) { - TravelNodePath travelPath(0.1f, 0.0, (uint8) TravelNodePathType::transport, entry, true); - travelPath.setPathAndCost(ppath, moveSpeed); - node->setPathTo(prevNode, travelPath); + TravelNodePath travelPath(0.1f, 0.0, (uint8) TravelNodePathType::transport, entry, + true); travelPath.setPathAndCost(ppath, moveSpeed); node->setPathTo(prevNode, travelPath); } } } @@ -2647,12 +2634,12 @@ void TravelMgr::LoadQuestTravelTable() */ /* - bool preloadNodePaths = false || fullNavPointReload || storeNavPointReload; //Calculate paths using PathGenerator. - bool preloadReLinkFullyLinked = false || fullNavPointReload || storeNavPointReload; //Retry nodes that are fully linked. - bool preloadUnlinkedPaths = false || fullNavPointReload; //Try to connect points currently unlinked. - bool preloadWorldPaths = true; //Try to load paths in overworld. - bool preloadInstancePaths = true; //Try to load paths in instances. - bool preloadSubPrint = false; //Print output every 2%. + bool preloadNodePaths = false || fullNavPointReload || storeNavPointReload; //Calculate paths using + PathGenerator. bool preloadReLinkFullyLinked = false || fullNavPointReload || storeNavPointReload; //Retry + nodes that are fully linked. bool preloadUnlinkedPaths = false || fullNavPointReload; //Try to connect points + currently unlinked. bool preloadWorldPaths = true; //Try to load paths in overworld. bool + preloadInstancePaths = true; //Try to load paths in instances. bool preloadSubPrint = false; //Print output + every 2%. if (preloadNodePaths) { @@ -2832,7 +2819,7 @@ void TravelMgr::LoadQuestTravelTable() sTravelNodeMap->printNodeStore(); sTravelNodeMap->saveNodeStore(); - //Creature/gos/zone export. + // Creature/gos/zone export. if (sPlayerbotAIConfig->hasLog("creatures.csv")) { for (CreatureData const* cData : WorldPosition().getCreaturesNear()) @@ -2841,7 +2828,8 @@ void TravelMgr::LoadQuestTravelTable() if (!cInfo) continue; - WorldPosition point = WorldPosition(cData->mapid, cData->posX, cData->posY, cData->posZ, cData->orientation); + WorldPosition point = + WorldPosition(cData->mapid, cData->posX, cData->posY, cData->posZ, cData->orientation); std::string name = cInfo->Name; name.erase(remove(name.begin(), name.end(), ','), name.end()); @@ -2866,29 +2854,16 @@ void TravelMgr::LoadQuestTravelTable() uint32 mapId = 0; std::vector pos; - static float const topNorthSouthLimit[] = - { - 2032.048340f, -6927.750000f, - 1634.863403f, -6157.505371f, - 1109.519775f, -5181.036133f, - 1315.204712f, -4096.020508f, - 1073.089233f, -3372.571533f, - 825.8331910f, -3125.778809f, - 657.3439940f, -2314.813232f, - 424.7361450f, -1888.283691f, - 744.3958130f, -1647.935425f, - 1424.160645f, -654.9481810f, - 1447.065308f, -169.7513580f, - 1208.715454f, 189.74870300f, - 1596.240356f, 998.61669900f, - 1577.923706f, 1293.4199220f, - 1458.520264f, 1727.3732910f, - 1591.916138f, 3728.1394040f - }; + static float const topNorthSouthLimit[] = { + 2032.048340f, -6927.750000f, 1634.863403f, -6157.505371f, 1109.519775f, -5181.036133f, 1315.204712f, + -4096.020508f, 1073.089233f, -3372.571533f, 825.8331910f, -3125.778809f, 657.3439940f, -2314.813232f, + 424.7361450f, -1888.283691f, 744.3958130f, -1647.935425f, 1424.160645f, -654.9481810f, 1447.065308f, + -169.7513580f, 1208.715454f, 189.74870300f, 1596.240356f, 998.61669900f, 1577.923706f, 1293.4199220f, + 1458.520264f, 1727.3732910f, 1591.916138f, 3728.1394040f}; pos.clear(); -# define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) +#define my_sizeof(type) ((char*)(&type + 1) - (char*)(&type)) uint32 size = my_sizeof(topNorthSouthLimit) / my_sizeof(topNorthSouthLimit[0]); for (uint32 i = 0; i < size - 1; i = i + 2) @@ -2900,26 +2875,17 @@ void TravelMgr::LoadQuestTravelTable() } std::ostringstream out; - out << "topNorthSouthLimit" << ","; - WorldPosition().printWKT(pos,out,1); + out << "topNorthSouthLimit" + << ","; + WorldPosition().printWKT(pos, out, 1); out << std::fixed; sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str()); - static float const ironforgeAreaSouthLimit[] = - { - -7491.33f, 3093.740f, - -7472.04f, -391.880f, - -6366.68f, -730.100f, - -6063.96f, -1411.76f, - -6087.62f, -2190.21f, - -6349.54f, -2533.66f, - -6308.63f, -3049.32f, - -6107.82f, -3345.30f, - -6008.49f, -3590.52f, - -5989.37f, -4312.29f, - -5806.26f, -5864.11f - }; + static float const ironforgeAreaSouthLimit[] = { + -7491.33f, 3093.740f, -7472.04f, -391.880f, -6366.68f, -730.100f, -6063.96f, -1411.76f, + -6087.62f, -2190.21f, -6349.54f, -2533.66f, -6308.63f, -3049.32f, -6107.82f, -3345.30f, + -6008.49f, -3590.52f, -5989.37f, -4312.29f, -5806.26f, -5864.11f}; pos.clear(); @@ -2936,31 +2902,18 @@ void TravelMgr::LoadQuestTravelTable() out.str(""); out.clear(); - out << "ironforgeAreaSouthLimit" << ","; + out << "ironforgeAreaSouthLimit" + << ","; WorldPosition().printWKT(pos, out, 1); out << std::fixed; sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str()); - static float const stormwindAreaNorthLimit[] = - { - -8004.250f, 3714.110f, - -8075.000f, -179.000f, - -8638.000f, 169.0000f, - -9044.000f, 35.00000f, - -9068.000f, -125.000f, - -9094.000f, -147.000f, - -9206.000f, -290.000f, - -9097.000f, -510.000f, - -8739.000f, -501.000f, - -8725.500f, -1618.45f, - -9810.400f, -1698.41f, - -10049.60f, -1740.40f, - -10670.61f, -1692.51f, - -10908.48f, -1563.87f, - -13006.40f, -1622.80f, - -12863.23f, -4798.42f - }; + static float const stormwindAreaNorthLimit[] = { + -8004.250f, 3714.110f, -8075.000f, -179.000f, -8638.000f, 169.0000f, -9044.000f, 35.00000f, + -9068.000f, -125.000f, -9094.000f, -147.000f, -9206.000f, -290.000f, -9097.000f, -510.000f, + -8739.000f, -501.000f, -8725.500f, -1618.45f, -9810.400f, -1698.41f, -10049.60f, -1740.40f, + -10670.61f, -1692.51f, -10908.48f, -1563.87f, -13006.40f, -1622.80f, -12863.23f, -4798.42f}; pos.clear(); @@ -2977,35 +2930,21 @@ void TravelMgr::LoadQuestTravelTable() out.str(""); out.clear(); - out << "stormwindAreaNorthLimit" << ","; + out << "stormwindAreaNorthLimit" + << ","; WorldPosition().printWKT(pos, out, 1); out << std::fixed; sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str()); - static float const stormwindAreaSouthLimit[] = - { - -8725.3378910f, 3535.62402300f, - -9525.6992190f, 910.13256800f, - -9796.9531250f, 839.06958000f, - -9946.3417970f, 743.10284400f, - -10287.361328f, 760.07647700f, - -10083.828125f, 380.38989300f, - -10148.072266f, 80.056450000f, - -10014.583984f, -161.6385190f, - -9978.1464840f, -361.6380310f, - -9877.4892580f, -563.3048710f, - -9980.9677730f, -1128.510498f, - -9991.7177730f, -1428.793213f, - -9887.5791020f, -1618.514038f, - -10169.600586f, -1801.582031f, - -9966.2744140f, -2227.197754f, - -9861.3095700f, -2989.841064f, - -9944.0263670f, -3205.886963f, - -9610.2099610f, -3648.369385f, - -7949.3295900f, -4081.389404f, - -7910.8593750f, -5855.578125f - }; + static float const stormwindAreaSouthLimit[] = { + -8725.3378910f, 3535.62402300f, -9525.6992190f, 910.13256800f, -9796.9531250f, 839.06958000f, + -9946.3417970f, 743.10284400f, -10287.361328f, 760.07647700f, -10083.828125f, 380.38989300f, + -10148.072266f, 80.056450000f, -10014.583984f, -161.6385190f, -9978.1464840f, -361.6380310f, + -9877.4892580f, -563.3048710f, -9980.9677730f, -1128.510498f, -9991.7177730f, -1428.793213f, + -9887.5791020f, -1618.514038f, -10169.600586f, -1801.582031f, -9966.2744140f, -2227.197754f, + -9861.3095700f, -2989.841064f, -9944.0263670f, -3205.886963f, -9610.2099610f, -3648.369385f, + -7949.3295900f, -4081.389404f, -7910.8593750f, -5855.578125f}; pos.clear(); @@ -3022,7 +2961,8 @@ void TravelMgr::LoadQuestTravelTable() out.str(""); out.clear(); - out << "stormwindAreaSouthLimit" << ","; + out << "stormwindAreaSouthLimit" + << ","; WorldPosition().printWKT(pos, out, 1); out << std::fixed; @@ -3030,42 +2970,15 @@ void TravelMgr::LoadQuestTravelTable() mapId = 1; - static float const northMiddleLimit[] = - { - -2280.00f, 4054.000f, - -2401.00f, 2365.000f, - -2432.00f, 1338.000f, - -2286.00f, 769.0000f, - -2137.00f, 662.0000f, - -2044.54f, 489.8600f, - -1808.52f, 436.3900f, - -1754.85f, 504.5500f, - -1094.55f, 651.7500f, - -747.460f, 647.7300f, - -685.550f, 408.4300f, - -311.380f, 114.4300f, - -358.400f, -587.420f, - -377.920f, -748.700f, - -512.570f, -919.490f, - -280.650f, -1008.87f, - -81.2900f, -930.890f, - 284.3100f, -1105.39f, - 568.8600f, -892.280f, - 1211.090f, -1135.55f, - 879.6000f, -2110.18f, - 788.9600f, -2276.02f, - 899.6800f, -2625.56f, - 1281.540f, -2689.42f, - 1521.820f, -3047.85f, - 1424.220f, -3365.69f, - 1694.110f, -3615.20f, - 2373.780f, -4019.96f, - 2388.130f, -5124.35f, - 2193.790f, -5484.38f, - 1703.570f, -5510.53f, - 1497.590f, -6376.56f, - 1368.000f, -8530.00f - }; + static float const northMiddleLimit[] = { + -2280.00f, 4054.000f, -2401.00f, 2365.000f, -2432.00f, 1338.000f, -2286.00f, 769.0000f, -2137.00f, + 662.0000f, -2044.54f, 489.8600f, -1808.52f, 436.3900f, -1754.85f, 504.5500f, -1094.55f, 651.7500f, + -747.460f, 647.7300f, -685.550f, 408.4300f, -311.380f, 114.4300f, -358.400f, -587.420f, -377.920f, + -748.700f, -512.570f, -919.490f, -280.650f, -1008.87f, -81.2900f, -930.890f, 284.3100f, -1105.39f, + 568.8600f, -892.280f, 1211.090f, -1135.55f, 879.6000f, -2110.18f, 788.9600f, -2276.02f, 899.6800f, + -2625.56f, 1281.540f, -2689.42f, 1521.820f, -3047.85f, 1424.220f, -3365.69f, 1694.110f, -3615.20f, + 2373.780f, -4019.96f, 2388.130f, -5124.35f, 2193.790f, -5484.38f, 1703.570f, -5510.53f, 1497.590f, + -6376.56f, 1368.000f, -8530.00f}; pos.clear(); @@ -3082,36 +2995,18 @@ void TravelMgr::LoadQuestTravelTable() out.str(""); out.clear(); - out << "northMiddleLimit" << ","; + out << "northMiddleLimit" + << ","; WorldPosition().printWKT(pos, out, 1); out << std::fixed; sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str()); - static float const durotarSouthLimit[] = - { - 2755.0f, -3766.f, - 2225.0f, -3596.f, - 1762.0f, -3746.f, - 1564.0f, -3943.f, - 1184.0f, -3915.f, - 737.00f, -3782.f, - -75.00f, -3742.f, - -263.0f, -3836.f, - -173.0f, -4064.f, - -81.00f, -4091.f, - -49.00f, -4089.f, - -16.00f, -4187.f, - -5.000f, -4192.f, - -14.00f, -4551.f, - -397.0f, -4601.f, - -522.0f, -4583.f, - -668.0f, -4539.f, - -790.0f, -4502.f, - -1176.f, -4213.f, - -1387.f, -4674.f, - -2243.f, -6046.f - }; + static float const durotarSouthLimit[] = { + 2755.0f, -3766.f, 2225.0f, -3596.f, 1762.0f, -3746.f, 1564.0f, -3943.f, 1184.0f, -3915.f, 737.00f, + -3782.f, -75.00f, -3742.f, -263.0f, -3836.f, -173.0f, -4064.f, -81.00f, -4091.f, -49.00f, -4089.f, + -16.00f, -4187.f, -5.000f, -4192.f, -14.00f, -4551.f, -397.0f, -4601.f, -522.0f, -4583.f, -668.0f, + -4539.f, -790.0f, -4502.f, -1176.f, -4213.f, -1387.f, -4674.f, -2243.f, -6046.f}; pos.clear(); @@ -3128,22 +3023,15 @@ void TravelMgr::LoadQuestTravelTable() out.str(""); out.clear(); - out << "durotarSouthLimit" << ","; + out << "durotarSouthLimit" + << ","; WorldPosition().printWKT(pos, out, 1); out << std::fixed; sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str()); - static float const valleyoftrialsSouthLimit[] = - { - -324.f, -3869.f, - -774.f, -3992.f, - -965.f, -4290.f, - -932.f, -4349.f, - -828.f, -4414.f, - -661.f, -4541.f, - -521.f, -4582.f - }; + static float const valleyoftrialsSouthLimit[] = {-324.f, -3869.f, -774.f, -3992.f, -965.f, -4290.f, -932.f, + -4349.f, -828.f, -4414.f, -661.f, -4541.f, -521.f, -4582.f}; pos.clear(); @@ -3160,29 +3048,22 @@ void TravelMgr::LoadQuestTravelTable() out.str(""); out.clear(); - out << "valleyoftrialsSouthLimit" << ","; + out << "valleyoftrialsSouthLimit" + << ","; WorldPosition().printWKT(pos, out, 1); out << std::fixed; sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str()); - static float const middleToSouthLimit[] = - { - -2402.010000f, 4255.7000000f, - -2475.933105f, 3199.5683590f, // Desolace - -2344.124023f, 1756.1643070f, - -2826.438965f, 403.82473800f, // Mulgore - -3472.819580f, 182.52247600f, // Feralas - -4365.006836f, -1602.575439f, // the Barrens - -4515.219727f, -1681.356079f, - -4543.093750f, -1882.869385f, // Thousand Needles - -4824.160000f, -2310.110000f, - -5102.913574f, -2647.062744f, - -5248.286621f, -3034.536377f, - -5246.920898f, -3339.139893f, - -5459.449707f, -4920.155273f, // Tanaris - -5437.000000f, -5863.000000f - }; + static float const middleToSouthLimit[] = { + -2402.010000f, 4255.7000000f, -2475.933105f, 3199.5683590f, // Desolace + -2344.124023f, 1756.1643070f, -2826.438965f, 403.82473800f, // Mulgore + -3472.819580f, 182.52247600f, // Feralas + -4365.006836f, -1602.575439f, // the Barrens + -4515.219727f, -1681.356079f, -4543.093750f, -1882.869385f, // Thousand Needles + -4824.160000f, -2310.110000f, -5102.913574f, -2647.062744f, -5248.286621f, + -3034.536377f, -5246.920898f, -3339.139893f, -5459.449707f, -4920.155273f, // Tanaris + -5437.000000f, -5863.000000f}; pos.clear(); @@ -3199,31 +3080,18 @@ void TravelMgr::LoadQuestTravelTable() out.str(""); out.clear(); - out << "middleToSouthLimit" << ","; + out << "middleToSouthLimit" + << ","; WorldPosition().printWKT(pos, out, 1); out << std::fixed; sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str()); - static float const orgrimmarSouthLimit[] = - { - 2132.5076f, -3912.2478f, - 1944.4298f, -3855.2583f, - 1735.6906f, -3834.2417f, - 1654.3671f, -3380.9902f, - 1593.9861f, -3975.5413f, - 1439.2548f, -4249.6923f, - 1436.3106f, -4007.8950f, - 1393.3199f, -4196.0625f, - 1445.2428f, -4373.9052f, - 1407.2349f, -4429.4145f, - 1464.7142f, -4545.2875f, - 1584.1331f, -4596.8764f, - 1716.8065f, -4601.1323f, - 1875.8312f, -4788.7187f, - 1979.7647f, -4883.4585f, - 2219.1562f, -4854.3330f - }; + static float const orgrimmarSouthLimit[] = { + 2132.5076f, -3912.2478f, 1944.4298f, -3855.2583f, 1735.6906f, -3834.2417f, 1654.3671f, -3380.9902f, + 1593.9861f, -3975.5413f, 1439.2548f, -4249.6923f, 1436.3106f, -4007.8950f, 1393.3199f, -4196.0625f, + 1445.2428f, -4373.9052f, 1407.2349f, -4429.4145f, 1464.7142f, -4545.2875f, 1584.1331f, -4596.8764f, + 1716.8065f, -4601.1323f, 1875.8312f, -4788.7187f, 1979.7647f, -4883.4585f, 2219.1562f, -4854.3330f}; pos.clear(); @@ -3240,34 +3108,19 @@ void TravelMgr::LoadQuestTravelTable() out.str(""); out.clear(); - out << "orgrimmarSouthLimit" << ","; + out << "orgrimmarSouthLimit" + << ","; WorldPosition().printWKT(pos, out, 1); out << std::fixed; sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str()); - static float const feralasThousandNeedlesSouthLimit[] = - { - -6495.4995f, -4711.9810f, - -6674.9995f, -4515.0019f, - -6769.5717f, -4122.4272f, - -6838.2651f, -3874.2792f, - -6851.1314f, -3659.1179f, - -6624.6845f, -3063.3843f, - -6416.9067f, -2570.1301f, - -5959.8466f, -2287.2634f, - -5947.9135f, -1866.5028f, - -5947.9135f, -820.48810f, - -5876.7114f, -3.5138000f, - -5876.7114f, 917.640700f, - -6099.3603f, 1153.28840f, - -6021.8989f, 1638.18090f, - -6091.6176f, 2335.88920f, - -6744.9946f, 2393.48550f, - -6973.8608f, 3077.02810f, - -7068.7241f, 4376.23040f, - -7142.1211f, 4808.43310f - }; + static float const feralasThousandNeedlesSouthLimit[] = { + -6495.4995f, -4711.9810f, -6674.9995f, -4515.0019f, -6769.5717f, -4122.4272f, -6838.2651f, -3874.2792f, + -6851.1314f, -3659.1179f, -6624.6845f, -3063.3843f, -6416.9067f, -2570.1301f, -5959.8466f, -2287.2634f, + -5947.9135f, -1866.5028f, -5947.9135f, -820.48810f, -5876.7114f, -3.5138000f, -5876.7114f, 917.640700f, + -6099.3603f, 1153.28840f, -6021.8989f, 1638.18090f, -6091.6176f, 2335.88920f, -6744.9946f, 2393.48550f, + -6973.8608f, 3077.02810f, -7068.7241f, 4376.23040f, -7142.1211f, 4808.43310f}; pos.clear(); @@ -3278,13 +3131,15 @@ void TravelMgr::LoadQuestTravelTable() if (feralasThousandNeedlesSouthLimit[i] == 0) break; - pos.push_back(WorldPosition(mapId, feralasThousandNeedlesSouthLimit[i], feralasThousandNeedlesSouthLimit[i + 1], 0)); + pos.push_back( + WorldPosition(mapId, feralasThousandNeedlesSouthLimit[i], feralasThousandNeedlesSouthLimit[i + 1], 0)); } out.str(""); out.clear(); - out << "feralasThousandNeedlesSouthLimit" << ","; + out << "feralasThousandNeedlesSouthLimit" + << ","; WorldPosition().printWKT(pos, out, 1); out << std::fixed; @@ -3299,7 +3154,8 @@ void TravelMgr::LoadQuestTravelTable() if (!data) continue; - WorldPosition point = WorldPosition(gData->mapid, gData->posX, gData->posY, gData->posZ, gData->orientation); + WorldPosition point = + WorldPosition(gData->mapid, gData->posX, gData->posY, gData->posZ, gData->orientation); std::string name = data->name; name.erase(remove(name.begin(), name.end(), ','), name.end()); @@ -3341,13 +3197,15 @@ void TravelMgr::LoadQuestTravelTable() if (!sTravelNodeMap->getMapOffset(loc.second.front().getMapId()) && loc.second.front().getMapId() != 0) continue; - std::vector points = loc.second;; + std::vector points = loc.second; + ; std::ostringstream out; WorldPosition pos = WorldPosition(points, WP_MEAN_CENTROID); - out << "\"center\"" << ","; + out << "\"center\"" + << ","; out << points.begin()->getMapId() << ","; out << points.begin()->getAreaName() << ","; out << points.begin()->getAreaName(true, true) << ","; @@ -3356,7 +3214,8 @@ void TravelMgr::LoadQuestTravelTable() out << "\n"; - out << "\"area\"" << ","; + out << "\"area\"" + << ","; out << points.begin()->getMapId() << ","; out << points.begin()->getAreaName() << ","; out << points.begin()->getAreaName(true, true) << ","; @@ -3372,7 +3231,7 @@ void TravelMgr::LoadQuestTravelTable() if (printStrategyMap && sPlayerbotAIConfig->hasLog("strategy.csv")) { static std::map classes; - static std::map > specs; + static std::map> specs; classes[CLASS_DRUID] = "druid"; specs[CLASS_DRUID][0] = "balance"; specs[CLASS_DRUID][1] = "feral combat"; @@ -3423,7 +3282,7 @@ void TravelMgr::LoadQuestTravelTable() specs[CLASS_DEATH_KNIGHT][1] = "frost"; specs[CLASS_DEATH_KNIGHT][2] = "unholy"; - //Use randombot 0. + // Use randombot 0. std::ostringstream cout; cout << sPlayerbotAIConfig->randomBotAccountPrefix << 0; std::string const accountName = cout.str(); @@ -3436,7 +3295,9 @@ void TravelMgr::LoadQuestTravelTable() Field* fields = result->Fetch(); uint32 accountId = fields[0].Get(); - WorldSession* session = new WorldSession(accountId, "" , nullptr, SEC_PLAYER, EXPANSION_WRATH_OF_THE_LICH_KING, time_t(0), LOCALE_enUS, 0, false, false, 0, true); + WorldSession* session = + new WorldSession(accountId, "", nullptr, SEC_PLAYER, EXPANSION_WRATH_OF_THE_LICH_KING, time_t(0), + LOCALE_enUS, 0, false, false, 0, true); std::vector, uint32>> classSpecLevel; @@ -3450,9 +3311,11 @@ void TravelMgr::LoadQuestTravelTable() { if (cls != 10) { - std::unique_ptr characterInfo = std::make_unique("dummy", race, cls, 1, 1, 1, 1, 1, 1); + std::unique_ptr characterInfo = + std::make_unique("dummy", race, cls, 1, 1, 1, 1, 1, 1); Player* player = new Player(session); - if (player->Create(sObjectMgr->GetGenerator().Generate(), characterInfo.get())) + if (player->Create(sObjectMgr->GetGenerator().Generate(), + characterInfo.get())) { for (uint8 tab = 0; tab < 3; tab++) { @@ -3508,7 +3371,8 @@ void TravelMgr::LoadQuestTravelTable() NextAction* nextAction = strat->getDefaultActions()[i]; std::ostringstream aout; - aout << nextAction->getRelevance() << "," << nextAction->getName() << ",,S:" << stratName; + aout << nextAction->getRelevance() << "," << nextAction->getName() + << ",,S:" << stratName; if (actions.find(aout.str().c_str()) != actions.end()) classSpecLevel = actions.find(aout.str().c_str())->second; @@ -3524,7 +3388,7 @@ void TravelMgr::LoadQuestTravelTable() strat->InitTriggers(triggers); for (auto& triggerNode : triggers) { - //out << " TN:" << triggerNode->getName(); + // out << " TN:" << triggerNode->getName(); if (Trigger* trigger = con->GetTrigger(triggerNode->getName())) { @@ -3535,17 +3399,20 @@ void TravelMgr::LoadQuestTravelTable() for (uint32 i = 0; i < NextAction::size(nextActions); i++) { NextAction* nextAction = nextActions[i]; - //out << " A:" << nextAction->getName() << "(" << nextAction->getRelevance() << ")"; + // out << " A:" << nextAction->getName() << "(" << + // nextAction->getRelevance() << ")"; std::ostringstream aout; - aout << nextAction->getRelevance() << "," << nextAction->getName() << "," << triggerNode->getName() << "," << stratName; + aout << nextAction->getRelevance() << "," << nextAction->getName() + << "," << triggerNode->getName() << "," << stratName; if (actions.find(aout.str().c_str()) != actions.end()) classSpecLevel = actions.find(aout.str().c_str())->second; else classSpecLevel.clear(); - classSpecLevel.push_back(std::make_pair(std::make_pair(cls, tab), lvl)); + classSpecLevel.push_back( + std::make_pair(std::make_pair(cls, tab), lvl)); actions.insert_or_assign(aout.str().c_str(), classSpecLevel); } @@ -3568,29 +3435,30 @@ void TravelMgr::LoadQuestTravelTable() for (auto& action : actions) actionKeys.push_back(action.first); - std::sort(actionKeys.begin(), actionKeys.end(), [](std::string const i, std::string const j) - { - std::stringstream is(i); - std::stringstream js(j); - float iref, jref; - std::string iact, jact, itrig, jtrig, istrat, jstrat; - is >> iref >> iact >> itrig >> istrat; - js >> jref >> jact >> jtrig >> jstrat; + std::sort(actionKeys.begin(), actionKeys.end(), + [](std::string const i, std::string const j) + { + std::stringstream is(i); + std::stringstream js(j); + float iref, jref; + std::string iact, jact, itrig, jtrig, istrat, jstrat; + is >> iref >> iact >> itrig >> istrat; + js >> jref >> jact >> jtrig >> jstrat; - if (iref > jref) - return true; + if (iref > jref) + return true; - if (iref == jref && istrat < jstrat) - return true; + if (iref == jref && istrat < jstrat) + return true; - if (iref == jref && !(istrat > jstrat) && iact < jact) - return true; + if (iref == jref && !(istrat > jstrat) && iact < jact) + return true; - if (iref == jref && !(istrat > jstrat) && !(iact > jact) && itrig < jtrig) - return true; + if (iref == jref && !(istrat > jstrat) && !(iact > jact) && itrig < jtrig) + return true; - return false; - }); + return false; + }); sPlayerbotAIConfig->log("strategy.csv", "relevance, action, trigger, strategy, classes"); @@ -3604,15 +3472,15 @@ void TravelMgr::LoadQuestTravelTable() for (auto cl : classSpecLevel) { - uint32 minLevel = MAX_LEVEL; uint32 maxLevel = 0; + uint32 minLevel = MAX_LEVEL; + uint32 maxLevel = 0; uint32 cls = cl.first.first; uint32 tb = cl.first.second; - if (std::find_if(classs.begin(), classs.end(), [cls, tb](std::pair, std::pair> i) - { - return i.first.first == cls && i.first.second == tb; - }) == classs.end()) + if (std::find_if(classs.begin(), classs.end(), + [cls, tb](std::pair, std::pair> i) + { return i.first.first == cls && i.first.second == tb; }) == classs.end()) { for (auto cll : classSpecLevel) { @@ -3635,22 +3503,21 @@ void TravelMgr::LoadQuestTravelTable() for (uint8 cls = CLASS_WARRIOR; cls < MAX_CLASSES; ++cls) { - bool a[3] = { false,false,false }; - uint32 min[3] = { 0,0,0 }; - uint32 max[3] = { 0,0,0 }; + bool a[3] = {false, false, false}; + uint32 min[3] = {0, 0, 0}; + uint32 max[3] = {0, 0, 0}; - if (std::find_if(classs.begin(), classs.end(), [cls](std::pair, std::pair> i) - { - return i.first.first == cls; - }) == classs.end()) + if (std::find_if(classs.begin(), classs.end(), + [cls](std::pair, std::pair> i) + { return i.first.first == cls; }) == classs.end()) continue; for (uint32 tb = 0; tb < 3; tb++) { - auto tcl = std::find_if(classs.begin(), classs.end(), [cls, tb](std::pair, std::pair> i) - { - return i.first.first == cls && i.first.second == tb; - }); + auto tcl = std::find_if( + classs.begin(), classs.end(), + [cls, tb](std::pair, std::pair> i) + { return i.first.first == cls && i.first.second == tb; }); if (tcl == classs.end()) continue; @@ -3678,7 +3545,8 @@ void TravelMgr::LoadQuestTravelTable() continue; if (min[tb] != 1 || max[tb] != MAX_LEVEL - 1) - out << specs[cls][tb] << " " << classes[cls] << "(" << min[tb] << "-" << max[tb] << ")"; + out << specs[cls][tb] << " " << classes[cls] << "(" << min[tb] << "-" << max[tb] + << ")"; else out << specs[cls][tb] << " " << classes[cls]; @@ -3751,8 +3619,9 @@ void TravelMgr::LoadQuestTravelTable() std::ostringstream out; std::string const name = i.second->getTitle(); name.erase(remove(name.begin(), name.end(), '\"'), name.end()); - out << std::fixed << std::setprecision(2) << name.c_str() << "," << i.first << "," << j->getDisplayX() << "," << j->getDisplayY() << "," << j->getX() << "," << j->getY() << "," << j->getZ(); - sPlayerbotAIConfig->log(5, out.str().c_str()); + out << std::fixed << std::setprecision(2) << name.c_str() << "," << i.first << "," << j->getDisplayX() << + "," << j->getDisplayY() << "," << j->getX() << "," << j->getY() << "," << j->getZ(); sPlayerbotAIConfig->log(5, + out.str().c_str()); } } @@ -3763,8 +3632,8 @@ uint32 TravelMgr::getDialogStatus(Player* pPlayer, int32 questgiver, Quest const { uint32 dialogStatus = DIALOG_STATUS_NONE; - QuestRelationBounds rbounds; // QuestRelations (quest-giver) - QuestRelationBounds irbounds; // InvolvedRelations (quest-finisher) + QuestRelationBounds rbounds; // QuestRelations (quest-giver) + QuestRelationBounds irbounds; // InvolvedRelations (quest-finisher) uint32 questId = pQuest->GetQuestId(); @@ -3794,7 +3663,8 @@ uint32 TravelMgr::getDialogStatus(Player* pPlayer, int32 questgiver, Quest const QuestStatus status = pPlayer->GetQuestStatus(questId); - if ((status == QUEST_STATUS_COMPLETE && !pPlayer->GetQuestRewardStatus(questId)) || (pQuest->IsAutoComplete() && pPlayer->CanTakeQuest(pQuest, false))) + if ((status == QUEST_STATUS_COMPLETE && !pPlayer->GetQuestRewardStatus(questId)) || + (pQuest->IsAutoComplete() && pPlayer->CanTakeQuest(pQuest, false))) { if (pQuest->IsAutoComplete() && pQuest->IsRepeatable()) { @@ -3831,7 +3701,8 @@ uint32 TravelMgr::getDialogStatus(Player* pPlayer, int32 questgiver, Quest const QuestStatus status = pPlayer->GetQuestStatus(questId); - if (status == QUEST_STATUS_NONE) // For all other cases the mark is handled either at some place else, or with involved-relations already + if (status == QUEST_STATUS_NONE) // For all other cases the mark is handled either at some place else, or with + // involved-relations already { if (pPlayer->CanSeeStartQuest(pQuest)) { @@ -3842,7 +3713,8 @@ uint32 TravelMgr::getDialogStatus(Player* pPlayer, int32 questgiver, Quest const { dialogStatusNew = DIALOG_STATUS_REWARD_REP; } - else if (lowLevelDiff < 0 || pPlayer->GetLevel() <= pPlayer->GetQuestLevel(pQuest) + uint32(lowLevelDiff)) + else if (lowLevelDiff < 0 || + pPlayer->GetLevel() <= pPlayer->GetQuestLevel(pQuest) + uint32(lowLevelDiff)) { dialogStatusNew = DIALOG_STATUS_AVAILABLE; } @@ -3867,8 +3739,9 @@ uint32 TravelMgr::getDialogStatus(Player* pPlayer, int32 questgiver, Quest const return dialogStatus; } -//Selects a random WorldPosition from a list. Use a distance weighted distribution. -std::vector TravelMgr::getNextPoint(WorldPosition* center, std::vector points, uint32 amount) +// Selects a random WorldPosition from a list. Use a distance weighted distribution. +std::vector TravelMgr::getNextPoint(WorldPosition* center, std::vector points, + uint32 amount) { std::vector retVec; @@ -3884,20 +3757,20 @@ std::vector TravelMgr::getNextPoint(WorldPosition* center, std:: std::vector weights; - //List of weights based on distance (Gausian curve that starts at 100 and lower to 1 at 1000 distance) - //std::transform(retVec.begin(), retVec.end(), std::back_inserter(weights), [center](WorldPosition point) { return 1 + 1000 * exp(-1 * pow(point.distance(center) / 400.0, 2)); }); + // List of weights based on distance (Gausian curve that starts at 100 and lower to 1 at 1000 distance) + // std::transform(retVec.begin(), retVec.end(), std::back_inserter(weights), [center](WorldPosition point) { return + // 1 + 1000 * exp(-1 * pow(point.distance(center) / 400.0, 2)); }); - //List of weights based on distance (Twice the distance = half the weight). Caps out at 200.0000 range. - std::transform(retVec.begin(), retVec.end(), std::back_inserter(weights), [center](WorldPosition* point) - { - return static_cast(200000.f / (1.f + point->distance(center))); - }); + // List of weights based on distance (Twice the distance = half the weight). Caps out at 200.0000 range. + std::transform(retVec.begin(), retVec.end(), std::back_inserter(weights), + [center](WorldPosition* point) + { return static_cast(200000.f / (1.f + point->distance(center))); }); Acore::Containers::RandomShuffle(retVec); std::vector dists; - //Total sum of all those weights. + // Total sum of all those weights. /* uint32 sum = std::accumulate(weights.begin(), weights.end(), 0); @@ -3908,7 +3781,8 @@ std::vector TravelMgr::getNextPoint(WorldPosition* center, std:: uint32 rnd = urand(0, sum); for (unsigned i = 0; i < points.size(); ++i) - if (rnd < weights[i] && (retVec.empty() || std::find(retVec.begin(), retVec.end(), points[i]) == retVec.end())) + if (rnd < weights[i] && (retVec.empty() || std::find(retVec.begin(), retVec.end(), points[i]) == + retVec.end())) { retVec.push_back(points[i]); break; @@ -3920,7 +3794,8 @@ std::vector TravelMgr::getNextPoint(WorldPosition* center, std:: return retVec; } -std::vector TravelMgr::getNextPoint(WorldPosition center, std::vector points, uint32 amount) +std::vector TravelMgr::getNextPoint(WorldPosition center, std::vector points, + uint32 amount) { std::vector retVec; @@ -3930,25 +3805,25 @@ std::vector TravelMgr::getNextPoint(WorldPosition center, std::ve return retVec; } - //List of weights based on distance (Gausian curve that starts at 100 and lower to 1 at 1000 distance) + // List of weights based on distance (Gausian curve that starts at 100 and lower to 1 at 1000 distance) std::vector weights; - std::transform(points.begin(), points.end(), std::back_inserter(weights), [center](WorldPosition point) - { - return 1 + 1000 * static_cast(exp(-1.f * pow(point.distance(center) / 400.f, 2.f))); - }); + std::transform(points.begin(), points.end(), std::back_inserter(weights), + [center](WorldPosition point) + { return 1 + 1000 * static_cast(exp(-1.f * pow(point.distance(center) / 400.f, 2.f))); }); - //Total sum of all those weights. + // Total sum of all those weights. uint32 sum = std::accumulate(weights.begin(), weights.end(), 0); - //Pick a random number in that range. + // Pick a random number in that range. uint32 rnd = urand(0, sum); - //Pick a random point based on weights. + // Pick a random point based on weights. for (uint32 nr = 0; nr < amount; nr++) { for (unsigned i = 0; i < points.size(); ++i) - if (rnd < weights[i] && (retVec.empty() || std::find(retVec.begin(), retVec.end(), points[i]) == retVec.end())) + if (rnd < weights[i] && + (retVec.empty() || std::find(retVec.begin(), retVec.end(), points[i]) == retVec.end())) { retVec.push_back(points[i]); break; @@ -3969,10 +3844,7 @@ std::vector TravelMgr::getNextPoint(WorldPosition center, std::ve return retVec; } -QuestStatusData* TravelMgr::getQuestStatus(Player* bot, uint32 questId) -{ - return &bot->getQuestStatusMap()[questId]; -} +QuestStatusData* TravelMgr::getQuestStatus(Player* bot, uint32 questId) { return &bot->getQuestStatusMap()[questId]; } bool TravelMgr::getObjectiveStatus(Player* bot, Quest const* pQuest, uint32 objective) { @@ -3985,8 +3857,8 @@ bool TravelMgr::getObjectiveStatus(Player* bot, Quest const* pQuest, uint32 obje QuestStatusData* questStatus = sTravelMgr->getQuestStatus(bot, questId); - uint32 reqCount = pQuest->RequiredItemCount[objective]; - uint32 hasCount = questStatus->ItemCount[objective]; + uint32 reqCount = pQuest->RequiredItemCount[objective]; + uint32 hasCount = questStatus->ItemCount[objective]; if (reqCount && hasCount < reqCount) return true; @@ -4000,7 +3872,9 @@ bool TravelMgr::getObjectiveStatus(Player* bot, Quest const* pQuest, uint32 obje return false; } -std::vector TravelMgr::getQuestTravelDestinations(Player* bot, int32 questId, bool ignoreFull, bool ignoreInactive, float maxDistance, bool ignoreObjectives) +std::vector TravelMgr::getQuestTravelDestinations(Player* bot, int32 questId, bool ignoreFull, + bool ignoreInactive, float maxDistance, + bool ignoreObjectives) { WorldPosition botLocation(bot); @@ -4062,7 +3936,8 @@ std::vector TravelMgr::getQuestTravelDestinations(Player* bo return retTravelLocations; } -std::vector TravelMgr::getRpgTravelDestinations(Player* bot, bool ignoreFull, bool ignoreInactive, float maxDistance) +std::vector TravelMgr::getRpgTravelDestinations(Player* bot, bool ignoreFull, bool ignoreInactive, + float maxDistance) { WorldPosition botLocation(bot); @@ -4085,7 +3960,8 @@ std::vector TravelMgr::getRpgTravelDestinations(Player* bot, return std::move(retTravelLocations); } -std::vector TravelMgr::getExploreTravelDestinations(Player* bot, bool ignoreFull, bool ignoreInactive) +std::vector TravelMgr::getExploreTravelDestinations(Player* bot, bool ignoreFull, + bool ignoreInactive) { WorldPosition botLocation(bot); @@ -4105,7 +3981,8 @@ std::vector TravelMgr::getExploreTravelDestinations(Player* return retTravelLocations; } -std::vector TravelMgr::getGrindTravelDestinations(Player* bot, bool ignoreFull, bool ignoreInactive, float maxDistance) +std::vector TravelMgr::getGrindTravelDestinations(Player* bot, bool ignoreFull, bool ignoreInactive, + float maxDistance) { WorldPosition botLocation(bot); @@ -4151,7 +4028,7 @@ void TravelMgr::addMapTransfer(WorldPosition start, WorldPosition end, float por if (sMap == eMap) return; - //Calculate shortcuts. + // Calculate shortcuts. if (makeShortcuts) { for (auto& mapTransfers : mapTransfersMap) @@ -4161,14 +4038,14 @@ void TravelMgr::addMapTransfer(WorldPosition start, WorldPosition end, float por for (auto& mapTransfer : mapTransfers.second) { - if (eMapt == sMap && sMapt != eMap) // [S1 >MT> E1 -> S2] >THIS> E2 + if (eMapt == sMap && sMapt != eMap) // [S1 >MT> E1 -> S2] >THIS> E2 { float newDistToEnd = mapTransDistance(*mapTransfer.getPointFrom(), start) + portalDistance; if (mapTransDistance(*mapTransfer.getPointFrom(), end) > newDistToEnd) addMapTransfer(*mapTransfer.getPointFrom(), end, newDistToEnd, false); } - if (sMapt == eMap && eMapt != sMap) // S1 >THIS> [E1 -> S2 >MT> E2] + if (sMapt == eMap && eMapt != sMap) // S1 >THIS> [E1 -> S2 >MT> E2] { float newDistToEnd = portalDistance + mapTransDistance(end, *mapTransfer.getPointTo()); if (mapTransDistance(start, *mapTransfer.getPointTo()) > newDistToEnd) @@ -4178,11 +4055,11 @@ void TravelMgr::addMapTransfer(WorldPosition start, WorldPosition end, float por } } - //Add actual transfer. + // Add actual transfer. auto mapTransfers = mapTransfersMap.find(std::make_pair(start.getMapId(), end.getMapId())); if (mapTransfers == mapTransfersMap.end()) - mapTransfersMap.insert({ { sMap, eMap }, {mapTransfer(start, end, portalDistance)} }); + mapTransfersMap.insert({{sMap, eMap}, {mapTransfer(start, end, portalDistance)}}); else mapTransfers->second.push_back(mapTransfer(start, end, portalDistance)); }; @@ -4208,13 +4085,12 @@ float TravelMgr::mapTransDistance(WorldPosition start, WorldPosition end) float minDist = 200000; - auto mapTransfers = mapTransfersMap.find({ sMap, eMap }); + auto mapTransfers = mapTransfersMap.find({sMap, eMap}); if (mapTransfers == mapTransfersMap.end()) return minDist; for (auto& mapTrans : mapTransfers->second) { - float dist = mapTrans.distance(start, end); if (dist < minDist) @@ -4234,7 +4110,7 @@ float TravelMgr::fastMapTransDistance(WorldPosition start, WorldPosition end) float minDist = 200000; - auto mapTransfers = mapTransfersMap.find({ sMap, eMap }); + auto mapTransfers = mapTransfersMap.find({sMap, eMap}); if (mapTransfers == mapTransfersMap.end()) return minDist; @@ -4250,21 +4126,16 @@ float TravelMgr::fastMapTransDistance(WorldPosition start, WorldPosition end) return minDist; } -QuestTravelDestination::QuestTravelDestination(uint32 questId1, float radiusMin1, float radiusMax1) : TravelDestination(radiusMin1, radiusMax1) +QuestTravelDestination::QuestTravelDestination(uint32 questId1, float radiusMin1, float radiusMax1) + : TravelDestination(radiusMin1, radiusMax1) { questId = questId1; questTemplate = sObjectMgr->GetQuestTemplate(questId); } -bool QuestTravelDestination::isActive(Player* bot) -{ - return bot->IsActiveQuest(questId); -} +bool QuestTravelDestination::isActive(Player* bot) { return bot->IsActiveQuest(questId); } -bool QuestObjectiveTravelDestination::isCreature() -{ - return GetQuestTemplate()->RequiredNpcOrGo[objective] > 0; -} +bool QuestObjectiveTravelDestination::isCreature() { return GetQuestTemplate()->RequiredNpcOrGo[objective] > 0; } uint32 QuestObjectiveTravelDestination::ReqCreature() { @@ -4276,10 +4147,7 @@ uint32 QuestObjectiveTravelDestination::ReqGOId() return !isCreature() ? abs(GetQuestTemplate()->RequiredNpcOrGo[objective]) : 0; } -uint32 QuestObjectiveTravelDestination::ReqCount() -{ - return GetQuestTemplate()->RequiredNpcOrGoCount[objective]; -} +uint32 QuestObjectiveTravelDestination::ReqCount() { return GetQuestTemplate()->RequiredNpcOrGoCount[objective]; } void TravelMgr::printGrid(uint32 mapId, int x, int y, std::string const type) { @@ -4314,7 +4182,8 @@ void TravelMgr::printObj(WorldObject* obj, std::string const type) { std::ostringstream out; out << sPlayerbotAIConfig->GetTimestampStr(); - out << "+00, " << obj->GetGUID().GetEntry() << "," << obj->GetGUID().GetCounter() << "," << cell.GridX() << "," << cell.GridY() << ", " << type << ","; + out << "+00, " << obj->GetGUID().GetEntry() << "," << obj->GetGUID().GetCounter() << "," << cell.GridX() + << "," << cell.GridY() << ", " << type << ","; p.printWKT(vcell, out, 1, true); sPlayerbotAIConfig->log(fileName, out.str().c_str()); @@ -4323,7 +4192,8 @@ void TravelMgr::printObj(WorldObject* obj, std::string const type) { std::ostringstream out; out << sPlayerbotAIConfig->GetTimestampStr(); - out << "+00, " << obj->GetGUID().GetEntry() << "," << obj->GetGUID().GetCounter() << "," << cell.GridX() << "," << cell.GridY() << ", " << type << ","; + out << "+00, " << obj->GetGUID().GetEntry() << "," << obj->GetGUID().GetCounter() << "," << cell.GridX() + << "," << cell.GridY() << ", " << type << ","; p.printWKT(vgrid, out, 1, true); sPlayerbotAIConfig->log(fileName, out.str().c_str()); @@ -4340,9 +4210,10 @@ void TravelMgr::printObj(WorldObject* obj, std::string const type) { std::ostringstream out; out << sPlayerbotAIConfig->GetTimestampStr(); - out << "+00, " << obj->GetGUID().GetEntry() << "," << obj->GetGUID().GetCounter() << "," << cell.GridX() << "," << cell.GridY() << ", " << type << ","; + out << "+00, " << obj->GetGUID().GetEntry() << "," << obj->GetGUID().GetCounter() << "," << cell.GridX() + << "," << cell.GridY() << ", " << type << ","; - p.printWKT({ p }, out, 0); + p.printWKT({p}, out, 0); sPlayerbotAIConfig->log(fileName, out.str().c_str()); } } diff --git a/src/TravelMgr.h b/src/TravelMgr.h index 0b4b2e99..9255e851 100644 --- a/src/TravelMgr.h +++ b/src/TravelMgr.h @@ -1,19 +1,20 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TRAVELMGR_H #define _PLAYERBOT_TRAVELMGR_H +#include +#include + #include "AiObject.h" #include "CreatureData.h" #include "GameObject.h" #include "GridDefines.h" #include "PlayerbotAIConfig.h" -#include -#include - class GuidPosition; class ObjectGuid; class Quest; @@ -24,48 +25,48 @@ struct QuestStatusData; namespace G3D { - class Vector2; - class Vector3; - class Vector4; -} +class Vector2; +class Vector3; +class Vector4; +} // namespace G3D -//Constructor types for WorldPosition +// Constructor types for WorldPosition enum WorldPositionConst { - WP_RANDOM = 0, - WP_CENTROID = 1, - WP_MEAN_CENTROID = 2, - WP_CLOSEST = 3 + WP_RANDOM = 0, + WP_CENTROID = 1, + WP_MEAN_CENTROID = 2, + WP_CLOSEST = 3 }; enum TravelState { - TRAVEL_STATE_IDLE = 0, - TRAVEL_STATE_TRAVEL_PICK_UP_QUEST = 1, - TRAVEL_STATE_WORK_PICK_UP_QUEST = 2, - TRAVEL_STATE_TRAVEL_DO_QUEST = 3, - TRAVEL_STATE_WORK_DO_QUEST = 4, - TRAVEL_STATE_TRAVEL_HAND_IN_QUEST = 5, - TRAVEL_STATE_WORK_HAND_IN_QUEST = 6, - TRAVEL_STATE_TRAVEL_RPG = 7, - TRAVEL_STATE_TRAVEL_EXPLORE = 8, + TRAVEL_STATE_IDLE = 0, + TRAVEL_STATE_TRAVEL_PICK_UP_QUEST = 1, + TRAVEL_STATE_WORK_PICK_UP_QUEST = 2, + TRAVEL_STATE_TRAVEL_DO_QUEST = 3, + TRAVEL_STATE_WORK_DO_QUEST = 4, + TRAVEL_STATE_TRAVEL_HAND_IN_QUEST = 5, + TRAVEL_STATE_WORK_HAND_IN_QUEST = 6, + TRAVEL_STATE_TRAVEL_RPG = 7, + TRAVEL_STATE_TRAVEL_EXPLORE = 8, MAX_TRAVEL_STATE }; enum TravelStatus { - TRAVEL_STATUS_NONE = 0, - TRAVEL_STATUS_PREPARE = 1, - TRAVEL_STATUS_TRAVEL = 2, - TRAVEL_STATUS_WORK = 3, - TRAVEL_STATUS_COOLDOWN = 4, - TRAVEL_STATUS_EXPIRED = 5, + TRAVEL_STATUS_NONE = 0, + TRAVEL_STATUS_PREPARE = 1, + TRAVEL_STATUS_TRAVEL = 2, + TRAVEL_STATUS_WORK = 3, + TRAVEL_STATUS_COOLDOWN = 4, + TRAVEL_STATUS_EXPIRED = 5, MAX_TRAVEL_STATUS }; class QuestTravelDestination; -//A quest destination container for quick lookup of all destinations related to a quest. +// A quest destination container for quick lookup of all destinations related to a quest. struct QuestContainer { std::vector questGivers; @@ -75,265 +76,256 @@ struct QuestContainer typedef std::pair mGridCoord; -//Extension of WorldLocation with distance functions. +// Extension of WorldLocation with distance functions. class WorldPosition : public WorldLocation { - public: - //Constructors - WorldPosition() : WorldLocation() { }; - WorldPosition(WorldLocation const& loc) : WorldLocation(loc) { } - WorldPosition(WorldPosition const& pos) : WorldLocation(pos), visitors(pos.visitors) { } - WorldPosition(std::string const str); - WorldPosition(uint32 mapid, float x, float y, float z = 0.f, float orientation = 0.f) : WorldLocation(mapid, x, y, z, orientation) { } - WorldPosition(uint32 mapId, const Position& pos); - WorldPosition(WorldObject const* wo); - WorldPosition(std::vector list, WorldPositionConst conType); - WorldPosition(std::vector list, WorldPositionConst conType); - WorldPosition(uint32 mapid, GridCoord grid); - WorldPosition(uint32 mapid, CellCoord cell); - WorldPosition(uint32 mapid, mGridCoord grid); +public: + // Constructors + WorldPosition() : WorldLocation(){}; + WorldPosition(WorldLocation const& loc) : WorldLocation(loc) {} + WorldPosition(WorldPosition const& pos) : WorldLocation(pos), visitors(pos.visitors) {} + WorldPosition(std::string const str); + WorldPosition(uint32 mapid, float x, float y, float z = 0.f, float orientation = 0.f) + : WorldLocation(mapid, x, y, z, orientation) + { + } + WorldPosition(uint32 mapId, const Position& pos); + WorldPosition(WorldObject const* wo); + WorldPosition(std::vector list, WorldPositionConst conType); + WorldPosition(std::vector list, WorldPositionConst conType); + WorldPosition(uint32 mapid, GridCoord grid); + WorldPosition(uint32 mapid, CellCoord cell); + WorldPosition(uint32 mapid, mGridCoord grid); - //Setters - void set(const WorldLocation& pos); - void setMapId(uint32 id); - void setX(float x); - void setY(float y); - void setZ(float z); - void setO(float o); + // Setters + void set(const WorldLocation& pos); + void setMapId(uint32 id); + void setX(float x); + void setY(float y); + void setZ(float z); + void setO(float o); - void addVisitor() + void addVisitor() { ++visitors; } + + void remVisitor() { --visitors; } + + // Getters + operator bool() const; + friend bool operator==(WorldPosition const& p1, const WorldPosition& p2); + friend bool operator!=(WorldPosition const& p1, const WorldPosition& p2); + + WorldPosition& operator=(WorldPosition const&) = default; + WorldPosition& operator+=(WorldPosition const& p1); + WorldPosition& operator-=(WorldPosition const& p1); + + uint32 getMapId(); + float getX(); + float getY(); + float getZ(); + float getO(); + + G3D::Vector3 getVector3(); + std::string const print(); + + std::string const to_string(); + + void printWKT(std::vector points, std::ostringstream& out, uint32 dim = 0, bool loop = false); + void printWKT(std::ostringstream& out) { printWKT({*this}, out); } + + uint32 getVisitors() { return visitors; } + + bool isOverworld(); + bool isInWater(); + bool isUnderWater(); + + WorldPosition relPoint(WorldPosition* center); + WorldPosition offset(WorldPosition* center); + float size(); + + // Slow distance function using possible map transfers. + float distance(WorldPosition* center); + float distance(WorldPosition center) { return distance(¢er); } + + float fDist(WorldPosition* center); + float fDist(WorldPosition center) { return fDist(¢er); } + + template + std::pair closest(std::vector> list) + { + return *std::min_element(list.begin(), list.end(), + [this](std::pair i, std::pair j) + { return this->distance(i.second) < this->distance(j.second); }); + } + + template + std::pair closest(std::vector list) + { + return closest(GetPosList(list)); + } + + // Returns the closest point from the list. + WorldPosition* closest(std::vector list) + { + return *std::min_element(list.begin(), list.end(), + [this](WorldPosition* i, WorldPosition* j) + { return this->distance(i) < this->distance(j); }); + } + + WorldPosition closest(std::vector list) + { + return *std::min_element(list.begin(), list.end(), + [this](WorldPosition i, WorldPosition j) + { return this->distance(i) < this->distance(j); }); + } + + // Quick square distance in 2d plane. + float sqDistance2d(WorldPosition center) + { + return (getX() - center.getX()) * (getX() - center.getX()) + + (getY() - center.getY()) * (getY() - center.getY()); + } + + // Quick square distance calculation without map check. Used for getting the minimum distant points. + float sqDistance(WorldPosition center) + { + return (getX() - center.getX()) * (getX() - center.getX()) + + (getY() - center.getY()) * (getY() - center.getY()) + + (getZ() - center.getZ()) * (getZ() - center.getZ()); + } + + float sqDistance2d(WorldPosition* center) + { + return (getX() - center->getX()) * (getX() - center->getX()) + + (getY() - center->getY()) * (getY() - center->getY()); + } + + float sqDistance(WorldPosition* center) + { + return (getX() - center->getX()) * (getX() - center->getX()) + + (getY() - center->getY()) * (getY() - center->getY()) + + (getZ() - center->getZ()) * (getZ() - center->getZ()); + } + + // Returns the closest point of the list. Fast but only works for the same map. + WorldPosition* closestSq(std::vector list) + { + return *std::min_element(list.begin(), list.end(), + [this](WorldPosition* i, WorldPosition* j) + { return this->sqDistance(i) < this->sqDistance(j); }); + } + + WorldPosition closestSq(std::vector list) + { + return *std::min_element(list.begin(), list.end(), + [this](WorldPosition i, WorldPosition j) + { return this->sqDistance(i) < this->sqDistance(j); }); + } + + float getAngleTo(WorldPosition endPos) + { + float ang = atan2(endPos.getY() - getY(), endPos.getX() - getX()); + return (ang >= 0) ? ang : 2 * static_cast(M_PI) + ang; + } + + float getAngleBetween(WorldPosition dir1, WorldPosition dir2) { return abs(getAngleTo(dir1) - getAngleTo(dir2)); } + + WorldPosition lastInRange(std::vector list, float minDist = -1.f, float maxDist = -1.f); + WorldPosition firstOutRange(std::vector list, float minDist = -1.f, float maxDist = -1.f); + + float mSign(WorldPosition* p1, WorldPosition* p2) + { + return (getX() - p2->getX()) * (p1->getY() - p2->getY()) - (p1->getX() - p2->getX()) * (getY() - p2->getY()); + } + + bool isInside(WorldPosition* p1, WorldPosition* p2, WorldPosition* p3); + + // Map functions. Player independent. + MapEntry const* getMapEntry(); + uint32 getInstanceId(); + Map* getMap(); + float getHeight(); // remove const - whipowill + + std::set getTransports(uint32 entry = 0); + + GridCoord getGridCoord() { return Acore::ComputeGridCoord(getX(), getY()); }; + std::vector getGridCoord(WorldPosition secondPos); + std::vector fromGridCoord(GridCoord GridCoord); + + CellCoord getCellCoord() { return Acore::ComputeCellCoord(getX(), getY()); } + std::vector fromCellCoord(CellCoord cellCoord); + std::vector gridFromCellCoord(CellCoord cellCoord); + + mGridCoord getmGridCoord() + { + return std::make_pair((int32)(CENTER_GRID_ID - getX() / SIZE_OF_GRIDS), + (int32)(CENTER_GRID_ID - getY() / SIZE_OF_GRIDS)); + } + + std::vector getmGridCoords(WorldPosition secondPos); + std::vector frommGridCoord(mGridCoord GridCoord); + + void loadMapAndVMap(uint32 mapId, uint8 x, uint8 y); + + void loadMapAndVMap() { loadMapAndVMap(getMapId(), getmGridCoord().first, getmGridCoord().second); } + + void loadMapAndVMaps(WorldPosition secondPos); + + // Display functions + WorldPosition getDisplayLocation(); + float getDisplayX() { return getDisplayLocation().getY() * -1.0; } + + float getDisplayY() { return getDisplayLocation().getX(); } + + uint16 getAreaId(); + AreaTableEntry const* getArea(); + std::string const getAreaName(bool fullName = true, bool zoneName = false); + + std::vector fromPointsArray(std::vector path); + + // Pathfinding + std::vector getPathStepFrom(WorldPosition startPos, Unit* bot); + std::vector getPathFromPath(std::vector startPath, Unit* bot, uint8 maxAttempt = 40); + + std::vector getPathFrom(WorldPosition startPos, Unit* bot) + { + return getPathFromPath({startPos}, bot); + } + + std::vector getPathTo(WorldPosition endPos, Unit* bot) { return endPos.getPathFrom(*this, bot); } + + bool isPathTo(std::vector path, float maxDistance = sPlayerbotAIConfig->targetPosRecalcDistance) + { + return !path.empty() && distance(path.back()) < maxDistance; + }; + bool cropPathTo(std::vector& path, float maxDistance = sPlayerbotAIConfig->targetPosRecalcDistance); + bool canPathTo(WorldPosition endPos, Unit* bot) { return endPos.isPathTo(getPathTo(endPos, bot)); } + + float getPathLength(std::vector points) + { + float dist = 0.f; + for (auto& p : points) { - ++visitors; + if (&p == &points.front()) + dist = 0.f; + else + dist += std::prev(&p, 1)->distance(p); } - void remVisitor() - { - --visitors; - } + return dist; + } - //Getters - operator bool() const; - friend bool operator==(WorldPosition const& p1, const WorldPosition &p2); - friend bool operator!=(WorldPosition const& p1, const WorldPosition &p2); + bool GetReachableRandomPointOnGround(Player* bot, float radius, bool randomRange = true); - WorldPosition& operator=(WorldPosition const&) = default; - WorldPosition& operator+=(WorldPosition const& p1); - WorldPosition& operator-=(WorldPosition const& p1); + uint32 getUnitsAggro(GuidVector& units, Player* bot); - uint32 getMapId(); - float getX(); - float getY(); - float getZ(); - float getO(); + // Creatures + std::vector getCreaturesNear(float radius = 0, uint32 entry = 0); - G3D::Vector3 getVector3(); - std::string const print(); + // GameObjects + std::vector getGameObjectsNear(float radius = 0, uint32 entry = 0); - std::string const to_string(); - - void printWKT(std::vector points, std::ostringstream& out, uint32 dim = 0, bool loop = false); - void printWKT(std::ostringstream& out) { printWKT({ *this }, out); } - - uint32 getVisitors() { return visitors; } - - bool isOverworld(); - bool isInWater(); - bool isUnderWater(); - - WorldPosition relPoint(WorldPosition* center); - WorldPosition offset(WorldPosition* center); - float size(); - - //Slow distance function using possible map transfers. - float distance(WorldPosition* center); - float distance(WorldPosition center) - { - return distance(¢er); - } - - float fDist(WorldPosition* center); - float fDist(WorldPosition center) - { - return fDist(¢er); - } - - template - std::pair closest(std::vector> list) - { - return *std::min_element(list.begin(), list.end(), [this](std::pair i, std::pair j) - { - return this->distance(i.second) < this->distance(j.second); - }); - } - - template - std::pair closest(std::vector list) - { - return closest(GetPosList(list)); - } - - //Returns the closest point from the list. - WorldPosition* closest(std::vector list) - { - return *std::min_element(list.begin(), list.end(), [this](WorldPosition* i, WorldPosition* j) { return this->distance(i) < this->distance(j); }); - } - - WorldPosition closest(std::vector list) - { - return *std::min_element(list.begin(), list.end(), [this](WorldPosition i, WorldPosition j) { return this->distance(i) < this->distance(j); }); - } - - //Quick square distance in 2d plane. - float sqDistance2d(WorldPosition center) - { - return (getX() - center.getX()) * (getX() - center.getX()) + (getY() - center.getY()) * (getY() - center.getY()); - } - - //Quick square distance calculation without map check. Used for getting the minimum distant points. - float sqDistance(WorldPosition center) - { - return (getX() - center.getX()) * (getX() - center.getX()) + (getY() - center.getY()) * - (getY() - center.getY()) + (getZ() - center.getZ()) * (getZ() - center.getZ()); - } - - float sqDistance2d(WorldPosition* center) - { - return (getX() - center->getX()) * (getX() - center->getX()) + (getY() - center->getY()) * (getY() - center->getY()); - } - - float sqDistance(WorldPosition* center) - { - return (getX() - center->getX()) * (getX() - center->getX()) + (getY() - center->getY()) * - (getY() - center->getY()) + (getZ() - center->getZ()) * (getZ() - center->getZ()); - } - - //Returns the closest point of the list. Fast but only works for the same map. - WorldPosition* closestSq(std::vector list) - { - return *std::min_element(list.begin(), list.end(), [this](WorldPosition* i, WorldPosition* j) { return this->sqDistance(i) < this->sqDistance(j); }); - } - - WorldPosition closestSq(std::vector list) - { - return *std::min_element(list.begin(), list.end(), [this](WorldPosition i, WorldPosition j) { return this->sqDistance(i) < this->sqDistance(j); }); - } - - float getAngleTo(WorldPosition endPos) - { - float ang = atan2(endPos.getY() - getY(), endPos.getX() - getX()); - return (ang >= 0) ? ang : 2 * static_cast(M_PI) + ang; - } - - float getAngleBetween(WorldPosition dir1, WorldPosition dir2) - { - return abs(getAngleTo(dir1) - getAngleTo(dir2)); - } - - WorldPosition lastInRange(std::vector list, float minDist = -1.f, float maxDist = -1.f); - WorldPosition firstOutRange(std::vector list, float minDist = -1.f, float maxDist = -1.f); - - float mSign(WorldPosition* p1, WorldPosition* p2) - { - return(getX() - p2->getX()) * (p1->getY() - p2->getY()) - (p1->getX() - p2->getX()) * (getY() - p2->getY()); - } - - bool isInside(WorldPosition* p1, WorldPosition* p2, WorldPosition* p3); - - //Map functions. Player independent. - MapEntry const* getMapEntry(); - uint32 getInstanceId(); - Map* getMap(); - float getHeight(); // remove const - whipowill - - std::set getTransports(uint32 entry = 0); - - GridCoord getGridCoord() { return Acore::ComputeGridCoord(getX(), getY()); }; - std::vector getGridCoord(WorldPosition secondPos); - std::vector fromGridCoord(GridCoord GridCoord); - - CellCoord getCellCoord() { return Acore::ComputeCellCoord(getX(), getY()); } - std::vector fromCellCoord(CellCoord cellCoord); - std::vector gridFromCellCoord(CellCoord cellCoord); - - mGridCoord getmGridCoord() - { - return std::make_pair((int32)(CENTER_GRID_ID - getX() / SIZE_OF_GRIDS), (int32)(CENTER_GRID_ID - getY() / SIZE_OF_GRIDS)); - } - - std::vector getmGridCoords(WorldPosition secondPos); - std::vector frommGridCoord(mGridCoord GridCoord); - - void loadMapAndVMap(uint32 mapId, uint8 x, uint8 y); - - void loadMapAndVMap() - { - loadMapAndVMap(getMapId(), getmGridCoord().first, getmGridCoord().second); - } - - void loadMapAndVMaps(WorldPosition secondPos); - - //Display functions - WorldPosition getDisplayLocation(); - float getDisplayX() - { - return getDisplayLocation().getY() * -1.0; - } - - float getDisplayY() - { - return getDisplayLocation().getX(); - } - - uint16 getAreaId(); - AreaTableEntry const* getArea(); - std::string const getAreaName(bool fullName = true, bool zoneName = false); - - std::vector fromPointsArray(std::vector path); - - //Pathfinding - std::vector getPathStepFrom(WorldPosition startPos, Unit* bot); - std::vector getPathFromPath(std::vector startPath, Unit* bot, uint8 maxAttempt = 40); - - std::vector getPathFrom(WorldPosition startPos, Unit* bot) - { - return getPathFromPath({ startPos }, bot); - } - - std::vector getPathTo(WorldPosition endPos, Unit* bot) - { - return endPos.getPathFrom(*this, bot); - } - - bool isPathTo(std::vector path, float maxDistance = sPlayerbotAIConfig->targetPosRecalcDistance) { return !path.empty() && distance(path.back()) < maxDistance; }; - bool cropPathTo(std::vector& path, float maxDistance = sPlayerbotAIConfig->targetPosRecalcDistance); - bool canPathTo(WorldPosition endPos, Unit* bot) { return endPos.isPathTo(getPathTo(endPos, bot)); } - - float getPathLength(std::vector points) - { - float dist = 0.f; - for (auto& p : points) - { - if (&p == &points.front()) - dist = 0.f; - else - dist += std::prev(&p, 1)->distance(p); - } - - return dist; - } - - bool GetReachableRandomPointOnGround(Player* bot, float radius, bool randomRange = true); - - uint32 getUnitsAggro(GuidVector& units, Player* bot); - - //Creatures - std::vector getCreaturesNear(float radius = 0, uint32 entry = 0); - - //GameObjects - std::vector getGameObjectsNear(float radius = 0, uint32 entry = 0); - - private: - uint32 visitors = 0; +private: + uint32 visitors = 0; }; inline ByteBuffer& operator<<(ByteBuffer& b, WorldPosition& guidP) @@ -365,71 +357,81 @@ inline ByteBuffer& operator>>(ByteBuffer& b, [[maybe_unused]] WorldPosition& g) return b; } -//Generic creature finder +// Generic creature finder class FindPointCreatureData { - public: - FindPointCreatureData(WorldPosition point1 = WorldPosition(), float radius1 = 0, uint32 entry1 = 0) { point = point1; radius = radius1; entry = entry1; } +public: + FindPointCreatureData(WorldPosition point1 = WorldPosition(), float radius1 = 0, uint32 entry1 = 0) + { + point = point1; + radius = radius1; + entry = entry1; + } - void operator()(CreatureData const& dataPair); - std::vector GetResult() const { return data; }; + void operator()(CreatureData const& dataPair); + std::vector GetResult() const { return data; }; - private: - WorldPosition point; - float radius; - uint32 entry; +private: + WorldPosition point; + float radius; + uint32 entry; - std::vector data; + std::vector data; }; -//Generic gameObject finder +// Generic gameObject finder class FindPointGameObjectData { - public: - FindPointGameObjectData(WorldPosition point1 = WorldPosition(), float radius1 = 0, uint32 entry1 = 0) { point = point1; radius = radius1; entry = entry1; } +public: + FindPointGameObjectData(WorldPosition point1 = WorldPosition(), float radius1 = 0, uint32 entry1 = 0) + { + point = point1; + radius = radius1; + entry = entry1; + } - void operator()(GameObjectData const& dataPair); - std::vector GetResult() const { return data; }; + void operator()(GameObjectData const& dataPair); + std::vector GetResult() const { return data; }; - private: - WorldPosition point; - float radius; - uint32 entry; +private: + WorldPosition point; + float radius; + uint32 entry; - std::vector data; + std::vector data; }; class GuidPosition : public ObjectGuid, public WorldPosition { - public: - GuidPosition() : ObjectGuid(), WorldPosition(), loadedFromDB(false) { } - GuidPosition(WorldObject* wo); - GuidPosition(CreatureData const& creData); - GuidPosition(GameObjectData const& goData); +public: + GuidPosition() : ObjectGuid(), WorldPosition(), loadedFromDB(false) {} + GuidPosition(WorldObject* wo); + GuidPosition(CreatureData const& creData); + GuidPosition(GameObjectData const& goData); - CreatureTemplate const* GetCreatureTemplate(); - GameObjectTemplate const* GetGameObjectTemplate(); + CreatureTemplate const* GetCreatureTemplate(); + GameObjectTemplate const* GetGameObjectTemplate(); - WorldObject* GetWorldObject(); - Creature* GetCreature(); - Unit* GetUnit(); - GameObject* GetGameObject(); - Player* GetPlayer(); + WorldObject* GetWorldObject(); + Creature* GetCreature(); + Unit* GetUnit(); + GameObject* GetGameObject(); + Player* GetPlayer(); - bool HasNpcFlag(NPCFlags flag); + bool HasNpcFlag(NPCFlags flag); - bool isDead(); //For loaded grids check if the unit/object is unloaded/dead. + bool isDead(); // For loaded grids check if the unit/object is unloaded/dead. - operator bool() const { return !IsEmpty(); } - bool operator==(ObjectGuid const& guid) const { return GetRawValue() == guid.GetRawValue(); } - bool operator!=(ObjectGuid const& guid) const { return GetRawValue() != guid.GetRawValue(); } - bool operator<(ObjectGuid const& guid) const { return GetRawValue() < guid.GetRawValue(); } + operator bool() const { return !IsEmpty(); } + bool operator==(ObjectGuid const& guid) const { return GetRawValue() == guid.GetRawValue(); } + bool operator!=(ObjectGuid const& guid) const { return GetRawValue() != guid.GetRawValue(); } + bool operator<(ObjectGuid const& guid) const { return GetRawValue() < guid.GetRawValue(); } - private: - bool loadedFromDB; +private: + bool loadedFromDB; }; -template +template std::vector> GetPosList(std::vector oList) { std::vector> retList; @@ -439,7 +441,7 @@ std::vector> GetPosList(std::vector oList) return std::move(retList); }; -template +template std::vector> GetPosVector(std::vector oList) { std::vector> retList; @@ -451,540 +453,488 @@ std::vector> GetPosVector(std::vector oList) class mapTransfer { - public: - mapTransfer(WorldPosition pointFrom1, WorldPosition pointTo1, float portalLength1 = 0.1f) - : pointFrom(pointFrom1), pointTo(pointTo1), portalLength(portalLength1) { } +public: + mapTransfer(WorldPosition pointFrom1, WorldPosition pointTo1, float portalLength1 = 0.1f) + : pointFrom(pointFrom1), pointTo(pointTo1), portalLength(portalLength1) + { + } - bool isFrom(WorldPosition point) - { - return point.getMapId() == pointFrom.getMapId(); - } + bool isFrom(WorldPosition point) { return point.getMapId() == pointFrom.getMapId(); } - bool isTo(WorldPosition point) - { - return point.getMapId() == pointTo.getMapId(); - } + bool isTo(WorldPosition point) { return point.getMapId() == pointTo.getMapId(); } - WorldPosition* getPointFrom() - { - return &pointFrom; - } + WorldPosition* getPointFrom() { return &pointFrom; } - WorldPosition* getPointTo() - { - return &pointTo; - } + WorldPosition* getPointTo() { return &pointTo; } - bool isUseful(WorldPosition point) - { - return isFrom(point) || isTo(point); - } + bool isUseful(WorldPosition point) { return isFrom(point) || isTo(point); } - float distance(WorldPosition point) - { - return isUseful(point) ? (isFrom(point) ? point.distance(pointFrom) : point.distance(pointTo)) : 200000; - } + float distance(WorldPosition point) + { + return isUseful(point) ? (isFrom(point) ? point.distance(pointFrom) : point.distance(pointTo)) : 200000; + } - bool isUseful(WorldPosition start, WorldPosition end) - { - return isFrom(start) && isTo(end); - } + bool isUseful(WorldPosition start, WorldPosition end) { return isFrom(start) && isTo(end); } - float distance(WorldPosition start, WorldPosition end) - { - return (isUseful(start, end) ? (start.distance(pointFrom) + portalLength + pointTo.distance(end)) : 200000); - } + float distance(WorldPosition start, WorldPosition end) + { + return (isUseful(start, end) ? (start.distance(pointFrom) + portalLength + pointTo.distance(end)) : 200000); + } - float fDist(WorldPosition start, WorldPosition end); + float fDist(WorldPosition start, WorldPosition end); - private: - WorldPosition pointFrom; - WorldPosition pointTo; - float portalLength = 0.1f; +private: + WorldPosition pointFrom; + WorldPosition pointTo; + float portalLength = 0.1f; }; -//A destination for a bot to travel to and do something. +// A destination for a bot to travel to and do something. class TravelDestination { - public: - TravelDestination() { } - TravelDestination(float radiusMin1, float radiusMax1) - { - radiusMin = radiusMin1; radiusMax = radiusMax1; - } - TravelDestination(std::vector points1, float radiusMin1, float radiusMax1) - { - points = points1; radiusMin = radiusMin1; radiusMax = radiusMax1; - } - virtual ~TravelDestination() = default; +public: + TravelDestination() {} + TravelDestination(float radiusMin1, float radiusMax1) + { + radiusMin = radiusMin1; + radiusMax = radiusMax1; + } + TravelDestination(std::vector points1, float radiusMin1, float radiusMax1) + { + points = points1; + radiusMin = radiusMin1; + radiusMax = radiusMax1; + } + virtual ~TravelDestination() = default; - void addPoint(WorldPosition* pos) - { - points.push_back(pos); - } + void addPoint(WorldPosition* pos) { points.push_back(pos); } - void setExpireDelay(uint32 delay) - { - expireDelay = delay; - } + void setExpireDelay(uint32 delay) { expireDelay = delay; } - void setCooldownDelay(uint32 delay) - { - cooldownDelay = delay; - } + void setCooldownDelay(uint32 delay) { cooldownDelay = delay; } - void setMaxVisitors(uint32 maxVisitors1 = 0, uint32 maxVisitorsPerPoint1 = 0) - { - maxVisitors = maxVisitors1; - maxVisitorsPerPoint = maxVisitorsPerPoint1; - } + void setMaxVisitors(uint32 maxVisitors1 = 0, uint32 maxVisitorsPerPoint1 = 0) + { + maxVisitors = maxVisitors1; + maxVisitorsPerPoint = maxVisitorsPerPoint1; + } - std::vector getPoints(bool ignoreFull = false); - uint32 getExpireDelay() { return expireDelay; } - uint32 getCooldownDelay() { return cooldownDelay; } + std::vector getPoints(bool ignoreFull = false); + uint32 getExpireDelay() { return expireDelay; } + uint32 getCooldownDelay() { return cooldownDelay; } - void addVisitor() - { - ++visitors; - } + void addVisitor() { ++visitors; } - void remVisitor() - { - --visitors; - } + void remVisitor() { --visitors; } - uint32 getVisitors() - { - return visitors; - } + uint32 getVisitors() { return visitors; } - virtual Quest const* GetQuestTemplate() { return nullptr; } - virtual bool isActive([[maybe_unused]] Player* bot) { return false; } + virtual Quest const* GetQuestTemplate() { return nullptr; } + virtual bool isActive([[maybe_unused]] Player* bot) { return false; } - bool isFull(bool ignoreFull = false); + bool isFull(bool ignoreFull = false); - virtual std::string const getName() { return "TravelDestination"; } - virtual int32 getEntry() { return 0; } - virtual std::string const getTitle() { return "generic travel destination"; } + virtual std::string const getName() { return "TravelDestination"; } + virtual int32 getEntry() { return 0; } + virtual std::string const getTitle() { return "generic travel destination"; } - WorldPosition* nearestPoint(WorldPosition* pos); + WorldPosition* nearestPoint(WorldPosition* pos); - float distanceTo(WorldPosition* pos) { return nearestPoint(pos)->distance(pos); } - bool onMap(WorldPosition* pos) { return nearestPoint(pos)->getMapId() == pos->getMapId(); } - virtual bool isIn(WorldPosition* pos, float radius = 0.f) { return onMap(pos) && distanceTo(pos) <= (radius? radius : radiusMin); } - virtual bool isOut(WorldPosition* pos, float radius = 0.f) { return !onMap(pos) || distanceTo(pos) > (radius? radius : radiusMax); } - float getRadiusMin() { return radiusMin; } + float distanceTo(WorldPosition* pos) { return nearestPoint(pos)->distance(pos); } + bool onMap(WorldPosition* pos) { return nearestPoint(pos)->getMapId() == pos->getMapId(); } + virtual bool isIn(WorldPosition* pos, float radius = 0.f) + { + return onMap(pos) && distanceTo(pos) <= (radius ? radius : radiusMin); + } + virtual bool isOut(WorldPosition* pos, float radius = 0.f) + { + return !onMap(pos) || distanceTo(pos) > (radius ? radius : radiusMax); + } + float getRadiusMin() { return radiusMin; } - std::vector touchingPoints(WorldPosition* pos); - std::vector sortedPoints(WorldPosition* pos); - std::vector nextPoint(WorldPosition* pos, bool ignoreFull = true); + std::vector touchingPoints(WorldPosition* pos); + std::vector sortedPoints(WorldPosition* pos); + std::vector nextPoint(WorldPosition* pos, bool ignoreFull = true); - protected: - std::vector points; - float radiusMin = 0; - float radiusMax = 0; +protected: + std::vector points; + float radiusMin = 0; + float radiusMax = 0; - uint32 visitors = 0; - uint32 maxVisitors = 0; - uint32 maxVisitorsPerPoint = 0; - uint32 expireDelay = 5 * 1000; - uint32 cooldownDelay = 60 * 1000; + uint32 visitors = 0; + uint32 maxVisitors = 0; + uint32 maxVisitorsPerPoint = 0; + uint32 expireDelay = 5 * 1000; + uint32 cooldownDelay = 60 * 1000; }; -//A travel target that is always inactive and jumps to cooldown. +// A travel target that is always inactive and jumps to cooldown. class NullTravelDestination : public TravelDestination { - public: - NullTravelDestination(uint32 cooldownDelay1 = 5 * 60 * 1000) : TravelDestination() - { - cooldownDelay = cooldownDelay1; - }; +public: + NullTravelDestination(uint32 cooldownDelay1 = 5 * 60 * 1000) : TravelDestination() + { + cooldownDelay = cooldownDelay1; + }; - Quest const* GetQuestTemplate() override { return nullptr; } + Quest const* GetQuestTemplate() override { return nullptr; } - bool isActive([[maybe_unused]] Player* bot) override { return false; } + bool isActive([[maybe_unused]] Player* bot) override { return false; } - std::string const getName() override { return "NullTravelDestination"; } - std::string const getTitle() override { return "no destination"; } + std::string const getName() override { return "NullTravelDestination"; } + std::string const getTitle() override { return "no destination"; } - bool isIn([[maybe_unused]] WorldPosition* pos, [[maybe_unused]] float radius = 0.f) override { return true; } - bool isOut([[maybe_unused]] WorldPosition* pos, [[maybe_unused]] float radius = 0.f) override { return false; } + bool isIn([[maybe_unused]] WorldPosition* pos, [[maybe_unused]] float radius = 0.f) override { return true; } + bool isOut([[maybe_unused]] WorldPosition* pos, [[maybe_unused]] float radius = 0.f) override { return false; } }; -//A travel target specifically related to a quest. +// A travel target specifically related to a quest. class QuestTravelDestination : public TravelDestination { - public: - QuestTravelDestination(uint32 questId1, float radiusMin1, float radiusMax1); +public: + QuestTravelDestination(uint32 questId1, float radiusMin1, float radiusMax1); - Quest const* GetQuestTemplate() override { return questTemplate; } + Quest const* GetQuestTemplate() override { return questTemplate; } - bool isActive(Player* bot) override; + bool isActive(Player* bot) override; - std::string const getName() override { return "QuestTravelDestination"; } - int32 getEntry() override { return 0; } - std::string const getTitle() override; + std::string const getName() override { return "QuestTravelDestination"; } + int32 getEntry() override { return 0; } + std::string const getTitle() override; - protected: - uint32 questId; - Quest const* questTemplate; +protected: + uint32 questId; + Quest const* questTemplate; }; -//A quest giver or taker. +// A quest giver or taker. class QuestRelationTravelDestination : public QuestTravelDestination { - public: - QuestRelationTravelDestination(uint32 quest_id1, uint32 entry1, uint32 relation1, float radiusMin1, float radiusMax1) : - QuestTravelDestination(quest_id1, radiusMin1, radiusMax1) - { - entry = entry1; - relation = relation1; - } +public: + QuestRelationTravelDestination(uint32 quest_id1, uint32 entry1, uint32 relation1, float radiusMin1, + float radiusMax1) + : QuestTravelDestination(quest_id1, radiusMin1, radiusMax1) + { + entry = entry1; + relation = relation1; + } - bool isActive(Player* bot) override; - std::string const getName() override { return "QuestRelationTravelDestination"; } - int32 getEntry() override { return entry; } - std::string const getTitle() override; - virtual uint32 getRelation() { return relation; } + bool isActive(Player* bot) override; + std::string const getName() override { return "QuestRelationTravelDestination"; } + int32 getEntry() override { return entry; } + std::string const getTitle() override; + virtual uint32 getRelation() { return relation; } - private: - uint32 relation; - int32 entry; +private: + uint32 relation; + int32 entry; }; -//A quest objective (creature/gameobject to grind/loot) +// A quest objective (creature/gameobject to grind/loot) class QuestObjectiveTravelDestination : public QuestTravelDestination { - public: - QuestObjectiveTravelDestination(uint32 quest_id1, uint32 entry1, uint32 objective1, float radiusMin1, float radiusMax1, uint32 itemId1 = 0) : - QuestTravelDestination(quest_id1, radiusMin1, radiusMax1) - { - objective = objective1; - entry = entry1; - itemId = itemId1; - } +public: + QuestObjectiveTravelDestination(uint32 quest_id1, uint32 entry1, uint32 objective1, float radiusMin1, + float radiusMax1, uint32 itemId1 = 0) + : QuestTravelDestination(quest_id1, radiusMin1, radiusMax1) + { + objective = objective1; + entry = entry1; + itemId = itemId1; + } - bool isCreature(); - uint32 ReqCreature(); - uint32 ReqGOId(); - uint32 ReqCount(); + bool isCreature(); + uint32 ReqCreature(); + uint32 ReqGOId(); + uint32 ReqCount(); - bool isActive(Player* bot) override; - std::string const getName() override { return "QuestObjectiveTravelDestination"; } - int32 getEntry() override { return entry; } - std::string const getTitle() override; + bool isActive(Player* bot) override; + std::string const getName() override { return "QuestObjectiveTravelDestination"; } + int32 getEntry() override { return entry; } + std::string const getTitle() override; - private: - uint32 objective; - uint32 entry; - uint32 itemId = 0; +private: + uint32 objective; + uint32 entry; + uint32 itemId = 0; }; -//A location with rpg target(s) based on race and level +// A location with rpg target(s) based on race and level class RpgTravelDestination : public TravelDestination { - public: - RpgTravelDestination(uint32 entry1, float radiusMin1, float radiusMax1) : TravelDestination(radiusMin1, radiusMax1) - { - entry = entry1; - } +public: + RpgTravelDestination(uint32 entry1, float radiusMin1, float radiusMax1) : TravelDestination(radiusMin1, radiusMax1) + { + entry = entry1; + } - bool isActive(Player* bot) override; - virtual CreatureTemplate const* GetCreatureTemplate(); - std::string const getName() override { return "RpgTravelDestination"; } - int32 getEntry() override { return 0; } - std::string const getTitle() override; + bool isActive(Player* bot) override; + virtual CreatureTemplate const* GetCreatureTemplate(); + std::string const getName() override { return "RpgTravelDestination"; } + int32 getEntry() override { return 0; } + std::string const getTitle() override; - protected: - uint32 entry; +protected: + uint32 entry; }; -//A location with zone exploration target(s) +// A location with zone exploration target(s) class ExploreTravelDestination : public TravelDestination { - public: - ExploreTravelDestination(uint32 areaId1, float radiusMin1, float radiusMax1) : TravelDestination(radiusMin1, radiusMax1) - { - areaId = areaId1; - } +public: + ExploreTravelDestination(uint32 areaId1, float radiusMin1, float radiusMax1) + : TravelDestination(radiusMin1, radiusMax1) + { + areaId = areaId1; + } - bool isActive(Player* bot) override; - std::string const getName() override { return "ExploreTravelDestination"; } - int32 getEntry() override { return 0; } - std::string const getTitle() override { return title; }; - virtual void setTitle(std::string newTitle) { title = newTitle; } - virtual uint32 getAreaId() { return areaId; } + bool isActive(Player* bot) override; + std::string const getName() override { return "ExploreTravelDestination"; } + int32 getEntry() override { return 0; } + std::string const getTitle() override { return title; }; + virtual void setTitle(std::string newTitle) { title = newTitle; } + virtual uint32 getAreaId() { return areaId; } - protected: - uint32 areaId; - std::string title = ""; +protected: + uint32 areaId; + std::string title = ""; }; -//A location with zone exploration target(s) +// A location with zone exploration target(s) class GrindTravelDestination : public TravelDestination { - public: - GrindTravelDestination(int32 entry1, float radiusMin1, float radiusMax1) : TravelDestination(radiusMin1, radiusMax1) - { - entry = entry1; - } +public: + GrindTravelDestination(int32 entry1, float radiusMin1, float radiusMax1) : TravelDestination(radiusMin1, radiusMax1) + { + entry = entry1; + } - bool isActive(Player* bot) override; - virtual CreatureTemplate const* GetCreatureTemplate(); - std::string const getName() override { return "GrindTravelDestination"; } - int32 getEntry() override { return entry; } - std::string const getTitle() override; + bool isActive(Player* bot) override; + virtual CreatureTemplate const* GetCreatureTemplate(); + std::string const getName() override { return "GrindTravelDestination"; } + int32 getEntry() override { return entry; } + std::string const getTitle() override; - protected: - int32 entry; +protected: + int32 entry; }; -//A location with a boss +// A location with a boss class BossTravelDestination : public TravelDestination { - public: - BossTravelDestination(int32 entry1, float radiusMin1, float radiusMax1) : TravelDestination(radiusMin1, radiusMax1) - { - entry = entry1; - cooldownDelay = 1000; - } +public: + BossTravelDestination(int32 entry1, float radiusMin1, float radiusMax1) : TravelDestination(radiusMin1, radiusMax1) + { + entry = entry1; + cooldownDelay = 1000; + } - bool isActive(Player* bot) override; - CreatureTemplate const* getCreatureTemplate(); - std::string const getName() override { return "BossTravelDestination"; } - int32 getEntry() override { return entry; } - std::string const getTitle() override; + bool isActive(Player* bot) override; + CreatureTemplate const* getCreatureTemplate(); + std::string const getName() override { return "BossTravelDestination"; } + int32 getEntry() override { return entry; } + std::string const getTitle() override; - protected: - int32 entry; +protected: + int32 entry; }; -//Current target and location for the bot to travel to. -//The flow is as follows: -//PREPARE (wait until no loot is near) -//TRAVEL (move towards target until close enough) (rpg and grind is disabled) -//WORK (grind/rpg until the target is no longer active) (rpg and grind is enabled on quest mobs) -//COOLDOWN (wait some time free to do what the bot wants) -//EXPIRE (if any of the above actions take too long pick a new target) +// Current target and location for the bot to travel to. +// The flow is as follows: +// PREPARE (wait until no loot is near) +// TRAVEL (move towards target until close enough) (rpg and grind is disabled) +// WORK (grind/rpg until the target is no longer active) (rpg and grind is enabled on quest mobs) +// COOLDOWN (wait some time free to do what the bot wants) +// EXPIRE (if any of the above actions take too long pick a new target) class TravelTarget : AiObject { - public: - TravelTarget(PlayerbotAI* botAI) : AiObject(botAI), m_status(TRAVEL_STATUS_NONE), startTime(getMSTime()) { }; - TravelTarget(PlayerbotAI* botAI, TravelDestination* tDestination1, WorldPosition* wPosition1) : AiObject(botAI), m_status(TRAVEL_STATUS_NONE), startTime(getMSTime()) - { - setTarget(tDestination1, wPosition1); - } +public: + TravelTarget(PlayerbotAI* botAI) : AiObject(botAI), m_status(TRAVEL_STATUS_NONE), startTime(getMSTime()){}; + TravelTarget(PlayerbotAI* botAI, TravelDestination* tDestination1, WorldPosition* wPosition1) + : AiObject(botAI), m_status(TRAVEL_STATUS_NONE), startTime(getMSTime()) + { + setTarget(tDestination1, wPosition1); + } - ~TravelTarget(); + ~TravelTarget(); - void setTarget(TravelDestination* tDestination1, WorldPosition* wPosition1, bool groupCopy1 = false); - void setStatus(TravelStatus status); - void setExpireIn(uint32 expireMs) - { - statusTime = getExpiredTime() + expireMs; - } + void setTarget(TravelDestination* tDestination1, WorldPosition* wPosition1, bool groupCopy1 = false); + void setStatus(TravelStatus status); + void setExpireIn(uint32 expireMs) { statusTime = getExpiredTime() + expireMs; } - void incRetry(bool isMove) - { - if (isMove) - ++moveRetryCount; - else - ++extendRetryCount; - } + void incRetry(bool isMove) + { + if (isMove) + ++moveRetryCount; + else + ++extendRetryCount; + } - void setRetry(bool isMove, uint32 newCount = 0) - { - if (isMove) - moveRetryCount = newCount; - else - extendRetryCount = newCount; - } + void setRetry(bool isMove, uint32 newCount = 0) + { + if (isMove) + moveRetryCount = newCount; + else + extendRetryCount = newCount; + } - void setForced(bool forced1) - { - forced = forced1; - } + void setForced(bool forced1) { forced = forced1; } - void setRadius(float radius1) - { - radius = radius1; - } + void setRadius(float radius1) { radius = radius1; } - void copyTarget(TravelTarget* target); - void addVisitors(); - void releaseVisitors(); + void copyTarget(TravelTarget* target); + void addVisitors(); + void releaseVisitors(); - float distance(Player* bot); + float distance(Player* bot); - WorldPosition* getPosition(); - TravelDestination* getDestination(); + WorldPosition* getPosition(); + TravelDestination* getDestination(); - uint32 getEntry() - { - if (!tDestination) - return 0; + uint32 getEntry() + { + if (!tDestination) + return 0; - return tDestination->getEntry(); - } + return tDestination->getEntry(); + } - PlayerbotAI* getAi() - { - return botAI; - } + PlayerbotAI* getAi() { return botAI; } - uint32 getExpiredTime() - { - return getMSTime() - startTime; - } + uint32 getExpiredTime() { return getMSTime() - startTime; } - uint32 getTimeLeft() - { - return statusTime - getExpiredTime(); - } + uint32 getTimeLeft() { return statusTime - getExpiredTime(); } - uint32 getMaxTravelTime(); - uint32 getRetryCount(bool isMove) - { - return isMove ? moveRetryCount: extendRetryCount; - } + uint32 getMaxTravelTime(); + uint32 getRetryCount(bool isMove) { return isMove ? moveRetryCount : extendRetryCount; } - bool isTraveling(); - bool isActive(); - bool isWorking(); - bool isPreparing(); - bool isMaxRetry(bool isMove) - { - return isMove ? (moveRetryCount > 5) : (extendRetryCount > 5); - } + bool isTraveling(); + bool isActive(); + bool isWorking(); + bool isPreparing(); + bool isMaxRetry(bool isMove) { return isMove ? (moveRetryCount > 5) : (extendRetryCount > 5); } - TravelStatus getStatus() - { - return m_status; - } + TravelStatus getStatus() { return m_status; } - TravelState getTravelState(); + TravelState getTravelState(); - bool isGroupCopy() - { - return groupCopy; - } + bool isGroupCopy() { return groupCopy; } - bool isForced() - { - return forced; - } + bool isForced() { return forced; } - protected: - TravelStatus m_status; +protected: + TravelStatus m_status; - uint32 startTime; - uint32 statusTime = 0; + uint32 startTime; + uint32 statusTime = 0; - bool forced = false; - float radius = 0.f; - bool groupCopy = false; - bool visitor = true; + bool forced = false; + float radius = 0.f; + bool groupCopy = false; + bool visitor = true; - uint32 extendRetryCount = 0; - uint32 moveRetryCount = 0; + uint32 extendRetryCount = 0; + uint32 moveRetryCount = 0; - TravelDestination* tDestination = nullptr; - WorldPosition* wPosition = nullptr; + TravelDestination* tDestination = nullptr; + WorldPosition* wPosition = nullptr; }; -//General container for all travel destinations. +// General container for all travel destinations. class TravelMgr { - public: - TravelMgr() { }; +public: + TravelMgr(){}; - static TravelMgr* instance() + static TravelMgr* instance() + { + static TravelMgr instance; + return &instance; + } + + void Clear(); + void LoadQuestTravelTable(); + + template + void weighted_shuffle(D first, D last, W first_weight, W last_weight, URBG&& g) + { + while (first != last && first_weight != last_weight) { - static TravelMgr instance; - return &instance; - } + std::discrete_distribution dd(first_weight, last_weight); + auto i = dd(g); - void Clear(); - void LoadQuestTravelTable(); - - template - void weighted_shuffle(D first, D last, W first_weight, W last_weight, URBG&& g) - { - while (first != last && first_weight != last_weight) + if (i) { - std::discrete_distributiondd(first_weight, last_weight); - auto i = dd(g); - - if (i) - { - std::swap(*first, *std::next(first, i)); - std::swap(*first_weight, *std::next(first_weight, i)); - } - ++first; - ++first_weight; + std::swap(*first, *std::next(first, i)); + std::swap(*first_weight, *std::next(first_weight, i)); } + ++first; + ++first_weight; } + } - std::vector getNextPoint(WorldPosition* center, std::vector points, uint32 amount = 1); - std::vector getNextPoint(WorldPosition center, std::vector points, uint32 amount = 1); - QuestStatusData* getQuestStatus(Player* bot, uint32 questId); - bool getObjectiveStatus(Player* bot, Quest const* pQuest, uint32 objective); - uint32 getDialogStatus(Player* pPlayer, int32 questgiver, Quest const* pQuest); - std::vector getQuestTravelDestinations(Player* bot, int32 questId = -1, bool ignoreFull = false, bool ignoreInactive = false, float maxDistance = 5000, bool ignoreObjectives = false); - std::vector getRpgTravelDestinations(Player* bot, bool ignoreFull = false, bool ignoreInactive = false, float maxDistance = 5000); - std::vector getExploreTravelDestinations(Player* bot, bool ignoreFull = false, bool ignoreInactive = false); - std::vector getGrindTravelDestinations(Player* bot, bool ignoreFull = false, bool ignoreInactive = false, float maxDistance = 5000); - std::vector getBossTravelDestinations(Player* bot, bool ignoreFull = false, bool ignoreInactive = false, float maxDistance = 25000); + std::vector getNextPoint(WorldPosition* center, std::vector points, + uint32 amount = 1); + std::vector getNextPoint(WorldPosition center, std::vector points, uint32 amount = 1); + QuestStatusData* getQuestStatus(Player* bot, uint32 questId); + bool getObjectiveStatus(Player* bot, Quest const* pQuest, uint32 objective); + uint32 getDialogStatus(Player* pPlayer, int32 questgiver, Quest const* pQuest); + std::vector getQuestTravelDestinations(Player* bot, int32 questId = -1, bool ignoreFull = false, + bool ignoreInactive = false, float maxDistance = 5000, + bool ignoreObjectives = false); + std::vector getRpgTravelDestinations(Player* bot, bool ignoreFull = false, + bool ignoreInactive = false, float maxDistance = 5000); + std::vector getExploreTravelDestinations(Player* bot, bool ignoreFull = false, + bool ignoreInactive = false); + std::vector getGrindTravelDestinations(Player* bot, bool ignoreFull = false, + bool ignoreInactive = false, float maxDistance = 5000); + std::vector getBossTravelDestinations(Player* bot, bool ignoreFull = false, + bool ignoreInactive = false, float maxDistance = 25000); - void setNullTravelTarget(Player* player); + void setNullTravelTarget(Player* player); - void addMapTransfer(WorldPosition start, WorldPosition end, float portalDistance = 0.1f, bool makeShortcuts = true); - void loadMapTransfers(); - float mapTransDistance(WorldPosition start, WorldPosition end); - float fastMapTransDistance(WorldPosition start, WorldPosition end); + void addMapTransfer(WorldPosition start, WorldPosition end, float portalDistance = 0.1f, bool makeShortcuts = true); + void loadMapTransfers(); + float mapTransDistance(WorldPosition start, WorldPosition end); + float fastMapTransDistance(WorldPosition start, WorldPosition end); - NullTravelDestination* nullTravelDestination = new NullTravelDestination(); - WorldPosition* nullWorldPosition = new WorldPosition(); + NullTravelDestination* nullTravelDestination = new NullTravelDestination(); + WorldPosition* nullWorldPosition = new WorldPosition(); - void addBadVmap(uint32 mapId, uint8 x, uint8 y) - { - badVmap.push_back(std::make_tuple(mapId, x, y)); - } + void addBadVmap(uint32 mapId, uint8 x, uint8 y) { badVmap.push_back(std::make_tuple(mapId, x, y)); } - void addBadMmap(uint32 mapId, uint8 x, uint8 y) - { - badMmap.push_back(std::make_tuple(mapId, x, y)); - } + void addBadMmap(uint32 mapId, uint8 x, uint8 y) { badMmap.push_back(std::make_tuple(mapId, x, y)); } - bool isBadVmap(uint32 mapId, uint8 x, uint8 y) - { - return std::find(badVmap.begin(), badVmap.end(), std::make_tuple(mapId, x, y)) != badVmap.end(); - } + bool isBadVmap(uint32 mapId, uint8 x, uint8 y) + { + return std::find(badVmap.begin(), badVmap.end(), std::make_tuple(mapId, x, y)) != badVmap.end(); + } - bool isBadMmap(uint32 mapId, uint8 x, uint8 y) - { - return std::find(badMmap.begin(), badMmap.end(), std::make_tuple(mapId, x, y)) != badMmap.end(); - } + bool isBadMmap(uint32 mapId, uint8 x, uint8 y) + { + return std::find(badMmap.begin(), badMmap.end(), std::make_tuple(mapId, x, y)) != badMmap.end(); + } - void printGrid(uint32 mapId, int x, int y, std::string const type); - void printObj(WorldObject* obj, std::string const type); + void printGrid(uint32 mapId, int x, int y, std::string const type); + void printObj(WorldObject* obj, std::string const type); - //protected: - void logQuestError(uint32 errorNr, Quest* quest, uint32 objective = 0, uint32 unitId = 0, uint32 itemId = 0); + // protected: + void logQuestError(uint32 errorNr, Quest* quest, uint32 objective = 0, uint32 unitId = 0, uint32 itemId = 0); - std::vector avoidLoaded; + std::vector avoidLoaded; - std::vector questGivers; - std::vector rpgNpcs; - std::vector grindMobs; - std::vector bossMobs; + std::vector questGivers; + std::vector rpgNpcs; + std::vector grindMobs; + std::vector bossMobs; - std::unordered_map exploreLocs; - std::unordered_map quests; + std::unordered_map exploreLocs; + std::unordered_map quests; - std::vector> badVmap, badMmap; + std::vector> badVmap, badMmap; - std::unordered_map, std::vector, boost::hash>> mapTransfersMap; + std::unordered_map, std::vector, boost::hash>> + mapTransfersMap; }; #define sTravelMgr TravelMgr::instance() diff --git a/src/TravelNode.cpp b/src/TravelNode.cpp index 04152be7..0acddeb7 100644 --- a/src/TravelNode.cpp +++ b/src/TravelNode.cpp @@ -1,18 +1,22 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TravelNode.h" + +#include +#include + #include "BudgetValues.h" #include "PathGenerator.h" #include "Playerbots.h" #include "ServerFacade.h" #include "TransportMgr.h" -#include -#include - -// TravelNodePath(float distance = 0.1f, float extraCost = 0, TravelNodePathType pathType = TravelNodePathType::walk, uint32 pathObject = 0, bool calculated = false, std::vector maxLevelCreature = { 0,0,0 }, float swimDistance = 0) +// TravelNodePath(float distance = 0.1f, float extraCost = 0, TravelNodePathType pathType = TravelNodePathType::walk, +// uint32 pathObject = 0, bool calculated = false, std::vector maxLevelCreature = { 0,0,0 }, float swimDistance = +// 0) std::string const TravelNodePath::print() { std::ostringstream out; @@ -22,13 +26,14 @@ std::string const TravelNodePath::print() out << std::to_string(uint8(pathType)) << ","; out << pathObject << ","; out << (calculated ? "true" : "false") << ","; - out << std::to_string(maxLevelCreature[0]) << "," << std::to_string(maxLevelCreature[1]) << "," << std::to_string(maxLevelCreature[2]) << ","; + out << std::to_string(maxLevelCreature[0]) << "," << std::to_string(maxLevelCreature[1]) << "," + << std::to_string(maxLevelCreature[2]) << ","; out << swimDistance << "f"; return out.str().c_str(); } -//Gets the extra information needed to properly calculate the cost. +// Gets the extra information needed to properly calculate the cost. void TravelNodePath::calculateCost(bool distanceOnly) { std::unordered_map aReact, hReact; @@ -39,7 +44,7 @@ void TravelNodePath::calculateCost(bool distanceOnly) return; distance = 0.1f; - maxLevelCreature = { 0, 0, 0 }; + maxLevelCreature = {0, 0, 0}; swimDistance = 0; WorldPosition lastPoint = WorldPosition(); @@ -47,7 +52,7 @@ void TravelNodePath::calculateCost(bool distanceOnly) { if (!distanceOnly) { - for (CreatureData const* cData : point.getCreaturesNear(50)) // Agro radius + 5 + for (CreatureData const* cData : point.getCreaturesNear(50)) // Agro radius + 5 { CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(cData->id1); if (cInfo) @@ -55,11 +60,15 @@ void TravelNodePath::calculateCost(bool distanceOnly) FactionTemplateEntry const* factionEntry = sFactionTemplateStore.LookupEntry(cInfo->faction); if (aReact.find(factionEntry) == aReact.end()) - aReact.insert(std::make_pair(factionEntry, Unit::GetFactionReactionTo(factionEntry, sFactionTemplateStore.LookupEntry(1)) > REP_NEUTRAL)); + aReact.insert(std::make_pair( + factionEntry, Unit::GetFactionReactionTo( + factionEntry, sFactionTemplateStore.LookupEntry(1)) > REP_NEUTRAL)); aFriend = aReact.find(factionEntry)->second; if (hReact.find(factionEntry) == hReact.end()) - hReact.insert(std::make_pair(factionEntry, Unit::GetFactionReactionTo(factionEntry, sFactionTemplateStore.LookupEntry(2)) > REP_NEUTRAL)); + hReact.insert(std::make_pair( + factionEntry, Unit::GetFactionReactionTo( + factionEntry, sFactionTemplateStore.LookupEntry(2)) > REP_NEUTRAL)); hFriend = hReact.find(factionEntry)->second; if (maxLevelCreature[0] < cInfo->maxlevel && !aFriend && !hFriend) @@ -87,14 +96,14 @@ void TravelNodePath::calculateCost(bool distanceOnly) calculated = true; } -//The cost to travel this path. +// The cost to travel this path. float TravelNodePath::getCost(Player* bot, uint32 cGold) { - float modifier = 1.0f; //Global modifier + float modifier = 1.0f; // Global modifier float timeCost = 0.1f; float runDistance = distance - swimDistance; - float speed = 8.0f; //default run speed - float swimSpeed = 4.0f; //default swim speed. + float speed = 8.0f; // default run speed + float swimSpeed = 4.0f; // default swim speed. if (bot) { @@ -115,8 +124,10 @@ float TravelNodePath::getCost(Player* bot, uint32 cGold) return -1; TaxiNodesEntry const* startTaxiNode = sTaxiNodesStore.LookupEntry(taxiPath->from); - TaxiNodesEntry const* endTaxiNode = sTaxiNodesStore.LookupEntry(taxiPath->to); - if (!startTaxiNode || !endTaxiNode || !startTaxiNode->MountCreatureID[bot->GetTeamId() == TEAM_ALLIANCE ? 1 : 0] || !endTaxiNode->MountCreatureID[bot->GetTeamId() == TEAM_ALLIANCE ? 1 : 0]) + TaxiNodesEntry const* endTaxiNode = sTaxiNodesStore.LookupEntry(taxiPath->to); + if (!startTaxiNode || !endTaxiNode || + !startTaxiNode->MountCreatureID[bot->GetTeamId() == TEAM_ALLIANCE ? 1 : 0] || + !endTaxiNode->MountCreatureID[bot->GetTeamId() == TEAM_ALLIANCE ? 1 : 0]) return -1; } @@ -127,22 +138,23 @@ float TravelNodePath::getCost(Player* bot, uint32 cGold) swimSpeed *= 1.5; uint32 level = bot->GetLevel(); - bool isAlliance = Unit::GetFactionReactionTo(bot->GetFactionTemplateEntry(), sFactionTemplateStore.LookupEntry(1)) > REP_NEUTRAL; + bool isAlliance = Unit::GetFactionReactionTo(bot->GetFactionTemplateEntry(), + sFactionTemplateStore.LookupEntry(1)) > REP_NEUTRAL; int factionAnnoyance = 0; if (maxLevelCreature.size() > 0) { - int mobAnnoyance = (maxLevelCreature[0] - level) - 10; //Mobs 10 levels below do not bother us. + int mobAnnoyance = (maxLevelCreature[0] - level) - 10; // Mobs 10 levels below do not bother us. if (isAlliance) - factionAnnoyance = (maxLevelCreature[2] - level) - 10; // Opposite faction below 30 do not bother us. + factionAnnoyance = (maxLevelCreature[2] - level) - 10; // Opposite faction below 30 do not bother us. else if (!isAlliance) factionAnnoyance = (maxLevelCreature[1] - level) - 10; if (mobAnnoyance > 0) - modifier += 0.1 * mobAnnoyance; // For each level the whole path takes 10% longer. + modifier += 0.1 * mobAnnoyance; // For each level the whole path takes 10% longer. if (factionAnnoyance > 0) - modifier += 0.3 * factionAnnoyance; // For each level the whole path takes 10% longer. + modifier += 0.3 * factionAnnoyance; // For each level the whole path takes 10% longer. } } else if (getPathType() == TravelNodePathType::flightPath) @@ -169,7 +181,7 @@ uint32 TravelNodePath::getPrice() return taxiPath->price; } -//Creates or appends the path from one node to another. Returns if the path. +// Creates or appends the path from one node to another. Returns if the path. TravelNodePath* TravelNode::buildPath(TravelNode* endNode, Unit* bot, bool postProcess) { if (getMapId() != endNode->getMapId()) @@ -177,26 +189,26 @@ TravelNodePath* TravelNode::buildPath(TravelNode* endNode, Unit* bot, bool postP TravelNodePath* returnNodePath; - if (!hasPathTo(endNode)) //Create path if it doesn't exists + if (!hasPathTo(endNode)) // Create path if it doesn't exists returnNodePath = setPathTo(endNode, TravelNodePath(), false); else - returnNodePath = getPathTo(endNode); //Get the exsisting path. + returnNodePath = getPathTo(endNode); // Get the exsisting path. - if (returnNodePath->getComplete()) //Path is already complete. Return it. + if (returnNodePath->getComplete()) // Path is already complete. Return it. return returnNodePath; std::vector path = returnNodePath->getPath(); if (path.empty()) - path = { *getPosition() }; //Start the path from the current Node. + path = {*getPosition()}; // Start the path from the current Node. - WorldPosition* endPos = endNode->getPosition(); //Build the path to the end Node. + WorldPosition* endPos = endNode->getPosition(); // Build the path to the end Node. - path = endPos->getPathFromPath(path, bot); //Pathfind from the existing path to the end Node. + path = endPos->getPathFromPath(path, bot); // Pathfind from the existing path to the end Node. - bool canPath = endPos->isPathTo(path); //Check if we reached our destination. + bool canPath = endPos->isPathTo(path); // Check if we reached our destination. - if (!canPath && endNode->hasLinkTo(this)) //Unable to find a path? See if the reverse is possible. + if (!canPath && endNode->hasLinkTo(this)) // Unable to find a path? See if the reverse is possible. { TravelNodePath backNodePath = *endNode->getPathTo(this); @@ -204,16 +216,16 @@ TravelNodePath* TravelNode::buildPath(TravelNode* endNode, Unit* bot, bool postP { std::vector bPath = backNodePath.getPath(); - if (!backNodePath.getComplete()) //Build it if it's not already complete. + if (!backNodePath.getComplete()) // Build it if it's not already complete. { if (bPath.empty()) - bPath = { *endNode->getPosition() }; //Start the path from the end Node. + bPath = {*endNode->getPosition()}; // Start the path from the end Node. - WorldPosition* thisPos = getPosition(); //Build the path to this Node. + WorldPosition* thisPos = getPosition(); // Build the path to this Node. - bPath = thisPos->getPathFromPath(bPath, bot); //Pathfind from the existing path to the this Node. + bPath = thisPos->getPathFromPath(bPath, bot); // Pathfind from the existing path to the this Node. - canPath = thisPos->isPathTo(bPath); //Check if we reached our destination. + canPath = thisPos->isPathTo(bPath); // Check if we reached our destination. } else canPath = true; @@ -226,13 +238,13 @@ TravelNodePath* TravelNode::buildPath(TravelNode* endNode, Unit* bot, bool postP } } - //Transports are (probably?) not solid at this moment. We need to walk over them so we need extra code for this. - //Some portals are 'too' solid so we can't properly walk in them. Again we need to bypass this. + // Transports are (probably?) not solid at this moment. We need to walk over them so we need extra code for this. + // Some portals are 'too' solid so we can't properly walk in them. Again we need to bypass this. if (!isTransport() && !isPortal() && (endNode->isPortal() || endNode->isTransport())) { - if (endNode->isTransport() && path.back().isInWater()) //Do not swim to boats. + if (endNode->isTransport() && path.back().isInWater()) // Do not swim to boats. canPath = false; - else if (!canPath && endPos->isPathTo(path, 20.0f)) //Cheat a little for transports and portals. + else if (!canPath && endPos->isPathTo(path, 20.0f)) // Cheat a little for transports and portals. { path.push_back(*endPos); canPath = true; @@ -257,14 +269,16 @@ TravelNodePath* TravelNode::buildPath(TravelNode* endNode, Unit* bot, bool postP if (isTransport() && path.size() > 1) { - WorldPosition secondPos = *std::next(path.begin()); //This is to prevent bots from jumping in the water from a transport. Need to remove this when transports are properly handled. + WorldPosition secondPos = + *std::next(path.begin()); // This is to prevent bots from jumping in the water from a transport. Need to + // remove this when transports are properly handled. if (secondPos.getMap() && secondPos.isInWater()) canPath = false; } returnNodePath->setComplete(canPath); - if(canPath && !hasLinkTo(endNode)) + if (canPath && !hasLinkTo(endNode)) setLinkTo(endNode, true); returnNodePath->setPath(path); @@ -292,11 +306,10 @@ TravelNodePath* TravelNode::buildPath(TravelNode* endNode, Unit* bot, bool postP return returnNodePath; } - -//Generic routine to remove references to nodes. +// Generic routine to remove references to nodes. void TravelNode::removeLinkTo(TravelNode* node, bool removePaths) { - if (node) //Unlink this specific node + if (node) // Unlink this specific node { if (removePaths) paths.erase(node); @@ -306,7 +319,7 @@ void TravelNode::removeLinkTo(TravelNode* node, bool removePaths) } else { - //Remove all references to this node. + // Remove all references to this node. for (auto& node : sTravelNodeMap->getNodes()) { if (node->hasPathTo(this)) @@ -336,12 +349,13 @@ std::vector TravelNode::getNodeMap(bool importantOnly, std::vector< if (!importantOnly || currentNode->isImportant()) closeList.push_back(currentNode); - for (auto & nextPath : *currentNode->getLinks()) + for (auto& nextPath : *currentNode->getLinks()) { TravelNode* nextNode = nextPath.first; if (std::find(openList.begin(), openList.end(), nextNode) == openList.end()) { - if (ignoreNodes.empty() || std::find(ignoreNodes.begin(), ignoreNodes.end(), nextNode) == ignoreNodes.end()) + if (ignoreNodes.empty() || + std::find(ignoreNodes.begin(), ignoreNodes.end(), nextNode) == ignoreNodes.end()) openList.push_back(nextNode); } } @@ -374,10 +388,9 @@ bool TravelNode::isUselessLink(TravelNode* farNode) if (nearNode->hasLinkTo(farNode)) { - //Is it quicker to go past second node to reach first node instead of going directly? + // Is it quicker to go past second node to reach first node instead of going directly? if (nearLength + nearNode->linkDistanceTo(farNode) < farLength * 1.1) return true; - } else { @@ -389,7 +402,7 @@ bool TravelNode::isUselessLink(TravelNode* farNode) if (route.hasNode(this)) continue; - //Is it quicker to go past second (and multiple) nodes to reach the first node instead of going directly? + // Is it quicker to go past second (and multiple) nodes to reach the first node instead of going directly? if (nearLength + route.getTotalDistance() < farLength * 1.1) return true; } @@ -465,8 +478,8 @@ bool TravelNode::cropUselessLinks() if (firstNode == secondNode) continue; - if (std::find(toRemove.begin(), toRemove.end(), [firstNode, secondNode](std::pair pair) {return pair.first == firstNode || pair.first == secondNode;}) != toRemove.end()) - continue; + if (std::find(toRemove.begin(), toRemove.end(), [firstNode, secondNode](std::pair + pair) {return pair.first == firstNode || pair.first == secondNode;}) != toRemove.end()) continue; if (firstNode->hasLinkTo(secondNode)) { @@ -489,8 +502,8 @@ bool TravelNode::cropUselessLinks() if (route.hasNode(this)) continue; - //Is it quicker to go past first (and multiple) nodes to reach the second node instead of going directly? - if (firstLength + route.getLength() < secondLength * 1.1) + //Is it quicker to go past first (and multiple) nodes to reach the second node instead of going + directly? if (firstLength + route.getLength() < secondLength * 1.1) { if (secondNode->hasLinkTo(this) && !firstNode->hasLinkTo(this)) continue; @@ -513,8 +526,8 @@ bool TravelNode::cropUselessLinks() if (this == secondNode) continue; - if (std::find(toRemove.begin(), toRemove.end(), [firstNode, secondNode](std::pair pair) {return pair.first == firstNode || pair.first == secondNode; }) != toRemove.end()) - continue; + if (std::find(toRemove.begin(), toRemove.end(), [firstNode, secondNode](std::pair pair) {return pair.first == firstNode || pair.first == secondNode; }) != toRemove.end()) continue; if (firstNode->hasLinkTo(secondNode)) { @@ -537,8 +550,8 @@ bool TravelNode::cropUselessLinks() if (route.hasNode(this)) continue; - //Is it quicker to go past first (and multiple) nodes to reach the second node instead of going directly? - if (firstLength + route.getLength() < secondLength * 1.1) + //Is it quicker to go past first (and multiple) nodes to reach the second node instead of going + directly? if (firstLength + route.getLength() < secondLength * 1.1) { if (secondNode->hasLinkTo(this) && !firstNode->hasLinkTo(this)) continue; @@ -596,7 +609,7 @@ void TravelNode::print([[maybe_unused]] bool printFailed) out << (isImportant() ? 1 : 0) << ","; out << mapSize; - sPlayerbotAIConfig->log("travelNodes.csv",out.str().c_str()); + sPlayerbotAIConfig->log("travelNodes.csv", out.str().c_str()); std::vector ppath; @@ -610,7 +623,7 @@ void TravelNode::print([[maybe_unused]] bool printFailed) TravelNodePath* path = getPathTo(endNode); - if (!hasLinkTo(endNode) && urand(0,20) && !printFailed) + if (!hasLinkTo(endNode) && urand(0, 20) && !printFailed) continue; ppath = path->getPath(); @@ -655,7 +668,7 @@ void TravelNode::print([[maybe_unused]] bool printFailed) } } -//Attempts to move ahead of the path. +// Attempts to move ahead of the path. bool TravelPath::makeShortCut(WorldPosition startPos, float maxDist) { if (getPath().empty()) @@ -667,7 +680,7 @@ bool TravelPath::makeShortCut(WorldPosition startPos, float maxDist) std::vector newPath; WorldPosition firstNode; - for (auto & p : fullPath) //cycle over the full path + for (auto& p : fullPath) // cycle over the full path { // if (p.point.getMapId() != startPos.getMapId()) // continue; @@ -679,19 +692,23 @@ bool TravelPath::makeShortCut(WorldPosition startPos, float maxDist) if (&p != &fullPath.front()) totalDist += p.point.sqDistance(std::prev(&p)->point); - if (curDist < sPlayerbotAIConfig->tooCloseDistance * sPlayerbotAIConfig->tooCloseDistance) // We are on the path. This is a good starting point + if (curDist < + sPlayerbotAIConfig->tooCloseDistance * + sPlayerbotAIConfig->tooCloseDistance) // We are on the path. This is a good starting point { minDist = curDist; totalDist = curDist; newPath.clear(); } - if (p.type != NODE_PREPATH) //Only look at the part after the first node and in the same map. + if (p.type != NODE_PREPATH) // Only look at the part after the first node and in the same map. { if (!firstNode) firstNode = p.point; - if (minDist == -1 || curDist < minDist || (curDist < maxDistSq && curDist < totalDist / 2)) //Start building from the last closest point or a point that is close but far on the path. + if (minDist == -1 || curDist < minDist || + (curDist < maxDistSq && curDist < totalDist / 2)) // Start building from the last closest point or + // a point that is close but far on the path. { minDist = curDist; totalDist = curDist; @@ -711,11 +728,11 @@ bool TravelPath::makeShortCut(WorldPosition startPos, float maxDist) WorldPosition beginPos = newPath.begin()->point; - //The old path seems to be the best. + // The old path seems to be the best. if (beginPos.distance(firstNode) < sPlayerbotAIConfig->tooCloseDistance) - return false; + return false; - //We are (nearly) on the new path. Just follow the rest. + // We are (nearly) on the new path. Just follow the rest. if (beginPos.distance(startPos) < sPlayerbotAIConfig->tooCloseDistance) { fullPath = newPath; @@ -724,11 +741,11 @@ bool TravelPath::makeShortCut(WorldPosition startPos, float maxDist) std::vector toPath = startPos.getPathTo(beginPos, nullptr); - //We can not reach the new begin position. Follow the complete path. + // We can not reach the new begin position. Follow the complete path. if (!beginPos.isPathTo(toPath)) return false; - //Move to the new path and continue. + // Move to the new path and continue. fullPath.clear(); addPath(toPath); addPath(newPath); @@ -736,9 +753,11 @@ bool TravelPath::makeShortCut(WorldPosition startPos, float maxDist) return true; } -bool TravelPath::shouldMoveToNextPoint(WorldPosition startPos, std::vector::iterator beg, std::vector::iterator ed, std::vector::iterator p, float& moveDist, float maxDist) +bool TravelPath::shouldMoveToNextPoint(WorldPosition startPos, std::vector::iterator beg, + std::vector::iterator ed, std::vector::iterator p, + float& moveDist, float maxDist) { - if (p == ed) //We are the end. Stop now. + if (p == ed) // We are the end. Stop now. return false; auto nextP = std::next(p); @@ -746,13 +765,13 @@ bool TravelPath::shouldMoveToNextPoint(WorldPosition startPos, std::vectortype == NODE_PORTAL && nextP->type == NODE_PORTAL && p->entry == nextP->entry) { - return false; //Move to teleport and activate area trigger. + return false; // Move to teleport and activate area trigger. } // We are using a hearthstone. if (p->type == NODE_TELEPORT && nextP->type == NODE_TELEPORT && p->entry == nextP->entry) { - return false; // Move to teleport and activate area trigger. + return false; // Move to teleport and activate area trigger. } // We are almost at a transport node. Move to the node before this. @@ -761,16 +780,17 @@ bool TravelPath::shouldMoveToNextPoint(WorldPosition startPos, std::vectortype == NODE_TRANSPORT && p->entry) { - if (nextP->type != NODE_TRANSPORT && p != beg && std::prev(p)->type != NODE_TRANSPORT) //We are not using the transport. Skip it. + if (nextP->type != NODE_TRANSPORT && p != beg && + std::prev(p)->type != NODE_TRANSPORT) // We are not using the transport. Skip it. return true; - return false; //Teleport to exit of transport. + return false; // Teleport to exit of transport. } - //We are moving to a flightpath and want to fly. + // We are moving to a flightpath and want to fly. if (p->type == NODE_FLIGHTPATH && nextP->type == NODE_FLIGHTPATH) { return false; @@ -778,7 +798,8 @@ bool TravelPath::shouldMoveToNextPoint(WorldPosition startPos, std::vectorpoint.distance(nextP->point); - if (p->point.getMapId() != startPos.getMapId() || ((moveDist + nextMove > maxDist || startPos.distance(nextP->point) > maxDist) && moveDist > 0)) + if (p->point.getMapId() != startPos.getMapId() || + ((moveDist + nextMove > maxDist || startPos.distance(nextP->point) > maxDist) && moveDist > 0)) { return false; } @@ -788,8 +809,9 @@ bool TravelPath::shouldMoveToNextPoint(WorldPosition startPos, std::vectorpoint.getMapId() != startPos.getMapId()) continue; @@ -828,7 +850,7 @@ WorldPosition TravelPath::getNextPoint(WorldPosition startPos, float maxDist, Tr break; } - //We are moving towards a teleport. Move to portal an activate area trigger + // We are moving towards a teleport. Move to portal an activate area trigger if (startP->type == NODE_PORTAL) { pathType = TravelNodePathType::portal; @@ -836,7 +858,7 @@ WorldPosition TravelPath::getNextPoint(WorldPosition startPos, float maxDist, Tr return startP->point; } - //We are using a hearthstone + // We are using a hearthstone if (startP->type == NODE_TELEPORT) { pathType = TravelNodePathType::teleportSpell; @@ -844,7 +866,7 @@ WorldPosition TravelPath::getNextPoint(WorldPosition startPos, float maxDist, Tr return startP->point; } - //We are moving towards a flight path. Move to flight master and activate flight path. + // We are moving towards a flight path. Move to flight master and activate flight path. if (startP->type == NODE_FLIGHTPATH && startPos.distance(startP->point) < INTERACTION_DISTANCE) { pathType = TravelNodePathType::flightPath; @@ -852,7 +874,7 @@ WorldPosition TravelPath::getNextPoint(WorldPosition startPos, float maxDist, Tr return startP->point; } - //We are moving towards transport. Teleport to next normal point instead. + // We are moving towards transport. Teleport to next normal point instead. if (startP->type == NODE_TRANSPORT) { for (auto p = startP + 1; p != ed; p++) @@ -866,11 +888,11 @@ WorldPosition TravelPath::getNextPoint(WorldPosition startPos, float maxDist, Tr } } - //We have to move far for next point. Try to make a cropped path. + // We have to move far for next point. Try to make a cropped path. if (moveDist < sPlayerbotAIConfig->targetPosRecalcDistance && std::next(startP) != ed) { - //std::vector path = startPos.getPathTo(std::next(startP)->point, nullptr); - //startP->point = startPos.lastInRange(path, -1, maxDist); + // std::vector path = startPos.getPathTo(std::next(startP)->point, nullptr); + // startP->point = startPos.lastInRange(path, -1, maxDist); return WorldPosition(); } @@ -882,7 +904,8 @@ std::ostringstream const TravelPath::print() std::ostringstream out; out << sPlayerbotAIConfig->GetTimestampStr(); - out << "+00," << "1,"; + out << "+00," + << "1,"; out << std::fixed; WorldPosition().printWKT(getPointPath(), out, 1); @@ -893,7 +916,7 @@ std::ostringstream const TravelPath::print() float TravelNodeRoute::getTotalDistance() { float totalLength = 0; - for (uint32 i = 0; ilinkDistanceTo(nodes[i + 1]); } @@ -901,11 +924,12 @@ float TravelNodeRoute::getTotalDistance() return totalLength; } -TravelPath TravelNodeRoute::buildPath(std::vector pathToStart, std::vector pathToEnd, [[maybe_unused]] Unit* bot) +TravelPath TravelNodeRoute::buildPath(std::vector pathToStart, std::vector pathToEnd, + [[maybe_unused]] Unit* bot) { TravelPath travelPath; - if (!pathToStart.empty()) //From start position to start of path. + if (!pathToStart.empty()) // From start position to start of path. travelPath.addPath(pathToStart, NODE_PREPATH); TravelNode* prevNode = nullptr; @@ -914,52 +938,57 @@ TravelPath TravelNodeRoute::buildPath(std::vector pathToStart, st if (prevNode) { TravelNodePath* nodePath = nullptr; - if (prevNode->hasPathTo(node)) //Get the path to the next node if it exists. + if (prevNode->hasPathTo(node)) // Get the path to the next node if it exists. nodePath = prevNode->getPathTo(node); - if (!nodePath || !nodePath->getComplete()) //Build the path to the next node if it doesn't exist. + if (!nodePath || !nodePath->getComplete()) // Build the path to the next node if it doesn't exist. { if (!prevNode->isTransport()) nodePath = prevNode->buildPath(node, nullptr); - else //For transports we have no proper path since the node is in air/water. Instead we build a reverse path and follow that. + else // For transports we have no proper path since the node is in air/water. Instead we build a + // reverse path and follow that. { - node->buildPath(prevNode, nullptr); //Reverse build to get proper path. + node->buildPath(prevNode, nullptr); // Reverse build to get proper path. nodePath = prevNode->getPathTo(node); } } TravelNodePath returnNodePath; - if (!nodePath || !nodePath->getComplete()) //It looks like we can't properly path to our node. Make a temporary reverse path and see if that works instead. + if (!nodePath || !nodePath->getComplete()) // It looks like we can't properly path to our node. Make a + // temporary reverse path and see if that works instead. { - returnNodePath = *node->buildPath(prevNode, nullptr); //Build reverse path and save it to a temporary variable. + returnNodePath = + *node->buildPath(prevNode, nullptr); // Build reverse path and save it to a temporary variable. std::vector path = returnNodePath.getPath(); - std::reverse(path.begin(), path.end()); //Reverse the path + std::reverse(path.begin(), path.end()); // Reverse the path returnNodePath.setPath(path); nodePath = &returnNodePath; } - if (!nodePath || !nodePath->getComplete()) //If we can not build a path just try to move to the node. + if (!nodePath || !nodePath->getComplete()) // If we can not build a path just try to move to the node. { travelPath.addPoint(*prevNode->getPosition(), NODE_NODE); prevNode = node; continue; } - if (nodePath->getPathType() == TravelNodePathType::portal) // Teleport to next node. + if (nodePath->getPathType() == TravelNodePathType::portal) // Teleport to next node. { - travelPath.addPoint(*prevNode->getPosition(), NODE_PORTAL, nodePath->getPathObject()); // Entry point - travelPath.addPoint(*node->getPosition(), NODE_PORTAL, nodePath->getPathObject()); // Exit point + travelPath.addPoint(*prevNode->getPosition(), NODE_PORTAL, nodePath->getPathObject()); // Entry point + travelPath.addPoint(*node->getPosition(), NODE_PORTAL, nodePath->getPathObject()); // Exit point } - else if (nodePath->getPathType() == TravelNodePathType::transport) // Move onto transport + else if (nodePath->getPathType() == TravelNodePathType::transport) // Move onto transport { - travelPath.addPoint(*prevNode->getPosition(), NODE_TRANSPORT, nodePath->getPathObject()); // Departure point - travelPath.addPoint(*node->getPosition(), NODE_TRANSPORT, nodePath->getPathObject()); // Arrival point + travelPath.addPoint(*prevNode->getPosition(), NODE_TRANSPORT, + nodePath->getPathObject()); // Departure point + travelPath.addPoint(*node->getPosition(), NODE_TRANSPORT, nodePath->getPathObject()); // Arrival point } - else if (nodePath->getPathType() == TravelNodePathType::flightPath) // Use the flightpath + else if (nodePath->getPathType() == TravelNodePathType::flightPath) // Use the flightpath { - travelPath.addPoint(*prevNode->getPosition(), NODE_FLIGHTPATH, nodePath->getPathObject()); // Departure point - travelPath.addPoint(*node->getPosition(), NODE_FLIGHTPATH, nodePath->getPathObject()); // Arrival point + travelPath.addPoint(*prevNode->getPosition(), NODE_FLIGHTPATH, + nodePath->getPathObject()); // Departure point + travelPath.addPoint(*node->getPosition(), NODE_FLIGHTPATH, nodePath->getPathObject()); // Arrival point } else if (nodePath->getPathType() == TravelNodePathType::teleportSpell) { @@ -970,13 +999,18 @@ TravelPath TravelNodeRoute::buildPath(std::vector pathToStart, st { std::vector path = nodePath->getPath(); - if (path.size() > 1 && node != nodes.back()) // Remove the last point since that will also be the start of the next path. + if (path.size() > 1 && + node != nodes.back()) // Remove the last point since that will also be the start of the next path. path.pop_back(); - if (path.size() > 1 && prevNode->isPortal() && nodePath->getPathType() != TravelNodePathType::portal) // Do not move to the area trigger if we don't plan to take the portal. + if (path.size() > 1 && prevNode->isPortal() && + nodePath->getPathType() != TravelNodePathType::portal) // Do not move to the area trigger if we + // don't plan to take the portal. path.erase(path.begin()); - if (path.size() > 1 && prevNode->isTransport() && nodePath->getPathType() != TravelNodePathType::transport) // Do not move to the transport if we aren't going to take it. + if (path.size() > 1 && prevNode->isTransport() && + nodePath->getPathType() != + TravelNodePathType::transport) // Do not move to the transport if we aren't going to take it. path.erase(path.begin()); travelPath.addPath(path, NODE_PATH); @@ -996,7 +1030,9 @@ std::ostringstream const TravelNodeRoute::print() std::ostringstream out; out << sPlayerbotAIConfig->GetTimestampStr(); - out << "+00" << ",0," << "\"LINESTRING("; + out << "+00" + << ",0," + << "\"LINESTRING("; for (auto& node : nodes) { @@ -1014,14 +1050,14 @@ TravelNodeMap::TravelNodeMap(TravelNodeMap* baseMap) baseMap->m_nMapMtx.lock_shared(); - for (auto & node : baseMap->getNodes()) + for (auto& node : baseMap->getNodes()) { newNode = new TravelNode(node); m_nodes.push_back(newNode); } - for (auto & node : baseMap->getNodes()) + for (auto& node : baseMap->getNodes()) { newNode = getNode(node); @@ -1036,13 +1072,15 @@ TravelNodeMap::TravelNodeMap(TravelNodeMap* baseMap) baseMap->m_nMapMtx.unlock_shared(); } -TravelNode* TravelNodeMap::addNode(WorldPosition pos, std::string const preferedName, bool isImportant, bool checkDuplicate, [[maybe_unused]] bool transport, [[maybe_unused]] uint32 transportId) +TravelNode* TravelNodeMap::addNode(WorldPosition pos, std::string const preferedName, bool isImportant, + bool checkDuplicate, [[maybe_unused]] bool transport, + [[maybe_unused]] uint32 transportId) { TravelNode* newNode; if (checkDuplicate) { - newNode = getNode(pos, nullptr , 5.0f); + newNode = getNode(pos, nullptr, 5.0f); if (newNode) return newNode; } @@ -1115,16 +1153,19 @@ std::vector TravelNodeMap::getNodes(WorldPosition pos, float range) for (auto& node : m_nodes) { if (node->getMapId() == pos.getMapId()) - if(range == -1 || node->getDistance(pos) <= range) + if (range == -1 || node->getDistance(pos) <= range) retVec.push_back(node); } - std::sort(retVec.begin(), retVec.end(), [pos](TravelNode* i, TravelNode* j) { return i->getPosition()->distance(pos) < j->getPosition()->distance(pos); }); + std::sort(retVec.begin(), retVec.end(), + [pos](TravelNode* i, TravelNode* j) + { return i->getPosition()->distance(pos) < j->getPosition()->distance(pos); }); return std::move(retVec); } -TravelNode* TravelNodeMap::getNode(WorldPosition pos, [[maybe_unused]] std::vector& ppath, Unit* bot, float range) +TravelNode* TravelNodeMap::getNode(WorldPosition pos, [[maybe_unused]] std::vector& ppath, Unit* bot, + float range) { float x = pos.getX(); float y = pos.getY(); @@ -1143,7 +1184,7 @@ TravelNode* TravelNodeMap::getNode(WorldPosition pos, [[maybe_unused]] std::vect c++; - if (c > 5) //Max 5 attempts + if (c > 5) // Max 5 attempts break; } @@ -1157,7 +1198,7 @@ TravelNodeRoute TravelNodeMap::getRoute(TravelNode* start, TravelNode* goal, Pla if (start == goal) return TravelNodeRoute(); - //Basic A* algoritm + // Basic A* algoritm std::unordered_map m_stubs; TravelNodeStub* startStub = &m_stubs.insert(std::make_pair(start, TravelNodeStub(start))).first->second; @@ -1207,10 +1248,11 @@ TravelNodeRoute TravelNodeMap::getRoute(TravelNode* start, TravelNode* goal, Pla childNode->m_g = 10 * MINUTE; childNode->m_h = childNode->dataNode->fDist(goal) / botSpeed; childNode->m_f = childNode->m_g + childNode->m_h; - //childNode->parent = startStub; + // childNode->parent = startStub; open.push_back(childNode); - std::push_heap(open.begin(), open.end(), [](TravelNodeStub* i, TravelNodeStub* j) {return i->m_f < j->m_f; }); + std::push_heap(open.begin(), open.end(), + [](TravelNodeStub* i, TravelNodeStub* j) { return i->m_f < j->m_f; }); childNode->open = true; } } @@ -1219,26 +1261,27 @@ TravelNodeRoute TravelNodeMap::getRoute(TravelNode* start, TravelNode* goal, Pla if (open.size() == 0 && !start->hasRouteTo(goal)) return TravelNodeRoute(); - std::make_heap(open.begin(), open.end(), [](TravelNodeStub* i, TravelNodeStub* j) {return i->m_f < j->m_f; }); + std::make_heap(open.begin(), open.end(), [](TravelNodeStub* i, TravelNodeStub* j) { return i->m_f < j->m_f; }); open.push_back(startStub); - std::push_heap(open.begin(), open.end(), [](TravelNodeStub* i, TravelNodeStub* j) {return i->m_f < j->m_f; }); + std::push_heap(open.begin(), open.end(), [](TravelNodeStub* i, TravelNodeStub* j) { return i->m_f < j->m_f; }); startStub->open = true; while (!open.empty()) { - std::sort(open.begin(), open.end(), [](TravelNodeStub* i, TravelNodeStub* j) {return i->m_f < j->m_f; }); + std::sort(open.begin(), open.end(), [](TravelNodeStub* i, TravelNodeStub* j) { return i->m_f < j->m_f; }); - currentNode = open.front(); // pop n node from open for which f is minimal + currentNode = open.front(); // pop n node from open for which f is minimal - std::pop_heap(open.begin(), open.end(), [](TravelNodeStub* i, TravelNodeStub* j) {return i->m_f < j->m_f; }); + std::pop_heap(open.begin(), open.end(), [](TravelNodeStub* i, TravelNodeStub* j) { return i->m_f < j->m_f; }); open.pop_back(); currentNode->open = false; currentNode->close = true; closed.push_back(currentNode); - if (currentNode->dataNode == goal || (currentNode->dataNode->getMapId() != start->getMapId() && currentNode->dataNode->isWalking())) + if (currentNode->dataNode == goal || + (currentNode->dataNode->getMapId() != start->getMapId() && currentNode->dataNode->isWalking())) { TravelNodeStub* parent = currentNode->parent; @@ -1256,7 +1299,7 @@ TravelNodeRoute TravelNodeMap::getRoute(TravelNode* start, TravelNode* goal, Pla return TravelNodeRoute(path); } - for (const auto& link : *currentNode->dataNode->getLinks()) // for each successor n' of n + for (const auto& link : *currentNode->dataNode->getLinks()) // for each successor n' of n { TravelNode* linkNode = link.first; float linkCost = link.second->getCost(bot, currentNode->currentGold); @@ -1265,12 +1308,13 @@ TravelNodeRoute TravelNodeMap::getRoute(TravelNode* start, TravelNode* goal, Pla continue; childNode = &m_stubs.insert(std::make_pair(linkNode, TravelNodeStub(linkNode))).first->second; - g = currentNode->m_g + linkCost; // stance from start + distance between the two nodes - if ((childNode->open || childNode->close) && childNode->m_g <= g) // n' is already in opend or closed with a lower cost g(n') - continue; // consider next successor + g = currentNode->m_g + linkCost; // stance from start + distance between the two nodes + if ((childNode->open || childNode->close) && + childNode->m_g <= g) // n' is already in opend or closed with a lower cost g(n') + continue; // consider next successor h = childNode->dataNode->fDist(goal) / botSpeed; - f = g + h; // compute f(n') + f = g + h; // compute f(n') childNode->m_f = f; childNode->m_g = g; childNode->m_h = h; @@ -1285,7 +1329,8 @@ TravelNodeRoute TravelNodeMap::getRoute(TravelNode* start, TravelNode* goal, Pla if (!childNode->open) { open.push_back(childNode); - std::push_heap(open.begin(), open.end(), [](TravelNodeStub* i, TravelNodeStub* j) {return i->m_f < j->m_f; }); + std::push_heap(open.begin(), open.end(), + [](TravelNodeStub* i, TravelNodeStub* j) { return i->m_f < j->m_f; }); childNode->open = true; } } @@ -1294,7 +1339,8 @@ TravelNodeRoute TravelNodeMap::getRoute(TravelNode* start, TravelNode* goal, Pla return TravelNodeRoute(); } -TravelNodeRoute TravelNodeMap::getRoute(WorldPosition startPos, WorldPosition endPos, std::vector& startPath, Player* bot) +TravelNodeRoute TravelNodeMap::getRoute(WorldPosition startPos, WorldPosition endPos, + std::vector& startPath, Player* bot) { if (m_nodes.empty()) return TravelNodeRoute(); @@ -1302,18 +1348,14 @@ TravelNodeRoute TravelNodeMap::getRoute(WorldPosition startPos, WorldPosition en std::vector newStartPath; std::vector startNodes = m_nodes, endNodes = m_nodes; - //Partial sort to get the closest 5 nodes at the begin of the array. - std::partial_sort(startNodes.begin(), startNodes.begin() + 5, startNodes.end(), [startPos](TravelNode* i, TravelNode* j) - { - return i->fDist(startPos) < j->fDist(startPos); - }); + // Partial sort to get the closest 5 nodes at the begin of the array. + std::partial_sort(startNodes.begin(), startNodes.begin() + 5, startNodes.end(), + [startPos](TravelNode* i, TravelNode* j) { return i->fDist(startPos) < j->fDist(startPos); }); - std::partial_sort(endNodes.begin(), endNodes.begin() + 5, endNodes.end(), [endPos](TravelNode* i, TravelNode* j) - { - return i->fDist(endPos) < j->fDist(endPos); - }); + std::partial_sort(endNodes.begin(), endNodes.begin() + 5, endNodes.end(), + [endPos](TravelNode* i, TravelNode* j) { return i->fDist(endPos) < j->fDist(endPos); }); - //Cycle over the combinations of these 5 nodes. + // Cycle over the combinations of these 5 nodes. uint32 startI = 0, endI = 0; while (startI < 5 && endI < 5) { @@ -1329,10 +1371,11 @@ TravelNodeRoute TravelNodeMap::getRoute(WorldPosition startPos, WorldPosition en if (!route.isEmpty()) { - //Check if the bot can actually walk to this start position. + // Check if the bot can actually walk to this start position. newStartPath = startPath; if (startNodePosition.cropPathTo(newStartPath, maxStartDistance) || - startNode->getPosition()->isPathTo(newStartPath = startPos.getPathTo(startNodePosition, nullptr), maxStartDistance)) + startNode->getPosition()->isPathTo(newStartPath = startPos.getPathTo(startNodePosition, nullptr), + maxStartDistance)) { startPath = newStartPath; return route; @@ -1341,10 +1384,10 @@ TravelNodeRoute TravelNodeMap::getRoute(WorldPosition startPos, WorldPosition en startI++; } - //Prefer a differnt end-node. + // Prefer a differnt end-node. endI++; - //Cycle to a different start-node if needed. + // Cycle to a different start-node if needed. if (endI > startI + 1) { startI++; @@ -1384,21 +1427,21 @@ TravelPath TravelNodeMap::getFullPath(WorldPosition startPos, WorldPosition endP PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); std::vector beginPath, endPath; - beginPath = endPos.getPathFromPath({ startPos }, nullptr, 40); + beginPath = endPos.getPathFromPath({startPos}, nullptr, 40); if (endPos.isPathTo(beginPath)) return TravelPath(beginPath); //[[Node pathfinding system]] - //We try to find nodes near the bot and near the end position that have a route between them. - //Then bot has to move towards/along the route. + // We try to find nodes near the bot and near the end position that have a route between them. + // Then bot has to move towards/along the route. sTravelNodeMap->m_nMapMtx.lock_shared(); - //Find the route of nodes starting at a node closest to the start position and ending at a node closest to the endposition. - //Also returns longPath: The path from the start position to the first node in the route. + // Find the route of nodes starting at a node closest to the start position and ending at a node closest to the + // endposition. Also returns longPath: The path from the start position to the first node in the route. TravelNodeRoute route = sTravelNodeMap->getRoute(startPos, endPos, beginPath, bot); - if(route.isEmpty()) + if (route.isEmpty()) return movePath; if (sPlayerbotAIConfig->hasLog("bot_pathfinding.csv")) @@ -1432,7 +1475,7 @@ bool TravelNodeMap::cropUselessNode(TravelNode* startNode) if (!startNode->isLinked() || startNode->isImportant()) return false; - std::vector ignore = { startNode }; + std::vector ignore = {startNode}; for (auto& node : getNodes(*startNode->getPosition(), 5000.f)) { @@ -1455,7 +1498,7 @@ TravelNode* TravelNodeMap::addZoneLinkNode(TravelNode* startNode) TravelNode* endNode = path.first; std::string zoneName = startNode->getPosition()->getAreaName(true, true); - for (auto & pos : path.second.getPath()) + for (auto& pos : path.second.getPath()) { std::string const newZoneName = pos.getAreaName(true, true); if (zoneName != newZoneName) @@ -1468,7 +1511,6 @@ TravelNode* TravelNodeMap::addZoneLinkNode(TravelNode* startNode) zoneName = newZoneName; } - } } @@ -1492,11 +1534,11 @@ TravelNode* TravelNodeMap::addRandomExtNode(TravelNode* startNode) if (path.empty()) continue; - //Prefer to skip complete links + // Prefer to skip complete links if (endNode->hasLinkTo(startNode) && startNode->hasLinkTo(endNode) && !urand(0, 20)) continue; - //Prefer to skip no links + // Prefer to skip no links if (!startNode->hasLinkTo(endNode) && !urand(0, 20)) continue; @@ -1518,7 +1560,6 @@ void TravelNodeMap::manageNodes(Unit* bot, bool mapFull) if (m_nMapMtx.try_lock()) { - TravelNode* startNode; TravelNode* newNode; @@ -1527,7 +1568,7 @@ void TravelNodeMap::manageNodes(Unit* bot, bool mapFull) cropUselessNode(startNode); } - //Pick random Node + // Pick random Node for (uint32 i = 0; i < (mapFull ? (uint32)20 : (uint32)1); i++) { std::vector rnodes = getNodes(WorldPosition(bot)); @@ -1552,7 +1593,6 @@ void TravelNodeMap::manageNodes(Unit* bot, bool mapFull) rePrint = nodeDone || rePrint || newNode; } - } if (rePrint && (mapFull || !urand(0, 20))) @@ -1575,13 +1615,15 @@ void TravelNodeMap::generateNpcNodes() for (auto& creatureData : WorldPosition().getCreaturesNear()) { - WorldPosition guidP(creatureData->mapid, creatureData->posX, creatureData->posY, creatureData->posZ, creatureData->orientation); + WorldPosition guidP(creatureData->mapid, creatureData->posX, creatureData->posY, creatureData->posZ, + creatureData->orientation); CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(creatureData->id1); if (!cInfo) continue; - uint32 flagMask = UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_FLIGHTMASTER | UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE; + uint32 flagMask = UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_FLIGHTMASTER | UNIT_NPC_FLAG_SPIRITHEALER | + UNIT_NPC_FLAG_SPIRITGUIDE; if (cInfo->npcflag & flagMask) { @@ -1650,7 +1692,7 @@ void TravelNodeMap::generateStartNodes() if (!info) continue; - WorldPosition pos(info->mapId, info->positionX, info->positionY, info->positionZ, info->orientation); + WorldPosition pos(info->mapId, info->positionX, info->positionY, info->positionZ, info->orientation); std::string const nodeName = startNames[i] + " start"; @@ -1663,7 +1705,7 @@ void TravelNodeMap::generateStartNodes() void TravelNodeMap::generateAreaTriggerNodes() { - //Entrance nodes + // Entrance nodes for (auto const& itr : sObjectMgr->GetAllAreaTriggerTeleports()) { @@ -1674,7 +1716,8 @@ void TravelNodeMap::generateAreaTriggerNodes() continue; WorldPosition inPos = WorldPosition(at->map, at->x, at->y, at->z, at->orientation); - WorldPosition outPos = WorldPosition(atEntry.target_mapId, atEntry.target_X, atEntry.target_Y, atEntry.target_Z, atEntry.target_Orientation); + WorldPosition outPos = WorldPosition(atEntry.target_mapId, atEntry.target_X, atEntry.target_Y, atEntry.target_Z, + atEntry.target_Orientation); std::string nodeName; @@ -1688,7 +1731,7 @@ void TravelNodeMap::generateAreaTriggerNodes() sTravelNodeMap->addNode(inPos, nodeName, true, true); } - //Exit nodes + // Exit nodes for (auto const& itr : sObjectMgr->GetAllAreaTriggerTeleports()) { @@ -1698,8 +1741,9 @@ void TravelNodeMap::generateAreaTriggerNodes() if (!at) continue; - WorldPosition inPos = WorldPosition(at->map, at->x, at->y, at->z, at->orientation); - WorldPosition outPos = WorldPosition(atEntry.target_mapId, atEntry.target_X, atEntry.target_Y, atEntry.target_Z, atEntry.target_Orientation); + WorldPosition inPos = WorldPosition(at->map, at->x, at->y, at->z, at->orientation); + WorldPosition outPos = WorldPosition(atEntry.target_mapId, atEntry.target_X, atEntry.target_Y, atEntry.target_Z, + atEntry.target_Orientation); std::string nodeName; @@ -1710,17 +1754,17 @@ void TravelNodeMap::generateAreaTriggerNodes() else nodeName = inPos.getAreaName(false) + " portal"; - TravelNode* entryNode = sTravelNodeMap->getNode(outPos, nullptr, 20.0f); //Entry side, portal exit. + TravelNode* entryNode = sTravelNodeMap->getNode(outPos, nullptr, 20.0f); // Entry side, portal exit. - TravelNode* outNode = sTravelNodeMap->addNode(outPos, nodeName, true, true); //Exit size, portal exit. + TravelNode* outNode = sTravelNodeMap->addNode(outPos, nodeName, true, true); // Exit size, portal exit. - TravelNode* inNode = sTravelNodeMap->getNode(inPos, nullptr, 5.0f); //Entry side, portal center. + TravelNode* inNode = sTravelNodeMap->getNode(inPos, nullptr, 5.0f); // Entry side, portal center. - //Portal link from area trigger to area trigger destination. + // Portal link from area trigger to area trigger destination. if (outNode && inNode) { TravelNodePath travelPath(0.1f, 3.0f, (uint8)TravelNodePathType::portal, itr.first, true); - travelPath.setPath({ *inNode->getPosition(), *outNode->getPosition() }); + travelPath.setPath({*inNode->getPosition(), *outNode->getPosition()}); inNode->setPathTo(outNode, travelPath); } } @@ -1745,7 +1789,7 @@ void TravelNodeMap::generateTransportNodes() std::vector ppath; TravelNode* prevNode = nullptr; - //Elevators/Trams + // Elevators/Trams if (path.empty()) { if (animation) @@ -1756,7 +1800,8 @@ void TravelNodeMap::generateTransportNodes() for (auto& transport : WorldPosition().getGameObjectsNear(0, itr.first)) { prevNode = nullptr; - WorldPosition basePos(transport->mapid, transport->posX, transport->posY, transport->posZ, transport->orientation); + WorldPosition basePos(transport->mapid, transport->posX, transport->posY, transport->posZ, + transport->orientation); WorldPosition lPos = WorldPosition(); for (auto& p : aPath) @@ -1764,7 +1809,9 @@ void TravelNodeMap::generateTransportNodes() float dx = -1 * p.second->X; float dy = -1 * p.second->Y; - WorldPosition pos = WorldPosition(basePos.getMapId(), basePos.getX() + dx, basePos.getY() + dy, basePos.getZ() + p.second->Z, basePos.getO()); + WorldPosition pos = + WorldPosition(basePos.getMapId(), basePos.getX() + dx, basePos.getY() + dy, + basePos.getZ() + p.second->Z, basePos.getO()); if (prevNode) { @@ -1773,7 +1820,8 @@ void TravelNodeMap::generateTransportNodes() if (pos.distance(&lPos) == 0) { - TravelNode* node = sTravelNodeMap->addNode(pos, data->name, true, true, true, itr.first); + TravelNode* node = + sTravelNodeMap->addNode(pos, data->name, true, true, true, itr.first); if (!prevNode) { @@ -1784,7 +1832,8 @@ void TravelNodeMap::generateTransportNodes() { float totalTime = (p.second->TimeSeg - timeStart) / 1000.0f; - TravelNodePath travelPath(0.1f, totalTime, (uint8)TravelNodePathType::transport, itr.first, true); + TravelNodePath travelPath(0.1f, totalTime, (uint8)TravelNodePathType::transport, + itr.first, true); node->setPathTo(prevNode, travelPath); ppath.clear(); ppath.push_back(pos); @@ -1803,13 +1852,16 @@ void TravelNodeMap::generateTransportNodes() { float dx = -1 * p.second->X; float dy = -1 * p.second->Y; - WorldPosition pos = WorldPosition(basePos.getMapId(), basePos.getX() + dx, basePos.getY() + dy, basePos.getZ() + p.second->Z, basePos.getO()); + WorldPosition pos = + WorldPosition(basePos.getMapId(), basePos.getX() + dx, basePos.getY() + dy, + basePos.getZ() + p.second->Z, basePos.getO()); ppath.push_back(pos); if (pos.distance(&lPos) == 0) { - TravelNode* node = sTravelNodeMap->addNode(pos, data->name, true, true, true, itr.first); + TravelNode* node = + sTravelNodeMap->addNode(pos, data->name, true, true, true, itr.first); if (node != prevNode) { if (p.second->TimeSeg < timeStart) @@ -1817,7 +1869,8 @@ void TravelNodeMap::generateTransportNodes() float totalTime = (p.second->TimeSeg - timeStart) / 1000.0f; - TravelNodePath travelPath(0.1f, totalTime, (uint8)TravelNodePathType::transport, itr.first, true); + TravelNodePath travelPath(0.1f, totalTime, (uint8)TravelNodePathType::transport, + itr.first, true); travelPath.setPath(ppath); node->setPathTo(prevNode, travelPath); ppath.clear(); @@ -1834,17 +1887,17 @@ void TravelNodeMap::generateTransportNodes() } } } - else //Boats/Zepelins + else // Boats/Zepelins { - //Loop over the path and connect stop locations. + // Loop over the path and connect stop locations. for (auto& p : path) { WorldPosition pos = WorldPosition(p->mapid, p->x, p->y, p->z, 0); - //if (data->displayId == 3015) - // pos.setZ(pos.getZ() + 6.0f); - //else if(data->displayId == 3031) - // pos.setZ(pos.getZ() - 17.0f); + // if (data->displayId == 3015) + // pos.setZ(pos.getZ() + 6.0f); + // else if(data->displayId == 3031) + // pos.setZ(pos.getZ() - 17.0f); if (prevNode) { @@ -1874,15 +1927,15 @@ void TravelNodeMap::generateTransportNodes() if (prevNode) { - //Continue from start until first stop and connect to end. + // Continue from start until first stop and connect to end. for (auto& p : path) { WorldPosition pos = WorldPosition(p->mapid, p->x, p->y, p->z, 0); - //if (data->displayId == 3015) - // pos.setZ(pos.getZ() + 6.0f); - //else if (data->displayId == 3031) - // pos.setZ(pos.getZ() - 17.0f); + // if (data->displayId == 3015) + // pos.setZ(pos.getZ() + 6.0f); + // else if (data->displayId == 3031) + // pos.setZ(pos.getZ() - 17.0f); ppath.push_back(pos); @@ -1892,7 +1945,8 @@ void TravelNodeMap::generateTransportNodes() if (node != prevNode) { - TravelNodePath travelPath(0.1f, 0.0, (uint8)TravelNodePathType::transport, itr.first, true); + TravelNodePath travelPath(0.1f, 0.0, (uint8)TravelNodePathType::transport, itr.first, + true); travelPath.setPathAndCost(ppath, moveSpeed); node->setPathTo(prevNode, travelPath); @@ -1908,7 +1962,7 @@ void TravelNodeMap::generateTransportNodes() void TravelNodeMap::generateZoneMeanNodes() { - //Zone means + // Zone means for (auto& loc : sTravelMgr->exploreLocs) { std::vector points; @@ -1920,7 +1974,7 @@ void TravelNodeMap::generateZoneMeanNodes() if (points.empty()) points = loc.second->getPoints(true); - WorldPosition pos = WorldPosition(points, WP_MEAN_CENTROID); + WorldPosition pos = WorldPosition(points, WP_MEAN_CENTROID); TravelNode* node = sTravelNodeMap->addNode(pos, pos.getAreaName(), true, true, false); } @@ -1942,7 +1996,7 @@ void TravelNodeMap::generateNodes() void TravelNodeMap::generateWalkPaths() { - //Pathfinder + // Pathfinder std::vector ppath; std::map nodeMaps; @@ -1952,10 +2006,9 @@ void TravelNodeMap::generateWalkPaths() nodeMaps[startNode->getMapId()] = true; } - for (auto& map : nodeMaps) { - for (auto& startNode : sTravelNodeMap->getNodes(WorldPosition(map.first,1,1))) + for (auto& startNode : sTravelNodeMap->getNodes(WorldPosition(map.first, 1, 1))) { if (startNode->isLinked()) continue; @@ -2057,7 +2110,7 @@ void TravelNodeMap::removeLowNodes() void TravelNodeMap::removeUselessPaths() { - //Clean up node links + // Clean up node links for (auto& startNode : sTravelNodeMap->getNodes()) { for (auto& path : *startNode->getPaths()) @@ -2068,7 +2121,7 @@ void TravelNodeMap::removeUselessPaths() while (true) { uint32 rem = 0; - //Clean up node links + // Clean up node links for (auto& startNode : sTravelNodeMap->getNodes()) { if (startNode->cropUselessLinks()) @@ -2196,22 +2249,26 @@ void TravelNodeMap::printNodeStore() std::string name = node->getName(); name.erase(remove(name.begin(), name.end(), '\"'), name.end()); -// struct addNode {uint32 node; WorldPosition point; std::string const name; bool isPortal; bool isTransport; uint32 transportId; }; + // struct addNode {uint32 node; WorldPosition point; std::string const name; bool isPortal; bool + // isTransport; uint32 transportId; }; out << std::fixed << std::setprecision(2) << " addNodes.push_back(addNode{" << i << ","; - out << "WorldPosition(" << node->getMapId() << ", " << node->getX() << "f, " << node->getY() << "f, " << node->getZ() << "f, " << node->getO() << "f),"; + out << "WorldPosition(" << node->getMapId() << ", " << node->getX() << "f, " << node->getY() << "f, " + << node->getZ() << "f, " << node->getO() << "f),"; out << "\"" << name << "\""; if (node->isTransport()) out << "," << (node->isTransport() ? "true" : "false") << "," << node->getTransportId(); out << "});"; -/* - out << std::fixed << std::setprecision(2) << " nodes[" << i << "] = sTravelNodeMap->addNode(&WorldPosition(" << node->getMapId() << "," << node->getX() << "f," << node->getY() << "f," << node->getZ() << "f,"<< node->getO() <<"f), \"" - << name << "\", " << (node->isImportant() ? "true" : "false") << ", true"; - if (node->isTransport()) - out << "," << (node->isTransport() ? "true" : "false") << "," << node->getTransportId(); + /* + out << std::fixed << std::setprecision(2) << " nodes[" << i << "] = + sTravelNodeMap->addNode(&WorldPosition(" << node->getMapId() << "," << node->getX() << "f," << node->getY() + << "f," << node->getZ() << "f,"<< node->getO() <<"f), \"" + << name << "\", " << (node->isImportant() ? "true" : "false") << ", true"; + if (node->isTransport()) + out << "," << (node->isTransport() ? "true" : "false") << "," << node->getTransportId(); - out << ");"; - */ + out << ");"; + */ sPlayerbotAIConfig->log(nodeStore, out.str().c_str()); saveNodes.insert(std::make_pair(node, i)); @@ -2225,13 +2282,16 @@ void TravelNodeMap::printNodeStore() { std::ostringstream out; - // struct linkNode { uint32 node1; uint32 node2; float distance; float extraCost; bool isPortal; bool isTransport; uint32 maxLevelMob; uint32 maxLevelAlliance; uint32 maxLevelHorde; float swimDistance; }; + // struct linkNode { uint32 node1; uint32 node2; float distance; float extraCost; bool isPortal; bool + // isTransport; uint32 maxLevelMob; uint32 maxLevelAlliance; uint32 maxLevelHorde; float + // swimDistance; }; - out << std::fixed << std::setprecision(2) << " linkNodes3.push_back(linkNode3{" << i << "," << saveNodes.find(Link.first)->second << ","; + out << std::fixed << std::setprecision(2) << " linkNodes3.push_back(linkNode3{" << i << "," + << saveNodes.find(Link.first)->second << ","; out << Link.second->print() << "});"; - //out << std::fixed << std::setprecision(1) << " nodes[" << i << "]->setPathTo(nodes[" << saveNodes.find(Link.first)->second << "],TravelNodePath("; - //out << Link.second->print() << "), true);"; + // out << std::fixed << std::setprecision(1) << " nodes[" << i << "]->setPathTo(nodes[" << + // saveNodes.find(Link.first)->second << "],TravelNodePath("; out << Link.second->print() << "), true);"; sPlayerbotAIConfig->log(nodeStore, out.str().c_str()); } } @@ -2291,7 +2351,8 @@ void TravelNodeMap::saveNodeStore() { TravelNodePath* path = link.second; - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_INS_TRAVELNODE_LINK); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_INS_TRAVELNODE_LINK); stmt->SetData(0, i); stmt->SetData(1, saveNodes.find(link.first)->second); stmt->SetData(2, static_cast(path->getPathType())); @@ -2313,7 +2374,8 @@ void TravelNodeMap::saveNodeStore() { WorldPosition point = ppath[j]; - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_INS_TRAVELNODE_PATH); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_INS_TRAVELNODE_PATH); stmt->SetData(0, i); stmt->SetData(1, saveNodes.find(link.first)->second); stmt->SetData(2, j); @@ -2341,13 +2403,16 @@ void TravelNodeMap::loadNodeStore() std::unordered_map saveNodes; { - if (PreparedQueryResult result = PlayerbotsDatabase.Query(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_TRAVELNODE))) + if (PreparedQueryResult result = + PlayerbotsDatabase.Query(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_TRAVELNODE))) { do { Field* fields = result->Fetch(); - TravelNode* node = addNode(WorldPosition(fields[2].Get(), fields[3].Get(), fields[4].Get(), fields[5].Get()), fields[1].Get(), true); + TravelNode* node = addNode(WorldPosition(fields[2].Get(), fields[3].Get(), + fields[4].Get(), fields[5].Get()), + fields[1].Get(), true); if (fields[6].Get()) node->setLinked(true); @@ -2368,7 +2433,8 @@ void TravelNodeMap::loadNodeStore() } { - if (PreparedQueryResult result = PlayerbotsDatabase.Query(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_TRAVELNODE_LINK))) + if (PreparedQueryResult result = + PlayerbotsDatabase.Query(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_TRAVELNODE_LINK))) { do { @@ -2380,7 +2446,13 @@ void TravelNodeMap::loadNodeStore() if (!startNode || !endNode) continue; - startNode->setPathTo(endNode, TravelNodePath(fields[4].Get(), fields[6].Get(), fields[2].Get(), fields[3].Get(), fields[7].Get(), { fields[8].Get(),fields[9].Get(),fields[10].Get() }, fields[5].Get()), true); + startNode->setPathTo( + endNode, + TravelNodePath(fields[4].Get(), fields[6].Get(), fields[2].Get(), + fields[3].Get(), fields[7].Get(), + {fields[8].Get(), fields[9].Get(), fields[10].Get()}, + fields[5].Get()), + true); if (!fields[7].Get()) hasToGen = true; @@ -2396,7 +2468,8 @@ void TravelNodeMap::loadNodeStore() } { - if (PreparedQueryResult result = PlayerbotsDatabase.Query(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_TRAVELNODE_PATH))) + if (PreparedQueryResult result = + PlayerbotsDatabase.Query(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_TRAVELNODE_PATH))) { do { @@ -2411,7 +2484,8 @@ void TravelNodeMap::loadNodeStore() TravelNodePath* path = startNode->getPathTo(endNode); std::vector ppath = path->getPath(); - ppath.push_back(WorldPosition(fields[3].Get(), fields[4].Get(), fields[5].Get(), fields[6].Get())); + ppath.push_back(WorldPosition(fields[3].Get(), fields[4].Get(), fields[5].Get(), + fields[6].Get())); path->setPath(ppath); @@ -2473,15 +2547,16 @@ void TravelNodeMap::calcMapOffset() } } - WorldPosition curPos = WorldPosition(0, -13000, -13000, 0,0); - WorldPosition endPos = WorldPosition(0, 3000, -13000, 0,0); + WorldPosition curPos = WorldPosition(0, -13000, -13000, 0, 0); + WorldPosition endPos = WorldPosition(0, 3000, -13000, 0, 0); uint32 i = 0; float maxY = 0; //+X -> -Y for (auto& mapId : mapIds) { - mapOffsets.push_back(std::make_pair(mapId, WorldPosition(mapId, curPos.getX() - min[i].getX(), curPos.getY() - max[i].getY(),0, 0))); + mapOffsets.push_back(std::make_pair( + mapId, WorldPosition(mapId, curPos.getX() - min[i].getX(), curPos.getY() - max[i].getY(), 0, 0))); maxY = std::max(maxY, (max[i].getY() - min[i].getY() + 500)); curPos.setX(curPos.getX() + (max[i].getX() - min[i].getX() + 500)); diff --git a/src/TravelNode.h b/src/TravelNode.h index 46b1d801..abc70eb0 100644 --- a/src/TravelNode.h +++ b/src/TravelNode.h @@ -1,372 +1,375 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TRAVELNODE_H #define _PLAYERBOT_TRAVELNODE_H -#include "TravelMgr.h" #include -//THEORY +#include "TravelMgr.h" + +// THEORY // -// Pathfinding in (c)mangos is based on detour recast an opensource nashmesh creation and pathfinding codebase. -// This system is used for mob and npc pathfinding and in this codebase also for bots. -// Because mobs and npc movement is based on following a player or a set path the PathGenerator is limited to 296y. -// This means that when trying to find a path from A to B distances beyond 296y will be a best guess often moving in a straight path. -// Bots would get stuck moving from Northshire to Stormwind because there is no 296y path that doesn't go (initially) the wrong direction. +// Pathfinding in (c)mangos is based on detour recast an opensource nashmesh creation and pathfinding codebase. +// This system is used for mob and npc pathfinding and in this codebase also for bots. +// Because mobs and npc movement is based on following a player or a set path the PathGenerator is limited to 296y. +// This means that when trying to find a path from A to B distances beyond 296y will be a best guess often moving in a +// straight path. Bots would get stuck moving from Northshire to Stormwind because there is no 296y path that doesn't +// go (initially) the wrong direction. // -// To remedy this limitation without altering the PathGenerator limits too much this node system was introduced. +// To remedy this limitation without altering the PathGenerator limits too much this node system was introduced. // -// ---> [N1] ---> [N2] ---> [N3] ---> +// ---> [N1] ---> [N2] ---> [N3] ---> // -// Bot at wants to move to -// [N1],[N2],[N3] are predefined nodes for wich we know we can move from [N1] to [N2] and from [N2] to [N3] but not from [N1] to [N3] -// If we can move fom [S] to [N1] and from [N3] to [E] we have a complete route to travel. +// Bot at wants to move to +// [N1],[N2],[N3] are predefined nodes for wich we know we can move from [N1] to [N2] and from [N2] to [N3] but not +// from [N1] to [N3] If we can move fom [S] to [N1] and from [N3] to [E] we have a complete route to travel. // -// Termonology: -// Node: a location on a map for which we know bots are likely to want to travel to or need to travel past to reach other nodes. -// Link: the connection between two nodes. A link signifies that the bot can travel from one node to another. A link is one-directional. -// Path: the waypointpath returned by the standard PathGenerator to move from one node (or position) to another. A path can be imcomplete or empty which means there is no link. -// Route: the list of nodes that give the shortest route from a node to a distant node. Routes are calculated using a standard A* search based on links. +// Termonology: +// Node: a location on a map for which we know bots are likely to want to travel to or need to travel past to reach +// other nodes. Link: the connection between two nodes. A link signifies that the bot can travel from one node to +// another. A link is one-directional. Path: the waypointpath returned by the standard PathGenerator to move from one +// node (or position) to another. A path can be imcomplete or empty which means there is no link. Route: the list of +// nodes that give the shortest route from a node to a distant node. Routes are calculated using a standard A* search +// based on links. // -// On server start saved nodes and links are loaded. Paths and routes are calculated on the fly but saved for future use. -// Nodes can be added and removed realtime however because bots access the nodes from different threads this requires a locking mechanism. +// On server start saved nodes and links are loaded. Paths and routes are calculated on the fly but saved for future +// use. Nodes can be added and removed realtime however because bots access the nodes from different threads this +// requires a locking mechanism. // -// Initially the current nodes have been made: -// Flightmasters and Inns (Bots can use these to fast-travel so eventually they will be included in the route calculation) -// WorldBosses and Unique bosses in instances (These are a logical places bots might want to go in instances) -// Player start spawns (Obviously all lvl1 bots will spawn and move from here) -// Area triggers locations with teleport and their teleport destinations (These used to travel in or between maps) -// Transports including elevators (Again used to travel in and in maps) -// (sub)Zone means (These are the center most point for each sub-zone which is good for global coverage) +// Initially the current nodes have been made: +// Flightmasters and Inns (Bots can use these to fast-travel so eventually they will be included in the route +// calculation) WorldBosses and Unique bosses in instances (These are a logical places bots might want to go in +// instances) Player start spawns (Obviously all lvl1 bots will spawn and move from here) Area triggers locations with +// teleport and their teleport destinations (These used to travel in or between maps) Transports including elevators +// (Again used to travel in and in maps) (sub)Zone means (These are the center most point for each sub-zone which is +// good for global coverage) // -// To increase coverage/linking extra nodes can be automatically be created. -// Current implentation places nodes on paths (including complete) at sub-zone transitions or randomly. -// After calculating possible links the node is removed if it does not create local coverage. +// To increase coverage/linking extra nodes can be automatically be created. +// Current implentation places nodes on paths (including complete) at sub-zone transitions or randomly. +// After calculating possible links the node is removed if it does not create local coverage. // enum class TravelNodePathType : uint8 { - none = 0, - walk = 1, - portal = 2, - transport = 3, - flightPath = 4, + none = 0, + walk = 1, + portal = 2, + transport = 3, + flightPath = 4, teleportSpell = 5 }; -//A connection between two nodes. +// A connection between two nodes. class TravelNodePath { - public: - //Legacy Constructor for travelnodestore - //TravelNodePath(float distance1, float extraCost1, bool portal1 = false, uint32 portalId1 = 0, bool transport1 = false, bool calculated = false, uint8 maxLevelMob1 = 0, uint8 maxLevelAlliance1 = 0, uint8 maxLevelHorde1 = 0, float swimDistance1 = 0, bool flightPath1 = false); +public: + // Legacy Constructor for travelnodestore + // TravelNodePath(float distance1, float extraCost1, bool portal1 = false, uint32 portalId1 = 0, bool transport1 = + // false, bool calculated = false, uint8 maxLevelMob1 = 0, uint8 maxLevelAlliance1 = 0, uint8 maxLevelHorde1 = 0, + // float swimDistance1 = 0, bool flightPath1 = false); - //Constructor - TravelNodePath(float distance = 0.1f, float extraCost = 0, uint8 pathType = (uint8)TravelNodePathType::walk, uint32 pathObject = 0, bool calculated = false, - std::vector maxLevelCreature = { 0, 0, 0 }, float swimDistance = 0) - : extraCost(extraCost), calculated(calculated), distance(distance), maxLevelCreature(maxLevelCreature), swimDistance(swimDistance), pathType(TravelNodePathType(pathType)), pathObject(pathObject) // reorder args - whipowill - { - if (pathType != (uint8)TravelNodePathType::walk) - complete = true; - }; + // Constructor + TravelNodePath(float distance = 0.1f, float extraCost = 0, uint8 pathType = (uint8)TravelNodePathType::walk, + uint32 pathObject = 0, bool calculated = false, std::vector maxLevelCreature = {0, 0, 0}, + float swimDistance = 0) + : extraCost(extraCost), + calculated(calculated), + distance(distance), + maxLevelCreature(maxLevelCreature), + swimDistance(swimDistance), + pathType(TravelNodePathType(pathType)), + pathObject(pathObject) // reorder args - whipowill + { + if (pathType != (uint8)TravelNodePathType::walk) + complete = true; + }; - TravelNodePath(TravelNodePath* basePath) - { - complete = basePath->complete; - path = basePath->path; - extraCost = basePath->extraCost; - calculated = basePath->calculated; - distance = basePath->distance; - maxLevelCreature = basePath->maxLevelCreature; - swimDistance = basePath->swimDistance; - pathType = basePath->pathType; - pathObject = basePath->pathObject; - }; + TravelNodePath(TravelNodePath* basePath) + { + complete = basePath->complete; + path = basePath->path; + extraCost = basePath->extraCost; + calculated = basePath->calculated; + distance = basePath->distance; + maxLevelCreature = basePath->maxLevelCreature; + swimDistance = basePath->swimDistance; + pathType = basePath->pathType; + pathObject = basePath->pathObject; + }; - // Getters - bool getComplete() { return complete || pathType != TravelNodePathType::walk; } - std::vector getPath() { return path; } + // Getters + bool getComplete() { return complete || pathType != TravelNodePathType::walk; } + std::vector getPath() { return path; } - TravelNodePathType getPathType() { return pathType; } - uint32 getPathObject() { return pathObject; } + TravelNodePathType getPathType() { return pathType; } + uint32 getPathObject() { return pathObject; } - float getDistance() { return distance; } - float getSwimDistance() { return swimDistance; } - float getExtraCost(){ return extraCost; } - std::vector getMaxLevelCreature(){ return maxLevelCreature; } + float getDistance() { return distance; } + float getSwimDistance() { return swimDistance; } + float getExtraCost() { return extraCost; } + std::vector getMaxLevelCreature() { return maxLevelCreature; } - void setCalculated(bool calculated1 = true) { calculated = calculated1; } + void setCalculated(bool calculated1 = true) { calculated = calculated1; } - bool getCalculated() { return calculated; } + bool getCalculated() { return calculated; } - std::string const print(); + std::string const print(); - //Setters - void setComplete(bool complete1) - { - complete = complete1; - } + // Setters + void setComplete(bool complete1) { complete = complete1; } - void setPath(std::vector path1) - { - path = path1; - } + void setPath(std::vector path1) { path = path1; } - void setPathAndCost(std::vector path1, float speed) - { - setPath(path1); - calculateCost(true); - extraCost = distance / speed; - } + void setPathAndCost(std::vector path1, float speed) + { + setPath(path1); + calculateCost(true); + extraCost = distance / speed; + } - //void setPortal(bool portal1, uint32 portalId1 = 0) { portal = portal1; portalId = portalId1; } - //void setTransport(bool transport1) { transport = transport1; } + // void setPortal(bool portal1, uint32 portalId1 = 0) { portal = portal1; portalId = portalId1; } + // void setTransport(bool transport1) { transport = transport1; } - void setPathType(TravelNodePathType pathType1) - { - pathType = pathType1; - } + void setPathType(TravelNodePathType pathType1) { pathType = pathType1; } - void setPathObject(uint32 pathObject1) - { - pathObject = pathObject1; - } + void setPathObject(uint32 pathObject1) { pathObject = pathObject1; } - void calculateCost(bool distanceOnly = false); + void calculateCost(bool distanceOnly = false); - float getCost(Player* bot = nullptr, uint32 cGold = 0); - uint32 getPrice(); + float getCost(Player* bot = nullptr, uint32 cGold = 0); + uint32 getPrice(); - private: - //Does the path have all the points to get to the destination? - bool complete = false; +private: + // Does the path have all the points to get to the destination? + bool complete = false; - //List of WorldPositions to get to the destination. - std::vector path = {}; + // List of WorldPositions to get to the destination. + std::vector path = {}; - //The extra (loading/transport) time it takes to take this path. - float extraCost = 0; + // The extra (loading/transport) time it takes to take this path. + float extraCost = 0; - bool calculated = false; + bool calculated = false; - //Derived distance in yards - float distance = 0.1f; + // Derived distance in yards + float distance = 0.1f; - //Calculated mobs level along the way. - std::vector maxLevelCreature = { 0, 0, 0 }; //mobs, horde, alliance + // Calculated mobs level along the way. + std::vector maxLevelCreature = {0, 0, 0}; // mobs, horde, alliance - //Calculated swiming distances along the way. - float swimDistance = 0; + // Calculated swiming distances along the way. + float swimDistance = 0; - TravelNodePathType pathType = TravelNodePathType::walk; - uint32 pathObject = 0; + TravelNodePathType pathType = TravelNodePathType::walk; + uint32 pathObject = 0; - /* - //Is the path a portal/teleport to the destination? - bool portal = false; - //Area trigger Id - uint32 portalId = 0; + /* + //Is the path a portal/teleport to the destination? + bool portal = false; + //Area trigger Id + uint32 portalId = 0; - //Is the path transport based? - bool transport = false; + //Is the path transport based? + bool transport = false; - // Is the path a flightpath? - bool flightPath = false; - */ + // Is the path a flightpath? + bool flightPath = false; + */ }; -//A waypoint to travel from or to. -//Each node knows which other nodes can be reached without help. +// A waypoint to travel from or to. +// Each node knows which other nodes can be reached without help. class TravelNode { - public: - //Constructors - TravelNode() { }; +public: + // Constructors + TravelNode(){}; - TravelNode(WorldPosition point1, std::string const nodeName1 = "Travel Node", bool important1 = false) + TravelNode(WorldPosition point1, std::string const nodeName1 = "Travel Node", bool important1 = false) + { + nodeName = nodeName1; + point = point1; + important = important1; + } + + TravelNode(TravelNode* baseNode) + { + nodeName = baseNode->nodeName; + point = baseNode->point; + important = baseNode->important; + } + + // Setters + void setLinked(bool linked1) { linked = linked1; } + void setPoint(WorldPosition point1) { point = point1; } + + // Getters + std::string const getName() { return nodeName; }; + WorldPosition* getPosition() { return &point; }; + std::unordered_map* getPaths() { return &paths; } + std::unordered_map* getLinks() { return &links; } + bool isImportant() { return important; }; + bool isLinked() { return linked; } + + bool isTransport() + { + for (auto const& link : *getLinks()) + if (link.second->getPathType() == TravelNodePathType::transport) + return true; + + return false; + } + + uint32 getTransportId() + { + for (auto const& link : *getLinks()) + if (link.second->getPathType() == TravelNodePathType::transport) + return link.second->getPathObject(); + + return false; + } + + bool isPortal() + { + for (auto const& link : *getLinks()) + if (link.second->getPathType() == TravelNodePathType::portal) + return true; + + return false; + } + + bool isWalking() + { + for (auto link : *getLinks()) + if (link.second->getPathType() == TravelNodePathType::walk) + return true; + + return false; + } + + // WorldLocation shortcuts + uint32 getMapId() { return point.getMapId(); } + float getX() { return point.getX(); } + float getY() { return point.getY(); } + float getZ() { return point.getZ(); } + float getO() { return point.getO(); } + float getDistance(WorldPosition pos) { return point.distance(pos); } + float getDistance(TravelNode* node) { return point.distance(node->getPosition()); } + float fDist(TravelNode* node) { return point.fDist(node->getPosition()); } + float fDist(WorldPosition pos) { return point.fDist(pos); } + + TravelNodePath* setPathTo(TravelNode* node, TravelNodePath path = TravelNodePath(), bool isLink = true) + { + if (this != node) { - nodeName = nodeName1; - point = point1; - important = important1; + paths[node] = path; + if (isLink) + links[node] = &paths[node]; + + return &paths[node]; } - TravelNode(TravelNode* baseNode) + return nullptr; + } + + bool hasPathTo(TravelNode* node) { return paths.find(node) != paths.end(); } + TravelNodePath* getPathTo(TravelNode* node) { return &paths[node]; } + bool hasCompletePathTo(TravelNode* node) { return hasPathTo(node) && getPathTo(node)->getComplete(); } + TravelNodePath* buildPath(TravelNode* endNode, Unit* bot, bool postProcess = false); + + void setLinkTo(TravelNode* node, float distance = 0.1f) + { + if (this != node) { - nodeName = baseNode->nodeName; - point = baseNode->point; - important = baseNode->important; + if (!hasPathTo(node)) + setPathTo(node, TravelNodePath(distance)); + else + links[node] = &paths[node]; } + } - //Setters - void setLinked(bool linked1) { linked = linked1; } - void setPoint(WorldPosition point1) { point = point1; } + bool hasLinkTo(TravelNode* node) { return links.find(node) != links.end(); } + float linkCostTo(TravelNode* node) { return paths.find(node)->second.getDistance(); } + float linkDistanceTo(TravelNode* node) { return paths.find(node)->second.getDistance(); } + void removeLinkTo(TravelNode* node, bool removePaths = false); - //Getters - std::string const getName() { return nodeName; }; - WorldPosition* getPosition() { return &point; }; - std::unordered_map* getPaths() { return &paths; } - std::unordered_map* getLinks() { return &links; } - bool isImportant() { return important; }; - bool isLinked() { return linked; } + bool isEqual(TravelNode* compareNode); - bool isTransport() - { - for (auto const& link : *getLinks()) - if (link.second->getPathType() == TravelNodePathType::transport) - return true; + // Removes links to other nodes that can also be reached by passing another node. + bool isUselessLink(TravelNode* farNode); + void cropUselessLink(TravelNode* farNode); + bool cropUselessLinks(); - return false; - } + // Returns all nodes that can be reached from this node. + std::vector getNodeMap(bool importantOnly = false, std::vector ignoreNodes = {}); - uint32 getTransportId() - { - for (auto const& link : *getLinks()) - if (link.second->getPathType() == TravelNodePathType::transport) - return link.second->getPathObject(); + // Checks if it is even possible to route to this node. + bool hasRouteTo(TravelNode* node) + { + if (routes.empty()) + for (auto mNode : getNodeMap()) + routes[mNode] = true; - return false; - } + return routes.find(node) != routes.end(); + }; - bool isPortal() - { - for (auto const& link : *getLinks()) - if (link.second->getPathType() == TravelNodePathType::portal) - return true; + void print(bool printFailed = true); - return false; - } +protected: + // Logical name of the node + std::string nodeName; + // WorldPosition of the node. + WorldPosition point; - bool isWalking() - { - for (auto link : *getLinks()) - if (link.second->getPathType() == TravelNodePathType::walk) - return true; + // List of paths to other nodes. + std::unordered_map paths; + // List of links to other nodes. + std::unordered_map links; - return false; - } + // List of nodes and if there is 'any' route possible + std::unordered_map routes; - //WorldLocation shortcuts - uint32 getMapId() { return point.getMapId(); } - float getX() { return point.getX(); } - float getY() { return point.getY(); } - float getZ() { return point.getZ(); } - float getO() { return point.getO(); } - float getDistance(WorldPosition pos) { return point.distance(pos); } - float getDistance(TravelNode* node) { return point.distance(node->getPosition()); } - float fDist(TravelNode* node) { return point.fDist(node->getPosition()); } - float fDist(WorldPosition pos) { return point.fDist(pos); } + // This node should not be removed + bool important = false; - TravelNodePath* setPathTo(TravelNode* node, TravelNodePath path = TravelNodePath(), bool isLink = true) - { - if (this != node) - { - paths[node] = path; - if (isLink) - links[node] = &paths[node]; + // This node has been checked for nearby links + bool linked = false; - return &paths[node]; - } - - return nullptr; - } - - bool hasPathTo(TravelNode* node) { return paths.find(node) != paths.end(); } - TravelNodePath* getPathTo(TravelNode* node) { return &paths[node]; } - bool hasCompletePathTo(TravelNode* node) { return hasPathTo(node) && getPathTo(node)->getComplete(); } - TravelNodePath* buildPath(TravelNode* endNode, Unit* bot, bool postProcess = false); - - void setLinkTo(TravelNode* node, float distance = 0.1f) - { - if (this != node) - { - if (!hasPathTo(node)) - setPathTo(node, TravelNodePath(distance)); - else - links[node] = &paths[node]; - } - } - - bool hasLinkTo(TravelNode* node) { return links.find(node) != links.end(); } - float linkCostTo(TravelNode* node) { return paths.find(node)->second.getDistance(); } - float linkDistanceTo(TravelNode* node) { return paths.find(node)->second.getDistance(); } - void removeLinkTo(TravelNode* node, bool removePaths = false); - - bool isEqual(TravelNode* compareNode); - - //Removes links to other nodes that can also be reached by passing another node. - bool isUselessLink(TravelNode* farNode); - void cropUselessLink(TravelNode* farNode); - bool cropUselessLinks(); - - //Returns all nodes that can be reached from this node. - std::vector getNodeMap(bool importantOnly = false, std::vector ignoreNodes = {}); - - // Checks if it is even possible to route to this node. - bool hasRouteTo(TravelNode* node) - { - if (routes.empty()) - for (auto mNode : getNodeMap()) - routes[mNode] = true; - - return routes.find(node) != routes.end(); - }; - - void print(bool printFailed = true); - - protected: - //Logical name of the node - std::string nodeName; - //WorldPosition of the node. - WorldPosition point; - - //List of paths to other nodes. - std::unordered_map paths; - //List of links to other nodes. - std::unordered_map links; - - //List of nodes and if there is 'any' route possible - std::unordered_map routes; - - //This node should not be removed - bool important = false; - - //This node has been checked for nearby links - bool linked = false; - - //This node is a (moving) transport. - //bool transport = false; - //Entry of transport. - //uint32 transportId = 0; + // This node is a (moving) transport. + // bool transport = false; + // Entry of transport. + // uint32 transportId = 0; }; class PortalNode : public TravelNode { - public: - PortalNode(TravelNode* baseNode) : TravelNode(baseNode) { }; +public: + PortalNode(TravelNode* baseNode) : TravelNode(baseNode){}; - void SetPortal(TravelNode* baseNode, TravelNode* endNode, uint32 portalSpell) - { - nodeName = baseNode->getName(); - point = *baseNode->getPosition(); - paths.clear(); - links.clear(); - TravelNodePath path(0.1f, 0.1f, (uint8)TravelNodePathType::teleportSpell, portalSpell, true); - setPathTo(endNode, path); - }; + void SetPortal(TravelNode* baseNode, TravelNode* endNode, uint32 portalSpell) + { + nodeName = baseNode->getName(); + point = *baseNode->getPosition(); + paths.clear(); + links.clear(); + TravelNodePath path(0.1f, 0.1f, (uint8)TravelNodePathType::teleportSpell, portalSpell, true); + setPathTo(endNode, path); + }; }; -//Route step type +// Route step type enum PathNodeType { - NODE_PREPATH = 0, - NODE_PATH = 1, - NODE_NODE = 2, - NODE_PORTAL = 3, - NODE_TRANSPORT = 4, + NODE_PREPATH = 0, + NODE_PATH = 1, + NODE_NODE = 2, + NODE_PORTAL = 3, + NODE_TRANSPORT = 4, NODE_FLIGHTPATH = 5, - NODE_TELEPORT = 6 + NODE_TELEPORT = 6 }; struct PathNodePoint @@ -376,200 +379,220 @@ struct PathNodePoint uint32 entry = 0; }; -//A complete list of points the bots has to walk to or teleport to. +// A complete list of points the bots has to walk to or teleport to. class TravelPath { - public: - TravelPath() { }; - TravelPath(std::vector fullPath1) { fullPath = fullPath1; } - TravelPath(std::vector path, PathNodeType type = NODE_PATH, uint32 entry = 0) +public: + TravelPath(){}; + TravelPath(std::vector fullPath1) { fullPath = fullPath1; } + TravelPath(std::vector path, PathNodeType type = NODE_PATH, uint32 entry = 0) + { + addPath(path, type, entry); + } + + void addPoint(PathNodePoint point) { fullPath.push_back(point); } + void addPoint(WorldPosition point, PathNodeType type = NODE_PATH, uint32 entry = 0) + { + fullPath.push_back(PathNodePoint{point, type, entry}); + } + void addPath(std::vector path, PathNodeType type = NODE_PATH, uint32 entry = 0) + { + for (auto& p : path) { - addPath(path, type, entry); - } - - void addPoint(PathNodePoint point) { fullPath.push_back(point); } - void addPoint(WorldPosition point, PathNodeType type = NODE_PATH, uint32 entry = 0) { fullPath.push_back(PathNodePoint{ point, type, entry }); } - void addPath(std::vector path, PathNodeType type = NODE_PATH, uint32 entry = 0) { for (auto& p : path) { fullPath.push_back(PathNodePoint{ p, type, entry }); }; } - void addPath(std::vector newPath) { fullPath.insert(fullPath.end(), newPath.begin(), newPath.end()); } - void clear() { fullPath.clear(); } - - bool empty() { return fullPath.empty(); } - std::vector getPath() { return fullPath; } - WorldPosition getFront() {return fullPath.front().point; } - WorldPosition getBack() { return fullPath.back().point; } - - std::vector getPointPath() - { - std::vector retVec; - for (auto const& p : fullPath) - retVec.push_back(p.point); - return retVec; + fullPath.push_back(PathNodePoint{p, type, entry}); }; + } + void addPath(std::vector newPath) + { + fullPath.insert(fullPath.end(), newPath.begin(), newPath.end()); + } + void clear() { fullPath.clear(); } - bool makeShortCut(WorldPosition startPos, float maxDist); - bool shouldMoveToNextPoint(WorldPosition startPos, std::vector::iterator beg, std::vector::iterator ed, std::vector::iterator p, float& moveDist, float maxDist); - WorldPosition getNextPoint(WorldPosition startPos, float maxDist, TravelNodePathType& pathType, uint32& entry); + bool empty() { return fullPath.empty(); } + std::vector getPath() { return fullPath; } + WorldPosition getFront() { return fullPath.front().point; } + WorldPosition getBack() { return fullPath.back().point; } - std::ostringstream const print(); + std::vector getPointPath() + { + std::vector retVec; + for (auto const& p : fullPath) + retVec.push_back(p.point); + return retVec; + }; - private: - std::vector fullPath; + bool makeShortCut(WorldPosition startPos, float maxDist); + bool shouldMoveToNextPoint(WorldPosition startPos, std::vector::iterator beg, + std::vector::iterator ed, std::vector::iterator p, + float& moveDist, float maxDist); + WorldPosition getNextPoint(WorldPosition startPos, float maxDist, TravelNodePathType& pathType, uint32& entry); + + std::ostringstream const print(); + +private: + std::vector fullPath; }; -//An stored A* search that gives a complete route from one node to another. +// An stored A* search that gives a complete route from one node to another. class TravelNodeRoute { - public: - TravelNodeRoute() { } - TravelNodeRoute(std::vector nodes1) { nodes = nodes1; /*currentNode = route.begin();*/ } +public: + TravelNodeRoute() {} + TravelNodeRoute(std::vector nodes1) { nodes = nodes1; /*currentNode = route.begin();*/ } - bool isEmpty() { return nodes.empty(); } + bool isEmpty() { return nodes.empty(); } - bool hasNode(TravelNode* node) { return findNode(node) != nodes.end(); } - float getTotalDistance(); + bool hasNode(TravelNode* node) { return findNode(node) != nodes.end(); } + float getTotalDistance(); - std::vector getNodes() { return nodes; } + std::vector getNodes() { return nodes; } - TravelPath buildPath(std::vector pathToStart = {}, std::vector pathToEnd = {}, Unit* bot = nullptr); + TravelPath buildPath(std::vector pathToStart = {}, std::vector pathToEnd = {}, + Unit* bot = nullptr); - std::ostringstream const print(); + std::ostringstream const print(); - private: - std::vector::iterator findNode(TravelNode* node) { return std::find(nodes.begin(), nodes.end(), node); } - std::vector nodes; +private: + std::vector::iterator findNode(TravelNode* node) + { + return std::find(nodes.begin(), nodes.end(), node); + } + std::vector nodes; }; -//A node container to aid A* calculations with nodes. +// A node container to aid A* calculations with nodes. class TravelNodeStub { - public: - TravelNodeStub(TravelNode* dataNode1) { dataNode = dataNode1; } +public: + TravelNodeStub(TravelNode* dataNode1) { dataNode = dataNode1; } - TravelNode* dataNode; - float m_f = 0.0, m_g = 0.0, m_h = 0.0; - bool open = false, close = false; - TravelNodeStub* parent = nullptr; - uint32 currentGold = 0; + TravelNode* dataNode; + float m_f = 0.0, m_g = 0.0, m_h = 0.0; + bool open = false, close = false; + TravelNodeStub* parent = nullptr; + uint32 currentGold = 0; }; -//The container of all nodes. +// The container of all nodes. class TravelNodeMap { - public: - TravelNodeMap() { }; - TravelNodeMap(TravelNodeMap* baseMap); +public: + TravelNodeMap(){}; + TravelNodeMap(TravelNodeMap* baseMap); - static TravelNodeMap* instance() - { - static TravelNodeMap instance; - return &instance; - } + static TravelNodeMap* instance() + { + static TravelNodeMap instance; + return &instance; + } - TravelNode* addNode(WorldPosition pos, std::string const preferedName = "Travel Node", bool isImportant = false, bool checkDuplicate = true, bool transport = false, uint32 transportId = 0); - void removeNode(TravelNode* node); - bool removeNodes() - { - if (m_nMapMtx.try_lock_for(std::chrono::seconds(10))) - { - for (auto& node : m_nodes) - removeNode(node); - - m_nMapMtx.unlock(); - return true; - } - - return false; - }; - - void fullLinkNode(TravelNode* startNode, Unit* bot); - - //Get all nodes - std::vector getNodes() { return m_nodes; } - std::vector getNodes(WorldPosition pos, float range = -1); - - //Find nearest node. - TravelNode* getNode(TravelNode* sameNode) + TravelNode* addNode(WorldPosition pos, std::string const preferedName = "Travel Node", bool isImportant = false, + bool checkDuplicate = true, bool transport = false, uint32 transportId = 0); + void removeNode(TravelNode* node); + bool removeNodes() + { + if (m_nMapMtx.try_lock_for(std::chrono::seconds(10))) { for (auto& node : m_nodes) - { - if (node->getName() == sameNode->getName() && node->getPosition() == sameNode->getPosition()) - return node; - } + removeNode(node); + m_nMapMtx.unlock(); + return true; + } + + return false; + }; + + void fullLinkNode(TravelNode* startNode, Unit* bot); + + // Get all nodes + std::vector getNodes() { return m_nodes; } + std::vector getNodes(WorldPosition pos, float range = -1); + + // Find nearest node. + TravelNode* getNode(TravelNode* sameNode) + { + for (auto& node : m_nodes) + { + if (node->getName() == sameNode->getName() && node->getPosition() == sameNode->getPosition()) + return node; + } + + return nullptr; + } + + TravelNode* getNode(WorldPosition pos, std::vector& ppath, Unit* bot = nullptr, float range = -1); + TravelNode* getNode(WorldPosition pos, Unit* bot = nullptr, float range = -1) + { + std::vector ppath; + return getNode(pos, ppath, bot, range); + } + + // Get Random Node + TravelNode* getRandomNode(WorldPosition pos) + { + std::vector rNodes = getNodes(pos); + if (rNodes.empty()) return nullptr; - } - TravelNode* getNode(WorldPosition pos, std::vector& ppath, Unit* bot = nullptr, float range = -1); - TravelNode* getNode(WorldPosition pos, Unit* bot = nullptr, float range = -1) - { - std::vector ppath; - return getNode(pos, ppath, bot, range); - } + return rNodes[urand(0, rNodes.size() - 1)]; + } - //Get Random Node - TravelNode* getRandomNode(WorldPosition pos) - { - std::vector rNodes = getNodes(pos); - if (rNodes.empty()) - return nullptr; + // Finds the best nodePath between two nodes + TravelNodeRoute getRoute(TravelNode* start, TravelNode* goal, Player* bot = nullptr); - return rNodes[urand(0, rNodes.size() - 1)]; - } + // Find the best node between two positions + TravelNodeRoute getRoute(WorldPosition startPos, WorldPosition endPos, std::vector& startPath, + Player* bot = nullptr); - //Finds the best nodePath between two nodes - TravelNodeRoute getRoute(TravelNode* start, TravelNode* goal, Player* bot = nullptr); + // Find the full path between those locations + static TravelPath getFullPath(WorldPosition startPos, WorldPosition endPos, Player* bot = nullptr); - //Find the best node between two positions - TravelNodeRoute getRoute(WorldPosition startPos, WorldPosition endPos, std::vector& startPath, Player* bot = nullptr); + // Manage/update nodes + void manageNodes(Unit* bot, bool mapFull = false); - //Find the full path between those locations - static TravelPath getFullPath(WorldPosition startPos, WorldPosition endPos, Player* bot = nullptr); + void setHasToGen() { hasToGen = true; } - //Manage/update nodes - void manageNodes(Unit* bot, bool mapFull = false); + void generateNpcNodes(); + void generateStartNodes(); + void generateAreaTriggerNodes(); + void generateNodes(); + void generateTransportNodes(); + void generateZoneMeanNodes(); - void setHasToGen() { hasToGen = true; } + void generateWalkPaths(); + void removeLowNodes(); + void removeUselessPaths(); + void calculatePathCosts(); + void generateTaxiPaths(); + void generatePaths(); - void generateNpcNodes(); - void generateStartNodes(); - void generateAreaTriggerNodes(); - void generateNodes(); - void generateTransportNodes(); - void generateZoneMeanNodes(); + void generateAll(); - void generateWalkPaths(); - void removeLowNodes(); - void removeUselessPaths(); - void calculatePathCosts(); - void generateTaxiPaths(); - void generatePaths(); + void printMap(); - void generateAll(); + void printNodeStore(); + void saveNodeStore(); + void loadNodeStore(); - void printMap(); + bool cropUselessNode(TravelNode* startNode); + TravelNode* addZoneLinkNode(TravelNode* startNode); + TravelNode* addRandomExtNode(TravelNode* startNode); - void printNodeStore(); - void saveNodeStore(); - void loadNodeStore(); + void calcMapOffset(); + WorldPosition getMapOffset(uint32 mapId); - bool cropUselessNode(TravelNode* startNode); - TravelNode* addZoneLinkNode(TravelNode* startNode); - TravelNode* addRandomExtNode(TravelNode* startNode); + std::shared_timed_mutex m_nMapMtx; + std::unordered_map> teleportNodes; - void calcMapOffset(); - WorldPosition getMapOffset(uint32 mapId); +private: + std::vector m_nodes; - std::shared_timed_mutex m_nMapMtx; - std::unordered_map> teleportNodes; + std::vector> mapOffsets; - private: - std::vector m_nodes; - - std::vector> mapOffsets; - - bool hasToSave = false; - bool hasToGen = false; - bool hasToFullGen = false; + bool hasToSave = false; + bool hasToGen = false; + bool hasToFullGen = false; }; #define sTravelNodeMap TravelNodeMap::instance() diff --git a/src/cs_playerbots.cpp b/src/cs_playerbots.cpp index 987cf0cb..a96dc6e3 100644 --- a/src/cs_playerbots.cpp +++ b/src/cs_playerbots.cpp @@ -13,39 +13,36 @@ * with this program. If not, see . */ +#include "BattleGroundTactics.h" #include "Chat.h" #include "GuildTaskMgr.h" #include "PerformanceMonitor.h" #include "PlayerbotMgr.h" #include "RandomPlayerbotMgr.h" #include "ScriptMgr.h" -#include "BattleGroundTactics.h" using namespace Acore::ChatCommands; class playerbots_commandscript : public CommandScript { public: - playerbots_commandscript() : CommandScript("playerbots_commandscript") { } + playerbots_commandscript() : CommandScript("playerbots_commandscript") {} ChatCommandTable GetCommands() const override { - static ChatCommandTable playerbotsDebugCommandTable = - { - { "bg", HandleDebugBGCommand, SEC_GAMEMASTER, Console::Yes }, + static ChatCommandTable playerbotsDebugCommandTable = { + {"bg", HandleDebugBGCommand, SEC_GAMEMASTER, Console::Yes}, }; - static ChatCommandTable playerbotsCommandTable = - { - { "bot", HandlePlayerbotCommand, SEC_PLAYER, Console::No }, - { "gtask", HandleGuildTaskCommand, SEC_GAMEMASTER, Console::Yes }, - { "pmon", HandlePerfMonCommand, SEC_GAMEMASTER, Console::Yes }, - { "rndbot", HandleRandomPlayerbotCommand, SEC_GAMEMASTER, Console::Yes }, - { "debug", playerbotsDebugCommandTable }, + static ChatCommandTable playerbotsCommandTable = { + {"bot", HandlePlayerbotCommand, SEC_PLAYER, Console::No}, + {"gtask", HandleGuildTaskCommand, SEC_GAMEMASTER, Console::Yes}, + {"pmon", HandlePerfMonCommand, SEC_GAMEMASTER, Console::Yes}, + {"rndbot", HandleRandomPlayerbotCommand, SEC_GAMEMASTER, Console::Yes}, + {"debug", playerbotsDebugCommandTable}, }; - static ChatCommandTable commandTable = - { - { "playerbots", playerbotsCommandTable }, + static ChatCommandTable commandTable = { + {"playerbots", playerbotsCommandTable}, }; return commandTable; @@ -96,7 +93,4 @@ public: } }; -void AddSC_playerbots_commandscript() -{ - new playerbots_commandscript(); -} +void AddSC_playerbots_commandscript() { new playerbots_commandscript(); } diff --git a/src/playerbots_loader.cpp b/src/playerbots_loader.cpp index 34ceea46..bd91e39c 100644 --- a/src/playerbots_loader.cpp +++ b/src/playerbots_loader.cpp @@ -19,7 +19,4 @@ void AddPlayerbotsScripts(); // Add all -void Addmod_playerbotsScripts() -{ - AddPlayerbotsScripts(); -} +void Addmod_playerbotsScripts() { AddPlayerbotsScripts(); } diff --git a/src/strategy/Action.cpp b/src/strategy/Action.cpp index 3fd4a723..5072cdf9 100644 --- a/src/strategy/Action.cpp +++ b/src/strategy/Action.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "Action.h" + #include "Playerbots.h" #include "Timer.h" @@ -66,8 +68,7 @@ NextAction** NextAction::array(uint32 nil, ...) { cur = va_arg(vl, NextAction*); ++size; - } - while (cur); + } while (cur); va_end(vl); @@ -85,28 +86,19 @@ void NextAction::destroy(NextAction** actions) if (!actions) return; - for (uint32 i=0; actions[i]; i++) + for (uint32 i = 0; actions[i]; i++) delete actions[i]; delete[] actions; } -Value* Action::GetTargetValue() -{ - return context->GetValue(GetTargetName()); -} +Value* Action::GetTargetValue() { return context->GetValue(GetTargetName()); } -Unit* Action::GetTarget() -{ - return GetTargetValue()->Get(); -} +Unit* Action::GetTarget() { return GetTargetValue()->Get(); } -ActionBasket::ActionBasket(ActionNode* action, float relevance, bool skipPrerequisites, Event event) : - action(action), relevance(relevance), skipPrerequisites(skipPrerequisites), event(event), created(getMSTime()) +ActionBasket::ActionBasket(ActionNode* action, float relevance, bool skipPrerequisites, Event event) + : action(action), relevance(relevance), skipPrerequisites(skipPrerequisites), event(event), created(getMSTime()) { } -bool ActionBasket::isExpired(uint32 msecs) -{ - return getMSTime() - created >= msecs; -} +bool ActionBasket::isExpired(uint32 msecs) { return getMSTime() - created >= msecs; } diff --git a/src/strategy/Action.h b/src/strategy/Action.h index 7069a5b3..03224f56 100644 --- a/src/strategy/Action.h +++ b/src/strategy/Action.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ACTION_H @@ -15,108 +16,119 @@ class Unit; class NextAction { - public: - NextAction(std::string const name, float relevance = 0.0f) : relevance(relevance), name(name) { } // name after relevance - whipowill - NextAction(NextAction const& o) : relevance(o.relevance), name(o.name) { } // name after relevance - whipowill +public: + NextAction(std::string const name, float relevance = 0.0f) + : relevance(relevance), name(name) {} // name after relevance - whipowill + NextAction(NextAction const& o) : relevance(o.relevance), name(o.name) {} // name after relevance - whipowill - std::string const getName() { return name; } - float getRelevance() {return relevance;} + std::string const getName() { return name; } + float getRelevance() { return relevance; } - static uint32 size(NextAction** actions); - static NextAction** clone(NextAction** actions); - static NextAction** merge(NextAction** what, NextAction** with); - static NextAction** array(uint32 nil,...); - static void destroy(NextAction** actions); + static uint32 size(NextAction** actions); + static NextAction** clone(NextAction** actions); + static NextAction** merge(NextAction** what, NextAction** with); + static NextAction** array(uint32 nil, ...); + static void destroy(NextAction** actions); - private: - float relevance; - std::string const name; +private: + float relevance; + std::string const name; }; class Action : public AiNamedObject { - public: - enum class ActionThreatType - { - None = 0, - Single = 1, - Aoe = 2 - }; +public: + enum class ActionThreatType + { + None = 0, + Single = 1, + Aoe = 2 + }; - Action(PlayerbotAI* botAI, std::string const name = "action") : AiNamedObject(botAI, name), verbose(false) { } // verbose after ainamedobject - whipowill - virtual ~Action(void) { } + Action(PlayerbotAI* botAI, std::string const name = "action") + : AiNamedObject(botAI, name), verbose(false) {} // verbose after ainamedobject - whipowill + virtual ~Action(void) {} - virtual bool Execute([[maybe_unused]] Event event) { return true; } - virtual bool isPossible() { return true; } - virtual bool isUseful() { return true; } - virtual NextAction** getPrerequisites() { return nullptr; } - virtual NextAction** getAlternatives() { return nullptr; } - virtual NextAction** getContinuers() { return nullptr; } - virtual ActionThreatType getThreatType() { return ActionThreatType::None; } - void Update() { } - void Reset() { } - virtual Unit* GetTarget(); - virtual Value* GetTargetValue(); - virtual std::string const GetTargetName() { return "self target"; } - void MakeVerbose() { verbose = true; } - void setRelevance(uint32 relevance1) { relevance = relevance1; }; - virtual float getRelevance() { return relevance; } + virtual bool Execute([[maybe_unused]] Event event) { return true; } + virtual bool isPossible() { return true; } + virtual bool isUseful() { return true; } + virtual NextAction** getPrerequisites() { return nullptr; } + virtual NextAction** getAlternatives() { return nullptr; } + virtual NextAction** getContinuers() { return nullptr; } + virtual ActionThreatType getThreatType() { return ActionThreatType::None; } + void Update() {} + void Reset() {} + virtual Unit* GetTarget(); + virtual Value* GetTargetValue(); + virtual std::string const GetTargetName() { return "self target"; } + void MakeVerbose() { verbose = true; } + void setRelevance(uint32 relevance1) { relevance = relevance1; }; + virtual float getRelevance() { return relevance; } - protected: - bool verbose; - float relevance = 0; +protected: + bool verbose; + float relevance = 0; }; class ActionNode { - public: - ActionNode(std::string const name, NextAction** prerequisites = nullptr, NextAction** alternatives = nullptr, NextAction** continuers = nullptr) : - name(name), action(nullptr), continuers(continuers), alternatives(alternatives), prerequisites(prerequisites) { } // reorder arguments - whipowill +public: + ActionNode(std::string const name, NextAction** prerequisites = nullptr, NextAction** alternatives = nullptr, + NextAction** continuers = nullptr) + : name(name), action(nullptr), continuers(continuers), alternatives(alternatives), prerequisites(prerequisites) + { + } // reorder arguments - whipowill - virtual ~ActionNode() - { - NextAction::destroy(prerequisites); - NextAction::destroy(alternatives); - NextAction::destroy(continuers); - } + virtual ~ActionNode() + { + NextAction::destroy(prerequisites); + NextAction::destroy(alternatives); + NextAction::destroy(continuers); + } - Action* getAction() { return action; } - void setAction(Action* action) { this->action = action; } - std::string const getName() { return name; } + Action* getAction() { return action; } + void setAction(Action* action) { this->action = action; } + std::string const getName() { return name; } - NextAction** getContinuers() { return NextAction::merge(NextAction::clone(continuers), action->getContinuers()); } - NextAction** getAlternatives() { return NextAction::merge(NextAction::clone(alternatives), action->getAlternatives()); } - NextAction** getPrerequisites() { return NextAction::merge(NextAction::clone(prerequisites), action->getPrerequisites()); } + NextAction** getContinuers() { return NextAction::merge(NextAction::clone(continuers), action->getContinuers()); } + NextAction** getAlternatives() + { + return NextAction::merge(NextAction::clone(alternatives), action->getAlternatives()); + } + NextAction** getPrerequisites() + { + return NextAction::merge(NextAction::clone(prerequisites), action->getPrerequisites()); + } - private: - std::string const name; - Action* action; - NextAction** continuers; - NextAction** alternatives; - NextAction** prerequisites; +private: + std::string const name; + Action* action; + NextAction** continuers; + NextAction** alternatives; + NextAction** prerequisites; }; class ActionBasket { - public: - ActionBasket(ActionNode* action, float relevance, bool skipPrerequisites, Event event); +public: + ActionBasket(ActionNode* action, float relevance, bool skipPrerequisites, Event event); - virtual ~ActionBasket(void) { } + virtual ~ActionBasket(void) {} - float getRelevance() {return relevance;} - ActionNode* getAction() {return action;} - Event getEvent() { return event; } - bool isSkipPrerequisites() { return skipPrerequisites; } - void AmendRelevance(float k) { relevance *= k; } - void setRelevance(float relevance) { this->relevance = relevance; } - bool isExpired(uint32 msecs); + float getRelevance() { return relevance; } + ActionNode* getAction() { return action; } + Event getEvent() { return event; } + bool isSkipPrerequisites() { return skipPrerequisites; } + void AmendRelevance(float k) { relevance *= k; } + void setRelevance(float relevance) { this->relevance = relevance; } + bool isExpired(uint32 msecs); - private: - ActionNode* action; - float relevance; - bool skipPrerequisites; - Event event; - uint32 created; +private: + ActionNode* action; + float relevance; + bool skipPrerequisites; + Event event; + uint32 created; }; #endif diff --git a/src/strategy/AiObject.cpp b/src/strategy/AiObject.cpp index cba1fa1d..5de5923e 100644 --- a/src/strategy/AiObject.cpp +++ b/src/strategy/AiObject.cpp @@ -1,15 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AiObject.h" + #include "Playerbots.h" -AiObject::AiObject(PlayerbotAI* botAI) : PlayerbotAIAware(botAI), bot(botAI->GetBot()), context(botAI->GetAiObjectContext()), chat(botAI->GetChatHelper()) +AiObject::AiObject(PlayerbotAI* botAI) + : PlayerbotAIAware(botAI), bot(botAI->GetBot()), context(botAI->GetAiObjectContext()), chat(botAI->GetChatHelper()) { } -Player* AiObject::GetMaster() -{ - return botAI->GetMaster(); -} +Player* AiObject::GetMaster() { return botAI->GetMaster(); } diff --git a/src/strategy/AiObject.h b/src/strategy/AiObject.h index ca28b42c..b80bce4e 100644 --- a/src/strategy/AiObject.h +++ b/src/strategy/AiObject.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_AIOBJECT_H @@ -15,26 +16,26 @@ class PlayerbotAI; class AiObject : public PlayerbotAIAware { - public: - AiObject(PlayerbotAI* botAI); +public: + AiObject(PlayerbotAI* botAI); - protected: - Player* bot; - Player* GetMaster(); - AiObjectContext* context; - ChatHelper* chat; +protected: + Player* bot; + Player* GetMaster(); + AiObjectContext* context; + ChatHelper* chat; }; class AiNamedObject : public AiObject { - public: - AiNamedObject(PlayerbotAI* botAI, std::string const name) : AiObject(botAI), name(name) { } +public: + AiNamedObject(PlayerbotAI* botAI, std::string const name) : AiObject(botAI), name(name) {} - public: - virtual std::string const getName() { return name; } +public: + virtual std::string const getName() { return name; } - protected: - std::string const name; +protected: + std::string const name; }; // @@ -44,475 +45,469 @@ class AiNamedObject : public AiObject #define NEXT_TRIGGERS(name, relevance) \ virtual NextAction* getNextAction() { return new NextAction(name, relevance); } -#define BEGIN_TRIGGER(clazz, super) \ -class clazz : public super \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : super(botAI) { } \ - bool IsActive() override; \ +#define BEGIN_TRIGGER(clazz, super) \ + class clazz : public super \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : super(botAI) {} \ + bool IsActive() override; #define END_TRIGGER() \ -}; + } \ + ; -#define BUFF_TRIGGER(clazz, spell) \ -class clazz : public BuffTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : BuffTrigger(botAI, spell) { } \ -} +#define BUFF_TRIGGER(clazz, spell) \ + class clazz : public BuffTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : BuffTrigger(botAI, spell) {} \ + } -#define BUFF_TRIGGER_A(clazz, spell) \ -class clazz : public BuffTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : BuffTrigger(botAI, spell) { } \ - bool IsActive() override; \ -} +#define BUFF_TRIGGER_A(clazz, spell) \ + class clazz : public BuffTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : BuffTrigger(botAI, spell) {} \ + bool IsActive() override; \ + } -#define BUFF_PARTY_TRIGGER(clazz, spell) \ -class clazz : public BuffOnPartyTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, spell) { } \ -} +#define BUFF_PARTY_TRIGGER(clazz, spell) \ + class clazz : public BuffOnPartyTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, spell) {} \ + } -#define BUFF_PARTY_TRIGGER_A(clazz, spell) \ -class clazz : public BuffOnPartyTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, spell) { } \ - bool IsActive() override; \ -} +#define BUFF_PARTY_TRIGGER_A(clazz, spell) \ + class clazz : public BuffOnPartyTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, spell) {} \ + bool IsActive() override; \ + } -#define DEBUFF_TRIGGER(clazz, spell) \ -class clazz : public DebuffTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : DebuffTrigger(botAI, spell) { } \ -} +#define DEBUFF_TRIGGER(clazz, spell) \ + class clazz : public DebuffTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : DebuffTrigger(botAI, spell) {} \ + } -#define DEBUFF_CHECKISOWNER_TRIGGER(clazz, spell) \ -class clazz : public DebuffTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : DebuffTrigger(botAI, spell, 1, true) { } \ -} +#define DEBUFF_CHECKISOWNER_TRIGGER(clazz, spell) \ + class clazz : public DebuffTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : DebuffTrigger(botAI, spell, 1, true) {} \ + } -#define DEBUFF_TRIGGER_A(clazz, spell) \ -class clazz : public DebuffTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : DebuffTrigger(botAI, spell) { } \ - bool IsActive() override; \ -} +#define DEBUFF_TRIGGER_A(clazz, spell) \ + class clazz : public DebuffTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : DebuffTrigger(botAI, spell) {} \ + bool IsActive() override; \ + } -#define DEBUFF_ENEMY_TRIGGER(clazz, spell) \ -class clazz : public DebuffOnAttackerTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, spell) { } \ -} +#define DEBUFF_ENEMY_TRIGGER(clazz, spell) \ + class clazz : public DebuffOnAttackerTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, spell) {} \ + } -#define DEBUFF_ENEMY_TRIGGER_A(clazz, spell) \ -class clazz : public DebuffOnAttackerTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, spell) { } \ - bool IsActive() override; \ -} +#define DEBUFF_ENEMY_TRIGGER_A(clazz, spell) \ + class clazz : public DebuffOnAttackerTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, spell) {} \ + bool IsActive() override; \ + } -#define CURE_TRIGGER(clazz, spell, dispel) \ -class clazz : public NeedCureTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : NeedCureTrigger(botAI, spell, dispel) { } \ -} +#define CURE_TRIGGER(clazz, spell, dispel) \ + class clazz : public NeedCureTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : NeedCureTrigger(botAI, spell, dispel) {} \ + } -#define CURE_PARTY_TRIGGER(clazz, spell, dispel) \ -class clazz : public PartyMemberNeedCureTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, spell, dispel) { } \ -} +#define CURE_PARTY_TRIGGER(clazz, spell, dispel) \ + class clazz : public PartyMemberNeedCureTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, spell, dispel) {} \ + } -#define CAN_CAST_TRIGGER(clazz, spell) \ -class clazz : public SpellCanBeCastTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : SpellCanBeCastTrigger(botAI, spell) { } \ -} +#define CAN_CAST_TRIGGER(clazz, spell) \ + class clazz : public SpellCanBeCastTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : SpellCanBeCastTrigger(botAI, spell) {} \ + } -#define CAN_CAST_TRIGGER_A(clazz, spell) \ -class clazz : public SpellCanBeCastTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : SpellCanBeCastTrigger(botAI, spell) { } \ - bool IsActive() override; \ -} +#define CAN_CAST_TRIGGER_A(clazz, spell) \ + class clazz : public SpellCanBeCastTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : SpellCanBeCastTrigger(botAI, spell) {} \ + bool IsActive() override; \ + } -#define CD_TRIGGER(clazz, spell) \ -class clazz : public SpellNoCooldownTrigger \ -{ \ - public: \ +#define CD_TRIGGER(clazz, spell) \ + class clazz : public SpellNoCooldownTrigger \ + { \ + public: \ clazz(PlayerbotAI* botAI) : SpellNoCooldownTrigger(botAI, spell) {} \ -} + } -#define INTERRUPT_TRIGGER(clazz, spell) \ -class clazz : public InterruptSpellTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, spell) { } \ -} +#define INTERRUPT_TRIGGER(clazz, spell) \ + class clazz : public InterruptSpellTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, spell) {} \ + } -#define INTERRUPT_TRIGGER_A(clazz, spell) \ -class clazz : public InterruptSpellTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, spell) { } \ - bool IsActive() override; \ -} +#define INTERRUPT_TRIGGER_A(clazz, spell) \ + class clazz : public InterruptSpellTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, spell) {} \ + bool IsActive() override; \ + } -#define HAS_AURA_TRIGGER(clazz, spell) \ -class clazz : public HasAuraTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : HasAuraTrigger(botAI, spell) { } \ -} +#define HAS_AURA_TRIGGER(clazz, spell) \ + class clazz : public HasAuraTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : HasAuraTrigger(botAI, spell) {} \ + } -#define HAS_AURA_TRIGGER_A(clazz, spell) \ -class clazz : public HasAuraTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : HasAuraTrigger(botAI, spell) { } \ - bool IsActive() override; \ -} +#define HAS_AURA_TRIGGER_A(clazz, spell) \ + class clazz : public HasAuraTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : HasAuraTrigger(botAI, spell) {} \ + bool IsActive() override; \ + } -#define SNARE_TRIGGER(clazz, spell) \ -class clazz : public SnareTargetTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : SnareTargetTrigger(botAI, spell) { } \ -} +#define SNARE_TRIGGER(clazz, spell) \ + class clazz : public SnareTargetTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : SnareTargetTrigger(botAI, spell) {} \ + } -#define SNARE_TRIGGER_A(clazz, spell) \ -class clazz : public SnareTargetTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : SnareTargetTrigger(botAI, spell) { } \ - bool IsActive() override; \ -} +#define SNARE_TRIGGER_A(clazz, spell) \ + class clazz : public SnareTargetTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : SnareTargetTrigger(botAI, spell) {} \ + bool IsActive() override; \ + } -#define PROTECT_TRIGGER(clazz, spell) \ -class clazz : public ProtectPartyMemberTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : ProtectPartyMemberTrigger(botAI) { } \ -} +#define PROTECT_TRIGGER(clazz, spell) \ + class clazz : public ProtectPartyMemberTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : ProtectPartyMemberTrigger(botAI) {} \ + } -#define DEFLECT_TRIGGER(clazz, spell) \ -class clazz : public DeflectSpellTrigger \ - { \ - public: \ - clazz(PlayerbotAI* botAI) : DeflectSpellTrigger(botAI, spell) { } \ -} +#define DEFLECT_TRIGGER(clazz, spell) \ + class clazz : public DeflectSpellTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : DeflectSpellTrigger(botAI, spell) {} \ + } -#define BOOST_TRIGGER(clazz, spell) \ -class clazz : public BoostTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : BoostTrigger(botAI, spell) { } \ -} +#define BOOST_TRIGGER(clazz, spell) \ + class clazz : public BoostTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : BoostTrigger(botAI, spell) {} \ + } -#define BOOST_TRIGGER_A(clazz, spell) \ -class clazz : public BoostTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : BoostTrigger(botAI, spell) { } \ - bool IsActive() override; \ -} +#define BOOST_TRIGGER_A(clazz, spell) \ + class clazz : public BoostTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : BoostTrigger(botAI, spell) {} \ + bool IsActive() override; \ + } -#define INTERRUPT_HEALER_TRIGGER(clazz, spell) \ -class clazz : public InterruptEnemyHealerTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, spell) { } \ -} +#define INTERRUPT_HEALER_TRIGGER(clazz, spell) \ + class clazz : public InterruptEnemyHealerTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, spell) {} \ + } -#define INTERRUPT_HEALER_TRIGGER_A(clazz, spell) \ -class clazz : public InterruptEnemyHealerTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, spell) { } \ - bool IsActive() override; \ -} +#define INTERRUPT_HEALER_TRIGGER_A(clazz, spell) \ + class clazz : public InterruptEnemyHealerTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, spell) {} \ + bool IsActive() override; \ + } -#define CC_TRIGGER(clazz, spell) \ -class clazz : public HasCcTargetTrigger \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, spell) { } \ -} +#define CC_TRIGGER(clazz, spell) \ + class clazz : public HasCcTargetTrigger \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, spell) {} \ + } // // ACTIONS // -#define MELEE_ACTION(clazz, spell) \ -class clazz : public CastMeleeSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, spell) { } \ -} +#define MELEE_ACTION(clazz, spell) \ + class clazz : public CastMeleeSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, spell) {} \ + } -#define MELEE_ACTION_U(clazz, spell, useful) \ -class clazz : public CastMeleeSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, spell) { } \ - bool isUseful() override { return useful; } \ -} +#define MELEE_ACTION_U(clazz, spell, useful) \ + class clazz : public CastMeleeSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, spell) {} \ + bool isUseful() override { return useful; } \ + } -#define SPELL_ACTION(clazz, spell) \ -class clazz : public CastSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastSpellAction(botAI, spell) { } \ -} +#define SPELL_ACTION(clazz, spell) \ + class clazz : public CastSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastSpellAction(botAI, spell) {} \ + } -#define SPELL_ACTION_U(clazz, spell, useful) \ -class clazz : public CastSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastSpellAction(botAI, spell) { } \ - bool isUseful() override { return useful; } \ -} +#define SPELL_ACTION_U(clazz, spell, useful) \ + class clazz : public CastSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastSpellAction(botAI, spell) {} \ + bool isUseful() override { return useful; } \ + } -#define HEAL_ACTION(clazz, spell) \ -class clazz : public CastHealingSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, spell) { } \ -} +#define HEAL_ACTION(clazz, spell) \ + class clazz : public CastHealingSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, spell) {} \ + } -#define HEAL_ACTION_U(clazz, spell, useful) \ -class clazz : public CastHealingSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, spell) { } \ - bool isUseful() override { return useful; } \ -} +#define HEAL_ACTION_U(clazz, spell, useful) \ + class clazz : public CastHealingSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, spell) {} \ + bool isUseful() override { return useful; } \ + } -#define HEAL_PARTY_ACTION(clazz, spell, estAmount, manaEfficiency) \ -class clazz : public HealPartyMemberAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, spell, estAmount, manaEfficiency) { } \ -} +#define HEAL_PARTY_ACTION(clazz, spell, estAmount, manaEfficiency) \ + class clazz : public HealPartyMemberAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, spell, estAmount, manaEfficiency) {} \ + } -#define AOE_HEAL_ACTION(clazz, spell, estAmount, manaEfficiency) \ -class clazz : public CastAoeHealSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastAoeHealSpellAction(botAI, spell) { } \ -} +#define AOE_HEAL_ACTION(clazz, spell, estAmount, manaEfficiency) \ + class clazz : public CastAoeHealSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastAoeHealSpellAction(botAI, spell) {} \ + } -#define BUFF_ACTION(clazz, spell) \ -class clazz : public CastBuffSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, spell) { } \ -} +#define BUFF_ACTION(clazz, spell) \ + class clazz : public CastBuffSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, spell) {} \ + } -#define BUFF_ACTION_U(clazz, spell, useful) \ -class clazz : public CastBuffSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, spell) { } \ - bool isUseful() override { return useful; } \ -} +#define BUFF_ACTION_U(clazz, spell, useful) \ + class clazz : public CastBuffSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, spell) {} \ + bool isUseful() override { return useful; } \ + } -#define BUFF_PARTY_ACTION(clazz, spell) \ -class clazz : public BuffOnPartyAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, spell) { } \ -} +#define BUFF_PARTY_ACTION(clazz, spell) \ + class clazz : public BuffOnPartyAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, spell) {} \ + } -#define CURE_ACTION(clazz, spell) \ -class clazz : public CastCureSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastCureSpellAction(botAI, spell) { } \ -} +#define CURE_ACTION(clazz, spell) \ + class clazz : public CastCureSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastCureSpellAction(botAI, spell) {} \ + } -#define CURE_PARTY_ACTION(clazz, spell, dispel) \ -class clazz : public CurePartyMemberAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, spell, dispel) { } \ -} +#define CURE_PARTY_ACTION(clazz, spell, dispel) \ + class clazz : public CurePartyMemberAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, spell, dispel) {} \ + } -#define RESS_ACTION(clazz, spell) \ -class clazz : public ResurrectPartyMemberAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : ResurrectPartyMemberAction(botAI, spell) { } \ -} +#define RESS_ACTION(clazz, spell) \ + class clazz : public ResurrectPartyMemberAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : ResurrectPartyMemberAction(botAI, spell) {} \ + } -#define DEBUFF_ACTION(clazz, spell) \ -class clazz : public CastDebuffSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, spell) { } \ -} +#define DEBUFF_ACTION(clazz, spell) \ + class clazz : public CastDebuffSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, spell) {} \ + } -#define DEBUFF_CHECKISOWNER_ACTION(clazz, spell) \ -class clazz : public CastDebuffSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, spell, true) { } \ -} +#define DEBUFF_CHECKISOWNER_ACTION(clazz, spell) \ + class clazz : public CastDebuffSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, spell, true) {} \ + } -#define DEBUFF_ACTION_U(clazz, spell, useful) \ -class clazz : public CastDebuffSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, spell) { } \ - bool isUseful() override { return useful; } \ -} +#define DEBUFF_ACTION_U(clazz, spell, useful) \ + class clazz : public CastDebuffSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, spell) {} \ + bool isUseful() override { return useful; } \ + } -#define DEBUFF_ACTION_R(clazz, spell, distance) \ -class clazz : public CastDebuffSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, spell) \ - { \ - range = distance; \ - } \ -} +#define DEBUFF_ACTION_R(clazz, spell, distance) \ + class clazz : public CastDebuffSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, spell) { range = distance; } \ + } -#define DEBUFF_ENEMY_ACTION(clazz, spell) \ -class clazz : public CastDebuffSpellOnAttackerAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, spell) { } \ -} +#define DEBUFF_ENEMY_ACTION(clazz, spell) \ + class clazz : public CastDebuffSpellOnAttackerAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, spell) {} \ + } -#define REACH_ACTION(clazz, spell, range) \ -class clazz : public CastReachTargetSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastReachTargetSpellAction(botAI, spell, range) { } \ -} +#define REACH_ACTION(clazz, spell, range) \ + class clazz : public CastReachTargetSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastReachTargetSpellAction(botAI, spell, range) {} \ + } -#define REACH_ACTION_U(clazz, spell, range, useful) \ -class clazz : public CastReachTargetSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastReachTargetSpellAction(botAI, spell, range) { } \ - bool isUseful() override { return useful; } \ -} +#define REACH_ACTION_U(clazz, spell, range, useful) \ + class clazz : public CastReachTargetSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastReachTargetSpellAction(botAI, spell, range) {} \ + bool isUseful() override { return useful; } \ + } -#define ENEMY_HEALER_ACTION(clazz, spell) \ -class clazz : public CastSpellOnEnemyHealerAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, spell) { } \ -} +#define ENEMY_HEALER_ACTION(clazz, spell) \ + class clazz : public CastSpellOnEnemyHealerAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, spell) {} \ + } +#define SNARE_ACTION(clazz, spell) \ + class clazz : public CastSnareSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastSnareSpellAction(botAI, spell) {} \ + } -#define SNARE_ACTION(clazz, spell) \ -class clazz : public CastSnareSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastSnareSpellAction(botAI, spell) { } \ -} +#define CC_ACTION(clazz, spell) \ + class clazz : public CastCrowdControlSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastCrowdControlSpellAction(botAI, spell) {} \ + } -#define CC_ACTION(clazz, spell) \ -class clazz : public CastCrowdControlSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastCrowdControlSpellAction(botAI, spell) { } \ -} - -#define PROTECT_ACTION(clazz, spell) \ -class clazz : public CastProtectSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastProtectSpellAction(botAI, spell) { } \ -} +#define PROTECT_ACTION(clazz, spell) \ + class clazz : public CastProtectSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastProtectSpellAction(botAI, spell) {} \ + } #define END_RANGED_SPELL_ACTION() \ -}; + } \ + ; -#define BEGIN_SPELL_ACTION(clazz, name) \ -class clazz : public CastSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastSpellAction(botAI, name) { } \ +#define BEGIN_SPELL_ACTION(clazz, name) \ + class clazz : public CastSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastSpellAction(botAI, name) {} #define END_SPELL_ACTION() \ -}; + } \ + ; -#define BEGIN_DEBUFF_ACTION(clazz, name) \ -class clazz : public CastDebuffSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, name) { } \ +#define BEGIN_DEBUFF_ACTION(clazz, name) \ + class clazz : public CastDebuffSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, name) {} #define BEGIN_RANGED_SPELL_ACTION(clazz, name) \ -class clazz : public CastSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastSpellAction(botAI, name) { } \ + class clazz : public CastSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastSpellAction(botAI, name) {} #define BEGIN_MELEE_SPELL_ACTION(clazz, name) \ -class clazz : public CastMeleeSpellAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, name) { } \ + class clazz : public CastMeleeSpellAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, name) {} #define END_RANGED_SPELL_ACTION() \ -}; + } \ + ; #define BEGIN_BUFF_ON_PARTY_ACTION(clazz, name) \ -class clazz : public BuffOnPartyAction \ -{ \ - public: \ - clazz(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, name) { } + class clazz : public BuffOnPartyAction \ + { \ + public: \ + clazz(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, name) {} // // Action node // // node_name , action, prerequisite -#define ACTION_NODE_P(name, spell, pre) \ -static ActionNode* name(PlayerbotAI* botAI) \ -{ \ - return new ActionNode(spell, \ - /*P*/ NextAction::array(0, new NextAction(pre), nullptr), \ - /*A*/ nullptr, \ - /*C*/ nullptr); \ -} +#define ACTION_NODE_P(name, spell, pre) \ + static ActionNode* name(PlayerbotAI* botAI) \ + { \ + return new ActionNode(spell, /*P*/ NextAction::array(0, new NextAction(pre), nullptr), /*A*/ nullptr, \ + /*C*/ nullptr); \ + } // node_name , action, alternative -#define ACTION_NODE_A(name, spell, alt) \ -static ActionNode* name(PlayerbotAI* botAI) \ -{ \ - return new ActionNode(spell, \ - /*P*/ nullptr, \ - /*A*/ NextAction::array(0, new NextAction(alt), nullptr), \ - /*C*/ nullptr); \ -} +#define ACTION_NODE_A(name, spell, alt) \ + static ActionNode* name(PlayerbotAI* botAI) \ + { \ + return new ActionNode(spell, /*P*/ nullptr, /*A*/ NextAction::array(0, new NextAction(alt), nullptr), \ + /*C*/ nullptr); \ + } // node_name , action, continuer -#define ACTION_NODE_C(name, spell, con) \ -static ActionNode* name(PlayerbotAI* botAI) \ -{ \ - return new ActionNode(spell, \ - /*P*/ nullptr, \ - /*A*/ nullptr, \ - /*C*/ NextAction::array(0, new NextAction(con), nullptr)); \ -} +#define ACTION_NODE_C(name, spell, con) \ + static ActionNode* name(PlayerbotAI* botAI) \ + { \ + return new ActionNode(spell, /*P*/ nullptr, /*A*/ nullptr, \ + /*C*/ NextAction::array(0, new NextAction(con), nullptr)); \ + } #endif diff --git a/src/strategy/AiObjectContext.cpp b/src/strategy/AiObjectContext.cpp index b65c5370..c844bb51 100644 --- a/src/strategy/AiObjectContext.cpp +++ b/src/strategy/AiObjectContext.cpp @@ -1,21 +1,23 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AiObjectContext.h" -#include "StrategyContext.h" + #include "ActionContext.h" #include "ChatActionContext.h" -#include "WorldPacketActionContext.h" #include "ChatTriggerContext.h" -#include "TriggerContext.h" -#include "SharedValueContext.h" -#include "WorldPacketTriggerContext.h" -#include "ValueContext.h" #include "Playerbots.h" -#include "raids/RaidTriggerContext.h" +#include "SharedValueContext.h" +#include "StrategyContext.h" +#include "TriggerContext.h" +#include "ValueContext.h" +#include "WorldPacketActionContext.h" +#include "WorldPacketTriggerContext.h" #include "raids/RaidActionContext.h" #include "raids/RaidStrategyContext.h" +#include "raids/RaidTriggerContext.h" #include "raids/naxxramas/RaidNaxxActionContext.h" #include "raids/naxxramas/RaidNaxxTriggerContext.h" @@ -26,7 +28,7 @@ AiObjectContext::AiObjectContext(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) strategyContexts.Add(new AssistStrategyContext()); strategyContexts.Add(new QuestStrategyContext()); strategyContexts.Add(new RaidStrategyContext()); - + actionContexts.Add(new ActionContext()); actionContexts.Add(new ChatActionContext()); actionContexts.Add(new WorldPacketActionContext()); @@ -116,35 +118,20 @@ std::set AiObjectContext::GetSiblingStrategy(std::string const name return strategyContexts.GetSiblings(name); } -Trigger* AiObjectContext::GetTrigger(std::string const name) -{ - return triggerContexts.GetContextObject(name, botAI); -} +Trigger* AiObjectContext::GetTrigger(std::string const name) { return triggerContexts.GetContextObject(name, botAI); } -Action* AiObjectContext::GetAction(std::string const name) -{ - return actionContexts.GetContextObject(name, botAI); -} +Action* AiObjectContext::GetAction(std::string const name) { return actionContexts.GetContextObject(name, botAI); } UntypedValue* AiObjectContext::GetUntypedValue(std::string const name) { return valueContexts.GetContextObject(name, botAI); } -std::set AiObjectContext::GetValues() -{ - return valueContexts.GetCreated(); -} +std::set AiObjectContext::GetValues() { return valueContexts.GetCreated(); } -std::set AiObjectContext::GetSupportedStrategies() -{ - return strategyContexts.supports(); -} +std::set AiObjectContext::GetSupportedStrategies() { return strategyContexts.supports(); } -std::set AiObjectContext::GetSupportedActions() -{ - return actionContexts.supports(); -} +std::set AiObjectContext::GetSupportedActions() { return actionContexts.supports(); } std::string const AiObjectContext::FormatValues() { @@ -166,7 +153,4 @@ std::string const AiObjectContext::FormatValues() return out.str(); } -void AiObjectContext::AddShared(NamedObjectContext* sharedValues) -{ - valueContexts.Add(sharedValues); -} +void AiObjectContext::AddShared(NamedObjectContext* sharedValues) { valueContexts.Add(sharedValues); } diff --git a/src/strategy/AiObjectContext.h b/src/strategy/AiObjectContext.h index 62db2265..f7bd2694 100644 --- a/src/strategy/AiObjectContext.h +++ b/src/strategy/AiObjectContext.h @@ -1,10 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_AIOBJECTCONTEXT_H #define _PLAYERBOT_AIOBJECTCONTEXT_H +#include +#include + #include "Common.h" #include "NamedObjectContext.h" #include "PlayerbotAIAware.h" @@ -12,62 +16,59 @@ #include "Trigger.h" #include "Value.h" -#include -#include - class PlayerbotAI; class AiObjectContext : public PlayerbotAIAware { - public: - AiObjectContext(PlayerbotAI* botAI); - virtual ~AiObjectContext() { } +public: + AiObjectContext(PlayerbotAI* botAI); + virtual ~AiObjectContext() {} - virtual Strategy* GetStrategy(std::string const name); - virtual std::set GetSiblingStrategy(std::string const name); - virtual Trigger* GetTrigger(std::string const name); - virtual Action* GetAction(std::string const name); - virtual UntypedValue* GetUntypedValue(std::string const name); + virtual Strategy* GetStrategy(std::string const name); + virtual std::set GetSiblingStrategy(std::string const name); + virtual Trigger* GetTrigger(std::string const name); + virtual Action* GetAction(std::string const name); + virtual UntypedValue* GetUntypedValue(std::string const name); - template - Value* GetValue(std::string const name) - { - return dynamic_cast*>(GetUntypedValue(name)); - } + template + Value* GetValue(std::string const name) + { + return dynamic_cast*>(GetUntypedValue(name)); + } - template - Value* GetValue(std::string const name, std::string const param) - { - return GetValue((std::string(name) + "::" + param)); - } + template + Value* GetValue(std::string const name, std::string const param) + { + return GetValue((std::string(name) + "::" + param)); + } - template - Value* GetValue(std::string const name, int32 param) - { - std::ostringstream out; - out << param; - return GetValue(name, out.str()); - } + template + Value* GetValue(std::string const name, int32 param) + { + std::ostringstream out; + out << param; + return GetValue(name, out.str()); + } - std::set GetValues(); - std::set GetSupportedStrategies(); - std::set GetSupportedActions(); - std::string const FormatValues(); + std::set GetValues(); + std::set GetSupportedStrategies(); + std::set GetSupportedActions(); + std::string const FormatValues(); - virtual void Update(); - virtual void Reset(); - virtual void AddShared(NamedObjectContext* sharedValues); + virtual void Update(); + virtual void Reset(); + virtual void AddShared(NamedObjectContext* sharedValues); - std::vector Save(); - void Load(std::vector data); + std::vector Save(); + void Load(std::vector data); - std::vector performanceStack; + std::vector performanceStack; - protected: - NamedObjectContextList strategyContexts; - NamedObjectContextList actionContexts; - NamedObjectContextList triggerContexts; - NamedObjectContextList valueContexts; +protected: + NamedObjectContextList strategyContexts; + NamedObjectContextList actionContexts; + NamedObjectContextList triggerContexts; + NamedObjectContextList valueContexts; }; #endif diff --git a/src/strategy/CustomStrategy.cpp b/src/strategy/CustomStrategy.cpp index 95df928c..cc6496d1 100644 --- a/src/strategy/CustomStrategy.cpp +++ b/src/strategy/CustomStrategy.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CustomStrategy.h" -#include "Playerbots.h" #include +#include "Playerbots.h" + std::map CustomStrategy::actionLinesCache; NextAction* toNextAction(std::string const action) @@ -33,7 +35,7 @@ NextAction** toNextActionArray(std::string const actions) res[index++] = na; } - res[index++] = nullptr; + res[index++] = nullptr; return res; } @@ -47,11 +49,9 @@ TriggerNode* toTriggerNode(std::string const actionLine) return nullptr; } -CustomStrategy::CustomStrategy(PlayerbotAI* botAI) : Strategy(botAI), Qualified() -{ -} +CustomStrategy::CustomStrategy(PlayerbotAI* botAI) : Strategy(botAI), Qualified() {} -void CustomStrategy::InitTriggers(std::vector &triggers) +void CustomStrategy::InitTriggers(std::vector& triggers) { if (actionLines.empty()) { @@ -68,7 +68,8 @@ void CustomStrategy::InitTriggers(std::vector &triggers) for (std::vector::iterator i = tokens.begin(); i != tokens.end(); ++i) { std::string const line = *i; - for (std::sregex_iterator j = std::sregex_iterator(line.begin(), line.end(), tpl); j != std::sregex_iterator(); ++j) + for (std::sregex_iterator j = std::sregex_iterator(line.begin(), line.end(), tpl); + j != std::sregex_iterator(); ++j) { std::smatch match = *j; std::string const actionLine = match[1].str(); @@ -88,7 +89,8 @@ void CustomStrategy::InitTriggers(std::vector &triggers) void CustomStrategy::LoadActionLines(uint32 owner) { - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_CUSTOM_STRATEGY_BY_OWNER_AND_NAME); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_CUSTOM_STRATEGY_BY_OWNER_AND_NAME); stmt->SetData(0, owner); stmt->SetData(1, qualifier); PreparedQueryResult result = PlayerbotsDatabase.Query(stmt); @@ -99,8 +101,7 @@ void CustomStrategy::LoadActionLines(uint32 owner) Field* fields = result->Fetch(); std::string const action = fields[1].Get(); actionLines.push_back(action); - } - while (result->NextRow()); + } while (result->NextRow()); } } diff --git a/src/strategy/CustomStrategy.h b/src/strategy/CustomStrategy.h index f2ad0bd7..82ec4d2b 100644 --- a/src/strategy/CustomStrategy.h +++ b/src/strategy/CustomStrategy.h @@ -1,30 +1,31 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CUSTOMSTRATEGY_H #define _PLAYERBOT_CUSTOMSTRATEGY_H -#include "Strategy.h" - #include +#include "Strategy.h" + class PlayerbotAI; class CustomStrategy : public Strategy, public Qualified { - public: - CustomStrategy(PlayerbotAI* botAI); +public: + CustomStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector &triggers) override; - std::string const getName() override { return std::string("custom::" + qualifier); } - void Reset(); + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return std::string("custom::" + qualifier); } + void Reset(); - static std::map actionLinesCache; + static std::map actionLinesCache; - private: - std::vector actionLines; - void LoadActionLines(uint32 owner); +private: + std::vector actionLines; + void LoadActionLines(uint32 owner); }; #endif diff --git a/src/strategy/Engine.cpp b/src/strategy/Engine.cpp index cf939ea9..d6960a68 100644 --- a/src/strategy/Engine.cpp +++ b/src/strategy/Engine.cpp @@ -1,13 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "Engine.h" + #include "Action.h" #include "Event.h" -#include "Queue.h" #include "PerformanceMonitor.h" #include "Playerbots.h" +#include "Queue.h" #include "Strategy.h" Engine::Engine(PlayerbotAI* botAI, AiObjectContext* factory) : PlayerbotAIAware(botAI), aiObjectContext(factory) @@ -125,12 +127,12 @@ void Engine::Init() MultiplyAndPush(strategy->getDefaultActions(), 0.0f, false, emptyEvent, "default"); } - if (testMode) - { + if (testMode) + { FILE* file = fopen("test.log", "w"); fprintf(file, "\n"); fclose(file); - } + } } bool Engine::DoNextAction(Unit* unit, uint32 depth, bool minimal) @@ -147,7 +149,7 @@ bool Engine::DoNextAction(Unit* unit, uint32 depth, bool minimal) // aiObjectContext->Update(); ProcessTriggers(minimal); PushDefaultActions(); - + uint32 iterations = 0; uint32 iterationsPerTick = queue.Size() * (minimal ? 2 : sPlayerbotAIConfig->iterationsPerTick); do @@ -156,7 +158,7 @@ bool Engine::DoNextAction(Unit* unit, uint32 depth, bool minimal) if (basket) { - float relevance = basket->getRelevance(); // just for reference + float relevance = basket->getRelevance(); // just for reference bool skipPrerequisites = basket->isSkipPrerequisites(); if (minimal && (relevance < 100)) @@ -172,12 +174,13 @@ bool Engine::DoNextAction(Unit* unit, uint32 depth, bool minimal) if (!action) { - //LOG_ERROR("playerbots", "Action: {} - is UNKNOWN - c:{} l:{}", actionNode->getName().c_str(), botAI->GetBot()->getClass(), botAI->GetBot()->GetLevel()); + // LOG_ERROR("playerbots", "Action: {} - is UNKNOWN - c:{} l:{}", actionNode->getName().c_str(), + // botAI->GetBot()->getClass(), botAI->GetBot()->GetLevel()); LogAction("A:%s - UNKNOWN", actionNode->getName().c_str()); } else if (action->isUseful()) { - for (std::vector::iterator i = multipliers.begin(); i!= multipliers.end(); i++) + for (std::vector::iterator i = multipliers.begin(); i != multipliers.end(); i++) { Multiplier* multiplier = *i; relevance *= multiplier->GetValue(action); @@ -185,7 +188,8 @@ bool Engine::DoNextAction(Unit* unit, uint32 depth, bool minimal) if (!relevance) { - LogAction("Multiplier %s made action %s useless", multiplier->getName().c_str(), action->getName().c_str()); + LogAction("Multiplier %s made action %s useless", multiplier->getName().c_str(), + action->getName().c_str()); break; } } @@ -203,7 +207,8 @@ bool Engine::DoNextAction(Unit* unit, uint32 depth, bool minimal) } } - PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_ACTION, action->getName(), &aiObjectContext->performanceStack); + PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_ACTION, action->getName(), + &aiObjectContext->performanceStack); actionExecuted = ListenAndExecute(action, event); if (pmo) pmo->finish(); @@ -264,8 +269,7 @@ bool Engine::DoNextAction(Unit* unit, uint32 depth, bool minimal) delete actionNode; } - } - while (basket && ++iterations <= iterationsPerTick); + } while (basket && ++iterations <= iterationsPerTick); // if (!basket) // { @@ -312,13 +316,14 @@ ActionNode* Engine::CreateActionNode(std::string const name) return node; } - return new ActionNode (name, - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); + return new ActionNode(name, + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); } -bool Engine::MultiplyAndPush(NextAction** actions, float forceRelevance, bool skipPrerequisites, Event event, char const* pushType) +bool Engine::MultiplyAndPush(NextAction** actions, float forceRelevance, bool skipPrerequisites, Event event, + char const* pushType) { bool pushed = false; if (actions) @@ -361,7 +366,7 @@ bool Engine::MultiplyAndPush(NextAction** actions, float forceRelevance, bool sk ActionResult Engine::ExecuteAction(std::string const name, Event event, std::string const qualifier) { - bool result = false; + bool result = false; ActionNode* actionNode = CreateActionNode(name); if (!actionNode) @@ -399,7 +404,7 @@ ActionResult Engine::ExecuteAction(std::string const name, Event event, std::str delete actionNode; - return result ? ACTION_RESULT_OK : ACTION_RESULT_FAILED; + return result ? ACTION_RESULT_OK : ACTION_RESULT_FAILED; } void Engine::addStrategy(std::string const name) @@ -421,21 +426,20 @@ void Engine::addStrategy(std::string const name) void Engine::addStrategies(std::string first, ...) { - addStrategy(first); + addStrategy(first); - va_list vl; - va_start(vl, first); + va_list vl; + va_start(vl, first); - const char* cur; - do - { - cur = va_arg(vl, const char*); - if (cur) - addStrategy(cur); - } - while (cur); + const char* cur; + do + { + cur = va_arg(vl, const char*); + if (cur) + addStrategy(cur); + } while (cur); - va_end(vl); + va_end(vl); } bool Engine::removeStrategy(std::string const name) @@ -463,10 +467,7 @@ void Engine::toggleStrategy(std::string const name) addStrategy(name); } -bool Engine::HasStrategy(std::string const name) -{ - return strategies.find(name) != strategies.end(); -} +bool Engine::HasStrategy(std::string const name) { return strategies.find(name) != strategies.end(); } void Engine::ProcessTriggers(bool minimal) { @@ -486,16 +487,17 @@ void Engine::ProcessTriggers(bool minimal) if (!trigger) continue; - + if (fires.find(trigger) != fires.end()) continue; - + if (testMode || trigger->needCheck()) { if (minimal && node->getFirstRelevance() < 100) continue; - PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_TRIGGER, trigger->getName(), &aiObjectContext->performanceStack); + PerformanceMonitorOperation* pmo = + sPerformanceMonitor->start(PERF_MON_TRIGGER, trigger->getName(), &aiObjectContext->performanceStack); Event event = trigger->Check(); if (pmo) pmo->finish(); @@ -574,12 +576,12 @@ void Engine::PushAgain(ActionNode* actionNode, float relevance, Event event) bool Engine::ContainsStrategy(StrategyType type) { - for (std::map::iterator i = strategies.begin(); i != strategies.end(); i++) - { - if (i->second->GetType() & type) - return true; - } - return false; + for (std::map::iterator i = strategies.begin(); i != strategies.end(); i++) + { + if (i->second->GetType() & type) + return true; + } + return false; } Action* Engine::InitializeAction(ActionNode* actionNode) @@ -658,7 +660,7 @@ void Engine::LogAction(char const* format, ...) } else { - LOG_DEBUG("playerbots", "{} {}", bot->GetName().c_str(), buf); + LOG_DEBUG("playerbots", "{} {}", bot->GetName().c_str(), buf); } } @@ -671,13 +673,13 @@ void Engine::ChangeStrategy(std::string const names) switch (name[0]) { case '+': - addStrategy(name+1); + addStrategy(name + 1); break; case '-': - removeStrategy(name+1); + removeStrategy(name + 1); break; case '~': - toggleStrategy(name+1); + toggleStrategy(name + 1); break; case '?': botAI->TellMaster(ListStrategies()); @@ -696,5 +698,5 @@ void Engine::LogValues() return; std::string const text = botAI->GetAiObjectContext()->FormatValues(); - LOG_DEBUG("playerbots", "Values for {}: {}", bot->GetName().c_str(), text.c_str()); + LOG_DEBUG("playerbots", "Values for {}: {}", bot->GetName().c_str(), text.c_str()); } diff --git a/src/strategy/Engine.h b/src/strategy/Engine.h index 96f86c2b..f25f97b3 100644 --- a/src/strategy/Engine.h +++ b/src/strategy/Engine.h @@ -1,18 +1,19 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ENGINE_H #define _PLAYERBOT_ENGINE_H +#include + #include "Multiplier.h" -#include "Queue.h" #include "PlayerbotAIAware.h" +#include "Queue.h" #include "Strategy.h" #include "Trigger.h" -#include - class Action; class ActionNode; class AiObjectContext; @@ -31,97 +32,86 @@ enum ActionResult class ActionExecutionListener { - public: - virtual ~ActionExecutionListener() { }; +public: + virtual ~ActionExecutionListener(){}; - virtual bool Before(Action* action, Event event) = 0; - virtual bool AllowExecution(Action* action, Event event) = 0; - virtual void After(Action* action, bool executed, Event event) = 0; - virtual bool OverrideResult(Action* action, bool executed, Event event) = 0; + virtual bool Before(Action* action, Event event) = 0; + virtual bool AllowExecution(Action* action, Event event) = 0; + virtual void After(Action* action, bool executed, Event event) = 0; + virtual bool OverrideResult(Action* action, bool executed, Event event) = 0; }; class ActionExecutionListeners : public ActionExecutionListener { - public: - virtual ~ActionExecutionListeners(); +public: + virtual ~ActionExecutionListeners(); - bool Before(Action* action, Event event) override; - bool AllowExecution(Action* action, Event event) override; - void After(Action* action, bool executed, Event event) override; - bool OverrideResult(Action* action, bool executed, Event event) override; + bool Before(Action* action, Event event) override; + bool AllowExecution(Action* action, Event event) override; + void After(Action* action, bool executed, Event event) override; + bool OverrideResult(Action* action, bool executed, Event event) override; - void Add(ActionExecutionListener* listener) - { - listeners.push_back(listener); - } + void Add(ActionExecutionListener* listener) { listeners.push_back(listener); } - void Remove(ActionExecutionListener* listener) - { - listeners.remove(listener); - } + void Remove(ActionExecutionListener* listener) { listeners.remove(listener); } - private: - std::list listeners; +private: + std::list listeners; }; class Engine : public PlayerbotAIAware { - public: - Engine(PlayerbotAI* botAI, AiObjectContext* factory); +public: + Engine(PlayerbotAI* botAI, AiObjectContext* factory); - void Init(); - void addStrategy(std::string const name); - void addStrategies(std::string first, ...); - bool removeStrategy(std::string const name); - bool HasStrategy(std::string const name); - void removeAllStrategies(); - void toggleStrategy(std::string const name); - std::string const ListStrategies(); - std::vector GetStrategies(); - bool ContainsStrategy(StrategyType type); - void ChangeStrategy(std::string const names); - std::string const GetLastAction() { return lastAction; } + void Init(); + void addStrategy(std::string const name); + void addStrategies(std::string first, ...); + bool removeStrategy(std::string const name); + bool HasStrategy(std::string const name); + void removeAllStrategies(); + void toggleStrategy(std::string const name); + std::string const ListStrategies(); + std::vector GetStrategies(); + bool ContainsStrategy(StrategyType type); + void ChangeStrategy(std::string const names); + std::string const GetLastAction() { return lastAction; } - virtual bool DoNextAction(Unit*, uint32 depth = 0, bool minimal = false); - ActionResult ExecuteAction(std::string const name, Event event = Event(), std::string const qualifier = ""); + virtual bool DoNextAction(Unit*, uint32 depth = 0, bool minimal = false); + ActionResult ExecuteAction(std::string const name, Event event = Event(), std::string const qualifier = ""); - void AddActionExecutionListener(ActionExecutionListener* listener) - { - actionExecutionListeners.Add(listener); - } + void AddActionExecutionListener(ActionExecutionListener* listener) { actionExecutionListeners.Add(listener); } - void removeActionExecutionListener(ActionExecutionListener* listener) - { - actionExecutionListeners.Remove(listener); - } + void removeActionExecutionListener(ActionExecutionListener* listener) { actionExecutionListeners.Remove(listener); } - virtual ~Engine(void); + virtual ~Engine(void); - bool testMode; + bool testMode; - private: - bool MultiplyAndPush(NextAction** actions, float forceRelevance, bool skipPrerequisites, Event event, const char* pushType); - void Reset(); - void ProcessTriggers(bool minimal); - void PushDefaultActions(); - void PushAgain(ActionNode* actionNode, float relevance, Event event); - ActionNode* CreateActionNode(std::string const name); - Action* InitializeAction(ActionNode* actionNode); - bool ListenAndExecute(Action* action, Event event); +private: + bool MultiplyAndPush(NextAction** actions, float forceRelevance, bool skipPrerequisites, Event event, + const char* pushType); + void Reset(); + void ProcessTriggers(bool minimal); + void PushDefaultActions(); + void PushAgain(ActionNode* actionNode, float relevance, Event event); + ActionNode* CreateActionNode(std::string const name); + Action* InitializeAction(ActionNode* actionNode); + bool ListenAndExecute(Action* action, Event event); - void LogAction(char const* format, ...); - void LogValues(); + void LogAction(char const* format, ...); + void LogValues(); - ActionExecutionListeners actionExecutionListeners; + ActionExecutionListeners actionExecutionListeners; - protected: - Queue queue; - std::vector triggers; - std::vector multipliers; - AiObjectContext* aiObjectContext; - std::map strategies; - float lastRelevance; - std::string lastAction; +protected: + Queue queue; + std::vector triggers; + std::vector multipliers; + AiObjectContext* aiObjectContext; + std::map strategies; + float lastRelevance; + std::string lastAction; }; #endif diff --git a/src/strategy/Event.cpp b/src/strategy/Event.cpp index ea81abf7..1835d19c 100644 --- a/src/strategy/Event.cpp +++ b/src/strategy/Event.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "Event.h" + #include "Playerbots.h" Event::Event(std::string const source, ObjectGuid object, Player* owner) : source(source), owner(owner) diff --git a/src/strategy/Event.h b/src/strategy/Event.h index 4601d4c5..0ec10658 100644 --- a/src/strategy/Event.h +++ b/src/strategy/Event.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_EVENT_H @@ -12,27 +13,33 @@ class Player; class Event { - public: - Event(Event const& other) : source(other.source), param(other.param), packet(other.packet), owner(other.owner) { } - Event() { } - Event(std::string const source) : source(source) { } - Event(std::string const source, std::string const param, Player* owner = nullptr) : source(source), param(param), owner(owner) { } - Event(std::string const source, WorldPacket& packet, Player* owner = nullptr) : source(source), packet(packet), owner(owner) { } - Event(std::string const source, ObjectGuid object, Player* owner = nullptr); - virtual ~Event() { } +public: + Event(Event const& other) : source(other.source), param(other.param), packet(other.packet), owner(other.owner) {} + Event() {} + Event(std::string const source) : source(source) {} + Event(std::string const source, std::string const param, Player* owner = nullptr) + : source(source), param(param), owner(owner) + { + } + Event(std::string const source, WorldPacket& packet, Player* owner = nullptr) + : source(source), packet(packet), owner(owner) + { + } + Event(std::string const source, ObjectGuid object, Player* owner = nullptr); + virtual ~Event() {} - std::string const GetSource() { return source; } - std::string const getParam() { return param; } - WorldPacket& getPacket() { return packet; } - ObjectGuid getObject(); - Player* getOwner() { return owner; } - bool operator! () const { return source.empty(); } + std::string const GetSource() { return source; } + std::string const getParam() { return param; } + WorldPacket& getPacket() { return packet; } + ObjectGuid getObject(); + Player* getOwner() { return owner; } + bool operator!() const { return source.empty(); } - protected: - std::string source; - std::string param; - WorldPacket packet; - Player* owner = nullptr; +protected: + std::string source; + std::string param; + WorldPacket packet; + Player* owner = nullptr; }; #endif diff --git a/src/strategy/ExternalEventHelper.cpp b/src/strategy/ExternalEventHelper.cpp index 8ef4a5ba..f5647cf4 100644 --- a/src/strategy/ExternalEventHelper.cpp +++ b/src/strategy/ExternalEventHelper.cpp @@ -1,11 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ExternalEventHelper.h" -#include "Trigger.h" + #include "ChatHelper.h" #include "Playerbots.h" +#include "Trigger.h" bool ExternalEventHelper::ParseChatCommand(std::string const command, Player* owner) { @@ -37,7 +39,8 @@ bool ExternalEventHelper::ParseChatCommand(std::string const command, Player* ow return true; } -void ExternalEventHelper::HandlePacket(std::map& handlers, WorldPacket const& packet, Player* owner) +void ExternalEventHelper::HandlePacket(std::map& handlers, WorldPacket const& packet, + Player* owner) { uint16 opcode = packet.GetOpcode(); std::string const name = handlers[opcode]; diff --git a/src/strategy/ExternalEventHelper.h b/src/strategy/ExternalEventHelper.h index 8b176868..6e1e70e3 100644 --- a/src/strategy/ExternalEventHelper.h +++ b/src/strategy/ExternalEventHelper.h @@ -1,29 +1,30 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_EXTERNALEVENTHELPER_H #define _PLAYERBOT_EXTERNALEVENTHELPER_H -#include "Common.h" - #include +#include "Common.h" + class AiObjectContext; class Player; class WorldPacket; class ExternalEventHelper { - public: - ExternalEventHelper(AiObjectContext* aiObjectContext) : aiObjectContext(aiObjectContext) { } +public: + ExternalEventHelper(AiObjectContext* aiObjectContext) : aiObjectContext(aiObjectContext) {} - bool ParseChatCommand(std::string const command, Player* owner = nullptr); - void HandlePacket(std::map& handlers, WorldPacket const& packet, Player* owner = nullptr); - bool HandleCommand(std::string const name, std::string const param, Player* owner = nullptr); + bool ParseChatCommand(std::string const command, Player* owner = nullptr); + void HandlePacket(std::map& handlers, WorldPacket const& packet, Player* owner = nullptr); + bool HandleCommand(std::string const name, std::string const param, Player* owner = nullptr); - private: - AiObjectContext* aiObjectContext; +private: + AiObjectContext* aiObjectContext; }; #endif diff --git a/src/strategy/ItemVisitors.cpp b/src/strategy/ItemVisitors.cpp index ce9d0266..2579fe9f 100644 --- a/src/strategy/ItemVisitors.cpp +++ b/src/strategy/ItemVisitors.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ItemVisitors.h" + #include "Playerbots.h" bool FindUsableItemVisitor::Visit(Item* item) @@ -15,7 +17,8 @@ bool FindUsableItemVisitor::Visit(Item* item) bool FindPotionVisitor::Accept(ItemTemplate const* proto) { - if (proto->Class == ITEM_CLASS_CONSUMABLE && (proto->SubClass == ITEM_SUBCLASS_POTION || proto->SubClass == ITEM_SUBCLASS_FLASK)) + if (proto->Class == ITEM_CLASS_CONSUMABLE && + (proto->SubClass == ITEM_SUBCLASS_POTION || proto->SubClass == ITEM_SUBCLASS_FLASK)) { for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; j++) { diff --git a/src/strategy/ItemVisitors.h b/src/strategy/ItemVisitors.h index d4e0244c..cc46d877 100644 --- a/src/strategy/ItemVisitors.h +++ b/src/strategy/ItemVisitors.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ITEMVISITORS_H @@ -17,407 +18,401 @@ char* strstri(char const* str1, char const* str2); enum IterateItemsMask : uint32 { - ITERATE_ITEMS_IN_BAGS = 1, - ITERATE_ITEMS_IN_EQUIP = 2, - ITERATE_ITEMS_IN_BANK = 4, - ITERATE_ALL_ITEMS = 255 + ITERATE_ITEMS_IN_BAGS = 1, + ITERATE_ITEMS_IN_EQUIP = 2, + ITERATE_ITEMS_IN_BANK = 4, + ITERATE_ALL_ITEMS = 255 }; class IterateItemsVisitor { - public: - IterateItemsVisitor() { } +public: + IterateItemsVisitor() {} - virtual bool Visit(Item* item) = 0; + virtual bool Visit(Item* item) = 0; }; class FindItemVisitor : public IterateItemsVisitor { - public: - FindItemVisitor() : IterateItemsVisitor(), result() { } +public: + FindItemVisitor() : IterateItemsVisitor(), result() {} - bool Visit(Item* item) override - { - if (!Accept(item->GetTemplate())) - return true; - - result.push_back(item); + bool Visit(Item* item) override + { + if (!Accept(item->GetTemplate())) return true; - } - std::vector& GetResult() { return result; } + result.push_back(item); + return true; + } - protected: - virtual bool Accept(ItemTemplate const* proto) = 0; + std::vector& GetResult() { return result; } - private: - std::vector result; +protected: + virtual bool Accept(ItemTemplate const* proto) = 0; + +private: + std::vector result; }; class FindUsableItemVisitor : public FindItemVisitor { - public: - FindUsableItemVisitor(Player* bot) : FindItemVisitor(), bot(bot) { } +public: + FindUsableItemVisitor(Player* bot) : FindItemVisitor(), bot(bot) {} - bool Visit(Item* item) override; + bool Visit(Item* item) override; - private: - Player* bot; +private: + Player* bot; }; class FindItemsByQualityVisitor : public IterateItemsVisitor { - public: - FindItemsByQualityVisitor(uint32 quality, uint32 count) : IterateItemsVisitor(), quality(quality), count(count) { } +public: + FindItemsByQualityVisitor(uint32 quality, uint32 count) : IterateItemsVisitor(), quality(quality), count(count) {} - bool Visit(Item* item) override - { - if (item->GetTemplate()->Quality != quality) - return true; - - if (result.size() >= (size_t)count) - return false; - - result.push_back(item); + bool Visit(Item* item) override + { + if (item->GetTemplate()->Quality != quality) return true; - } - std::vector& GetResult() - { - return result; - } + if (result.size() >= (size_t)count) + return false; - private: - uint32 quality; - uint32 count; - std::vector result; + result.push_back(item); + return true; + } + + std::vector& GetResult() { return result; } + +private: + uint32 quality; + uint32 count; + std::vector result; }; class FindItemsToTradeByQualityVisitor : public FindItemsByQualityVisitor { - public: - FindItemsToTradeByQualityVisitor(uint32 quality, uint32 count) : FindItemsByQualityVisitor(quality, count) { } +public: + FindItemsToTradeByQualityVisitor(uint32 quality, uint32 count) : FindItemsByQualityVisitor(quality, count) {} - bool Visit(Item* item) override - { - if (item->IsSoulBound()) - return true; + bool Visit(Item* item) override + { + if (item->IsSoulBound()) + return true; - return FindItemsByQualityVisitor::Visit(item); - } + return FindItemsByQualityVisitor::Visit(item); + } }; class FindItemsToTradeByClassVisitor : public IterateItemsVisitor { - public: - FindItemsToTradeByClassVisitor(uint32 itemClass, uint32 itemSubClass, uint32 count) - : IterateItemsVisitor(), itemClass(itemClass), itemSubClass(itemSubClass), count(count) { } // reorder args - whipowill +public: + FindItemsToTradeByClassVisitor(uint32 itemClass, uint32 itemSubClass, uint32 count) + : IterateItemsVisitor(), itemClass(itemClass), itemSubClass(itemSubClass), count(count) + { + } // reorder args - whipowill - bool Visit(Item* item) override - { - if (item->IsSoulBound()) - return true; - - if (item->GetTemplate()->Class != itemClass || item->GetTemplate()->SubClass != itemSubClass) - return true; - - if (result.size() >= (size_t)count) - return false; - - result.push_back(item); + bool Visit(Item* item) override + { + if (item->IsSoulBound()) return true; - } - std::vector& GetResult() - { - return result; - } + if (item->GetTemplate()->Class != itemClass || item->GetTemplate()->SubClass != itemSubClass) + return true; - private: - uint32 itemClass; - uint32 itemSubClass; - uint32 count; - std::vector result; + if (result.size() >= (size_t)count) + return false; + + result.push_back(item); + return true; + } + + std::vector& GetResult() { return result; } + +private: + uint32 itemClass; + uint32 itemSubClass; + uint32 count; + std::vector result; }; class QueryItemCountVisitor : public IterateItemsVisitor { - public: - QueryItemCountVisitor(uint32 itemId) : count(0), itemId(itemId) { } +public: + QueryItemCountVisitor(uint32 itemId) : count(0), itemId(itemId) {} - bool Visit(Item* item) override - { - if (item->GetTemplate()->ItemId == itemId) - count += item->GetCount(); + bool Visit(Item* item) override + { + if (item->GetTemplate()->ItemId == itemId) + count += item->GetCount(); - return true; - } + return true; + } - uint32 GetCount() { return count; } + uint32 GetCount() { return count; } - protected: - uint32 count; - uint32 itemId; +protected: + uint32 count; + uint32 itemId; }; class QueryNamedItemCountVisitor : public QueryItemCountVisitor { - public: - QueryNamedItemCountVisitor(std::string const name) : QueryItemCountVisitor(0), name(name) { } +public: + QueryNamedItemCountVisitor(std::string const name) : QueryItemCountVisitor(0), name(name) {} - bool Visit(Item* item) override - { - ItemTemplate const* proto = item->GetTemplate(); - if (proto && proto->Name1.c_str() && strstri(proto->Name1.c_str(), name.c_str())) - count += item->GetCount(); + bool Visit(Item* item) override + { + ItemTemplate const* proto = item->GetTemplate(); + if (proto && proto->Name1.c_str() && strstri(proto->Name1.c_str(), name.c_str())) + count += item->GetCount(); - return true; - } + return true; + } - private: - std::string const name; +private: + std::string const name; }; class FindNamedItemVisitor : public FindItemVisitor { - public: - FindNamedItemVisitor([[maybe_unused]] Player* bot, std::string const name) : FindItemVisitor(), name(name) { } +public: + FindNamedItemVisitor([[maybe_unused]] Player* bot, std::string const name) : FindItemVisitor(), name(name) {} - bool Accept(ItemTemplate const* proto) override - { - return proto && proto->Name1.c_str() && strstri(proto->Name1.c_str(), name.c_str()); - } + bool Accept(ItemTemplate const* proto) override + { + return proto && proto->Name1.c_str() && strstri(proto->Name1.c_str(), name.c_str()); + } - private: - std::string const name; +private: + std::string const name; }; class FindItemByIdVisitor : public FindItemVisitor { - public: - FindItemByIdVisitor(uint32 id) : FindItemVisitor(), id(id) { } +public: + FindItemByIdVisitor(uint32 id) : FindItemVisitor(), id(id) {} - bool Accept(ItemTemplate const* proto) override - { - return proto->ItemId == id; - } + bool Accept(ItemTemplate const* proto) override { return proto->ItemId == id; } - private: - uint32 id; +private: + uint32 id; }; class FindItemByIdsVisitor : public FindItemVisitor { - public: - FindItemByIdsVisitor(ItemIds ids) : FindItemVisitor(), ids(ids) { } +public: + FindItemByIdsVisitor(ItemIds ids) : FindItemVisitor(), ids(ids) {} - bool Accept(ItemTemplate const* proto) override - { - return ids.find(proto->ItemId) != ids.end(); - } + bool Accept(ItemTemplate const* proto) override { return ids.find(proto->ItemId) != ids.end(); } - private: - ItemIds ids; +private: + ItemIds ids; }; class ListItemsVisitor : public IterateItemsVisitor { - public: - ListItemsVisitor() : IterateItemsVisitor() { } +public: + ListItemsVisitor() : IterateItemsVisitor() {} - std::map items; - std::map soulbound; + std::map items; + std::map soulbound; - bool Visit(Item* item) override - { - uint32 id = item->GetTemplate()->ItemId; + bool Visit(Item* item) override + { + uint32 id = item->GetTemplate()->ItemId; - if (items.find(id) == items.end()) - items[id] = 0; + if (items.find(id) == items.end()) + items[id] = 0; - items[id] += item->GetCount(); - soulbound[id] = item->IsSoulBound(); - return true; - } + items[id] += item->GetCount(); + soulbound[id] = item->IsSoulBound(); + return true; + } }; class ItemCountByQuality : public IterateItemsVisitor { - public: - ItemCountByQuality() : IterateItemsVisitor() - { - for (uint32 i = 0; i < MAX_ITEM_QUALITY; ++i) - count[i] = 0; - } +public: + ItemCountByQuality() : IterateItemsVisitor() + { + for (uint32 i = 0; i < MAX_ITEM_QUALITY; ++i) + count[i] = 0; + } - bool Visit(Item* item) override - { - ++count[item->GetTemplate()->Quality]; - return true; - } + bool Visit(Item* item) override + { + ++count[item->GetTemplate()->Quality]; + return true; + } - public: - std::map count; +public: + std::map count; }; class FindPotionVisitor : public FindUsableItemVisitor { - public: - FindPotionVisitor(Player* bot, uint32 effectId) : FindUsableItemVisitor(bot), effectId(effectId) { } +public: + FindPotionVisitor(Player* bot, uint32 effectId) : FindUsableItemVisitor(bot), effectId(effectId) {} - bool Accept(ItemTemplate const* proto) override; + bool Accept(ItemTemplate const* proto) override; - private: - uint32 effectId; +private: + uint32 effectId; }; class FindFoodVisitor : public FindUsableItemVisitor { - public: - FindFoodVisitor(Player* bot, uint32 spellCategory, bool conjured = false) : FindUsableItemVisitor(bot), - spellCategory(spellCategory), conjured(conjured) { } +public: + FindFoodVisitor(Player* bot, uint32 spellCategory, bool conjured = false) + : FindUsableItemVisitor(bot), spellCategory(spellCategory), conjured(conjured) + { + } - bool Accept(ItemTemplate const* proto) override - { - return proto->Class == ITEM_CLASS_CONSUMABLE && (proto->SubClass == ITEM_SUBCLASS_CONSUMABLE || proto->SubClass == ITEM_SUBCLASS_FOOD) && - proto->Spells[0].SpellCategory == spellCategory && (!conjured || proto->IsConjuredConsumable()); - } + bool Accept(ItemTemplate const* proto) override + { + return proto->Class == ITEM_CLASS_CONSUMABLE && + (proto->SubClass == ITEM_SUBCLASS_CONSUMABLE || proto->SubClass == ITEM_SUBCLASS_FOOD) && + proto->Spells[0].SpellCategory == spellCategory && (!conjured || proto->IsConjuredConsumable()); + } - private: - uint32 spellCategory; - bool conjured; +private: + uint32 spellCategory; + bool conjured; }; class FindMountVisitor : public FindUsableItemVisitor { - public: - FindMountVisitor(Player* bot) : FindUsableItemVisitor(bot) { } +public: + FindMountVisitor(Player* bot) : FindUsableItemVisitor(bot) {} - bool Accept(ItemTemplate const* proto) override; + bool Accept(ItemTemplate const* proto) override; - private: - uint32 effectId; +private: + uint32 effectId; }; class FindPetVisitor : public FindUsableItemVisitor { - public: - FindPetVisitor(Player* bot) : FindUsableItemVisitor(bot) { } +public: + FindPetVisitor(Player* bot) : FindUsableItemVisitor(bot) {} - bool Accept(ItemTemplate const* proto) override; + bool Accept(ItemTemplate const* proto) override; }; class FindAmmoVisitor : public FindUsableItemVisitor { - public: - FindAmmoVisitor(Player* bot, uint32 weaponType) : FindUsableItemVisitor(bot), weaponType(weaponType) { } +public: + FindAmmoVisitor(Player* bot, uint32 weaponType) : FindUsableItemVisitor(bot), weaponType(weaponType) {} - bool Accept(ItemTemplate const* proto)override + bool Accept(ItemTemplate const* proto) override + { + if (proto->Class == ITEM_CLASS_PROJECTILE) { - if (proto->Class == ITEM_CLASS_PROJECTILE) + uint32 subClass = 0; + switch (weaponType) { - uint32 subClass = 0; - switch (weaponType) - { - case ITEM_SUBCLASS_WEAPON_GUN: - subClass = ITEM_SUBCLASS_BULLET; - break; - case ITEM_SUBCLASS_WEAPON_BOW: - case ITEM_SUBCLASS_WEAPON_CROSSBOW: - subClass = ITEM_SUBCLASS_ARROW; - break; - } - - if (!subClass) - return false; - - if (proto->SubClass == subClass) - return true; + case ITEM_SUBCLASS_WEAPON_GUN: + subClass = ITEM_SUBCLASS_BULLET; + break; + case ITEM_SUBCLASS_WEAPON_BOW: + case ITEM_SUBCLASS_WEAPON_CROSSBOW: + subClass = ITEM_SUBCLASS_ARROW; + break; } - return false; + if (!subClass) + return false; + + if (proto->SubClass == subClass) + return true; } - private: - uint32 weaponType; + return false; + } + +private: + uint32 weaponType; }; class FindQuestItemVisitor : public FindUsableItemVisitor { - public: - FindQuestItemVisitor(Player* bot) : FindUsableItemVisitor(bot) { } +public: + FindQuestItemVisitor(Player* bot) : FindUsableItemVisitor(bot) {} - bool Accept(ItemTemplate const* proto) override + bool Accept(ItemTemplate const* proto) override + { + if (proto->Class == ITEM_CLASS_QUEST) { - if (proto->Class == ITEM_CLASS_QUEST) - { - return true; - } - return false; + return true; } + return false; + } }; class FindRecipeVisitor : public FindUsableItemVisitor { - public: - FindRecipeVisitor(Player* bot, SkillType skill = SKILL_NONE) : FindUsableItemVisitor(bot), skill(skill) { }; +public: + FindRecipeVisitor(Player* bot, SkillType skill = SKILL_NONE) : FindUsableItemVisitor(bot), skill(skill){}; - bool Accept(ItemTemplate const* proto) override + bool Accept(ItemTemplate const* proto) override + { + if (proto->Class == ITEM_CLASS_RECIPE) { - if (proto->Class == ITEM_CLASS_RECIPE) + if (skill == SKILL_NONE) + return true; + + switch (proto->SubClass) { - if (skill == SKILL_NONE) - return true; - - switch (proto->SubClass) - { - case ITEM_SUBCLASS_LEATHERWORKING_PATTERN: - return skill == SKILL_LEATHERWORKING; - case ITEM_SUBCLASS_TAILORING_PATTERN: - return skill == SKILL_TAILORING; - case ITEM_SUBCLASS_ENGINEERING_SCHEMATIC: - return skill == SKILL_ENGINEERING; - case ITEM_SUBCLASS_BLACKSMITHING: - return skill == SKILL_BLACKSMITHING; - case ITEM_SUBCLASS_COOKING_RECIPE: - return skill == SKILL_COOKING; - case ITEM_SUBCLASS_ALCHEMY_RECIPE: - return skill == SKILL_ALCHEMY; - case ITEM_SUBCLASS_FIRST_AID_MANUAL: - return skill == SKILL_FIRST_AID; - case ITEM_SUBCLASS_ENCHANTING_FORMULA: - return skill == SKILL_ENCHANTING; - case ITEM_SUBCLASS_FISHING_MANUAL: - return skill == SKILL_FISHING; - } + case ITEM_SUBCLASS_LEATHERWORKING_PATTERN: + return skill == SKILL_LEATHERWORKING; + case ITEM_SUBCLASS_TAILORING_PATTERN: + return skill == SKILL_TAILORING; + case ITEM_SUBCLASS_ENGINEERING_SCHEMATIC: + return skill == SKILL_ENGINEERING; + case ITEM_SUBCLASS_BLACKSMITHING: + return skill == SKILL_BLACKSMITHING; + case ITEM_SUBCLASS_COOKING_RECIPE: + return skill == SKILL_COOKING; + case ITEM_SUBCLASS_ALCHEMY_RECIPE: + return skill == SKILL_ALCHEMY; + case ITEM_SUBCLASS_FIRST_AID_MANUAL: + return skill == SKILL_FIRST_AID; + case ITEM_SUBCLASS_ENCHANTING_FORMULA: + return skill == SKILL_ENCHANTING; + case ITEM_SUBCLASS_FISHING_MANUAL: + return skill == SKILL_FISHING; } - - return false; } - private: - SkillType skill; + return false; + } + +private: + SkillType skill; }; class FindItemUsageVisitor : public FindUsableItemVisitor { - public: - FindItemUsageVisitor(Player* bot, ItemUsage usage = ITEM_USAGE_NONE); +public: + FindItemUsageVisitor(Player* bot, ItemUsage usage = ITEM_USAGE_NONE); - bool Accept(ItemTemplate const* proto) override; + bool Accept(ItemTemplate const* proto) override; - private: - AiObjectContext* context; - ItemUsage usage; +private: + AiObjectContext* context; + ItemUsage usage; }; class FindUsableNamedItemVisitor : public FindUsableItemVisitor { - public: - FindUsableNamedItemVisitor(Player* bot, std::string name): FindUsableItemVisitor(bot), name(name) {} +public: + FindUsableNamedItemVisitor(Player* bot, std::string name) : FindUsableItemVisitor(bot), name(name) {} - bool Accept(ItemTemplate const* proto) override; - private: - std::string name; + bool Accept(ItemTemplate const* proto) override; + +private: + std::string name; }; #endif diff --git a/src/strategy/Multiplier.h b/src/strategy/Multiplier.h index 7bb39c73..133bda86 100644 --- a/src/strategy/Multiplier.h +++ b/src/strategy/Multiplier.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MULTIPLIER_H @@ -12,11 +13,11 @@ class PlayerbotAI; class Multiplier : public AiNamedObject { - public: - Multiplier(PlayerbotAI* botAI, std::string const name) : AiNamedObject(botAI, name) {} - virtual ~Multiplier() { } +public: + Multiplier(PlayerbotAI* botAI, std::string const name) : AiNamedObject(botAI, name) {} + virtual ~Multiplier() {} - virtual float GetValue([[maybe_unused]] Action* action) { return 1.0f; } + virtual float GetValue([[maybe_unused]] Action* action) { return 1.0f; } }; #endif diff --git a/src/strategy/NamedObjectContext.cpp b/src/strategy/NamedObjectContext.cpp index 1c53b55f..308c913b 100644 --- a/src/strategy/NamedObjectContext.cpp +++ b/src/strategy/NamedObjectContext.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "NamedObjectContext.h" + #include "Playerbots.h" void Qualified::Qualify(int qual) @@ -24,7 +26,7 @@ std::string const Qualified::MultiQualify(std::vector qualifiers) std::vector Qualified::getMultiQualifiers(std::string const qualifier1) { std::istringstream iss(qualifier1); - return { std::istream_iterator{iss}, std::istream_iterator{} }; + return {std::istream_iterator{iss}, std::istream_iterator{}}; } int32 Qualified::getMultiQualifier(std::string const qualifier1, uint32 pos) diff --git a/src/strategy/NamedObjectContext.h b/src/strategy/NamedObjectContext.h index 7f4509e7..25b66b3d 100644 --- a/src/strategy/NamedObjectContext.h +++ b/src/strategy/NamedObjectContext.h @@ -1,283 +1,272 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_NAMEDOBJECTCONEXT_H #define _PLAYERBOT_NAMEDOBJECTCONEXT_H -#include "Common.h" - -#include -#include -#include #include +#include +#include +#include #include +#include "Common.h" + class PlayerbotAI; class Qualified { - public: - Qualified() { }; - Qualified(std::string const qualifier) : qualifier(qualifier) { } - Qualified(int32 qualifier1) - { - Qualify(qualifier1); - } +public: + Qualified(){}; + Qualified(std::string const qualifier) : qualifier(qualifier) {} + Qualified(int32 qualifier1) { Qualify(qualifier1); } - virtual void Qualify(int qual); + virtual void Qualify(int qual); - virtual void Qualify(std::string const qual) - { - qualifier = qual; - } + virtual void Qualify(std::string const qual) { qualifier = qual; } - std::string const getQualifier() { return qualifier; } + std::string const getQualifier() { return qualifier; } - static std::string const MultiQualify(std::vector qualifiers); - static std::vector getMultiQualifiers(std::string const qualifier1); - static int32 getMultiQualifier(std::string const qualifier1, uint32 pos); + static std::string const MultiQualify(std::vector qualifiers); + static std::vector getMultiQualifiers(std::string const qualifier1); + static int32 getMultiQualifier(std::string const qualifier1, uint32 pos); - protected: - std::string qualifier; +protected: + std::string qualifier; }; template class NamedObjectFactory { - protected: - typedef T*(*ActionCreator)(PlayerbotAI* botAI); - std::unordered_map creators; +protected: + typedef T* (*ActionCreator)(PlayerbotAI* botAI); + std::unordered_map creators; - public: - T* create(std::string name, PlayerbotAI* botAI) +public: + T* create(std::string name, PlayerbotAI* botAI) + { + size_t found = name.find("::"); + std::string qualifier; + if (found != std::string::npos) { - size_t found = name.find("::"); - std::string qualifier; - if (found != std::string::npos) - { - qualifier = name.substr(found + 2); - name = name.substr(0, found); - } - - if (creators.find(name) == creators.end()) - return nullptr; - - ActionCreator creator = creators[name]; - if (!creator) - return nullptr; - - T* object = (*creator)(botAI); - Qualified* q = dynamic_cast(object); - if (q && found != std::string::npos) - q->Qualify(qualifier); - - return object; + qualifier = name.substr(found + 2); + name = name.substr(0, found); } - std::set supports() - { - std::set keys; - for (typename std::unordered_map::iterator it = creators.begin(); it != creators.end(); it++) - keys.insert(it->first); + if (creators.find(name) == creators.end()) + return nullptr; - return keys; - } + ActionCreator creator = creators[name]; + if (!creator) + return nullptr; + + T* object = (*creator)(botAI); + Qualified* q = dynamic_cast(object); + if (q && found != std::string::npos) + q->Qualify(qualifier); + + return object; + } + + std::set supports() + { + std::set keys; + for (typename std::unordered_map::iterator it = creators.begin(); + it != creators.end(); it++) + keys.insert(it->first); + + return keys; + } }; template class NamedObjectContext : public NamedObjectFactory { - public: - NamedObjectContext(bool shared = false, bool supportsSiblings = false) : - NamedObjectFactory(), shared(shared), supportsSiblings(supportsSiblings) { } +public: + NamedObjectContext(bool shared = false, bool supportsSiblings = false) + : NamedObjectFactory(), shared(shared), supportsSiblings(supportsSiblings) + { + } - virtual ~NamedObjectContext() + virtual ~NamedObjectContext() { Clear(); } + + T* create(std::string const name, PlayerbotAI* botAI) + { + if (created.find(name) == created.end()) + return created[name] = NamedObjectFactory::create(name, botAI); + + return created[name]; + } + + void Clear() + { + for (typename std::unordered_map::iterator i = created.begin(); i != created.end(); i++) { - Clear(); + if (i->second) + delete i->second; } - T* create(std::string const name, PlayerbotAI* botAI) + created.clear(); + } + + void Update() + { + for (typename std::unordered_map::iterator i = created.begin(); i != created.end(); i++) { - if (created.find(name) == created.end()) - return created[name] = NamedObjectFactory::create(name, botAI); - - return created[name]; + if (i->second) + i->second->Update(); } + } - void Clear() + void Reset() + { + for (typename std::unordered_map::iterator i = created.begin(); i != created.end(); i++) { - for (typename std::unordered_map::iterator i = created.begin(); i != created.end(); i++) - { - if (i->second) - delete i->second; - } - - created.clear(); + if (i->second) + i->second->Reset(); } + } - void Update() - { - for (typename std::unordered_map::iterator i = created.begin(); i != created.end(); i++) - { - if (i->second) - i->second->Update(); - } - } + bool IsShared() { return shared; } + bool IsSupportsSiblings() { return supportsSiblings; } - void Reset() - { - for (typename std::unordered_map::iterator i = created.begin(); i != created.end(); i++) - { - if (i->second) - i->second->Reset(); - } - } + std::set GetCreated() + { + std::set keys; + for (typename std::unordered_map::iterator it = created.begin(); it != created.end(); it++) + keys.insert(it->first); - bool IsShared() { return shared; } - bool IsSupportsSiblings() { return supportsSiblings; } + return keys; + } - std::set GetCreated() - { - std::set keys; - for (typename std::unordered_map::iterator it = created.begin(); it != created.end(); it++) - keys.insert(it->first); - - return keys; - } - - protected: - std::unordered_map created; - bool shared; - bool supportsSiblings; +protected: + std::unordered_map created; + bool shared; + bool supportsSiblings; }; template class NamedObjectContextList { - public: - virtual ~NamedObjectContextList() +public: + virtual ~NamedObjectContextList() + { + for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) { - for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) - { - NamedObjectContext* context = *i; - if (!context->IsShared()) - delete context; - } + NamedObjectContext* context = *i; + if (!context->IsShared()) + delete context; + } + } + + void Add(NamedObjectContext* context) { contexts.push_back(context); } + + T* GetContextObject(std::string const name, PlayerbotAI* botAI) + { + for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) + { + if (T* object = (*i)->create(name, botAI)) + return object; } - void Add(NamedObjectContext* context) + return nullptr; + } + + void Update() + { + for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) { - contexts.push_back(context); + if (!(*i)->IsShared()) + (*i)->Update(); + } + } + + void Reset() + { + for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) + { + (*i)->Reset(); + } + } + + std::set GetSiblings(std::string const name) + { + for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) + { + if (!(*i)->IsSupportsSiblings()) + continue; + + std::set supported = (*i)->supports(); + std::set::iterator found = supported.find(name); + if (found == supported.end()) + continue; + + supported.erase(found); + return supported; } - T* GetContextObject(std::string const name, PlayerbotAI* botAI) - { - for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) - { - if (T* object = (*i)->create(name, botAI)) - return object; - } + return std::set(); + } - return nullptr; + std::set supports() + { + std::set result; + for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) + { + std::set supported = (*i)->supports(); + + for (std::set::iterator j = supported.begin(); j != supported.end(); j++) + result.insert(*j); } - void Update() + return result; + } + + std::set GetCreated() + { + std::set result; + for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) { - for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) - { - if (!(*i)->IsShared()) - (*i)->Update(); - } + std::set createdKeys = (*i)->GetCreated(); + + for (std::set::iterator j = createdKeys.begin(); j != createdKeys.end(); j++) + result.insert(*j); } - void Reset() - { - for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) - { - (*i)->Reset(); - } - } + return result; + } - std::set GetSiblings(std::string const name) - { - for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) - { - if (!(*i)->IsSupportsSiblings()) - continue; - - std::set supported = (*i)->supports(); - std::set::iterator found = supported.find(name); - if (found == supported.end()) - continue; - - supported.erase(found); - return supported; - } - - return std::set(); - } - - std::set supports() - { - std::set result; - for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) - { - std::set supported = (*i)->supports(); - - for (std::set::iterator j = supported.begin(); j != supported.end(); j++) - result.insert(*j); - } - - return result; - } - - std::set GetCreated() - { - std::set result; - for (typename std::vector*>::iterator i = contexts.begin(); i != contexts.end(); i++) - { - std::set createdKeys = (*i)->GetCreated(); - - for (std::set::iterator j = createdKeys.begin(); j != createdKeys.end(); j++) - result.insert(*j); - } - - return result; - } - - private: - std::vector*> contexts; +private: + std::vector*> contexts; }; template class NamedObjectFactoryList { - public: - virtual ~NamedObjectFactoryList() +public: + virtual ~NamedObjectFactoryList() + { + for (typename std::list*>::iterator i = factories.begin(); i != factories.end(); i++) + delete *i; + } + + void Add(NamedObjectFactory* context) { factories.push_front(context); } + + T* GetContextObject(std::string const& name, PlayerbotAI* botAI) + { + for (typename std::list*>::iterator i = factories.begin(); i != factories.end(); i++) { - for (typename std::list*>::iterator i = factories.begin(); i != factories.end(); i++) - delete *i; + if (T* object = (*i)->create(name, botAI)) + return object; } - void Add(NamedObjectFactory* context) - { - factories.push_front(context); - } + return nullptr; + } - T* GetContextObject(std::string const &name, PlayerbotAI* botAI) - { - for (typename std::list*>::iterator i = factories.begin(); i != factories.end(); i++) - { - if (T* object = (*i)->create(name, botAI)) - return object; - } - - return nullptr; - } - - private: - std::list*> factories; +private: + std::list*> factories; }; #endif diff --git a/src/strategy/PassiveMultiplier.cpp b/src/strategy/PassiveMultiplier.cpp index 597df513..ef4329ac 100644 --- a/src/strategy/PassiveMultiplier.cpp +++ b/src/strategy/PassiveMultiplier.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PassiveMultiplier.h" + #include "Action.h" #include "AiObjectContext.h" @@ -30,7 +32,7 @@ PassiveMultiplier::PassiveMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "pa float PassiveMultiplier::GetValue(Action* action) { if (!action) - return 1.0f; + return 1.0f; std::string const name = action->getName(); diff --git a/src/strategy/PassiveMultiplier.h b/src/strategy/PassiveMultiplier.h index 1c5dcfa2..3f8abb10 100644 --- a/src/strategy/PassiveMultiplier.h +++ b/src/strategy/PassiveMultiplier.h @@ -1,27 +1,28 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PASSIVEMULTIPLIER_H #define _PLAYERBOT_PASSIVEMULTIPLIER_H -#include "Multiplier.h" - #include +#include "Multiplier.h" + class Action; class PlayerbotAI; class PassiveMultiplier : public Multiplier { - public: - PassiveMultiplier(PlayerbotAI* botAI); +public: + PassiveMultiplier(PlayerbotAI* botAI); - float GetValue(Action* action) override; + float GetValue(Action* action) override; - private: - static std::vector allowedActions; - static std::vector allowedParts; +private: + static std::vector allowedActions; + static std::vector allowedParts; }; #endif diff --git a/src/strategy/Queue.cpp b/src/strategy/Queue.cpp index c70fccc7..7ffc3ae1 100644 --- a/src/strategy/Queue.cpp +++ b/src/strategy/Queue.cpp @@ -1,26 +1,28 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "Queue.h" + #include "AiObjectContext.h" #include "Log.h" #include "PlayerbotAIConfig.h" -void Queue::Push(ActionBasket *action) +void Queue::Push(ActionBasket* action) { - if (action) + if (action) { for (std::list::iterator iter = actions.begin(); iter != actions.end(); iter++) { ActionBasket* basket = *iter; if (action->getAction()->getName() == basket->getAction()->getName()) { - if (basket->getRelevance() < action->getRelevance()) - basket->setRelevance(action->getRelevance()); + if (basket->getRelevance() < action->getRelevance()) + basket->setRelevance(action->getRelevance()); - if (ActionNode* actionNode = action->getAction()) - delete actionNode; + if (ActionNode* actionNode = action->getAction()) + delete actionNode; delete action; @@ -28,34 +30,34 @@ void Queue::Push(ActionBasket *action) } } - actions.push_back(action); + actions.push_back(action); } } ActionNode* Queue::Pop() { - float max = -1; - ActionBasket* selection = nullptr; + float max = -1; + ActionBasket* selection = nullptr; - for (std::list::iterator iter = actions.begin(); iter != actions.end(); iter++) - { - ActionBasket* basket = *iter; - if (basket->getRelevance() > max) - { - max = basket->getRelevance(); - selection = basket; - } - } + for (std::list::iterator iter = actions.begin(); iter != actions.end(); iter++) + { + ActionBasket* basket = *iter; + if (basket->getRelevance() > max) + { + max = basket->getRelevance(); + selection = basket; + } + } - if (selection != nullptr) - { - ActionNode* action = selection->getAction(); - actions.remove(selection); - delete selection; - return action; - } + if (selection != nullptr) + { + ActionNode* action = selection->getAction(); + actions.remove(selection); + delete selection; + return action; + } - return nullptr; + return nullptr; } ActionBasket* Queue::Peek() @@ -75,10 +77,7 @@ ActionBasket* Queue::Peek() return selection; } -uint32 Queue::Size() -{ - return actions.size(); -} +uint32 Queue::Size() { return actions.size(); } void Queue::RemoveExpired() { diff --git a/src/strategy/Queue.h b/src/strategy/Queue.h index 6a089cad..5378d5e4 100644 --- a/src/strategy/Queue.h +++ b/src/strategy/Queue.h @@ -1,27 +1,28 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_QUEUE_H #define _PLAYERBOT_QUEUE_H -#include "Common.h" #include "Action.h" +#include "Common.h" class Queue { - public: - Queue(void) { } - ~Queue(void) { } +public: + Queue(void) {} + ~Queue(void) {} - void Push(ActionBasket *action); - ActionNode* Pop(); - ActionBasket* Peek(); - uint32 Size(); - void RemoveExpired(); + void Push(ActionBasket* action); + ActionNode* Pop(); + ActionBasket* Peek(); + uint32 Size(); + void RemoveExpired(); - private: - std::list actions; +private: + std::list actions; }; #endif diff --git a/src/strategy/Strategy.cpp b/src/strategy/Strategy.cpp index 201e6997..e6fe779d 100644 --- a/src/strategy/Strategy.cpp +++ b/src/strategy/Strategy.cpp @@ -1,116 +1,118 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "Strategy.h" + #include "Playerbots.h" class ActionNodeFactoryInternal : public NamedObjectFactory { - public: - ActionNodeFactoryInternal() - { - creators["melee"] = &melee; - creators["healthstone"] = &healthstone; - creators["be near"] = &follow_master_random; - creators["attack anything"] = &attack_anything; - creators["move random"] = &move_random; - creators["move to loot"] = &move_to_loot; - creators["food"] = &food; - creators["drink"] = &drink; - creators["mana potion"] = &mana_potion; - creators["healing potion"] = &healing_potion; - creators["flee"] = &flee; - } +public: + ActionNodeFactoryInternal() + { + creators["melee"] = &melee; + creators["healthstone"] = &healthstone; + creators["be near"] = &follow_master_random; + creators["attack anything"] = &attack_anything; + creators["move random"] = &move_random; + creators["move to loot"] = &move_to_loot; + creators["food"] = &food; + creators["drink"] = &drink; + creators["mana potion"] = &mana_potion; + creators["healing potion"] = &healing_potion; + creators["flee"] = &flee; + } - private: - static ActionNode* melee([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("melee", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } +private: + static ActionNode* melee([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("melee", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* healthstone([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("healthstone", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("healing potion"), nullptr), - /*C*/ nullptr); - } + static ActionNode* healthstone([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("healthstone", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("healing potion"), nullptr), + /*C*/ nullptr); + } - static ActionNode* follow_master_random([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("be near", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("follow"), nullptr), - /*C*/ nullptr); - } + static ActionNode* follow_master_random([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("be near", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("follow"), nullptr), + /*C*/ nullptr); + } - static ActionNode* attack_anything([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("attack anything", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* attack_anything([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("attack anything", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* move_random([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("move random", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("stay line"), nullptr), - /*C*/ nullptr); - } + static ActionNode* move_random([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("move random", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("stay line"), nullptr), + /*C*/ nullptr); + } - static ActionNode* move_to_loot([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("move to loot", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* move_to_loot([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("move to loot", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* food([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("food", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* food([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("food", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* drink([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("drink", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* drink([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("drink", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* mana_potion([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("mana potion", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("drink"), nullptr), - /*C*/ nullptr); - } + static ActionNode* mana_potion([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("mana potion", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("drink"), nullptr), + /*C*/ nullptr); + } - static ActionNode* healing_potion([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("healing potion", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("food"), nullptr), - /*C*/ nullptr); - } + static ActionNode* healing_potion([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("healing potion", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("food"), nullptr), + /*C*/ nullptr); + } - static ActionNode* flee([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("flee", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* flee([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("flee", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } }; Strategy::Strategy(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) @@ -118,8 +120,4 @@ Strategy::Strategy(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) actionNodeFactories.Add(new ActionNodeFactoryInternal()); } -ActionNode* Strategy::GetAction(std::string const name) -{ - return actionNodeFactories.GetContextObject(name, botAI); -} - +ActionNode* Strategy::GetAction(std::string const name) { return actionNodeFactories.GetContextObject(name, botAI); } diff --git a/src/strategy/Strategy.h b/src/strategy/Strategy.h index 4de7b671..f307a45c 100644 --- a/src/strategy/Strategy.h +++ b/src/strategy/Strategy.h @@ -1,26 +1,27 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_STRATEGY_H #define _PLAYERBOT_STRATEGY_H #include "Action.h" -#include "NamedObjectContext.h" #include "Multiplier.h" -#include "Trigger.h" +#include "NamedObjectContext.h" #include "PlayerbotAIAware.h" +#include "Trigger.h" enum StrategyType : uint32 { - STRATEGY_TYPE_GENERIC = 0, - STRATEGY_TYPE_COMBAT = 1, - STRATEGY_TYPE_NONCOMBAT = 2, - STRATEGY_TYPE_TANK = 4, - STRATEGY_TYPE_DPS = 8, - STRATEGY_TYPE_HEAL = 16, - STRATEGY_TYPE_RANGED = 32, - STRATEGY_TYPE_MELEE = 64 + STRATEGY_TYPE_GENERIC = 0, + STRATEGY_TYPE_COMBAT = 1, + STRATEGY_TYPE_NONCOMBAT = 2, + STRATEGY_TYPE_TANK = 4, + STRATEGY_TYPE_DPS = 8, + STRATEGY_TYPE_HEAL = 16, + STRATEGY_TYPE_RANGED = 32, + STRATEGY_TYPE_MELEE = 64 }; // enum ActionPriority @@ -54,21 +55,21 @@ static float ACTION_EMERGENCY = 90.0f; class Strategy : public PlayerbotAIAware { - public: - Strategy(PlayerbotAI* botAI); - virtual ~Strategy() { } +public: + Strategy(PlayerbotAI* botAI); + virtual ~Strategy() {} - virtual NextAction** getDefaultActions() { return nullptr; } - virtual void InitTriggers([[maybe_unused]] std::vector &triggers) { } - virtual void InitMultipliers([[maybe_unused]] std::vector &multipliers) { } - virtual std::string const getName() = 0; - virtual uint32 GetType() const { return STRATEGY_TYPE_GENERIC; } - virtual ActionNode* GetAction(std::string const name); - void Update() { } - void Reset() { } + virtual NextAction** getDefaultActions() { return nullptr; } + virtual void InitTriggers([[maybe_unused]] std::vector& triggers) {} + virtual void InitMultipliers([[maybe_unused]] std::vector& multipliers) {} + virtual std::string const getName() = 0; + virtual uint32 GetType() const { return STRATEGY_TYPE_GENERIC; } + virtual ActionNode* GetAction(std::string const name); + void Update() {} + void Reset() {} - protected: - NamedObjectFactoryList actionNodeFactories; +protected: + NamedObjectFactoryList actionNodeFactories; }; #endif diff --git a/src/strategy/StrategyContext.h b/src/strategy/StrategyContext.h index 82090440..cf86dca4 100644 --- a/src/strategy/StrategyContext.h +++ b/src/strategy/StrategyContext.h @@ -1,17 +1,17 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_STRATEGYCONTEXT_H #define _PLAYERBOT_STRATEGYCONTEXT_H -#include "CustomStrategy.h" -#include "NamedObjectContext.h" #include "AttackEnemyPlayersStrategy.h" #include "BattlegroundStrategy.h" #include "CastTimeStrategy.h" #include "ChatCommandHandlerStrategy.h" #include "ConserveManaStrategy.h" +#include "CustomStrategy.h" #include "DeadStrategy.h" #include "DebugStrategy.h" #include "DpsAssistStrategy.h" @@ -29,15 +29,16 @@ #include "MaintenanceStrategy.h" #include "MarkRtiStrategy.h" #include "MeleeCombatStrategy.h" +#include "NamedObjectContext.h" #include "NonCombatStrategy.h" -#include "QuestStrategies.h" #include "PassiveStrategy.h" #include "PullStrategy.h" +#include "QuestStrategies.h" +#include "RTSCStrategy.h" #include "RacialsStrategy.h" #include "RangedCombatStrategy.h" #include "ReturnStrategy.h" #include "RpgStrategy.h" -#include "RTSCStrategy.h" #include "RunawayStrategy.h" #include "StayStrategy.h" #include "TankAssistStrategy.h" @@ -50,184 +51,182 @@ class StrategyContext : public NamedObjectContext { - public: - StrategyContext() - { - creators["racials"] = &StrategyContext::racials; - creators["loot"] = &StrategyContext::loot; - creators["gather"] = &StrategyContext::gather; - creators["emote"] = &StrategyContext::emote; - creators["passive"] = &StrategyContext::passive; - // creators["conserve mana"] = &StrategyContext::conserve_mana; - creators["auto save mana"] = &StrategyContext::auto_save_mana; - creators["food"] = &StrategyContext::food; - creators["chat"] = &StrategyContext::chat; - creators["default"] = &StrategyContext::world_packet; - creators["ready check"] = &StrategyContext::ready_check; - creators["dead"] = &StrategyContext::dead; - creators["flee"] = &StrategyContext::flee; - creators["duel"] = &StrategyContext::duel; - creators["start duel"] = &StrategyContext::start_duel; - creators["kite"] = &StrategyContext::kite; - creators["potions"] = &StrategyContext::potions; - creators["cast time"] = &StrategyContext::cast_time; - creators["threat"] = &StrategyContext::threat; - creators["focus"] = &StrategyContext::focus; - creators["tell target"] = &StrategyContext::tell_target; - creators["pvp"] = &StrategyContext::pvp; - creators["return"] = &StrategyContext::_return; - creators["lfg"] = &StrategyContext::lfg; - creators["custom"] = &StrategyContext::custom; - creators["reveal"] = &StrategyContext::reveal; - creators["collision"] = &StrategyContext::collision; - creators["rpg"] = &StrategyContext::rpg; - creators["travel"] = &StrategyContext::travel; - creators["explore"] = &StrategyContext::explore; - creators["map"] = &StrategyContext::map; - creators["map full"] = &StrategyContext::map_full; - creators["sit"] = &StrategyContext::sit; - creators["mark rti"] = &StrategyContext::mark_rti; - creators["adds"] = &StrategyContext::possible_adds; - creators["close"] = &StrategyContext::close; - creators["ranged"] = &StrategyContext::ranged; - creators["behind"] = &StrategyContext::behind; - creators["bg"] = &StrategyContext::bg; - creators["battleground"] = &StrategyContext::battleground; - creators["warsong"] = &StrategyContext::warsong; - creators["alterac"] = &StrategyContext::alterac; - creators["arathi"] = &StrategyContext::arathi; - creators["eye"] = &StrategyContext::eye; - creators["isle"] = &StrategyContext::isle; - creators["arena"] = &StrategyContext::arena; - creators["mount"] = &StrategyContext::mount; - creators["rtsc"] = &StrategyContext::rtsc; - creators["attack tagged"] = &StrategyContext::attack_tagged; - creators["debug"] = &StrategyContext::debug; - creators["debug move"] = &StrategyContext::debug_move; - creators["debug rpg"] = &StrategyContext::debug_rpg; - creators["debug spell"] = &StrategyContext::debug_spell; - creators["maintenance"] = &StrategyContext::maintenance; - creators["group"] = &StrategyContext::group; - creators["guild"] = &StrategyContext::guild; - creators["grind"] = &StrategyContext::grind; - creators["avoid aoe"] = &StrategyContext::avoid_aoe; - creators["move random"] = &StrategyContext::move_random; - creators["combat formation"] = &StrategyContext::combat_formation; - } +public: + StrategyContext() + { + creators["racials"] = &StrategyContext::racials; + creators["loot"] = &StrategyContext::loot; + creators["gather"] = &StrategyContext::gather; + creators["emote"] = &StrategyContext::emote; + creators["passive"] = &StrategyContext::passive; + // creators["conserve mana"] = &StrategyContext::conserve_mana; + creators["auto save mana"] = &StrategyContext::auto_save_mana; + creators["food"] = &StrategyContext::food; + creators["chat"] = &StrategyContext::chat; + creators["default"] = &StrategyContext::world_packet; + creators["ready check"] = &StrategyContext::ready_check; + creators["dead"] = &StrategyContext::dead; + creators["flee"] = &StrategyContext::flee; + creators["duel"] = &StrategyContext::duel; + creators["start duel"] = &StrategyContext::start_duel; + creators["kite"] = &StrategyContext::kite; + creators["potions"] = &StrategyContext::potions; + creators["cast time"] = &StrategyContext::cast_time; + creators["threat"] = &StrategyContext::threat; + creators["focus"] = &StrategyContext::focus; + creators["tell target"] = &StrategyContext::tell_target; + creators["pvp"] = &StrategyContext::pvp; + creators["return"] = &StrategyContext::_return; + creators["lfg"] = &StrategyContext::lfg; + creators["custom"] = &StrategyContext::custom; + creators["reveal"] = &StrategyContext::reveal; + creators["collision"] = &StrategyContext::collision; + creators["rpg"] = &StrategyContext::rpg; + creators["travel"] = &StrategyContext::travel; + creators["explore"] = &StrategyContext::explore; + creators["map"] = &StrategyContext::map; + creators["map full"] = &StrategyContext::map_full; + creators["sit"] = &StrategyContext::sit; + creators["mark rti"] = &StrategyContext::mark_rti; + creators["adds"] = &StrategyContext::possible_adds; + creators["close"] = &StrategyContext::close; + creators["ranged"] = &StrategyContext::ranged; + creators["behind"] = &StrategyContext::behind; + creators["bg"] = &StrategyContext::bg; + creators["battleground"] = &StrategyContext::battleground; + creators["warsong"] = &StrategyContext::warsong; + creators["alterac"] = &StrategyContext::alterac; + creators["arathi"] = &StrategyContext::arathi; + creators["eye"] = &StrategyContext::eye; + creators["isle"] = &StrategyContext::isle; + creators["arena"] = &StrategyContext::arena; + creators["mount"] = &StrategyContext::mount; + creators["rtsc"] = &StrategyContext::rtsc; + creators["attack tagged"] = &StrategyContext::attack_tagged; + creators["debug"] = &StrategyContext::debug; + creators["debug move"] = &StrategyContext::debug_move; + creators["debug rpg"] = &StrategyContext::debug_rpg; + creators["debug spell"] = &StrategyContext::debug_spell; + creators["maintenance"] = &StrategyContext::maintenance; + creators["group"] = &StrategyContext::group; + creators["guild"] = &StrategyContext::guild; + creators["grind"] = &StrategyContext::grind; + creators["avoid aoe"] = &StrategyContext::avoid_aoe; + creators["move random"] = &StrategyContext::move_random; + creators["combat formation"] = &StrategyContext::combat_formation; + } - private: - static Strategy* behind(PlayerbotAI* botAI) { return new SetBehindCombatStrategy(botAI); } - static Strategy* ranged(PlayerbotAI* botAI) { return new RangedCombatStrategy(botAI); } - static Strategy* close(PlayerbotAI* botAI) { return new MeleeCombatStrategy(botAI); } - static Strategy* mark_rti(PlayerbotAI* botAI) { return new MarkRtiStrategy(botAI); } - static Strategy* tell_target(PlayerbotAI* botAI) { return new TellTargetStrategy(botAI); } - static Strategy* threat(PlayerbotAI* botAI) { return new ThreatStrategy(botAI); } - static Strategy* focus(PlayerbotAI* botAI) { return new FocusStrategy(botAI); } - static Strategy* cast_time(PlayerbotAI* botAI) { return new CastTimeStrategy(botAI); } - static Strategy* potions(PlayerbotAI* botAI) { return new UsePotionsStrategy(botAI); } - static Strategy* kite(PlayerbotAI* botAI) { return new KiteStrategy(botAI); } - static Strategy* duel(PlayerbotAI* botAI) { return new DuelStrategy(botAI); } - static Strategy* start_duel(PlayerbotAI* botAI) { return new StartDuelStrategy(botAI); } - static Strategy* flee(PlayerbotAI* botAI) { return new FleeStrategy(botAI); } - static Strategy* dead(PlayerbotAI* botAI) { return new DeadStrategy(botAI); } - static Strategy* racials(PlayerbotAI* botAI) { return new RacialsStrategy(botAI); } - static Strategy* loot(PlayerbotAI* botAI) { return new LootNonCombatStrategy(botAI); } - static Strategy* gather(PlayerbotAI* botAI) { return new GatherStrategy(botAI); } - static Strategy* emote(PlayerbotAI* botAI) { return new EmoteStrategy(botAI); } - static Strategy* passive(PlayerbotAI* botAI) { return new PassiveStrategy(botAI); } - // static Strategy* conserve_mana(PlayerbotAI* botAI) { return new ConserveManaStrategy(botAI); } - static Strategy* auto_save_mana(PlayerbotAI* botAI) { return new HealerAutoSaveManaStrategy(botAI); } - static Strategy* food(PlayerbotAI* botAI) { return new UseFoodStrategy(botAI); } - static Strategy* chat(PlayerbotAI* botAI) { return new ChatCommandHandlerStrategy(botAI); } - static Strategy* world_packet(PlayerbotAI* botAI) { return new WorldPacketHandlerStrategy(botAI); } - static Strategy* ready_check(PlayerbotAI* botAI) { return new ReadyCheckStrategy(botAI); } - static Strategy* pvp(PlayerbotAI* botAI) { return new AttackEnemyPlayersStrategy(botAI); } - static Strategy* _return(PlayerbotAI* botAI) { return new ReturnStrategy(botAI); } - static Strategy* lfg(PlayerbotAI* botAI) { return new LfgStrategy(botAI); } - static Strategy* custom(PlayerbotAI* botAI) { return new CustomStrategy(botAI); } - static Strategy* reveal(PlayerbotAI* botAI) { return new RevealStrategy(botAI); } - static Strategy* collision(PlayerbotAI* botAI) { return new CollisionStrategy(botAI); } - static Strategy* rpg(PlayerbotAI* botAI) { return new RpgStrategy(botAI); } - static Strategy* travel(PlayerbotAI* botAI) { return new TravelStrategy(botAI); } - static Strategy* explore(PlayerbotAI* botAI) { return new ExploreStrategy(botAI); } - static Strategy* map(PlayerbotAI* botAI) { return new MapStrategy(botAI); } - static Strategy* map_full(PlayerbotAI* botAI) { return new MapFullStrategy(botAI); } - static Strategy* sit(PlayerbotAI* botAI) { return new SitStrategy(botAI); } - static Strategy* possible_adds(PlayerbotAI* botAI) { return new PossibleAddsStrategy(botAI); } - static Strategy* mount(PlayerbotAI* botAI) { return new MountStrategy(botAI); } - static Strategy* bg(PlayerbotAI* botAI) { return new BGStrategy(botAI); } - static Strategy* battleground(PlayerbotAI* botAI) { return new BattlegroundStrategy(botAI); } - static Strategy* warsong(PlayerbotAI* botAI) { return new WarsongStrategy(botAI); } - static Strategy* alterac(PlayerbotAI* botAI) { return new AlteracStrategy(botAI); } - static Strategy* arathi(PlayerbotAI* botAI) { return new ArathiStrategy(botAI); } - static Strategy* eye(PlayerbotAI* botAI) { return new EyeStrategy(botAI); } - static Strategy* isle(PlayerbotAI* botAI) { return new IsleStrategy(botAI); } - static Strategy* arena(PlayerbotAI* botAI) { return new ArenaStrategy(botAI); } - static Strategy* rtsc(PlayerbotAI* botAI) { return new RTSCStrategy(botAI); } - static Strategy* attack_tagged(PlayerbotAI* botAI) { return new AttackTaggedStrategy(botAI); } - static Strategy* debug(PlayerbotAI* botAI) { return new DebugStrategy(botAI); } - static Strategy* debug_move(PlayerbotAI* botAI) { return new DebugMoveStrategy(botAI); } - static Strategy* debug_rpg(PlayerbotAI* botAI) { return new DebugRpgStrategy(botAI); } - static Strategy* debug_spell(PlayerbotAI* botAI) { return new DebugSpellStrategy(botAI); } - static Strategy* maintenance(PlayerbotAI* botAI) { return new MaintenanceStrategy(botAI); } - static Strategy* group(PlayerbotAI* botAI) { return new GroupStrategy(botAI); } - static Strategy* guild (PlayerbotAI* botAI) { return new GuildStrategy(botAI); } - static Strategy* grind(PlayerbotAI* botAI) { return new GrindingStrategy(botAI); } - static Strategy* avoid_aoe(PlayerbotAI* botAI) { return new AvoidAoeStrategy(botAI); } - static Strategy* move_random(PlayerbotAI* ai) { return new MoveRandomStrategy(ai); } - static Strategy* combat_formation(PlayerbotAI* ai) { return new CombatFormationStrategy(ai); } +private: + static Strategy* behind(PlayerbotAI* botAI) { return new SetBehindCombatStrategy(botAI); } + static Strategy* ranged(PlayerbotAI* botAI) { return new RangedCombatStrategy(botAI); } + static Strategy* close(PlayerbotAI* botAI) { return new MeleeCombatStrategy(botAI); } + static Strategy* mark_rti(PlayerbotAI* botAI) { return new MarkRtiStrategy(botAI); } + static Strategy* tell_target(PlayerbotAI* botAI) { return new TellTargetStrategy(botAI); } + static Strategy* threat(PlayerbotAI* botAI) { return new ThreatStrategy(botAI); } + static Strategy* focus(PlayerbotAI* botAI) { return new FocusStrategy(botAI); } + static Strategy* cast_time(PlayerbotAI* botAI) { return new CastTimeStrategy(botAI); } + static Strategy* potions(PlayerbotAI* botAI) { return new UsePotionsStrategy(botAI); } + static Strategy* kite(PlayerbotAI* botAI) { return new KiteStrategy(botAI); } + static Strategy* duel(PlayerbotAI* botAI) { return new DuelStrategy(botAI); } + static Strategy* start_duel(PlayerbotAI* botAI) { return new StartDuelStrategy(botAI); } + static Strategy* flee(PlayerbotAI* botAI) { return new FleeStrategy(botAI); } + static Strategy* dead(PlayerbotAI* botAI) { return new DeadStrategy(botAI); } + static Strategy* racials(PlayerbotAI* botAI) { return new RacialsStrategy(botAI); } + static Strategy* loot(PlayerbotAI* botAI) { return new LootNonCombatStrategy(botAI); } + static Strategy* gather(PlayerbotAI* botAI) { return new GatherStrategy(botAI); } + static Strategy* emote(PlayerbotAI* botAI) { return new EmoteStrategy(botAI); } + static Strategy* passive(PlayerbotAI* botAI) { return new PassiveStrategy(botAI); } + // static Strategy* conserve_mana(PlayerbotAI* botAI) { return new ConserveManaStrategy(botAI); } + static Strategy* auto_save_mana(PlayerbotAI* botAI) { return new HealerAutoSaveManaStrategy(botAI); } + static Strategy* food(PlayerbotAI* botAI) { return new UseFoodStrategy(botAI); } + static Strategy* chat(PlayerbotAI* botAI) { return new ChatCommandHandlerStrategy(botAI); } + static Strategy* world_packet(PlayerbotAI* botAI) { return new WorldPacketHandlerStrategy(botAI); } + static Strategy* ready_check(PlayerbotAI* botAI) { return new ReadyCheckStrategy(botAI); } + static Strategy* pvp(PlayerbotAI* botAI) { return new AttackEnemyPlayersStrategy(botAI); } + static Strategy* _return(PlayerbotAI* botAI) { return new ReturnStrategy(botAI); } + static Strategy* lfg(PlayerbotAI* botAI) { return new LfgStrategy(botAI); } + static Strategy* custom(PlayerbotAI* botAI) { return new CustomStrategy(botAI); } + static Strategy* reveal(PlayerbotAI* botAI) { return new RevealStrategy(botAI); } + static Strategy* collision(PlayerbotAI* botAI) { return new CollisionStrategy(botAI); } + static Strategy* rpg(PlayerbotAI* botAI) { return new RpgStrategy(botAI); } + static Strategy* travel(PlayerbotAI* botAI) { return new TravelStrategy(botAI); } + static Strategy* explore(PlayerbotAI* botAI) { return new ExploreStrategy(botAI); } + static Strategy* map(PlayerbotAI* botAI) { return new MapStrategy(botAI); } + static Strategy* map_full(PlayerbotAI* botAI) { return new MapFullStrategy(botAI); } + static Strategy* sit(PlayerbotAI* botAI) { return new SitStrategy(botAI); } + static Strategy* possible_adds(PlayerbotAI* botAI) { return new PossibleAddsStrategy(botAI); } + static Strategy* mount(PlayerbotAI* botAI) { return new MountStrategy(botAI); } + static Strategy* bg(PlayerbotAI* botAI) { return new BGStrategy(botAI); } + static Strategy* battleground(PlayerbotAI* botAI) { return new BattlegroundStrategy(botAI); } + static Strategy* warsong(PlayerbotAI* botAI) { return new WarsongStrategy(botAI); } + static Strategy* alterac(PlayerbotAI* botAI) { return new AlteracStrategy(botAI); } + static Strategy* arathi(PlayerbotAI* botAI) { return new ArathiStrategy(botAI); } + static Strategy* eye(PlayerbotAI* botAI) { return new EyeStrategy(botAI); } + static Strategy* isle(PlayerbotAI* botAI) { return new IsleStrategy(botAI); } + static Strategy* arena(PlayerbotAI* botAI) { return new ArenaStrategy(botAI); } + static Strategy* rtsc(PlayerbotAI* botAI) { return new RTSCStrategy(botAI); } + static Strategy* attack_tagged(PlayerbotAI* botAI) { return new AttackTaggedStrategy(botAI); } + static Strategy* debug(PlayerbotAI* botAI) { return new DebugStrategy(botAI); } + static Strategy* debug_move(PlayerbotAI* botAI) { return new DebugMoveStrategy(botAI); } + static Strategy* debug_rpg(PlayerbotAI* botAI) { return new DebugRpgStrategy(botAI); } + static Strategy* debug_spell(PlayerbotAI* botAI) { return new DebugSpellStrategy(botAI); } + static Strategy* maintenance(PlayerbotAI* botAI) { return new MaintenanceStrategy(botAI); } + static Strategy* group(PlayerbotAI* botAI) { return new GroupStrategy(botAI); } + static Strategy* guild(PlayerbotAI* botAI) { return new GuildStrategy(botAI); } + static Strategy* grind(PlayerbotAI* botAI) { return new GrindingStrategy(botAI); } + static Strategy* avoid_aoe(PlayerbotAI* botAI) { return new AvoidAoeStrategy(botAI); } + static Strategy* move_random(PlayerbotAI* ai) { return new MoveRandomStrategy(ai); } + static Strategy* combat_formation(PlayerbotAI* ai) { return new CombatFormationStrategy(ai); } }; class MovementStrategyContext : public NamedObjectContext { - public: - MovementStrategyContext() : NamedObjectContext(false, true) - { - creators["follow"] = &MovementStrategyContext::follow_master; - creators["stay"] = &MovementStrategyContext::stay; - creators["runaway"] = &MovementStrategyContext::runaway; - creators["flee from adds"] = &MovementStrategyContext::flee_from_adds; - creators["guard"] = &MovementStrategyContext::guard; - } - - private: - static Strategy* guard(PlayerbotAI* botAI) { return new GuardStrategy(botAI); } - static Strategy* follow_master(PlayerbotAI* botAI) { return new FollowMasterStrategy(botAI); } - static Strategy* stay(PlayerbotAI* botAI) { return new StayStrategy(botAI); } - static Strategy* runaway(PlayerbotAI* botAI) { return new RunawayStrategy(botAI); } - static Strategy* flee_from_adds(PlayerbotAI* botAI) { return new FleeFromAddsStrategy(botAI); } - }; - - class AssistStrategyContext : public NamedObjectContext +public: + MovementStrategyContext() : NamedObjectContext(false, true) { - public: - AssistStrategyContext() : NamedObjectContext(false, true) - { - creators["dps assist"] = &AssistStrategyContext::dps_assist; - creators["dps aoe"] = &AssistStrategyContext::dps_aoe; - creators["tank assist"] = &AssistStrategyContext::tank_assist; - } + creators["follow"] = &MovementStrategyContext::follow_master; + creators["stay"] = &MovementStrategyContext::stay; + creators["runaway"] = &MovementStrategyContext::runaway; + creators["flee from adds"] = &MovementStrategyContext::flee_from_adds; + creators["guard"] = &MovementStrategyContext::guard; + } - private: - static Strategy* dps_assist(PlayerbotAI* botAI) { return new DpsAssistStrategy(botAI); } - static Strategy* dps_aoe(PlayerbotAI* botAI) { return new DpsAoeStrategy(botAI); } - static Strategy* tank_assist(PlayerbotAI* botAI) { return new TankAssistStrategy(botAI); } +private: + static Strategy* guard(PlayerbotAI* botAI) { return new GuardStrategy(botAI); } + static Strategy* follow_master(PlayerbotAI* botAI) { return new FollowMasterStrategy(botAI); } + static Strategy* stay(PlayerbotAI* botAI) { return new StayStrategy(botAI); } + static Strategy* runaway(PlayerbotAI* botAI) { return new RunawayStrategy(botAI); } + static Strategy* flee_from_adds(PlayerbotAI* botAI) { return new FleeFromAddsStrategy(botAI); } +}; + +class AssistStrategyContext : public NamedObjectContext +{ +public: + AssistStrategyContext() : NamedObjectContext(false, true) + { + creators["dps assist"] = &AssistStrategyContext::dps_assist; + creators["dps aoe"] = &AssistStrategyContext::dps_aoe; + creators["tank assist"] = &AssistStrategyContext::tank_assist; + } + +private: + static Strategy* dps_assist(PlayerbotAI* botAI) { return new DpsAssistStrategy(botAI); } + static Strategy* dps_aoe(PlayerbotAI* botAI) { return new DpsAoeStrategy(botAI); } + static Strategy* tank_assist(PlayerbotAI* botAI) { return new TankAssistStrategy(botAI); } }; class QuestStrategyContext : public NamedObjectContext { - public: - QuestStrategyContext() : NamedObjectContext(false, true) - { - creators["quest"] = &QuestStrategyContext::quest; - creators["accept all quests"] = &QuestStrategyContext::accept_all_quests; - } +public: + QuestStrategyContext() : NamedObjectContext(false, true) + { + creators["quest"] = &QuestStrategyContext::quest; + creators["accept all quests"] = &QuestStrategyContext::accept_all_quests; + } - private: - static Strategy* quest(PlayerbotAI* botAI) { return new DefaultQuestStrategy(botAI); } - static Strategy* accept_all_quests(PlayerbotAI* botAI) { return new AcceptAllQuestsStrategy(botAI); } +private: + static Strategy* quest(PlayerbotAI* botAI) { return new DefaultQuestStrategy(botAI); } + static Strategy* accept_all_quests(PlayerbotAI* botAI) { return new AcceptAllQuestsStrategy(botAI); } }; - - #endif diff --git a/src/strategy/Trigger.cpp b/src/strategy/Trigger.cpp index 564d1962..b2c97499 100644 --- a/src/strategy/Trigger.cpp +++ b/src/strategy/Trigger.cpp @@ -1,38 +1,36 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "Trigger.h" + #include "Event.h" #include "Playerbots.h" #include "Timer.h" -Trigger::Trigger(PlayerbotAI* botAI, std::string const name, int32 checkInterval) : - AiNamedObject(botAI, name), checkInterval(checkInterval == 1 ? 1 : (checkInterval < 100 ? checkInterval * 1000 : checkInterval)), lastCheckTime(0) +Trigger::Trigger(PlayerbotAI* botAI, std::string const name, int32 checkInterval) + : AiNamedObject(botAI, name), + checkInterval(checkInterval == 1 ? 1 : (checkInterval < 100 ? checkInterval * 1000 : checkInterval)), + lastCheckTime(0) { } Event Trigger::Check() { - if (IsActive()) - { - Event event(getName()); - return event; - } + if (IsActive()) + { + Event event(getName()); + return event; + } - Event event; - return event; + Event event; + return event; } -Value* Trigger::GetTargetValue() -{ - return context->GetValue(GetTargetName()); -} +Value* Trigger::GetTargetValue() { return context->GetValue(GetTargetName()); } -Unit* Trigger::GetTarget() -{ - return GetTargetValue()->Get(); -} +Unit* Trigger::GetTarget() { return GetTargetValue()->Get(); } bool Trigger::needCheck() { diff --git a/src/strategy/Trigger.h b/src/strategy/Trigger.h index eeaaea97..ce2dd06d 100644 --- a/src/strategy/Trigger.h +++ b/src/strategy/Trigger.h @@ -1,69 +1,64 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TRIGGER_H #define _PLAYERBOT_TRIGGER_H -#include "Common.h" #include "Action.h" +#include "Common.h" class PlayerbotAI; class Unit; class Trigger : public AiNamedObject { - public: - Trigger(PlayerbotAI* botAI, std::string const name = "trigger", int32 checkInterval = 1); +public: + Trigger(PlayerbotAI* botAI, std::string const name = "trigger", int32 checkInterval = 1); - virtual ~Trigger() { } + virtual ~Trigger() {} - virtual Event Check(); - virtual void ExternalEvent([[maybe_unused]] std::string const param, [[maybe_unused]] Player* owner = nullptr) { } - virtual void ExternalEvent([[maybe_unused]] WorldPacket& packet, [[maybe_unused]] Player* owner = nullptr) { } - virtual bool IsActive() { return false; } - virtual NextAction** getHandlers() { return nullptr; } - void Update() { } - virtual void Reset() { } - virtual Unit* GetTarget(); - virtual Value* GetTargetValue(); - virtual std::string const GetTargetName() { return "self target"; } + virtual Event Check(); + virtual void ExternalEvent([[maybe_unused]] std::string const param, [[maybe_unused]] Player* owner = nullptr) {} + virtual void ExternalEvent([[maybe_unused]] WorldPacket& packet, [[maybe_unused]] Player* owner = nullptr) {} + virtual bool IsActive() { return false; } + virtual NextAction** getHandlers() { return nullptr; } + void Update() {} + virtual void Reset() {} + virtual Unit* GetTarget(); + virtual Value* GetTargetValue(); + virtual std::string const GetTargetName() { return "self target"; } - bool needCheck(); + bool needCheck(); - protected: - int32 checkInterval; - uint32 lastCheckTime; +protected: + int32 checkInterval; + uint32 lastCheckTime; }; class TriggerNode { - public: - TriggerNode(std::string const name, NextAction** handlers = nullptr) : trigger(nullptr), handlers(handlers), name(name) { } // reorder args - whipowill +public: + TriggerNode(std::string const name, NextAction** handlers = nullptr) + : trigger(nullptr), handlers(handlers), name(name) + { + } // reorder args - whipowill - virtual ~TriggerNode() - { - NextAction::destroy(handlers); - } + virtual ~TriggerNode() { NextAction::destroy(handlers); } - Trigger* getTrigger() { return trigger; } - void setTrigger(Trigger* trigger) { this->trigger = trigger; } - std::string const getName() { return name; } + Trigger* getTrigger() { return trigger; } + void setTrigger(Trigger* trigger) { this->trigger = trigger; } + std::string const getName() { return name; } - NextAction** getHandlers() - { - return NextAction::merge(NextAction::clone(handlers), trigger->getHandlers()); - } + NextAction** getHandlers() { return NextAction::merge(NextAction::clone(handlers), trigger->getHandlers()); } - float getFirstRelevance() - { - return handlers[0] ? handlers[0]->getRelevance() : -1; - } + float getFirstRelevance() { return handlers[0] ? handlers[0]->getRelevance() : -1; } - private: - Trigger* trigger; - NextAction** handlers; - std::string const name; +private: + Trigger* trigger; + NextAction** handlers; + std::string const name; }; #endif diff --git a/src/strategy/Value.cpp b/src/strategy/Value.cpp index 464e0d1f..82f8a45c 100644 --- a/src/strategy/Value.cpp +++ b/src/strategy/Value.cpp @@ -1,13 +1,16 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "Value.h" + #include "PerformanceMonitor.h" #include "Playerbots.h" #include "Timer.h" -UnitCalculatedValue::UnitCalculatedValue(PlayerbotAI* botAI, std::string const name, int32 checkInterval) : CalculatedValue(botAI, name, checkInterval) +UnitCalculatedValue::UnitCalculatedValue(PlayerbotAI* botAI, std::string const name, int32 checkInterval) + : CalculatedValue(botAI, name, checkInterval) { } @@ -44,8 +47,8 @@ std::string const FloatCalculatedValue::Format() return out.str(); } -CDPairCalculatedValue::CDPairCalculatedValue(PlayerbotAI* botAI, std::string const name, int32 checkInterval) : - CalculatedValue(botAI, name, checkInterval) +CDPairCalculatedValue::CDPairCalculatedValue(PlayerbotAI* botAI, std::string const name, int32 checkInterval) + : CalculatedValue(botAI, name, checkInterval) { // lastCheckTime = getMSTime() - checkInterval / 2; } @@ -62,15 +65,16 @@ std::string const CDPairCalculatedValue::Format() return ""; } -CDPairListCalculatedValue::CDPairListCalculatedValue(PlayerbotAI* botAI, std::string const name, int32 checkInterval) : - CalculatedValue>(botAI, name, checkInterval) +CDPairListCalculatedValue::CDPairListCalculatedValue(PlayerbotAI* botAI, std::string const name, int32 checkInterval) + : CalculatedValue>(botAI, name, checkInterval) { // lastCheckTime = time(nullptr) - checkInterval / 2; } std::string const CDPairListCalculatedValue::Format() { - std::ostringstream out; out << "{"; + std::ostringstream out; + out << "{"; std::vector cdPairs = Calculate(); for (CreatureData const* cdPair : cdPairs) { @@ -81,8 +85,8 @@ std::string const CDPairListCalculatedValue::Format() return out.str(); } -ObjectGuidCalculatedValue::ObjectGuidCalculatedValue(PlayerbotAI* botAI, std::string const name, int32 checkInterval) : - CalculatedValue(botAI, name, checkInterval) +ObjectGuidCalculatedValue::ObjectGuidCalculatedValue(PlayerbotAI* botAI, std::string const name, int32 checkInterval) + : CalculatedValue(botAI, name, checkInterval) { // lastCheckTime = time(nullptr) - checkInterval / 2; } @@ -93,8 +97,9 @@ std::string const ObjectGuidCalculatedValue::Format() return guid ? std::to_string(guid.GetRawValue()) : ""; } -ObjectGuidListCalculatedValue::ObjectGuidListCalculatedValue(PlayerbotAI* botAI, std::string const name, int32 checkInterval) : - CalculatedValue(botAI, name, checkInterval) +ObjectGuidListCalculatedValue::ObjectGuidListCalculatedValue(PlayerbotAI* botAI, std::string const name, + int32 checkInterval) + : CalculatedValue(botAI, name, checkInterval) { } @@ -116,17 +121,22 @@ std::string const ObjectGuidListCalculatedValue::Format() Unit* UnitCalculatedValue::Get() { - if (checkInterval < 2) { - PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_VALUE, this->getName(), this->context ? &this->context->performanceStack : nullptr); + if (checkInterval < 2) + { + PerformanceMonitorOperation* pmo = sPerformanceMonitor->start( + PERF_MON_VALUE, this->getName(), this->context ? &this->context->performanceStack : nullptr); value = Calculate(); if (pmo) pmo->finish(); - } else { + } + else + { time_t now = getMSTime(); if (!lastCheckTime || now - lastCheckTime >= checkInterval) { lastCheckTime = now; - PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_VALUE, this->getName(), this->context ? &this->context->performanceStack : nullptr); + PerformanceMonitorOperation* pmo = sPerformanceMonitor->start( + PERF_MON_VALUE, this->getName(), this->context ? &this->context->performanceStack : nullptr); value = Calculate(); if (pmo) pmo->finish(); diff --git a/src/strategy/Value.h b/src/strategy/Value.h index 4d4196a3..2ea60de7 100644 --- a/src/strategy/Value.h +++ b/src/strategy/Value.h @@ -1,388 +1,418 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_VALUE_H #define _PLAYERBOT_VALUE_H +#include + #include "AiObject.h" #include "ObjectGuid.h" #include "PerformanceMonitor.h" #include "Timer.h" #include "Unit.h" -#include - class PlayerbotAI; class Unit; class FleeInfo { - public: - Position fromPos; - float radius; - float angle; - uint32 timestamp; - int GetAngleRangeIndex() { return (angle + 2 * M_PI) / (M_PI / 2); } // [0, 7) +public: + Position fromPos; + float radius; + float angle; + uint32 timestamp; + int GetAngleRangeIndex() { return (angle + 2 * M_PI) / (M_PI / 2); } // [0, 7) }; struct CreatureData; class UntypedValue : public AiNamedObject { - public: - UntypedValue(PlayerbotAI* botAI, std::string const name) : AiNamedObject(botAI, name) { } - virtual ~UntypedValue() { } - virtual void Update() { } - virtual void Reset() { } - virtual std::string const Format() { return "?"; } - virtual std::string const Save() { return "?"; } - virtual bool Load([[maybe_unused]] std::string const value) { return false; } +public: + UntypedValue(PlayerbotAI* botAI, std::string const name) : AiNamedObject(botAI, name) {} + virtual ~UntypedValue() {} + virtual void Update() {} + virtual void Reset() {} + virtual std::string const Format() { return "?"; } + virtual std::string const Save() { return "?"; } + virtual bool Load([[maybe_unused]] std::string const value) { return false; } }; -template +template class Value { - public: - virtual ~Value() { } - virtual T Get() = 0; - virtual T LazyGet() = 0; - virtual T& RefGet() = 0; - virtual void Reset() { } - virtual void Set(T value) = 0; - operator T() { return Get(); } +public: + virtual ~Value() {} + virtual T Get() = 0; + virtual T LazyGet() = 0; + virtual T& RefGet() = 0; + virtual void Reset() {} + virtual void Set(T value) = 0; + operator T() { return Get(); } }; -template +template class CalculatedValue : public UntypedValue, public Value { - public: - CalculatedValue(PlayerbotAI* botAI, std::string const name = "value", uint32 checkInterval = 1) : UntypedValue(botAI, name), - checkInterval(checkInterval == 1 ? 1 : (checkInterval < 100 ? checkInterval * 1000 : checkInterval)) /*turn s -> ms?*/, lastCheckTime(0) { } +public: + CalculatedValue(PlayerbotAI* botAI, std::string const name = "value", uint32 checkInterval = 1) + : UntypedValue(botAI, name), + checkInterval( + checkInterval == 1 ? 1 : (checkInterval < 100 ? checkInterval * 1000 : checkInterval)) /*turn s -> ms?*/, + lastCheckTime(0) + { + } - virtual ~CalculatedValue() { } + virtual ~CalculatedValue() {} - T Get() override + T Get() override + { + if (checkInterval < 2) { - if (checkInterval < 2) { - // PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_VALUE, this->getName(), this->context ? &this->context->performanceStack : nullptr); + // PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_VALUE, this->getName(), + // this->context ? &this->context->performanceStack : nullptr); + value = Calculate(); + // if (pmo) + // pmo->finish(); + } + else + { + time_t now = getMSTime(); + if (!lastCheckTime || now - lastCheckTime >= checkInterval) + { + lastCheckTime = now; + // PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_VALUE, this->getName(), + // this->context ? &this->context->performanceStack : nullptr); value = Calculate(); // if (pmo) // pmo->finish(); - } else { - time_t now = getMSTime(); - if (!lastCheckTime || now - lastCheckTime >= checkInterval) - { - lastCheckTime = now; - // PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_VALUE, this->getName(), this->context ? &this->context->performanceStack : nullptr); - value = Calculate(); - // if (pmo) - // pmo->finish(); - } } - return value; } + return value; + } - T LazyGet() override + T LazyGet() override + { + if (!lastCheckTime) + return Get(); + + return value; + } + T& RefGet() override + { + if (checkInterval < 2) { - if (!lastCheckTime) - return Get(); - - return value; + // PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_VALUE, this->getName(), + // this->context ? &this->context->performanceStack : nullptr); + value = Calculate(); + // if (pmo) + // pmo->finish(); } - T& RefGet() override + else { - if (checkInterval < 2) { - // PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_VALUE, this->getName(), this->context ? &this->context->performanceStack : nullptr); + time_t now = getMSTime(); + if (!lastCheckTime || now - lastCheckTime >= checkInterval) + { + lastCheckTime = now; + // PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_VALUE, this->getName(), + // this->context ? &this->context->performanceStack : nullptr); value = Calculate(); // if (pmo) // pmo->finish(); - } else { - time_t now = getMSTime(); - if (!lastCheckTime || now - lastCheckTime >= checkInterval) - { - lastCheckTime = now; - // PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_VALUE, this->getName(), this->context ? &this->context->performanceStack : nullptr); - value = Calculate(); - // if (pmo) - // pmo->finish(); - } } - return value; } - void Set(T val) override { value = val; } - void Update() override {} - void Reset() override { lastCheckTime = 0; } + return value; + } + void Set(T val) override { value = val; } + void Update() override {} + void Reset() override { lastCheckTime = 0; } - protected: - virtual T Calculate() = 0; +protected: + virtual T Calculate() = 0; - uint32 checkInterval; - uint32 lastCheckTime; - T value; + uint32 checkInterval; + uint32 lastCheckTime; + T value; }; template class SingleCalculatedValue : public CalculatedValue { - public: - SingleCalculatedValue(PlayerbotAI* botAI, std::string const name = "value") : CalculatedValue(botAI, name) +public: + SingleCalculatedValue(PlayerbotAI* botAI, std::string const name = "value") : CalculatedValue(botAI, name) + { + this->Reset(); + } + + T Get() override + { + time_t now = time(0); + if (!this->lastCheckTime) { - this->Reset(); + this->lastCheckTime = now; + + PerformanceMonitorOperation* pmo = sPerformanceMonitor->start( + PERF_MON_VALUE, this->getName(), this->context ? &this->context->performanceStack : nullptr); + this->value = this->Calculate(); + if (pmo) + pmo->finish(); } - T Get() override - { - time_t now = time(0); - if (!this->lastCheckTime) - { - this->lastCheckTime = now; - - PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_VALUE, this->getName(), this->context ? &this->context->performanceStack : nullptr); - this->value = this->Calculate(); - if (pmo) - pmo->finish(); - } - - return this->value; - } + return this->value; + } }; -template +template class MemoryCalculatedValue : public CalculatedValue { - public: - MemoryCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1) : CalculatedValue(botAI, name, checkInterval) - { - lastChangeTime = time(0); - } +public: + MemoryCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1) + : CalculatedValue(botAI, name, checkInterval) + { + lastChangeTime = time(0); + } - virtual bool EqualToLast(T value) = 0; - virtual bool CanCheckChange() - { - return time(0) - lastChangeTime < minChangeInterval || EqualToLast(this->value); - } + virtual bool EqualToLast(T value) = 0; + virtual bool CanCheckChange() { return time(0) - lastChangeTime < minChangeInterval || EqualToLast(this->value); } - virtual bool UpdateChange() - { - if (CanCheckChange()) - return false; + virtual bool UpdateChange() + { + if (CanCheckChange()) + return false; - lastChangeTime = time(0); - lastValue = this->value; - return true; - } + lastChangeTime = time(0); + lastValue = this->value; + return true; + } - void Set([[maybe_unused]] T value) override - { - CalculatedValue::Set(this->value); - UpdateChange(); - } + void Set([[maybe_unused]] T value) override + { + CalculatedValue::Set(this->value); + UpdateChange(); + } - T Get() override - { - this->value = CalculatedValue::Get(); - UpdateChange(); - return this->value; - } + T Get() override + { + this->value = CalculatedValue::Get(); + UpdateChange(); + return this->value; + } - T LazyGet() override - { - return this->value; - } + T LazyGet() override { return this->value; } - time_t LastChangeOn() - { - Get(); - UpdateChange(); - return lastChangeTime; - } + time_t LastChangeOn() + { + Get(); + UpdateChange(); + return lastChangeTime; + } - uint32 LastChangeDelay() { return time(0) - LastChangeOn(); } + uint32 LastChangeDelay() { return time(0) - LastChangeOn(); } - void Reset() override - { - CalculatedValue::Reset(); - lastChangeTime = time(0); - } + void Reset() override + { + CalculatedValue::Reset(); + lastChangeTime = time(0); + } - protected: - T lastValue; - uint32 minChangeInterval = 0; - time_t lastChangeTime; +protected: + T lastValue; + uint32 minChangeInterval = 0; + time_t lastChangeTime; }; -template +template class LogCalculatedValue : public MemoryCalculatedValue { - public: - LogCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1) : MemoryCalculatedValue(botAI, name, checkInterval) { } +public: + LogCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1) + : MemoryCalculatedValue(botAI, name, checkInterval) + { + } - bool UpdateChange() override - { - if (MemoryCalculatedValue::UpdateChange()) - return false; + bool UpdateChange() override + { + if (MemoryCalculatedValue::UpdateChange()) + return false; - valueLog.push_back(std::make_pair(this->value, time(0))); + valueLog.push_back(std::make_pair(this->value, time(0))); - if (valueLog.size() > logLength) - valueLog.pop_front(); - return true; - } + if (valueLog.size() > logLength) + valueLog.pop_front(); + return true; + } - std::list> ValueLog() { return valueLog; } + std::list> ValueLog() { return valueLog; } - void Reset() override - { - MemoryCalculatedValue::Reset(); - valueLog.clear(); - } + void Reset() override + { + MemoryCalculatedValue::Reset(); + valueLog.clear(); + } - protected: - std::list> valueLog; - uint8 logLength = 10; - }; +protected: + std::list> valueLog; + uint8 logLength = 10; +}; class Uint8CalculatedValue : public CalculatedValue { - public: - Uint8CalculatedValue(PlayerbotAI* botAI, std::string const name = "value", uint32 checkInterval = 1) : - CalculatedValue(botAI, name, checkInterval) { } +public: + Uint8CalculatedValue(PlayerbotAI* botAI, std::string const name = "value", uint32 checkInterval = 1) + : CalculatedValue(botAI, name, checkInterval) + { + } - std::string const Format() override; + std::string const Format() override; }; class Uint32CalculatedValue : public CalculatedValue { - public: - Uint32CalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int checkInterval = 1) : - CalculatedValue(botAI, name, checkInterval) { } +public: + Uint32CalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int checkInterval = 1) + : CalculatedValue(botAI, name, checkInterval) + { + } - std::string const Format() override; + std::string const Format() override; }; class FloatCalculatedValue : public CalculatedValue { - public: - FloatCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int checkInterval = 1) : - CalculatedValue(botAI, name, checkInterval) { } +public: + FloatCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int checkInterval = 1) + : CalculatedValue(botAI, name, checkInterval) + { + } - std::string const Format() override; + std::string const Format() override; }; class BoolCalculatedValue : public CalculatedValue { - public: - BoolCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int checkInterval = 1) : - CalculatedValue(botAI, name, checkInterval) { } +public: + BoolCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int checkInterval = 1) + : CalculatedValue(botAI, name, checkInterval) + { + } - std::string const Format() override - { - return Calculate() ? "true" : "false"; - } + std::string const Format() override { return Calculate() ? "true" : "false"; } }; class UnitCalculatedValue : public CalculatedValue { - public: - UnitCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1); +public: + UnitCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1); - std::string const Format() override; - Unit* Get() override; + std::string const Format() override; + Unit* Get() override; }; class CDPairCalculatedValue : public CalculatedValue { - public: - CDPairCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1); +public: + CDPairCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1); - std::string const Format() override; + std::string const Format() override; }; class CDPairListCalculatedValue : public CalculatedValue> { - public: - CDPairListCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1); +public: + CDPairListCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1); - std::string const Format() override; + std::string const Format() override; }; class ObjectGuidCalculatedValue : public CalculatedValue { - public: - ObjectGuidCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1); +public: + ObjectGuidCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1); - std::string const Format() override; + std::string const Format() override; }; class ObjectGuidListCalculatedValue : public CalculatedValue { - public: - ObjectGuidListCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1); +public: + ObjectGuidListCalculatedValue(PlayerbotAI* botAI, std::string const name = "value", int32 checkInterval = 1); - std::string const Format() override; + std::string const Format() override; }; -template +template class ManualSetValue : public UntypedValue, public Value { - public: - ManualSetValue(PlayerbotAI* botAI, T defaultValue, std::string const name = "value") : - UntypedValue(botAI, name), value(defaultValue), defaultValue(defaultValue) { } +public: + ManualSetValue(PlayerbotAI* botAI, T defaultValue, std::string const name = "value") + : UntypedValue(botAI, name), value(defaultValue), defaultValue(defaultValue) + { + } - virtual ~ManualSetValue() { } + virtual ~ManualSetValue() {} - T Get() override { return value; } - T LazyGet() override { return value; } - T& RefGet() override { return value; } - void Set(T val) override { value = val; } - void Update() override {} - void Reset() override - { - value = defaultValue; - } + T Get() override { return value; } + T LazyGet() override { return value; } + T& RefGet() override { return value; } + void Set(T val) override { value = val; } + void Update() override {} + void Reset() override { value = defaultValue; } - protected: - T value; - T defaultValue; +protected: + T value; + T defaultValue; }; class UnitManualSetValue : public ManualSetValue { - public: - UnitManualSetValue(PlayerbotAI* botAI, Unit* defaultValue, std::string const name = "value") : - ManualSetValue(botAI, defaultValue, name) { } +public: + UnitManualSetValue(PlayerbotAI* botAI, Unit* defaultValue, std::string const name = "value") + : ManualSetValue(botAI, defaultValue, name) + { + } - std::string const Format() override; - Unit* Get() override; + std::string const Format() override; + Unit* Get() override; }; class DisperseDistanceValue : public ManualSetValue { - public: - DisperseDistanceValue(PlayerbotAI* botAI, float defaultValue = -1.0f, std::string const name = "disperse distance") : - ManualSetValue(botAI, defaultValue, name) { } +public: + DisperseDistanceValue(PlayerbotAI* botAI, float defaultValue = -1.0f, std::string const name = "disperse distance") + : ManualSetValue(botAI, defaultValue, name) + { + } }; class LastFleeAngleValue : public ManualSetValue { - public: - LastFleeAngleValue(PlayerbotAI* botAI, float defaultValue = 0.0f, std::string const name = "last flee angle") : - ManualSetValue(botAI, defaultValue, name) { } +public: + LastFleeAngleValue(PlayerbotAI* botAI, float defaultValue = 0.0f, std::string const name = "last flee angle") + : ManualSetValue(botAI, defaultValue, name) + { + } }; class LastFleeTimestampValue : public ManualSetValue { - public: - LastFleeTimestampValue(PlayerbotAI* botAI, uint32 defaultValue = 0, std::string const name = "last flee timestamp") : - ManualSetValue(botAI, defaultValue, name) { } +public: + LastFleeTimestampValue(PlayerbotAI* botAI, uint32 defaultValue = 0, std::string const name = "last flee timestamp") + : ManualSetValue(botAI, defaultValue, name) + { + } }; class RecentlyFleeInfo : public ManualSetValue> { - public: - RecentlyFleeInfo(PlayerbotAI* botAI, std::list defaultValue = {}, std::string const name = "recently flee info") : - ManualSetValue>(botAI, defaultValue, name) { } +public: + RecentlyFleeInfo(PlayerbotAI* botAI, std::list defaultValue = {}, + std::string const name = "recently flee info") + : ManualSetValue>(botAI, defaultValue, name) + { + } }; #endif diff --git a/src/strategy/actions/AcceptBattlegroundInvitationAction.cpp b/src/strategy/actions/AcceptBattlegroundInvitationAction.cpp index 38382bc3..7ff30433 100644 --- a/src/strategy/actions/AcceptBattlegroundInvitationAction.cpp +++ b/src/strategy/actions/AcceptBattlegroundInvitationAction.cpp @@ -1,22 +1,24 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AcceptBattlegroundInvitationAction.h" + #include "Event.h" #include "Playerbots.h" bool AcceptBgInvitationAction::Execute(Event event) { - uint8 type = 0; // arenatype if arena - uint8 unk2 = 0; // unk, can be 0x0 (may be if was invited?) and 0x1 - uint32 bgTypeId_ = BATTLEGROUND_WS; // type id from dbc - uint16 unk = 0x1F90; // 0x1F90 constant?*/ + uint8 type = 0; // arenatype if arena + uint8 unk2 = 0; // unk, can be 0x0 (may be if was invited?) and 0x1 + uint32 bgTypeId_ = BATTLEGROUND_WS; // type id from dbc + uint16 unk = 0x1F90; // 0x1F90 constant?*/ uint8 action = 1; WorldPacket packet(CMSG_BATTLEFIELD_PORT, 20); packet << type << unk2 << (uint32)bgTypeId_ << unk << action; - //packet << bgTypeId_ << action; + // packet << bgTypeId_ << action; bot->GetSession()->HandleBattleFieldPortOpcode(packet); botAI->ResetStrategies(); diff --git a/src/strategy/actions/AcceptBattlegroundInvitationAction.h b/src/strategy/actions/AcceptBattlegroundInvitationAction.h index a949f216..3552957b 100644 --- a/src/strategy/actions/AcceptBattlegroundInvitationAction.h +++ b/src/strategy/actions/AcceptBattlegroundInvitationAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ACCEPTBATTLEGROUNDINVITATIONACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class AcceptBgInvitationAction : public Action { - public: - AcceptBgInvitationAction(PlayerbotAI* botAI) : Action(botAI, "accept bg invitatio") { } +public: + AcceptBgInvitationAction(PlayerbotAI* botAI) : Action(botAI, "accept bg invitatio") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/AcceptDuelAction.cpp b/src/strategy/actions/AcceptDuelAction.cpp index 8c41378b..fe88fe07 100644 --- a/src/strategy/actions/AcceptDuelAction.cpp +++ b/src/strategy/actions/AcceptDuelAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AcceptDuelAction.h" + #include "Event.h" #include "Playerbots.h" @@ -16,7 +18,8 @@ bool AcceptDuelAction::Execute(Event event) p >> playerGuid; // do not auto duel with low hp - if ((!botAI->HasRealPlayerMaster() || (botAI->GetMaster() && botAI->GetMaster()->GetGUID() != playerGuid)) && AI_VALUE2(uint8, "health", "self target") < 90) + if ((!botAI->HasRealPlayerMaster() || (botAI->GetMaster() && botAI->GetMaster()->GetGUID() != playerGuid)) && + AI_VALUE2(uint8, "health", "self target") < 90) { WorldPacket packet(CMSG_DUEL_CANCELLED, 8); packet << flagGuid; diff --git a/src/strategy/actions/AcceptDuelAction.h b/src/strategy/actions/AcceptDuelAction.h index fe665e86..c49efb9d 100644 --- a/src/strategy/actions/AcceptDuelAction.h +++ b/src/strategy/actions/AcceptDuelAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ACCEPTDUELACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class AcceptDuelAction : public Action { - public: - AcceptDuelAction(PlayerbotAI* botAI) : Action(botAI, "accept duel") { } +public: + AcceptDuelAction(PlayerbotAI* botAI) : Action(botAI, "accept duel") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/AcceptInvitationAction.cpp b/src/strategy/actions/AcceptInvitationAction.cpp index 5bd261c1..4b8e3159 100644 --- a/src/strategy/actions/AcceptInvitationAction.cpp +++ b/src/strategy/actions/AcceptInvitationAction.cpp @@ -1,13 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AcceptInvitationAction.h" + #include "Event.h" #include "ObjectAccessor.h" #include "PlayerbotAIConfig.h" -#include "Playerbots.h" #include "PlayerbotSecurity.h" +#include "Playerbots.h" #include "WorldPacket.h" bool AcceptInvitationAction::Execute(Event event) @@ -41,8 +43,8 @@ bool AcceptInvitationAction::Execute(Event event) if (sRandomPlayerbotMgr->IsRandomBot(bot)) botAI->SetMaster(inviter); - //else - //sPlayerbotDbStore->Save(botAI); + // else + // sPlayerbotDbStore->Save(botAI); botAI->ResetStrategies(); botAI->ChangeStrategy("+follow,-lfg,-bg", BOT_STATE_NON_COMBAT); @@ -50,7 +52,8 @@ bool AcceptInvitationAction::Execute(Event event) botAI->TellMaster("Hello"); - if (sPlayerbotAIConfig->summonWhenGroup && bot->GetDistance(inviter) > sPlayerbotAIConfig->sightDistance) { + if (sPlayerbotAIConfig->summonWhenGroup && bot->GetDistance(inviter) > sPlayerbotAIConfig->sightDistance) + { Teleport(inviter, bot); } return true; diff --git a/src/strategy/actions/AcceptInvitationAction.h b/src/strategy/actions/AcceptInvitationAction.h index fd4154bd..7208fbe4 100644 --- a/src/strategy/actions/AcceptInvitationAction.h +++ b/src/strategy/actions/AcceptInvitationAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ACCEPTINVITATIONACTION_H @@ -12,10 +13,10 @@ class PlayerbotAI; class AcceptInvitationAction : public SummonAction { - public: - AcceptInvitationAction(PlayerbotAI* botAI) : SummonAction(botAI, "accept invitation") { } +public: + AcceptInvitationAction(PlayerbotAI* botAI) : SummonAction(botAI, "accept invitation") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/AcceptQuestAction.cpp b/src/strategy/actions/AcceptQuestAction.cpp index ec6674cc..51e64db0 100644 --- a/src/strategy/actions/AcceptQuestAction.cpp +++ b/src/strategy/actions/AcceptQuestAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AcceptQuestAction.h" + #include "Event.h" #include "Playerbots.h" @@ -112,7 +114,7 @@ bool AcceptQuestShareAction::Execute(Event event) bot->SetDivider(ObjectGuid::Empty); } - if (bot->CanAddQuest( qInfo, false)) + if (bot->CanAddQuest(qInfo, false)) { bot->AddQuest(qInfo, master); @@ -125,7 +127,7 @@ bool AcceptQuestShareAction::Execute(Event event) if (qInfo->GetSrcSpell() > 0) { - bot->CastSpell( bot, qInfo->GetSrcSpell(), true); + bot->CastSpell(bot, qInfo->GetSrcSpell(), true); } botAI->TellMaster("Quest accepted"); diff --git a/src/strategy/actions/AcceptQuestAction.h b/src/strategy/actions/AcceptQuestAction.h index a843fc41..4a9cba03 100644 --- a/src/strategy/actions/AcceptQuestAction.h +++ b/src/strategy/actions/AcceptQuestAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ACCEPTQUESTACTION_H @@ -13,25 +14,27 @@ class WorldObject; class AcceptAllQuestsAction : public QuestAction { - public: - AcceptAllQuestsAction(PlayerbotAI* botAI, std::string const name = "accept all quests") : QuestAction(botAI, name) { } +public: + AcceptAllQuestsAction(PlayerbotAI* botAI, std::string const name = "accept all quests") : QuestAction(botAI, name) + { + } - protected: - void ProcessQuest(Quest const* quest, Object* questGiver) override; +protected: + void ProcessQuest(Quest const* quest, Object* questGiver) override; }; class AcceptQuestAction : public AcceptAllQuestsAction { - public: - AcceptQuestAction(PlayerbotAI* botAI) : AcceptAllQuestsAction(botAI, "accept quest") { } - bool Execute(Event event) override; +public: + AcceptQuestAction(PlayerbotAI* botAI) : AcceptAllQuestsAction(botAI, "accept quest") {} + bool Execute(Event event) override; }; class AcceptQuestShareAction : public Action { - public: - AcceptQuestShareAction(PlayerbotAI* botAI) : Action(botAI, "accept quest share") { } - bool Execute(Event event) override; +public: + AcceptQuestShareAction(PlayerbotAI* botAI) : Action(botAI, "accept quest share") {} + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/AcceptResurrectAction.cpp b/src/strategy/actions/AcceptResurrectAction.cpp index acae958a..cdf6fb6a 100644 --- a/src/strategy/actions/AcceptResurrectAction.cpp +++ b/src/strategy/actions/AcceptResurrectAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AcceptResurrectAction.h" + #include "Event.h" #include "Playerbots.h" @@ -18,8 +20,8 @@ bool AcceptResurrectAction::Execute(Event event) WorldPacket packet(CMSG_RESURRECT_RESPONSE, 8 + 1); packet << guid; - packet << uint8(1); // accept - bot->GetSession()->HandleResurrectResponseOpcode(packet); // queue the packet to get around race condition + packet << uint8(1); // accept + bot->GetSession()->HandleResurrectResponseOpcode(packet); // queue the packet to get around race condition botAI->ChangeEngine(BOT_STATE_NON_COMBAT); diff --git a/src/strategy/actions/AcceptResurrectAction.h b/src/strategy/actions/AcceptResurrectAction.h index d3aed1dd..9dfa3a81 100644 --- a/src/strategy/actions/AcceptResurrectAction.h +++ b/src/strategy/actions/AcceptResurrectAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ACCEPTRESURRECTACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class AcceptResurrectAction : public Action { - public: - AcceptResurrectAction(PlayerbotAI* botAI) : Action(botAI, "accept resurrect") { } +public: + AcceptResurrectAction(PlayerbotAI* botAI) : Action(botAI, "accept resurrect") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ActionContext.h b/src/strategy/actions/ActionContext.h index e7caf4e2..dc40d9ff 100644 --- a/src/strategy/actions/ActionContext.h +++ b/src/strategy/actions/ActionContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ACTIONCONTEXT_H @@ -8,21 +9,23 @@ #include "AddLootAction.h" #include "AttackAction.h" #include "AutoLearnSpellAction.h" -#include "BattleGroundTactics.h" +#include "AutoTeleportForLevelAction.h" #include "BattleGroundJoinAction.h" +#include "BattleGroundTactics.h" #include "BuyAction.h" #include "CastCustomSpellAction.h" #include "ChangeStrategyAction.h" #include "ChangeTalentsAction.h" #include "CheckMailAction.h" #include "CheckValuesAction.h" +#include "ChooseRpgTargetAction.h" #include "ChooseTargetActions.h" #include "ChooseTravelTargetAction.h" -#include "ChooseRpgTargetAction.h" #include "CombatActions.h" #include "DelayAction.h" #include "DestroyItemAction.h" #include "EmoteAction.h" +#include "FollowActions.h" #include "GenericActions.h" #include "GenericSpellActions.h" #include "GiveItemAction.h" @@ -33,14 +36,14 @@ #include "ImbueAction.h" #include "InviteToGroupAction.h" #include "LeaveGroupAction.h" -#include "FollowActions.h" #include "LootAction.h" -#include "MovementActions.h" #include "MoveToRpgTargetAction.h" #include "MoveToTravelTargetAction.h" +#include "MovementActions.h" #include "NonCombatActions.h" #include "OutfitAction.h" #include "PositionAction.h" +#include "RaidNaxxActions.h" #include "RandomBotUpdateAction.h" #include "ReachTargetActions.h" #include "ReleaseSpiritAction.h" @@ -54,354 +57,353 @@ #include "StayActions.h" #include "SuggestWhatToDoAction.h" #include "TravelAction.h" -#include "XpGainAction.h" #include "VehicleActions.h" #include "WorldBuffAction.h" -#include "RaidNaxxActions.h" -#include "AutoTeleportForLevelAction.h" +#include "XpGainAction.h" class PlayerbotAI; class ActionContext : public NamedObjectContext { - public: - ActionContext() - { - creators["mark rti"] = &ActionContext::mark_rti; - creators["set return position"] = &ActionContext::set_return_position; - creators["rpg"] = &ActionContext::rpg; - creators["crpg"] = &ActionContext::crpg; - creators["choose rpg target"] = &ActionContext::choose_rpg_target; - creators["move to rpg target"] = &ActionContext::move_to_rpg_target; - creators["travel"] = &ActionContext::travel; - creators["choose travel target"] = &ActionContext::choose_travel_target; - creators["move to travel target"] = &ActionContext::move_to_travel_target; - creators["move out of collision"] = &ActionContext::move_out_of_collision; - creators["move random"] = &ActionContext::move_random; - creators["attack"] = &ActionContext::melee; - creators["melee"] = &ActionContext::melee; - creators["switch to melee"] = &ActionContext::switch_to_melee; - creators["switch to ranged"] = &ActionContext::switch_to_ranged; - creators["reach spell"] = &ActionContext::ReachSpell; - creators["reach melee"] = &ActionContext::ReachMelee; - creators["reach party member to heal"] = &ActionContext::reach_party_member_to_heal; - creators["reach party member to resurrect"] = &ActionContext::reach_party_member_to_resurrect; - creators["flee"] = &ActionContext::flee; - creators["flee with pet"] = &ActionContext::flee_with_pet; - creators["avoid aoe"] = &ActionContext::avoid_aoe; - creators["combat formation move"] = &ActionContext::combat_formation_move; - creators["disperse set"] = &ActionContext::disperse_set; - creators["gift of the naaru"] = &ActionContext::gift_of_the_naaru; - creators["shoot"] = &ActionContext::shoot; - creators["lifeblood"] = &ActionContext::lifeblood; - creators["arcane torrent"] = &ActionContext::arcane_torrent; - creators["end pull"] = &ActionContext::end_pull; - creators["healthstone"] = &ActionContext::healthstone; - creators["healing potion"] = &ActionContext::healing_potion; - creators["mana potion"] = &ActionContext::mana_potion; - creators["food"] = &ActionContext::food; - creators["drink"] = &ActionContext::drink; - creators["tank assist"] = &ActionContext::tank_assist; - creators["dps assist"] = &ActionContext::dps_assist; - creators["dps aoe"] = &ActionContext::dps_aoe; - creators["attack rti target"] = &ActionContext::attack_rti_target; - creators["loot"] = &ActionContext::loot; - creators["add loot"] = &ActionContext::add_loot; - creators["add gathering loot"] = &ActionContext::add_gathering_loot; - creators["add all loot"] = &ActionContext::add_all_loot; - creators["release loot"] = &ActionContext::release_loot; - creators["shoot"] = &ActionContext::shoot; - creators["follow"] = &ActionContext::follow; - creators["flee to master"] = &ActionContext::flee_to_master; - creators["runaway"] = &ActionContext::runaway; - creators["stay"] = &ActionContext::stay; - creators["sit"] = &ActionContext::sit; - creators["attack anything"] = &ActionContext::attack_anything; - creators["attack least hp target"] = &ActionContext::attack_least_hp_target; - creators["attack enemy player"] = &ActionContext::attack_enemy_player; - creators["emote"] = &ActionContext::emote; - creators["talk"] = &ActionContext::talk; - creators["suggest what to do"] = &ActionContext::suggest_what_to_do; - creators["suggest trade"] = &ActionContext::suggest_trade; - creators["suggest dungeon"] = &ActionContext::suggest_dungeon; - creators["return"] = &ActionContext::_return; - creators["move to loot"] = &ActionContext::move_to_loot; - creators["open loot"] = &ActionContext::open_loot; - creators["guard"] = &ActionContext::guard; - creators["move out of enemy contact"] = &ActionContext::move_out_of_enemy_contact; - creators["set facing"] = &ActionContext::set_facing; - creators["set behind"] = &ActionContext::set_behind; - creators["attack duel opponent"] = &ActionContext::attack_duel_opponent; - creators["drop target"] = &ActionContext::drop_target; - creators["check mail"] = &ActionContext::check_mail; - creators["say"] = &ActionContext::say; - creators["reveal gathering item"] = &ActionContext::reveal_gathering_item; - creators["outfit"] = &ActionContext::outfit; - creators["random bot update"] = &ActionContext::random_bot_update; - creators["delay"] = &ActionContext::delay; - creators["greet"] = &ActionContext::greet; - creators["check values"] = &ActionContext::check_values; - creators["ra"] = &ActionContext::ra; - creators["apply poison"] = &ActionContext::apply_poison; - creators["apply stone"] = &ActionContext::apply_stone; - creators["apply oil"] = &ActionContext::apply_oil; - creators["try emergency"] = &ActionContext::try_emergency; - creators["give food"] = &ActionContext::give_food; - creators["give water"] = &ActionContext::give_water; - creators["mount"] = &ActionContext::mount; - creators["war stomp"] = &ActionContext::war_stomp; - creators["auto talents"] = &ActionContext::auto_talents; - creators["auto learn spell"] = &ActionContext::auto_learn_spell; - creators["auto teleport for level"] = &ActionContext::auto_teleport_for_level; - creators["auto upgrade equip"] = &ActionContext::auto_upgrade_equip; - creators["xp gain"] = &ActionContext::xp_gain; - creators["invite nearby"] = &ActionContext::invite_nearby; - creators["invite guild"] = &ActionContext::invite_guild; - creators["leave far away"] = &ActionContext::leave_far_away; - creators["move to dark portal"] = &ActionContext::move_to_dark_portal; - creators["move from dark portal"] = &ActionContext::move_from_dark_portal; - creators["use dark portal azeroth"] = &ActionContext::use_dark_portal_azeroth; - creators["world buff"] = &ActionContext::world_buff; - creators["hearthstone"] = &ActionContext::hearthstone; - creators["cast random spell"] = &ActionContext::cast_random_spell; - creators["free bg join"] = &ActionContext::free_bg_join; - creators["use random recipe"] = &ActionContext::use_random_recipe; - creators["use random quest item"] = &ActionContext::use_random_quest_item; - creators["craft random item"] = &ActionContext::craft_random_item; - creators["smart destroy item"] = &ActionContext::smart_destroy_item; - creators["disenchant random item"] = &ActionContext::disenchant_random_item; - creators["enchant random item"] = &ActionContext::enchant_random_item; - creators["reset instances"] = &ActionContext::reset_instances; - creators["buy petition"] = &ActionContext::buy_petition; - creators["offer petition"] = &ActionContext::offer_petition; - creators["offer petition nearby"] = &ActionContext::offer_petition_nearby; - creators["turn in petition"] = &ActionContext::turn_in_petition; - creators["buy tabard"] = &ActionContext::buy_tabard; - creators["guild manage nearby"] = &ActionContext::guild_manage_nearby; - - // BG Tactics - creators["bg tactics"] = &ActionContext::bg_tactics; - creators["bg move to start"] = &ActionContext::bg_move_to_start; - creators["bg move to objective"] = &ActionContext::bg_move_to_objective; - creators["bg select objective"] = &ActionContext::bg_select_objective; - creators["bg check objective"] = &ActionContext::bg_check_objective; - creators["bg attack fc"] = &ActionContext::bg_attack_fc; - creators["bg protect fc"] = &ActionContext::bg_protect_fc; - creators["bg use buff"] = &ActionContext::bg_use_buff; - creators["attack enemy flag carrier"] = &ActionContext::attack_enemy_fc; - creators["bg check flag"] = &ActionContext::bg_check_flag; - - // Vehicles - creators["enter vehicle"] = &ActionContext::enter_vehicle; - creators["leave vehicle"] = &ActionContext::leave_vehicle; - creators["hurl boulder"] = &ActionContext::hurl_boulder; - creators["ram"] = &ActionContext::ram; - creators["steam rush"] = &ActionContext::steam_rush; - creators["steam blast"] = &ActionContext::steam_blast; - creators["napalm"] = &ActionContext::napalm; - creators["fire cannon"] = &ActionContext::fire_cannon; - creators["incendiary rocket"] = &ActionContext::incendiary_rocket; - creators["rocket blast"] = &ActionContext::rocket_blast; - creators["blade salvo"] = &ActionContext::blade_salvo; - creators["glaive throw"] = &ActionContext::glaive_throw; - - //Rpg - creators["rpg stay"] = &ActionContext::rpg_stay; - creators["rpg work"] = &ActionContext::rpg_work; - creators["rpg emote"] = &ActionContext::rpg_emote; - creators["rpg cancel"] = &ActionContext::rpg_cancel; - creators["rpg taxi"] = &ActionContext::rpg_taxi; - creators["rpg discover"] = &ActionContext::rpg_discover; - creators["rpg start quest"] = &ActionContext::rpg_start_quest; - creators["rpg end quest"] = &ActionContext::rpg_end_quest; - creators["rpg buy"] = &ActionContext::rpg_buy; - creators["rpg sell"] = &ActionContext::rpg_sell; - creators["rpg repair"] = &ActionContext::rpg_repair; - creators["rpg train"] = &ActionContext::rpg_train; - creators["rpg heal"] = &ActionContext::rpg_heal; - creators["rpg home bind"] = &ActionContext::rpg_home_bind; - creators["rpg queue bg"] = &ActionContext::rpg_queue_bg; - creators["rpg buy petition"] = &ActionContext::rpg_buy_petition; - creators["rpg use"] = &ActionContext::rpg_use; - creators["rpg spell"] = &ActionContext::rpg_spell; - creators["rpg craft"] = &ActionContext::rpg_craft; - creators["rpg trade useful"] = &ActionContext::rpg_trade_useful; - creators["rpg duel"] = &ActionContext::rpg_duel; - creators["rpg mount anim"] = &ActionContext::rpg_mount_anim; - - creators["toggle pet spell"] = &ActionContext::toggle_pet_spell; - creators["pet attack"] = &ActionContext::pet_attack; - - } - - private: - static Action* give_water(PlayerbotAI* botAI) { return new GiveWaterAction(botAI); } - static Action* give_food(PlayerbotAI* botAI) { return new GiveFoodAction(botAI); } - static Action* ra(PlayerbotAI* botAI) { return new RemoveAuraAction(botAI); } - static Action* mark_rti(PlayerbotAI* botAI) { return new MarkRtiAction(botAI); } - static Action* set_return_position(PlayerbotAI* botAI) { return new SetReturnPositionAction(botAI); } - static Action* rpg(PlayerbotAI* botAI) { return new RpgAction(botAI); } - static Action* crpg(PlayerbotAI* botAI) { return new CRpgAction(botAI); } - static Action* choose_rpg_target(PlayerbotAI* botAI) { return new ChooseRpgTargetAction(botAI); } - static Action* move_to_rpg_target(PlayerbotAI* botAI) { return new MoveToRpgTargetAction(botAI); } - static Action* travel(PlayerbotAI* botAI) { return new TravelAction(botAI); } - static Action* choose_travel_target(PlayerbotAI* botAI) { return new ChooseTravelTargetAction(botAI); } - static Action* move_to_travel_target(PlayerbotAI* botAI) { return new MoveToTravelTargetAction(botAI); } - static Action* move_out_of_collision(PlayerbotAI* botAI) { return new MoveOutOfCollisionAction(botAI); } - static Action* move_random(PlayerbotAI* botAI) { return new MoveRandomAction(botAI); } - static Action* check_values(PlayerbotAI* botAI) { return new CheckValuesAction(botAI); } - static Action* greet(PlayerbotAI* botAI) { return new GreetAction(botAI); } - static Action* check_mail(PlayerbotAI* botAI) { return new CheckMailAction(botAI); } - static Action* drop_target(PlayerbotAI* botAI) { return new DropTargetAction(botAI); } - static Action* attack_duel_opponent(PlayerbotAI* botAI) { return new AttackDuelOpponentAction(botAI); } - static Action* guard(PlayerbotAI* botAI) { return new GuardAction(botAI); } - static Action* open_loot(PlayerbotAI* botAI) { return new OpenLootAction(botAI); } - static Action* move_to_loot(PlayerbotAI* botAI) { return new MoveToLootAction(botAI); } - static Action* _return(PlayerbotAI* botAI) { return new ReturnAction(botAI); } - static Action* shoot(PlayerbotAI* botAI) { return new CastShootAction(botAI); } - static Action* melee(PlayerbotAI* botAI) { return new MeleeAction(botAI); } - static Action* switch_to_melee(PlayerbotAI* botAI) { return new SwitchToMeleeAction(botAI); } - static Action* switch_to_ranged(PlayerbotAI* botAI) { return new SwitchToRangedAction(botAI); } - static Action* ReachSpell(PlayerbotAI* botAI) { return new ReachSpellAction(botAI); } - static Action* ReachMelee(PlayerbotAI* botAI) { return new ReachMeleeAction(botAI); } - static Action* reach_party_member_to_heal(PlayerbotAI* botAI) { return new ReachPartyMemberToHealAction(botAI); } - static Action* reach_party_member_to_resurrect(PlayerbotAI* botAI) { return new ReachPartyMemberToResurrectAction(botAI); } - static Action* flee(PlayerbotAI* botAI) { return new FleeAction(botAI); } - static Action* flee_with_pet(PlayerbotAI* botAI) { return new FleeWithPetAction(botAI); } - static Action* avoid_aoe(PlayerbotAI* botAI) { return new AvoidAoeAction(botAI); } - static Action* combat_formation_move(PlayerbotAI* botAI) { return new CombatFormationMoveAction(botAI); } - static Action* disperse_set(PlayerbotAI* botAI) { return new DisperseSetAction(botAI); } - static Action* gift_of_the_naaru(PlayerbotAI* botAI) { return new CastGiftOfTheNaaruAction(botAI); } - static Action* lifeblood(PlayerbotAI* botAI) { return new CastLifeBloodAction(botAI); } - static Action* arcane_torrent(PlayerbotAI* botAI) { return new CastArcaneTorrentAction(botAI); } - static Action* mana_tap(PlayerbotAI* botAI) { return new CastManaTapAction(botAI); } - static Action* end_pull(PlayerbotAI* botAI) { return new ChangeCombatStrategyAction(botAI, "-pull"); } - - static Action* emote(PlayerbotAI* botAI) { return new EmoteAction(botAI); } - static Action* talk(PlayerbotAI* botAI) { return new TalkAction(botAI); } - static Action* suggest_what_to_do(PlayerbotAI* botAI) { return new SuggestWhatToDoAction(botAI); } - static Action* suggest_trade(PlayerbotAI* botAI) { return new SuggestTradeAction(botAI); } - static Action* suggest_dungeon(PlayerbotAI* botAI) { return new SuggestDungeonAction(botAI); } - static Action* attack_anything(PlayerbotAI* botAI) { return new AttackAnythingAction(botAI); } - static Action* attack_least_hp_target(PlayerbotAI* botAI) { return new AttackLeastHpTargetAction(botAI); } - static Action* attack_enemy_player(PlayerbotAI* botAI) { return new AttackEnemyPlayerAction(botAI); } - static Action* stay(PlayerbotAI* botAI) { return new StayAction(botAI); } - static Action* sit(PlayerbotAI* botAI) { return new SitAction(botAI); } - static Action* runaway(PlayerbotAI* botAI) { return new RunAwayAction(botAI); } - static Action* follow(PlayerbotAI* botAI) { return new FollowAction(botAI); } - static Action* flee_to_master(PlayerbotAI* botAI) { return new FleeToMasterAction(botAI); } - static Action* add_gathering_loot(PlayerbotAI* botAI) { return new AddGatheringLootAction(botAI); } - static Action* add_loot(PlayerbotAI* botAI) { return new AddLootAction(botAI); } - static Action* add_all_loot(PlayerbotAI* botAI) { return new AddAllLootAction(botAI); } - static Action* loot(PlayerbotAI* botAI) { return new LootAction(botAI); } - static Action* release_loot(PlayerbotAI* botAI) { return new ReleaseLootAction(botAI); } - static Action* dps_assist(PlayerbotAI* botAI) { return new DpsAssistAction(botAI); } - static Action* dps_aoe(PlayerbotAI* botAI) { return new DpsAoeAction(botAI); } - static Action* attack_rti_target(PlayerbotAI* botAI) { return new AttackRtiTargetAction(botAI); } - static Action* tank_assist(PlayerbotAI* botAI) { return new TankAssistAction(botAI); } - static Action* drink(PlayerbotAI* botAI) { return new DrinkAction(botAI); } - static Action* food(PlayerbotAI* botAI) { return new EatAction(botAI); } - static Action* mana_potion(PlayerbotAI* botAI) { return new UseManaPotion(botAI); } - static Action* healing_potion(PlayerbotAI* botAI) { return new UseHealingPotion(botAI); } - static Action* healthstone(PlayerbotAI* botAI) { return new UseItemAction(botAI, "healthstone"); } - static Action* move_out_of_enemy_contact(PlayerbotAI* botAI) { return new MoveOutOfEnemyContactAction(botAI); } - static Action* set_facing(PlayerbotAI* botAI) { return new SetFacingTargetAction(botAI); } - static Action* set_behind(PlayerbotAI* botAI) { return new SetBehindTargetAction(botAI); } - static Action* say(PlayerbotAI* botAI) { return new SayAction(botAI); } - static Action* reveal_gathering_item(PlayerbotAI* botAI) { return new RevealGatheringItemAction(botAI); } - static Action* outfit(PlayerbotAI* botAI) { return new OutfitAction(botAI); } - static Action* random_bot_update(PlayerbotAI* botAI) { return new RandomBotUpdateAction(botAI); } - static Action* delay(PlayerbotAI* botAI) { return new DelayAction(botAI); } - - static Action* apply_poison(PlayerbotAI* botAI) { return new ImbueWithPoisonAction(botAI); } - static Action* apply_oil(PlayerbotAI* botAI) { return new ImbueWithOilAction(botAI); } - static Action* apply_stone(PlayerbotAI* botAI) { return new ImbueWithStoneAction(botAI); } - static Action* try_emergency(PlayerbotAI* botAI) { return new TryEmergencyAction(botAI); } - static Action* mount(PlayerbotAI* botAI) { return new CastSpellAction(botAI, "mount"); } - static Action* war_stomp(PlayerbotAI* botAI) { return new CastWarStompAction(botAI); } - static Action* auto_talents(PlayerbotAI* botAI) { return new AutoSetTalentsAction(botAI); } - static Action* auto_learn_spell(PlayerbotAI* botAI) { return new AutoLearnSpellAction(botAI); } - static Action* auto_teleport_for_level(PlayerbotAI* botAI) { return new AutoTeleportForLevelAction(botAI); } - static Action* auto_upgrade_equip(PlayerbotAI* botAI) { return new AutoUpgradeEquipAction(botAI); } - static Action* xp_gain(PlayerbotAI* botAI) { return new XpGainAction(botAI); } - static Action* invite_nearby(PlayerbotAI* botAI) { return new InviteNearbyToGroupAction(botAI); } - static Action* invite_guild(PlayerbotAI* botAI) { return new InviteGuildToGroupAction(botAI); } - static Action* leave_far_away(PlayerbotAI* botAI) { return new LeaveFarAwayAction(botAI); } - static Action* move_to_dark_portal(PlayerbotAI* botAI) { return new MoveToDarkPortalAction(botAI); } - static Action* use_dark_portal_azeroth(PlayerbotAI* botAI) { return new DarkPortalAzerothAction(botAI); } - static Action* move_from_dark_portal(PlayerbotAI* botAI) { return new MoveFromDarkPortalAction(botAI); } - static Action* world_buff(PlayerbotAI* botAI) { return new WorldBuffAction(botAI); } - static Action* hearthstone(PlayerbotAI* botAI) { return new UseHearthStone(botAI); } - static Action* cast_random_spell(PlayerbotAI* botAI) { return new CastRandomSpellAction(botAI); } - static Action* free_bg_join(PlayerbotAI* botAI) { return new FreeBGJoinAction(botAI); } - - static Action* use_random_recipe(PlayerbotAI* botAI) { return new UseRandomRecipe(botAI); } - static Action* use_random_quest_item(PlayerbotAI* botAI) { return new UseRandomQuestItem(botAI); } - static Action* craft_random_item(PlayerbotAI* botAI) { return new CraftRandomItemAction(botAI); } - static Action* smart_destroy_item(PlayerbotAI* botAI) { return new SmartDestroyItemAction(botAI); } - static Action* disenchant_random_item(PlayerbotAI* botAI) { return new DisEnchantRandomItemAction(botAI); } - static Action* enchant_random_item(PlayerbotAI* botAI) { return new EnchantRandomItemAction(botAI); } - static Action* reset_instances(PlayerbotAI* botAI) { return new ResetInstancesAction(botAI); } - static Action* buy_petition(PlayerbotAI* botAI) { return new BuyPetitionAction(botAI); } - static Action* offer_petition(PlayerbotAI* botAI) { return new PetitionOfferAction(botAI); } - static Action* offer_petition_nearby(PlayerbotAI* botAI) { return new PetitionOfferNearbyAction(botAI); } - static Action* turn_in_petition(PlayerbotAI* botAI) { return new PetitionTurnInAction(botAI); } - static Action* buy_tabard(PlayerbotAI* botAI) { return new BuyTabardAction(botAI); } - static Action* guild_manage_nearby(PlayerbotAI* botAI) { return new GuildManageNearbyAction(botAI); } +public: + ActionContext() + { + creators["mark rti"] = &ActionContext::mark_rti; + creators["set return position"] = &ActionContext::set_return_position; + creators["rpg"] = &ActionContext::rpg; + creators["crpg"] = &ActionContext::crpg; + creators["choose rpg target"] = &ActionContext::choose_rpg_target; + creators["move to rpg target"] = &ActionContext::move_to_rpg_target; + creators["travel"] = &ActionContext::travel; + creators["choose travel target"] = &ActionContext::choose_travel_target; + creators["move to travel target"] = &ActionContext::move_to_travel_target; + creators["move out of collision"] = &ActionContext::move_out_of_collision; + creators["move random"] = &ActionContext::move_random; + creators["attack"] = &ActionContext::melee; + creators["melee"] = &ActionContext::melee; + creators["switch to melee"] = &ActionContext::switch_to_melee; + creators["switch to ranged"] = &ActionContext::switch_to_ranged; + creators["reach spell"] = &ActionContext::ReachSpell; + creators["reach melee"] = &ActionContext::ReachMelee; + creators["reach party member to heal"] = &ActionContext::reach_party_member_to_heal; + creators["reach party member to resurrect"] = &ActionContext::reach_party_member_to_resurrect; + creators["flee"] = &ActionContext::flee; + creators["flee with pet"] = &ActionContext::flee_with_pet; + creators["avoid aoe"] = &ActionContext::avoid_aoe; + creators["combat formation move"] = &ActionContext::combat_formation_move; + creators["disperse set"] = &ActionContext::disperse_set; + creators["gift of the naaru"] = &ActionContext::gift_of_the_naaru; + creators["shoot"] = &ActionContext::shoot; + creators["lifeblood"] = &ActionContext::lifeblood; + creators["arcane torrent"] = &ActionContext::arcane_torrent; + creators["end pull"] = &ActionContext::end_pull; + creators["healthstone"] = &ActionContext::healthstone; + creators["healing potion"] = &ActionContext::healing_potion; + creators["mana potion"] = &ActionContext::mana_potion; + creators["food"] = &ActionContext::food; + creators["drink"] = &ActionContext::drink; + creators["tank assist"] = &ActionContext::tank_assist; + creators["dps assist"] = &ActionContext::dps_assist; + creators["dps aoe"] = &ActionContext::dps_aoe; + creators["attack rti target"] = &ActionContext::attack_rti_target; + creators["loot"] = &ActionContext::loot; + creators["add loot"] = &ActionContext::add_loot; + creators["add gathering loot"] = &ActionContext::add_gathering_loot; + creators["add all loot"] = &ActionContext::add_all_loot; + creators["release loot"] = &ActionContext::release_loot; + creators["shoot"] = &ActionContext::shoot; + creators["follow"] = &ActionContext::follow; + creators["flee to master"] = &ActionContext::flee_to_master; + creators["runaway"] = &ActionContext::runaway; + creators["stay"] = &ActionContext::stay; + creators["sit"] = &ActionContext::sit; + creators["attack anything"] = &ActionContext::attack_anything; + creators["attack least hp target"] = &ActionContext::attack_least_hp_target; + creators["attack enemy player"] = &ActionContext::attack_enemy_player; + creators["emote"] = &ActionContext::emote; + creators["talk"] = &ActionContext::talk; + creators["suggest what to do"] = &ActionContext::suggest_what_to_do; + creators["suggest trade"] = &ActionContext::suggest_trade; + creators["suggest dungeon"] = &ActionContext::suggest_dungeon; + creators["return"] = &ActionContext::_return; + creators["move to loot"] = &ActionContext::move_to_loot; + creators["open loot"] = &ActionContext::open_loot; + creators["guard"] = &ActionContext::guard; + creators["move out of enemy contact"] = &ActionContext::move_out_of_enemy_contact; + creators["set facing"] = &ActionContext::set_facing; + creators["set behind"] = &ActionContext::set_behind; + creators["attack duel opponent"] = &ActionContext::attack_duel_opponent; + creators["drop target"] = &ActionContext::drop_target; + creators["check mail"] = &ActionContext::check_mail; + creators["say"] = &ActionContext::say; + creators["reveal gathering item"] = &ActionContext::reveal_gathering_item; + creators["outfit"] = &ActionContext::outfit; + creators["random bot update"] = &ActionContext::random_bot_update; + creators["delay"] = &ActionContext::delay; + creators["greet"] = &ActionContext::greet; + creators["check values"] = &ActionContext::check_values; + creators["ra"] = &ActionContext::ra; + creators["apply poison"] = &ActionContext::apply_poison; + creators["apply stone"] = &ActionContext::apply_stone; + creators["apply oil"] = &ActionContext::apply_oil; + creators["try emergency"] = &ActionContext::try_emergency; + creators["give food"] = &ActionContext::give_food; + creators["give water"] = &ActionContext::give_water; + creators["mount"] = &ActionContext::mount; + creators["war stomp"] = &ActionContext::war_stomp; + creators["auto talents"] = &ActionContext::auto_talents; + creators["auto learn spell"] = &ActionContext::auto_learn_spell; + creators["auto teleport for level"] = &ActionContext::auto_teleport_for_level; + creators["auto upgrade equip"] = &ActionContext::auto_upgrade_equip; + creators["xp gain"] = &ActionContext::xp_gain; + creators["invite nearby"] = &ActionContext::invite_nearby; + creators["invite guild"] = &ActionContext::invite_guild; + creators["leave far away"] = &ActionContext::leave_far_away; + creators["move to dark portal"] = &ActionContext::move_to_dark_portal; + creators["move from dark portal"] = &ActionContext::move_from_dark_portal; + creators["use dark portal azeroth"] = &ActionContext::use_dark_portal_azeroth; + creators["world buff"] = &ActionContext::world_buff; + creators["hearthstone"] = &ActionContext::hearthstone; + creators["cast random spell"] = &ActionContext::cast_random_spell; + creators["free bg join"] = &ActionContext::free_bg_join; + creators["use random recipe"] = &ActionContext::use_random_recipe; + creators["use random quest item"] = &ActionContext::use_random_quest_item; + creators["craft random item"] = &ActionContext::craft_random_item; + creators["smart destroy item"] = &ActionContext::smart_destroy_item; + creators["disenchant random item"] = &ActionContext::disenchant_random_item; + creators["enchant random item"] = &ActionContext::enchant_random_item; + creators["reset instances"] = &ActionContext::reset_instances; + creators["buy petition"] = &ActionContext::buy_petition; + creators["offer petition"] = &ActionContext::offer_petition; + creators["offer petition nearby"] = &ActionContext::offer_petition_nearby; + creators["turn in petition"] = &ActionContext::turn_in_petition; + creators["buy tabard"] = &ActionContext::buy_tabard; + creators["guild manage nearby"] = &ActionContext::guild_manage_nearby; // BG Tactics - static Action* bg_tactics(PlayerbotAI* botAI) { return new BGTactics(botAI); } - static Action* bg_move_to_start(PlayerbotAI* botAI) { return new BGTactics(botAI, "move to start"); } - static Action* bg_move_to_objective(PlayerbotAI* botAI) { return new BGTactics(botAI, "move to objective"); } - static Action* bg_select_objective(PlayerbotAI* botAI) { return new BGTactics(botAI, "select objective"); } - static Action* bg_check_objective(PlayerbotAI* botAI) { return new BGTactics(botAI, "check objective"); } - static Action* bg_attack_fc(PlayerbotAI* botAI) { return new BGTactics(botAI, "attack fc"); } - static Action* bg_protect_fc(PlayerbotAI* botAI) { return new BGTactics(botAI, "protect fc"); } - static Action* attack_enemy_fc(PlayerbotAI* botAI) { return new AttackEnemyFlagCarrierAction(botAI); } - static Action* bg_use_buff(PlayerbotAI* botAI) { return new BGTactics(botAI, "use buff"); } - static Action* bg_check_flag(PlayerbotAI* botAI) { return new BGTactics(botAI, "check flag"); } + creators["bg tactics"] = &ActionContext::bg_tactics; + creators["bg move to start"] = &ActionContext::bg_move_to_start; + creators["bg move to objective"] = &ActionContext::bg_move_to_objective; + creators["bg select objective"] = &ActionContext::bg_select_objective; + creators["bg check objective"] = &ActionContext::bg_check_objective; + creators["bg attack fc"] = &ActionContext::bg_attack_fc; + creators["bg protect fc"] = &ActionContext::bg_protect_fc; + creators["bg use buff"] = &ActionContext::bg_use_buff; + creators["attack enemy flag carrier"] = &ActionContext::attack_enemy_fc; + creators["bg check flag"] = &ActionContext::bg_check_flag; // Vehicles - static Action* enter_vehicle(PlayerbotAI* botAI) { return new EnterVehicleAction(botAI); } - static Action* leave_vehicle(PlayerbotAI* botAI) { return new LeaveVehicleAction(botAI); } - static Action* hurl_boulder(PlayerbotAI* botAI) { return new CastHurlBoulderAction(botAI); } - static Action* ram(PlayerbotAI* botAI) { return new CastRamAction(botAI); } - static Action* steam_blast(PlayerbotAI* botAI) { return new CastSteamBlastAction(botAI); } - static Action* steam_rush(PlayerbotAI* botAI) { return new CastSteamRushAction(botAI); } - static Action* napalm(PlayerbotAI* botAI) { return new CastNapalmAction(botAI); } - static Action* fire_cannon(PlayerbotAI* botAI) { return new CastFireCannonAction(botAI); } - static Action* incendiary_rocket(PlayerbotAI* botAI) { return new CastIncendiaryRocketAction(botAI); } - static Action* rocket_blast(PlayerbotAI* botAI) { return new CastRocketBlastAction(botAI); } - static Action* glaive_throw(PlayerbotAI* botAI) { return new CastGlaiveThrowAction(botAI); } - static Action* blade_salvo(PlayerbotAI* botAI) { return new CastBladeSalvoAction(botAI); } + creators["enter vehicle"] = &ActionContext::enter_vehicle; + creators["leave vehicle"] = &ActionContext::leave_vehicle; + creators["hurl boulder"] = &ActionContext::hurl_boulder; + creators["ram"] = &ActionContext::ram; + creators["steam rush"] = &ActionContext::steam_rush; + creators["steam blast"] = &ActionContext::steam_blast; + creators["napalm"] = &ActionContext::napalm; + creators["fire cannon"] = &ActionContext::fire_cannon; + creators["incendiary rocket"] = &ActionContext::incendiary_rocket; + creators["rocket blast"] = &ActionContext::rocket_blast; + creators["blade salvo"] = &ActionContext::blade_salvo; + creators["glaive throw"] = &ActionContext::glaive_throw; - //Rpg - static Action* rpg_stay(PlayerbotAI* botAI) { return new RpgStayAction(botAI); } - static Action* rpg_work(PlayerbotAI* botAI) { return new RpgWorkAction(botAI); } - static Action* rpg_emote(PlayerbotAI* botAI) { return new RpgEmoteAction(botAI); } - static Action* rpg_cancel(PlayerbotAI* botAI) { return new RpgCancelAction(botAI); } - static Action* rpg_taxi(PlayerbotAI* botAI) { return new RpgTaxiAction(botAI); } - static Action* rpg_discover(PlayerbotAI* botAI) { return new RpgDiscoverAction(botAI); } - static Action* rpg_start_quest(PlayerbotAI* botAI) { return new RpgStartQuestAction(botAI); } - static Action* rpg_end_quest(PlayerbotAI* botAI) { return new RpgEndQuestAction(botAI); } - static Action* rpg_buy(PlayerbotAI* botAI) { return new RpgBuyAction(botAI); } - static Action* rpg_sell(PlayerbotAI* botAI) { return new RpgSellAction(botAI); } - static Action* rpg_repair(PlayerbotAI* botAI) { return new RpgRepairAction(botAI); } - static Action* rpg_train(PlayerbotAI* botAI) { return new RpgTrainAction(botAI); } - static Action* rpg_heal(PlayerbotAI* botAI) { return new RpgHealAction(botAI); } - static Action* rpg_home_bind(PlayerbotAI* botAI) { return new RpgHomeBindAction(botAI); } - static Action* rpg_queue_bg(PlayerbotAI* botAI) { return new RpgQueueBgAction(botAI); } - static Action* rpg_buy_petition(PlayerbotAI* botAI) { return new RpgBuyPetitionAction(botAI); } - static Action* rpg_use(PlayerbotAI* botAI) { return new RpgUseAction(botAI); } - static Action* rpg_spell(PlayerbotAI* botAI) { return new RpgSpellAction(botAI); } - static Action* rpg_craft(PlayerbotAI* botAI) { return new RpgCraftAction(botAI); } - static Action* rpg_trade_useful(PlayerbotAI* botAI) { return new RpgTradeUsefulAction(botAI); } - static Action* rpg_duel(PlayerbotAI* botAI) { return new RpgDuelAction(botAI); } - static Action* rpg_mount_anim(PlayerbotAI* botAI) { return new RpgMountAnimAction(botAI); } + // Rpg + creators["rpg stay"] = &ActionContext::rpg_stay; + creators["rpg work"] = &ActionContext::rpg_work; + creators["rpg emote"] = &ActionContext::rpg_emote; + creators["rpg cancel"] = &ActionContext::rpg_cancel; + creators["rpg taxi"] = &ActionContext::rpg_taxi; + creators["rpg discover"] = &ActionContext::rpg_discover; + creators["rpg start quest"] = &ActionContext::rpg_start_quest; + creators["rpg end quest"] = &ActionContext::rpg_end_quest; + creators["rpg buy"] = &ActionContext::rpg_buy; + creators["rpg sell"] = &ActionContext::rpg_sell; + creators["rpg repair"] = &ActionContext::rpg_repair; + creators["rpg train"] = &ActionContext::rpg_train; + creators["rpg heal"] = &ActionContext::rpg_heal; + creators["rpg home bind"] = &ActionContext::rpg_home_bind; + creators["rpg queue bg"] = &ActionContext::rpg_queue_bg; + creators["rpg buy petition"] = &ActionContext::rpg_buy_petition; + creators["rpg use"] = &ActionContext::rpg_use; + creators["rpg spell"] = &ActionContext::rpg_spell; + creators["rpg craft"] = &ActionContext::rpg_craft; + creators["rpg trade useful"] = &ActionContext::rpg_trade_useful; + creators["rpg duel"] = &ActionContext::rpg_duel; + creators["rpg mount anim"] = &ActionContext::rpg_mount_anim; - static Action* toggle_pet_spell(PlayerbotAI* ai) { return new TogglePetSpellAutoCastAction(ai); } - static Action* pet_attack(PlayerbotAI* ai) { return new PetAttackAction(ai); } - + creators["toggle pet spell"] = &ActionContext::toggle_pet_spell; + creators["pet attack"] = &ActionContext::pet_attack; + } + +private: + static Action* give_water(PlayerbotAI* botAI) { return new GiveWaterAction(botAI); } + static Action* give_food(PlayerbotAI* botAI) { return new GiveFoodAction(botAI); } + static Action* ra(PlayerbotAI* botAI) { return new RemoveAuraAction(botAI); } + static Action* mark_rti(PlayerbotAI* botAI) { return new MarkRtiAction(botAI); } + static Action* set_return_position(PlayerbotAI* botAI) { return new SetReturnPositionAction(botAI); } + static Action* rpg(PlayerbotAI* botAI) { return new RpgAction(botAI); } + static Action* crpg(PlayerbotAI* botAI) { return new CRpgAction(botAI); } + static Action* choose_rpg_target(PlayerbotAI* botAI) { return new ChooseRpgTargetAction(botAI); } + static Action* move_to_rpg_target(PlayerbotAI* botAI) { return new MoveToRpgTargetAction(botAI); } + static Action* travel(PlayerbotAI* botAI) { return new TravelAction(botAI); } + static Action* choose_travel_target(PlayerbotAI* botAI) { return new ChooseTravelTargetAction(botAI); } + static Action* move_to_travel_target(PlayerbotAI* botAI) { return new MoveToTravelTargetAction(botAI); } + static Action* move_out_of_collision(PlayerbotAI* botAI) { return new MoveOutOfCollisionAction(botAI); } + static Action* move_random(PlayerbotAI* botAI) { return new MoveRandomAction(botAI); } + static Action* check_values(PlayerbotAI* botAI) { return new CheckValuesAction(botAI); } + static Action* greet(PlayerbotAI* botAI) { return new GreetAction(botAI); } + static Action* check_mail(PlayerbotAI* botAI) { return new CheckMailAction(botAI); } + static Action* drop_target(PlayerbotAI* botAI) { return new DropTargetAction(botAI); } + static Action* attack_duel_opponent(PlayerbotAI* botAI) { return new AttackDuelOpponentAction(botAI); } + static Action* guard(PlayerbotAI* botAI) { return new GuardAction(botAI); } + static Action* open_loot(PlayerbotAI* botAI) { return new OpenLootAction(botAI); } + static Action* move_to_loot(PlayerbotAI* botAI) { return new MoveToLootAction(botAI); } + static Action* _return(PlayerbotAI* botAI) { return new ReturnAction(botAI); } + static Action* shoot(PlayerbotAI* botAI) { return new CastShootAction(botAI); } + static Action* melee(PlayerbotAI* botAI) { return new MeleeAction(botAI); } + static Action* switch_to_melee(PlayerbotAI* botAI) { return new SwitchToMeleeAction(botAI); } + static Action* switch_to_ranged(PlayerbotAI* botAI) { return new SwitchToRangedAction(botAI); } + static Action* ReachSpell(PlayerbotAI* botAI) { return new ReachSpellAction(botAI); } + static Action* ReachMelee(PlayerbotAI* botAI) { return new ReachMeleeAction(botAI); } + static Action* reach_party_member_to_heal(PlayerbotAI* botAI) { return new ReachPartyMemberToHealAction(botAI); } + static Action* reach_party_member_to_resurrect(PlayerbotAI* botAI) + { + return new ReachPartyMemberToResurrectAction(botAI); + } + static Action* flee(PlayerbotAI* botAI) { return new FleeAction(botAI); } + static Action* flee_with_pet(PlayerbotAI* botAI) { return new FleeWithPetAction(botAI); } + static Action* avoid_aoe(PlayerbotAI* botAI) { return new AvoidAoeAction(botAI); } + static Action* combat_formation_move(PlayerbotAI* botAI) { return new CombatFormationMoveAction(botAI); } + static Action* disperse_set(PlayerbotAI* botAI) { return new DisperseSetAction(botAI); } + static Action* gift_of_the_naaru(PlayerbotAI* botAI) { return new CastGiftOfTheNaaruAction(botAI); } + static Action* lifeblood(PlayerbotAI* botAI) { return new CastLifeBloodAction(botAI); } + static Action* arcane_torrent(PlayerbotAI* botAI) { return new CastArcaneTorrentAction(botAI); } + static Action* mana_tap(PlayerbotAI* botAI) { return new CastManaTapAction(botAI); } + static Action* end_pull(PlayerbotAI* botAI) { return new ChangeCombatStrategyAction(botAI, "-pull"); } + + static Action* emote(PlayerbotAI* botAI) { return new EmoteAction(botAI); } + static Action* talk(PlayerbotAI* botAI) { return new TalkAction(botAI); } + static Action* suggest_what_to_do(PlayerbotAI* botAI) { return new SuggestWhatToDoAction(botAI); } + static Action* suggest_trade(PlayerbotAI* botAI) { return new SuggestTradeAction(botAI); } + static Action* suggest_dungeon(PlayerbotAI* botAI) { return new SuggestDungeonAction(botAI); } + static Action* attack_anything(PlayerbotAI* botAI) { return new AttackAnythingAction(botAI); } + static Action* attack_least_hp_target(PlayerbotAI* botAI) { return new AttackLeastHpTargetAction(botAI); } + static Action* attack_enemy_player(PlayerbotAI* botAI) { return new AttackEnemyPlayerAction(botAI); } + static Action* stay(PlayerbotAI* botAI) { return new StayAction(botAI); } + static Action* sit(PlayerbotAI* botAI) { return new SitAction(botAI); } + static Action* runaway(PlayerbotAI* botAI) { return new RunAwayAction(botAI); } + static Action* follow(PlayerbotAI* botAI) { return new FollowAction(botAI); } + static Action* flee_to_master(PlayerbotAI* botAI) { return new FleeToMasterAction(botAI); } + static Action* add_gathering_loot(PlayerbotAI* botAI) { return new AddGatheringLootAction(botAI); } + static Action* add_loot(PlayerbotAI* botAI) { return new AddLootAction(botAI); } + static Action* add_all_loot(PlayerbotAI* botAI) { return new AddAllLootAction(botAI); } + static Action* loot(PlayerbotAI* botAI) { return new LootAction(botAI); } + static Action* release_loot(PlayerbotAI* botAI) { return new ReleaseLootAction(botAI); } + static Action* dps_assist(PlayerbotAI* botAI) { return new DpsAssistAction(botAI); } + static Action* dps_aoe(PlayerbotAI* botAI) { return new DpsAoeAction(botAI); } + static Action* attack_rti_target(PlayerbotAI* botAI) { return new AttackRtiTargetAction(botAI); } + static Action* tank_assist(PlayerbotAI* botAI) { return new TankAssistAction(botAI); } + static Action* drink(PlayerbotAI* botAI) { return new DrinkAction(botAI); } + static Action* food(PlayerbotAI* botAI) { return new EatAction(botAI); } + static Action* mana_potion(PlayerbotAI* botAI) { return new UseManaPotion(botAI); } + static Action* healing_potion(PlayerbotAI* botAI) { return new UseHealingPotion(botAI); } + static Action* healthstone(PlayerbotAI* botAI) { return new UseItemAction(botAI, "healthstone"); } + static Action* move_out_of_enemy_contact(PlayerbotAI* botAI) { return new MoveOutOfEnemyContactAction(botAI); } + static Action* set_facing(PlayerbotAI* botAI) { return new SetFacingTargetAction(botAI); } + static Action* set_behind(PlayerbotAI* botAI) { return new SetBehindTargetAction(botAI); } + static Action* say(PlayerbotAI* botAI) { return new SayAction(botAI); } + static Action* reveal_gathering_item(PlayerbotAI* botAI) { return new RevealGatheringItemAction(botAI); } + static Action* outfit(PlayerbotAI* botAI) { return new OutfitAction(botAI); } + static Action* random_bot_update(PlayerbotAI* botAI) { return new RandomBotUpdateAction(botAI); } + static Action* delay(PlayerbotAI* botAI) { return new DelayAction(botAI); } + + static Action* apply_poison(PlayerbotAI* botAI) { return new ImbueWithPoisonAction(botAI); } + static Action* apply_oil(PlayerbotAI* botAI) { return new ImbueWithOilAction(botAI); } + static Action* apply_stone(PlayerbotAI* botAI) { return new ImbueWithStoneAction(botAI); } + static Action* try_emergency(PlayerbotAI* botAI) { return new TryEmergencyAction(botAI); } + static Action* mount(PlayerbotAI* botAI) { return new CastSpellAction(botAI, "mount"); } + static Action* war_stomp(PlayerbotAI* botAI) { return new CastWarStompAction(botAI); } + static Action* auto_talents(PlayerbotAI* botAI) { return new AutoSetTalentsAction(botAI); } + static Action* auto_learn_spell(PlayerbotAI* botAI) { return new AutoLearnSpellAction(botAI); } + static Action* auto_teleport_for_level(PlayerbotAI* botAI) { return new AutoTeleportForLevelAction(botAI); } + static Action* auto_upgrade_equip(PlayerbotAI* botAI) { return new AutoUpgradeEquipAction(botAI); } + static Action* xp_gain(PlayerbotAI* botAI) { return new XpGainAction(botAI); } + static Action* invite_nearby(PlayerbotAI* botAI) { return new InviteNearbyToGroupAction(botAI); } + static Action* invite_guild(PlayerbotAI* botAI) { return new InviteGuildToGroupAction(botAI); } + static Action* leave_far_away(PlayerbotAI* botAI) { return new LeaveFarAwayAction(botAI); } + static Action* move_to_dark_portal(PlayerbotAI* botAI) { return new MoveToDarkPortalAction(botAI); } + static Action* use_dark_portal_azeroth(PlayerbotAI* botAI) { return new DarkPortalAzerothAction(botAI); } + static Action* move_from_dark_portal(PlayerbotAI* botAI) { return new MoveFromDarkPortalAction(botAI); } + static Action* world_buff(PlayerbotAI* botAI) { return new WorldBuffAction(botAI); } + static Action* hearthstone(PlayerbotAI* botAI) { return new UseHearthStone(botAI); } + static Action* cast_random_spell(PlayerbotAI* botAI) { return new CastRandomSpellAction(botAI); } + static Action* free_bg_join(PlayerbotAI* botAI) { return new FreeBGJoinAction(botAI); } + + static Action* use_random_recipe(PlayerbotAI* botAI) { return new UseRandomRecipe(botAI); } + static Action* use_random_quest_item(PlayerbotAI* botAI) { return new UseRandomQuestItem(botAI); } + static Action* craft_random_item(PlayerbotAI* botAI) { return new CraftRandomItemAction(botAI); } + static Action* smart_destroy_item(PlayerbotAI* botAI) { return new SmartDestroyItemAction(botAI); } + static Action* disenchant_random_item(PlayerbotAI* botAI) { return new DisEnchantRandomItemAction(botAI); } + static Action* enchant_random_item(PlayerbotAI* botAI) { return new EnchantRandomItemAction(botAI); } + static Action* reset_instances(PlayerbotAI* botAI) { return new ResetInstancesAction(botAI); } + static Action* buy_petition(PlayerbotAI* botAI) { return new BuyPetitionAction(botAI); } + static Action* offer_petition(PlayerbotAI* botAI) { return new PetitionOfferAction(botAI); } + static Action* offer_petition_nearby(PlayerbotAI* botAI) { return new PetitionOfferNearbyAction(botAI); } + static Action* turn_in_petition(PlayerbotAI* botAI) { return new PetitionTurnInAction(botAI); } + static Action* buy_tabard(PlayerbotAI* botAI) { return new BuyTabardAction(botAI); } + static Action* guild_manage_nearby(PlayerbotAI* botAI) { return new GuildManageNearbyAction(botAI); } + + // BG Tactics + static Action* bg_tactics(PlayerbotAI* botAI) { return new BGTactics(botAI); } + static Action* bg_move_to_start(PlayerbotAI* botAI) { return new BGTactics(botAI, "move to start"); } + static Action* bg_move_to_objective(PlayerbotAI* botAI) { return new BGTactics(botAI, "move to objective"); } + static Action* bg_select_objective(PlayerbotAI* botAI) { return new BGTactics(botAI, "select objective"); } + static Action* bg_check_objective(PlayerbotAI* botAI) { return new BGTactics(botAI, "check objective"); } + static Action* bg_attack_fc(PlayerbotAI* botAI) { return new BGTactics(botAI, "attack fc"); } + static Action* bg_protect_fc(PlayerbotAI* botAI) { return new BGTactics(botAI, "protect fc"); } + static Action* attack_enemy_fc(PlayerbotAI* botAI) { return new AttackEnemyFlagCarrierAction(botAI); } + static Action* bg_use_buff(PlayerbotAI* botAI) { return new BGTactics(botAI, "use buff"); } + static Action* bg_check_flag(PlayerbotAI* botAI) { return new BGTactics(botAI, "check flag"); } + + // Vehicles + static Action* enter_vehicle(PlayerbotAI* botAI) { return new EnterVehicleAction(botAI); } + static Action* leave_vehicle(PlayerbotAI* botAI) { return new LeaveVehicleAction(botAI); } + static Action* hurl_boulder(PlayerbotAI* botAI) { return new CastHurlBoulderAction(botAI); } + static Action* ram(PlayerbotAI* botAI) { return new CastRamAction(botAI); } + static Action* steam_blast(PlayerbotAI* botAI) { return new CastSteamBlastAction(botAI); } + static Action* steam_rush(PlayerbotAI* botAI) { return new CastSteamRushAction(botAI); } + static Action* napalm(PlayerbotAI* botAI) { return new CastNapalmAction(botAI); } + static Action* fire_cannon(PlayerbotAI* botAI) { return new CastFireCannonAction(botAI); } + static Action* incendiary_rocket(PlayerbotAI* botAI) { return new CastIncendiaryRocketAction(botAI); } + static Action* rocket_blast(PlayerbotAI* botAI) { return new CastRocketBlastAction(botAI); } + static Action* glaive_throw(PlayerbotAI* botAI) { return new CastGlaiveThrowAction(botAI); } + static Action* blade_salvo(PlayerbotAI* botAI) { return new CastBladeSalvoAction(botAI); } + + // Rpg + static Action* rpg_stay(PlayerbotAI* botAI) { return new RpgStayAction(botAI); } + static Action* rpg_work(PlayerbotAI* botAI) { return new RpgWorkAction(botAI); } + static Action* rpg_emote(PlayerbotAI* botAI) { return new RpgEmoteAction(botAI); } + static Action* rpg_cancel(PlayerbotAI* botAI) { return new RpgCancelAction(botAI); } + static Action* rpg_taxi(PlayerbotAI* botAI) { return new RpgTaxiAction(botAI); } + static Action* rpg_discover(PlayerbotAI* botAI) { return new RpgDiscoverAction(botAI); } + static Action* rpg_start_quest(PlayerbotAI* botAI) { return new RpgStartQuestAction(botAI); } + static Action* rpg_end_quest(PlayerbotAI* botAI) { return new RpgEndQuestAction(botAI); } + static Action* rpg_buy(PlayerbotAI* botAI) { return new RpgBuyAction(botAI); } + static Action* rpg_sell(PlayerbotAI* botAI) { return new RpgSellAction(botAI); } + static Action* rpg_repair(PlayerbotAI* botAI) { return new RpgRepairAction(botAI); } + static Action* rpg_train(PlayerbotAI* botAI) { return new RpgTrainAction(botAI); } + static Action* rpg_heal(PlayerbotAI* botAI) { return new RpgHealAction(botAI); } + static Action* rpg_home_bind(PlayerbotAI* botAI) { return new RpgHomeBindAction(botAI); } + static Action* rpg_queue_bg(PlayerbotAI* botAI) { return new RpgQueueBgAction(botAI); } + static Action* rpg_buy_petition(PlayerbotAI* botAI) { return new RpgBuyPetitionAction(botAI); } + static Action* rpg_use(PlayerbotAI* botAI) { return new RpgUseAction(botAI); } + static Action* rpg_spell(PlayerbotAI* botAI) { return new RpgSpellAction(botAI); } + static Action* rpg_craft(PlayerbotAI* botAI) { return new RpgCraftAction(botAI); } + static Action* rpg_trade_useful(PlayerbotAI* botAI) { return new RpgTradeUsefulAction(botAI); } + static Action* rpg_duel(PlayerbotAI* botAI) { return new RpgDuelAction(botAI); } + static Action* rpg_mount_anim(PlayerbotAI* botAI) { return new RpgMountAnimAction(botAI); } + + static Action* toggle_pet_spell(PlayerbotAI* ai) { return new TogglePetSpellAutoCastAction(ai); } + static Action* pet_attack(PlayerbotAI* ai) { return new PetAttackAction(ai); } }; #endif diff --git a/src/strategy/actions/AddLootAction.cpp b/src/strategy/actions/AddLootAction.cpp index 8d80b734..fadf3dac 100644 --- a/src/strategy/actions/AddLootAction.cpp +++ b/src/strategy/actions/AddLootAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AddLootAction.h" + #include "CellImpl.h" #include "Event.h" #include "GridNotifiers.h" @@ -35,20 +37,11 @@ bool AddAllLootAction::Execute(Event event) return added; } -bool AddLootAction::isUseful() -{ - return true; -} +bool AddLootAction::isUseful() { return true; } -bool AddAllLootAction::isUseful() -{ - return true; -} +bool AddAllLootAction::isUseful() { return true; } -bool AddAllLootAction::AddLoot(ObjectGuid guid) -{ - return AI_VALUE(LootObjectStack*, "available loot")->Add(guid); -} +bool AddAllLootAction::AddLoot(ObjectGuid guid) { return AI_VALUE(LootObjectStack*, "available loot")->Add(guid); } bool AddGatheringLootAction::AddLoot(ObjectGuid guid) { diff --git a/src/strategy/actions/AddLootAction.h b/src/strategy/actions/AddLootAction.h index 58d529a0..c38a4396 100644 --- a/src/strategy/actions/AddLootAction.h +++ b/src/strategy/actions/AddLootAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ADDLOOTACTION_H @@ -12,30 +13,30 @@ class PlayerbotAI; class AddLootAction : public Action { - public: - AddLootAction(PlayerbotAI* botAI) : Action(botAI, "add loot") { } - bool Execute(Event event) override; - bool isUseful() override; +public: + AddLootAction(PlayerbotAI* botAI) : Action(botAI, "add loot") {} + bool Execute(Event event) override; + bool isUseful() override; }; class AddAllLootAction : public Action { - public: - AddAllLootAction(PlayerbotAI* botAI, std::string const name = "add all loot") : Action(botAI, name) { } - bool Execute(Event event) override; - bool isUseful() override; +public: + AddAllLootAction(PlayerbotAI* botAI, std::string const name = "add all loot") : Action(botAI, name) {} + bool Execute(Event event) override; + bool isUseful() override; - protected: - virtual bool AddLoot(ObjectGuid guid); +protected: + virtual bool AddLoot(ObjectGuid guid); }; class AddGatheringLootAction : public AddAllLootAction { - public: - AddGatheringLootAction(PlayerbotAI* botAI) : AddAllLootAction(botAI, "add gathering loot") { } +public: + AddGatheringLootAction(PlayerbotAI* botAI) : AddAllLootAction(botAI, "add gathering loot") {} - protected: - bool AddLoot(ObjectGuid guid) override; +protected: + bool AddLoot(ObjectGuid guid) override; }; #endif diff --git a/src/strategy/actions/AreaTriggerAction.cpp b/src/strategy/actions/AreaTriggerAction.cpp index 40f54bfd..4bd64ede 100644 --- a/src/strategy/actions/AreaTriggerAction.cpp +++ b/src/strategy/actions/AreaTriggerAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AreaTriggerAction.h" + #include "Event.h" #include "LastMovementValue.h" #include "Playerbots.h" @@ -10,7 +12,7 @@ bool ReachAreaTriggerAction::Execute(Event event) { - if (botAI->IsRealPlayer()) //Do not trigger own area trigger. + if (botAI->IsRealPlayer()) // Do not trigger own area trigger. return false; uint32 triggerId; diff --git a/src/strategy/actions/AreaTriggerAction.h b/src/strategy/actions/AreaTriggerAction.h index c444f5b8..74dd4af7 100644 --- a/src/strategy/actions/AreaTriggerAction.h +++ b/src/strategy/actions/AreaTriggerAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_AREATRIGGERACTION_H @@ -11,18 +12,18 @@ class PlayerbotAI; class ReachAreaTriggerAction : public MovementAction { - public: - ReachAreaTriggerAction(PlayerbotAI* botAI) : MovementAction(botAI, "reach area trigger") { } +public: + ReachAreaTriggerAction(PlayerbotAI* botAI) : MovementAction(botAI, "reach area trigger") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class AreaTriggerAction : public MovementAction { - public: - AreaTriggerAction(PlayerbotAI* botAI) : MovementAction(botAI, "area trigger") { } +public: + AreaTriggerAction(PlayerbotAI* botAI) : MovementAction(botAI, "area trigger") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ArenaTeamActions.cpp b/src/strategy/actions/ArenaTeamActions.cpp index a9cc4acd..3563bfe1 100644 --- a/src/strategy/actions/ArenaTeamActions.cpp +++ b/src/strategy/actions/ArenaTeamActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ArenaTeamActions.h" + #include "ArenaTeamMgr.h" #include "Playerbots.h" @@ -38,14 +40,16 @@ bool ArenaTeamAcceptAction::Execute(Event event) WorldPacket data(CMSG_ARENA_TEAM_ACCEPT); bot->GetSession()->HandleArenaTeamAcceptOpcode(data); bot->Say("Thanks for the invite!", LANG_UNIVERSAL); - LOG_INFO("playerbots", "Bot {} <{}> accepts Arena Team invite", bot->GetGUID().ToString().c_str(), bot->GetName().c_str()); + LOG_INFO("playerbots", "Bot {} <{}> accepts Arena Team invite", bot->GetGUID().ToString().c_str(), + bot->GetName().c_str()); return true; } else { WorldPacket data(CMSG_ARENA_TEAM_DECLINE); bot->GetSession()->HandleArenaTeamDeclineOpcode(data); - LOG_INFO("playerbots", "Bot {} <{}> declines Arena Team invite", bot->GetGUID().ToString().c_str(), bot->GetName().c_str()); + LOG_INFO("playerbots", "Bot {} <{}> declines Arena Team invite", bot->GetGUID().ToString().c_str(), + bot->GetName().c_str()); return false; } diff --git a/src/strategy/actions/ArenaTeamActions.h b/src/strategy/actions/ArenaTeamActions.h index 2916e72b..703fde57 100644 --- a/src/strategy/actions/ArenaTeamActions.h +++ b/src/strategy/actions/ArenaTeamActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ARENATEAMACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class ArenaTeamAcceptAction : public Action { - public: - ArenaTeamAcceptAction(PlayerbotAI* botAI) : Action(botAI, "arena team accept") { } +public: + ArenaTeamAcceptAction(PlayerbotAI* botAI) : Action(botAI, "arena team accept") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/AttackAction.cpp b/src/strategy/actions/AttackAction.cpp index 344138d6..1dc98984 100644 --- a/src/strategy/actions/AttackAction.cpp +++ b/src/strategy/actions/AttackAction.cpp @@ -1,13 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AttackAction.h" + +#include "CreatureAI.h" #include "Event.h" #include "LootObjectStack.h" #include "Playerbots.h" #include "ServerFacade.h" -#include "CreatureAI.h" #include "Unit.h" bool AttackAction::Execute(Event event) @@ -15,8 +17,9 @@ bool AttackAction::Execute(Event event) Unit* target = GetTarget(); if (!target) return false; - - if (!target->IsInWorld()) { + + if (!target->IsInWorld()) + { return false; } return Attack(target); @@ -36,7 +39,7 @@ bool AttackMyTargetAction::Execute(Event event) return false; } - + botAI->GetAiObjectContext()->GetValue("prioritized targets")->Set({guid}); bool result = Attack(botAI->GetUnit(guid)); if (result) @@ -47,7 +50,8 @@ bool AttackMyTargetAction::Execute(Event event) bool AttackAction::Attack(Unit* target, bool with_pet /*true*/) { - if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE || bot->HasUnitState(UNIT_STATE_IN_FLIGHT)) + if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE || + bot->HasUnitState(UNIT_STATE_IN_FLIGHT)) { if (verbose) botAI->TellError("I cannot attack in flight"); @@ -109,16 +113,18 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/) context->GetValue("current target")->Set(target); context->GetValue("available loot")->Get()->Add(guid); - + bool melee = bot->IsWithinMeleeRange(target) || botAI->IsMelee(bot); bot->Attack(target, melee); - if (IsMovingAllowed() && !bot->HasInArc(CAST_ANGLE_IN_FRONT, target)) { + if (IsMovingAllowed() && !bot->HasInArc(CAST_ANGLE_IN_FRONT, target)) + { sServerFacade->SetFacingTo(bot, target); } botAI->ChangeEngine(BOT_STATE_COMBAT); - if (!bot->GetVictim()) { + if (!bot->GetVictim()) + { return false; } /* prevent pet dead immediately in group */ @@ -141,12 +147,6 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/) return true; } -bool AttackDuelOpponentAction::isUseful() -{ - return AI_VALUE(Unit*, "duel target"); -} +bool AttackDuelOpponentAction::isUseful() { return AI_VALUE(Unit*, "duel target"); } -bool AttackDuelOpponentAction::Execute(Event event) -{ - return Attack(AI_VALUE(Unit*, "duel target")); -} +bool AttackDuelOpponentAction::Execute(Event event) { return Attack(AI_VALUE(Unit*, "duel target")); } diff --git a/src/strategy/actions/AttackAction.h b/src/strategy/actions/AttackAction.h index b606eea2..ee95cb24 100644 --- a/src/strategy/actions/AttackAction.h +++ b/src/strategy/actions/AttackAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ATTACKACTION_H @@ -11,31 +12,34 @@ class PlayerbotAI; class AttackAction : public MovementAction { - public: - AttackAction(PlayerbotAI* botAI, std::string const name) : MovementAction(botAI, name) { } +public: + AttackAction(PlayerbotAI* botAI, std::string const name) : MovementAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; - protected: - bool Attack(Unit* target, bool with_pet = true); +protected: + bool Attack(Unit* target, bool with_pet = true); }; class AttackMyTargetAction : public AttackAction { - public: - AttackMyTargetAction(PlayerbotAI* botAI, std::string const name = "attack my target") : AttackAction(botAI, name) { } +public: + AttackMyTargetAction(PlayerbotAI* botAI, std::string const name = "attack my target") : AttackAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class AttackDuelOpponentAction : public AttackAction +{ +public: + AttackDuelOpponentAction(PlayerbotAI* botAI, std::string const name = "attack duel opponent") + : AttackAction(botAI, name) { - public: - AttackDuelOpponentAction(PlayerbotAI* botAI, std::string const name = "attack duel opponent") : AttackAction(botAI, name) { } + } - public: - bool Execute(Event event) override; - bool isUseful() override; +public: + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/AutoLearnSpellAction.cpp b/src/strategy/actions/AutoLearnSpellAction.cpp index 24205a64..e75945f6 100644 --- a/src/strategy/actions/AutoLearnSpellAction.cpp +++ b/src/strategy/actions/AutoLearnSpellAction.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AutoLearnSpellAction.h" + #include "Event.h" +#include "GuildMgr.h" #include "PlayerbotFactory.h" #include "Playerbots.h" -#include "GuildMgr.h" bool AutoLearnSpellAction::Execute(Event event) { @@ -30,10 +32,12 @@ bool AutoLearnSpellAction::Execute(Event event) void AutoLearnSpellAction::LearnSpells(std::ostringstream* out) { - if (sPlayerbotAIConfig->autoLearnTrainerSpells && sRandomPlayerbotMgr->IsRandomBot(bot))// || (!botAI->GetMaster() && sRandomPlayerbotMgr->IsRandomBot(bot))) + if (sPlayerbotAIConfig->autoLearnTrainerSpells && + sRandomPlayerbotMgr->IsRandomBot(bot)) // || (!botAI->GetMaster() && sRandomPlayerbotMgr->IsRandomBot(bot))) LearnTrainerSpells(out); - if (sPlayerbotAIConfig->autoLearnQuestSpells && sRandomPlayerbotMgr->IsRandomBot(bot))// || (!botAI->GetMaster() && sRandomPlayerbotMgr->IsRandomBot(bot))) + if (sPlayerbotAIConfig->autoLearnQuestSpells && + sRandomPlayerbotMgr->IsRandomBot(bot)) // || (!botAI->GetMaster() && sRandomPlayerbotMgr->IsRandomBot(bot))) LearnQuestSpells(out); if (sPlayerbotAIConfig->randomBotGuildTalk) @@ -63,7 +67,8 @@ void AutoLearnSpellAction::LearnTrainerSpells(std::ostringstream* out) // bot->LearnDefaultSkills(); // CreatureTemplateContainer const* creatureTemplateContainer = sObjectMgr->GetCreatureTemplates(); - // for (CreatureTemplateContainer::const_iterator i = creatureTemplateContainer->begin(); i != creatureTemplateContainer->end(); ++i) + // for (CreatureTemplateContainer::const_iterator i = creatureTemplateContainer->begin(); i != + // creatureTemplateContainer->end(); ++i) // { // CreatureTemplate const& co = i->second; // if (co.trainer_type != TRAINER_TYPE_TRADESKILLS && co.trainer_type != TRAINER_TYPE_CLASS) @@ -72,16 +77,17 @@ void AutoLearnSpellAction::LearnTrainerSpells(std::ostringstream* out) // if (co.trainer_type == TRAINER_TYPE_CLASS && co.trainer_class != bot->getClass()) // continue; - // uint32 trainerId = co.Entry; + // uint32 trainerId = co.Entry; - // TrainerSpellData const* trainer_spells = sObjectMgr->GetNpcTrainerSpells(trainerId); + // TrainerSpellData const* trainer_spells = sObjectMgr->GetNpcTrainerSpells(trainerId); // if (!trainer_spells) // trainer_spells = sObjectMgr->GetNpcTrainerSpells(trainerId); // if (!trainer_spells) // continue; - // for (TrainerSpellMap::const_iterator itr = trainer_spells->spellList.begin(); itr != trainer_spells->spellList.end(); ++itr) + // for (TrainerSpellMap::const_iterator itr = trainer_spells->spellList.begin(); itr != + // trainer_spells->spellList.end(); ++itr) // { // TrainerSpell const* tSpell = &itr->second; @@ -127,7 +133,7 @@ void AutoLearnSpellAction::LearnTrainerSpells(std::ostringstream* out) void AutoLearnSpellAction::LearnQuestSpells(std::ostringstream* out) { - //CreatureTemplate const* co = sCreatureStorage.LookupEntry(id); + // CreatureTemplate const* co = sCreatureStorage.LookupEntry(id); ObjectMgr::QuestMap const& questTemplates = sObjectMgr->GetQuestTemplates(); for (ObjectMgr::QuestMap::const_iterator i = questTemplates.begin(); i != questTemplates.end(); ++i) { @@ -137,7 +143,8 @@ void AutoLearnSpellAction::LearnQuestSpells(std::ostringstream* out) if (!quest->GetRequiredClasses() || quest->IsRepeatable() || quest->GetMinLevel() < 10) continue; - if (!bot->SatisfyQuestClass(quest, false) || quest->GetMinLevel() > bot->GetLevel() || !bot->SatisfyQuestRace(quest, false)) + if (!bot->SatisfyQuestClass(quest, false) || quest->GetMinLevel() > bot->GetLevel() || + !bot->SatisfyQuestRace(quest, false)) continue; if (quest->GetRewSpellCast() > 0) @@ -197,12 +204,15 @@ void AutoLearnSpellAction::LearnSpell(uint32 spellId, std::ostringstream* out) } } -bool AutoUpgradeEquipAction::Execute(Event event) { - if (!sPlayerbotAIConfig->autoUpgradeEquip || !sRandomPlayerbotMgr->IsRandomBot(bot)) { +bool AutoUpgradeEquipAction::Execute(Event event) +{ + if (!sPlayerbotAIConfig->autoUpgradeEquip || !sRandomPlayerbotMgr->IsRandomBot(bot)) + { return false; } PlayerbotFactory factory(bot, bot->GetLevel(), ITEM_QUALITY_RARE); - if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) { + if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) + { factory.InitEquipment(true); } factory.InitAmmo(); diff --git a/src/strategy/actions/AutoLearnSpellAction.h b/src/strategy/actions/AutoLearnSpellAction.h index 1cefaf48..e9fb14ee 100644 --- a/src/strategy/actions/AutoLearnSpellAction.h +++ b/src/strategy/actions/AutoLearnSpellAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_AUTOLEARNSPELLACTION_H @@ -11,24 +12,24 @@ class PlayerbotAI; class AutoLearnSpellAction : public Action { - public: - AutoLearnSpellAction(PlayerbotAI* botAI, std::string const name = "auto learn spell") : Action(botAI, name) { } +public: + AutoLearnSpellAction(PlayerbotAI* botAI, std::string const name = "auto learn spell") : Action(botAI, name) {} - bool Execute(Event event); + bool Execute(Event event); - private: - void LearnSpells(std::ostringstream* out); - void LearnTrainerSpells(std::ostringstream* out); - void LearnQuestSpells(std::ostringstream* out); - void LearnSpell(uint32 spellId, std::ostringstream* out); +private: + void LearnSpells(std::ostringstream* out); + void LearnTrainerSpells(std::ostringstream* out); + void LearnQuestSpells(std::ostringstream* out); + void LearnSpell(uint32 spellId, std::ostringstream* out); }; class AutoUpgradeEquipAction : public Action { - public: - AutoUpgradeEquipAction(PlayerbotAI* botAI, std::string const name = "auto upgrade equip") : Action(botAI, name) { } +public: + AutoUpgradeEquipAction(PlayerbotAI* botAI, std::string const name = "auto upgrade equip") : Action(botAI, name) {} - bool Execute(Event event); + bool Execute(Event event); }; #endif diff --git a/src/strategy/actions/AutoTeleportForLevelAction.cpp b/src/strategy/actions/AutoTeleportForLevelAction.cpp index 0f4c8f63..9906ad25 100644 --- a/src/strategy/actions/AutoTeleportForLevelAction.cpp +++ b/src/strategy/actions/AutoTeleportForLevelAction.cpp @@ -1,15 +1,19 @@ #include "AutoTeleportForLevelAction.h" + #include "PlayerbotAIConfig.h" #include "PlayerbotFactory.h" -#include "RandomPlayerbotMgr.h" #include "Playerbots.h" +#include "RandomPlayerbotMgr.h" #include "SharedDefines.h" -bool AutoTeleportForLevelAction::Execute(Event event) { - if (!sPlayerbotAIConfig->autoTeleportForLevel || !sRandomPlayerbotMgr->IsRandomBot(bot)) { +bool AutoTeleportForLevelAction::Execute(Event event) +{ + if (!sPlayerbotAIConfig->autoTeleportForLevel || !sRandomPlayerbotMgr->IsRandomBot(bot)) + { return false; } - if (botAI->HasRealPlayerMaster()) { + if (botAI->HasRealPlayerMaster()) + { return false; } sRandomPlayerbotMgr->RandomTeleportForLevel(bot); diff --git a/src/strategy/actions/AutoTeleportForLevelAction.h b/src/strategy/actions/AutoTeleportForLevelAction.h index ca13edf2..67be8932 100644 --- a/src/strategy/actions/AutoTeleportForLevelAction.h +++ b/src/strategy/actions/AutoTeleportForLevelAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_AUTOTELEPORTFORLEVELACTION_H @@ -11,10 +12,13 @@ class PlayerbotAI; class AutoTeleportForLevelAction : public Action { - public: - AutoTeleportForLevelAction(PlayerbotAI* botAI, std::string const name = "auto teleport for level") : Action(botAI, name) { } +public: + AutoTeleportForLevelAction(PlayerbotAI* botAI, std::string const name = "auto teleport for level") + : Action(botAI, name) + { + } - bool Execute(Event event); + bool Execute(Event event); }; #endif diff --git a/src/strategy/actions/BankAction.cpp b/src/strategy/actions/BankAction.cpp index 91a9dd89..d49559a0 100644 --- a/src/strategy/actions/BankAction.cpp +++ b/src/strategy/actions/BankAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "BankAction.h" + #include "Event.h" #include "ItemCountValue.h" #include "Playerbots.h" @@ -102,7 +104,7 @@ bool BankAction::Deposit(Item* pItem) out << "put " << chat->FormatItem(pItem->GetTemplate(), pItem->GetCount()) << " to bank"; botAI->TellMaster(out.str()); - return true; + return true; } void BankAction::ListItems() @@ -143,14 +145,14 @@ Item* BankAction::FindItemInBank(uint32 ItemId) if (!pItemProto) continue; - if (pItemProto->ItemId == ItemId) // have required item + if (pItemProto->ItemId == ItemId) // have required item return pItem; } } for (uint8 bag = BANK_SLOT_BAG_START; bag < BANK_SLOT_BAG_END; ++bag) { - Bag const* const pBag = (Bag *) bot->GetItemByPos(INVENTORY_SLOT_BAG_0, bag); + Bag const* const pBag = (Bag*)bot->GetItemByPos(INVENTORY_SLOT_BAG_0, bag); if (pBag) for (uint8 slot = 0; slot < pBag->GetBagSize(); ++slot) { diff --git a/src/strategy/actions/BankAction.h b/src/strategy/actions/BankAction.h index 905ae778..90aacd5c 100644 --- a/src/strategy/actions/BankAction.h +++ b/src/strategy/actions/BankAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_BANKACTION_H @@ -12,17 +13,17 @@ class PlayerbotAI; class BankAction : public InventoryAction { - public: - BankAction(PlayerbotAI* botAI) : InventoryAction(botAI, "bank") { } +public: + BankAction(PlayerbotAI* botAI) : InventoryAction(botAI, "bank") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - bool ExecuteBank(std::string const text, Unit* bank); - void ListItems(); - bool Withdraw(uint32 itemid); - bool Deposit(Item* pItem); - Item* FindItemInBank(uint32 ItemId); +private: + bool ExecuteBank(std::string const text, Unit* bank); + void ListItems(); + bool Withdraw(uint32 itemid); + bool Deposit(Item* pItem); + Item* FindItemInBank(uint32 ItemId); }; #endif diff --git a/src/strategy/actions/BattleGroundJoinAction.cpp b/src/strategy/actions/BattleGroundJoinAction.cpp index dd668aca..2c773b5a 100644 --- a/src/strategy/actions/BattleGroundJoinAction.cpp +++ b/src/strategy/actions/BattleGroundJoinAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "BattleGroundJoinAction.h" + #include "ArenaTeam.h" #include "ArenaTeamMgr.h" #include "BattlegroundMgr.h" @@ -16,7 +18,7 @@ bool BGJoinAction::Execute(Event event) { uint32 queueType = AI_VALUE(uint32, "bg type"); - if (!queueType) // force join to fill bg + if (!queueType) // force join to fill bg { if (bgList.empty()) return false; @@ -53,7 +55,7 @@ bool BGJoinAction::Execute(Event event) } // set bg type and bm guid - //botAI->GetAiObjectContext()->GetValue("bg master")->Set(bmGUID); + // botAI->GetAiObjectContext()->GetValue("bg master")->Set(bmGUID); botAI->GetAiObjectContext()->GetValue("bg type")->Set(queueTypeId); queueType = queueTypeId; } @@ -63,19 +65,19 @@ bool BGJoinAction::Execute(Event event) bool BGJoinAction::gatherArenaTeam(ArenaType type) { - ArenaTeam* arenateam = sArenaTeamMgr->GetArenaTeamByCaptain(bot->GetGUID(), type); if (!arenateam) return false; - if (arenateam->GetMembersSize() < ((uint32) arenateam->GetType())) + if (arenateam->GetMembersSize() < ((uint32)arenateam->GetType())) return false; GuidVector members; // search for arena team members and make them online - for (ArenaTeam::MemberList::iterator itr = arenateam->GetMembers().begin(); itr != arenateam->GetMembers().end(); ++itr) + for (ArenaTeam::MemberList::iterator itr = arenateam->GetMembers().begin(); itr != arenateam->GetMembers().end(); + ++itr) { bool offline = false; Player* member = ObjectAccessor::FindConnectedPlayer(itr->Guid); @@ -83,8 +85,8 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type) { offline = true; } - //if (!member && !sObjectMgr->GetPlayerAccountIdByGUID(itr->guid)) - // continue; + // if (!member && !sObjectMgr->GetPlayerAccountIdByGUID(itr->guid)) + // continue; if (offline) sRandomPlayerbotMgr->AddPlayerBot(itr->Guid, 0); @@ -107,10 +109,10 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type) if (member->GetGUID() == bot->GetGUID()) continue; - if(member->InBattleground()) + if (member->InBattleground()) continue; - if(member->InBattlegroundQueue()) + if (member->InBattlegroundQueue()) continue; if (member->GetGroup()) @@ -125,7 +127,8 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type) if (!members.size() || (int)members.size() < (int)(arenateam->GetType() - 1)) { - LOG_INFO("playerbots", "Team #{} <{}> has not enough members for match", arenateam->GetId(), arenateam->GetName().c_str()); + LOG_INFO("playerbots", "Team #{} <{}> has not enough members for match", arenateam->GetId(), + arenateam->GetName().c_str()); return false; } @@ -137,24 +140,25 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type) if (!group->Create(bot)) { - LOG_INFO("playerbots", "Team #{} <{}>: Can't create group for arena queue", arenateam->GetId(), arenateam->GetName()); + LOG_INFO("playerbots", "Team #{} <{}>: Can't create group for arena queue", arenateam->GetId(), + arenateam->GetName()); return false; } else sGroupMgr->AddGroup(group); - LOG_INFO("playerbots", "Bot {} <{}>: Leader of <{}>", bot->GetGUID().ToString().c_str(), bot->GetName(), arenateam->GetName()); - + LOG_INFO("playerbots", "Bot {} <{}>: Leader of <{}>", bot->GetGUID().ToString().c_str(), bot->GetName(), + arenateam->GetName()); for (auto i = begin(members); i != end(members); ++i) { if (*i == bot->GetGUID()) continue; - //if (count >= (int)arenateam->GetType()) - //break; + // if (count >= (int)arenateam->GetType()) + // break; - if (group->GetMembersCount() >= (uint32) arenateam->GetType()) + if (group->GetMembersCount() >= (uint32)arenateam->GetType()) break; Player* member = ObjectAccessor::FindConnectedPlayer(*i); @@ -174,19 +178,20 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type) memberBotAI->Reset(); member->TeleportTo(bot->GetMapId(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), 0); - - LOG_INFO("playerbots", "Bot {} <{}>: Member of <{}>", member->GetGUID().ToString().c_str(), member->GetName().c_str(), arenateam->GetName().c_str()); - + LOG_INFO("playerbots", "Bot {} <{}>: Member of <{}>", member->GetGUID().ToString().c_str(), + member->GetName().c_str(), arenateam->GetName().c_str()); } if (group && group->GetMembersCount() >= (uint32)arenateam->GetType()) { - LOG_INFO("playerbots", "Team #{} <{}> Group is ready for match", arenateam->GetId(), arenateam->GetName().c_str()); + LOG_INFO("playerbots", "Team #{} <{}> Group is ready for match", arenateam->GetId(), + arenateam->GetName().c_str()); return true; } else { - LOG_INFO("playerbots", "Team #{} <{}> Group is not ready for match (not enough members)", arenateam->GetId(), arenateam->GetName().c_str()); + LOG_INFO("playerbots", "Team #{} <{}> Group is not ready for match (not enough members)", arenateam->GetId(), + arenateam->GetName().c_str()); group->Disband(); } @@ -229,7 +234,10 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun return false; TeamId teamId = bot->GetTeamId(); - bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty() ? sPlayerbotAIConfig->diffEmpty : sPlayerbotAIConfig->diffWithPlayer) * 1.1; + bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty() + ? sPlayerbotAIConfig->diffEmpty + : sPlayerbotAIConfig->diffWithPlayer) * + 1.1; uint32 BracketSize = bg->GetMaxPlayersPerTeam() * 2; uint32 TeamSize = bg->GetMaxPlayersPerTeam(); @@ -251,11 +259,15 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun // Check if bots should join Rated Arena (Only captains can queue) uint32 ratedArenaBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount; - uint32 ratedArenaPlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount; - uint32 ratedArenaInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount; - uint32 activeRatedArenaQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue; + uint32 ratedArenaPlayerCount = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount; + uint32 ratedArenaInstanceCount = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount; + uint32 activeRatedArenaQueue = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue; - bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) < (BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount)); + bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) < + (BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount)); if (isRated) { @@ -269,10 +281,14 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun // Check if bots should join Skirmish Arena // We have extra bots queue because same faction can vs each other but can't be in the same group. - uint32 skirmishArenaBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount; - uint32 skirmishArenaPlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount; - uint32 skirmishArenaInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount; - uint32 activeSkirmishArenaQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue; + uint32 skirmishArenaBotCount = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount; + uint32 skirmishArenaPlayerCount = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount; + uint32 skirmishArenaInstanceCount = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount; + uint32 activeSkirmishArenaQueue = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue; uint32 maxRequiredSkirmishBots = BracketSize * (activeSkirmishArenaQueue + skirmishArenaInstanceCount); if (maxRequiredSkirmishBots != 0) maxRequiredSkirmishBots = maxRequiredSkirmishBots + TeamSize; @@ -293,14 +309,14 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun uint32 activeBgQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeBgQueue; uint32 bgInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgInstanceCount; - if(teamId == TEAM_ALLIANCE) + if (teamId == TEAM_ALLIANCE) { - if((bgAllianceBotCount + bgAlliancePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount)) + if ((bgAllianceBotCount + bgAlliancePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount)) return true; } else { - if((bgHordeBotCount + bgHordePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount)) + if ((bgHordeBotCount + bgHordePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount)) return true; } @@ -351,9 +367,9 @@ bool BGJoinAction::isUseful() return false; // do not try if in dungeon - //Map* map = bot->GetMap(); - //if (map && map->Instanceable()) - // return false; + // Map* map = bot->GetMap(); + // if (map && map->Instanceable()) + // return false; bgList.clear(); ratedList.clear(); @@ -415,8 +431,8 @@ bool BGJoinAction::JoinQueue(uint32 type) // get BG MapId uint32 bgTypeId_ = bgTypeId; - uint32 instanceId = 0; // 0 = First Available - + uint32 instanceId = 0; // 0 = First Available + bool isPremade = false; bool isArena = false; bool isRated = false; @@ -431,7 +447,7 @@ bool BGJoinAction::JoinQueue(uint32 type) isArena = true; // get battlemaster - //Unit* unit = botAI->GetUnit(AI_VALUE2(CreatureData const*, "bg master", bgTypeId)); + // Unit* unit = botAI->GetUnit(AI_VALUE2(CreatureData const*, "bg master", bgTypeId)); Unit* unit = botAI->GetUnit(sRandomPlayerbotMgr->GetBattleMasterGUID(bot, bgTypeId)); if (!unit && isArena) { @@ -442,10 +458,10 @@ bool BGJoinAction::JoinQueue(uint32 type) // This breaks groups as refresh includes a remove from group function call. // refresh food/regs - //sRandomPlayerbotMgr->Refresh(bot); + // sRandomPlayerbotMgr->Refresh(bot); bool joinAsGroup = bot->GetGroup() && bot->GetGroup()->GetLeaderGUID() == bot->GetGUID(); - + // in wotlk only arena requires battlemaster guid ObjectGuid guid = isArena ? unit->GetGUID() : bot->GetGUID(); @@ -459,7 +475,7 @@ bool BGJoinAction::JoinQueue(uint32 type) break; case BATTLEGROUND_AB: _bgType = "AB"; - break; + break; case BATTLEGROUND_EY: _bgType = "EotS"; break; @@ -505,10 +521,11 @@ bool BGJoinAction::JoinQueue(uint32 type) } } - LOG_INFO("playerbots", "Bot {} {}:{} <{}> queued {} {}", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str(), _bgType.c_str(), - isRated ? "Rated Arena" : isArena ? "Arena" : ""); - + LOG_INFO("playerbots", "Bot {} {}:{} <{}> queued {} {}", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str(), _bgType.c_str(), + isRated ? "Rated Arena" + : isArena ? "Arena" + : ""); if (isArena) { @@ -519,17 +536,19 @@ bool BGJoinAction::JoinQueue(uint32 type) } else if (!joinAsGroup) { - if(teamId == TEAM_ALLIANCE) + if (teamId == TEAM_ALLIANCE) sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount++; else sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount++; } else { - if(teamId == TEAM_ALLIANCE) - sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount += bot->GetGroup()->GetMembersCount(); + if (teamId == TEAM_ALLIANCE) + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount += + bot->GetGroup()->GetMembersCount(); else - sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount += bot->GetGroup()->GetMembersCount(); + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount += + bot->GetGroup()->GetMembersCount(); } botAI->GetAiObjectContext()->GetValue("bg type")->Set(0); @@ -559,7 +578,10 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg return false; TeamId teamId = bot->GetTeamId(); - bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty() ? sPlayerbotAIConfig->diffEmpty : sPlayerbotAIConfig->diffWithPlayer) * 1.1; + bool noLag = sWorldUpdateTime.GetAverageUpdateTime() < (sRandomPlayerbotMgr->GetPlayers().empty() + ? sPlayerbotAIConfig->diffEmpty + : sPlayerbotAIConfig->diffWithPlayer) * + 1.1; uint32 BracketSize = bg->GetMaxPlayersPerTeam() * 2; uint32 TeamSize = bg->GetMaxPlayersPerTeam(); @@ -581,11 +603,15 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg // Check if bots should join Rated Arena (Only captains can queue) uint32 ratedArenaBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount; - uint32 ratedArenaPlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount; - uint32 ratedArenaInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount; - uint32 activeRatedArenaQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue; + uint32 ratedArenaPlayerCount = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount; + uint32 ratedArenaInstanceCount = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount; + uint32 activeRatedArenaQueue = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue; - bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) < (BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount)); + bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) < + (BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount)); if (isRated) { @@ -599,10 +625,14 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg // Check if bots should join Skirmish Arena // We have extra bots queue because same faction can vs each other but can't be in the same group. - uint32 skirmishArenaBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount; - uint32 skirmishArenaPlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount; - uint32 skirmishArenaInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount; - uint32 activeSkirmishArenaQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue; + uint32 skirmishArenaBotCount = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount; + uint32 skirmishArenaPlayerCount = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount; + uint32 skirmishArenaInstanceCount = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount; + uint32 activeSkirmishArenaQueue = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue; uint32 maxRequiredSkirmishBots = BracketSize * (activeSkirmishArenaQueue + skirmishArenaInstanceCount); if (maxRequiredSkirmishBots != 0) maxRequiredSkirmishBots = maxRequiredSkirmishBots + TeamSize; @@ -623,14 +653,14 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg uint32 activeBgQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeBgQueue; uint32 bgInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgInstanceCount; - if(teamId == TEAM_ALLIANCE) + if (teamId == TEAM_ALLIANCE) { - if((bgAllianceBotCount + bgAlliancePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount)) + if ((bgAllianceBotCount + bgAlliancePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount)) return true; } else { - if((bgHordeBotCount + bgHordePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount)) + if ((bgHordeBotCount + bgHordePlayerCount) < TeamSize * (activeBgQueue + bgInstanceCount)) return true; } @@ -642,7 +672,7 @@ bool BGLeaveAction::Execute(Event event) if (!(bot->InBattlegroundQueue() || bot->InBattleground())) return false; - //botAI->ChangeStrategy("-bg", BOT_STATE_NON_COMBAT); + // botAI->ChangeStrategy("-bg", BOT_STATE_NON_COMBAT); BattlegroundQueueTypeId queueTypeId = bot->GetBattlegroundQueueTypeId(0); BattlegroundTypeId _bgTypeId = BattlegroundMgr::BGTemplateId(queueTypeId); @@ -661,8 +691,9 @@ bool BGLeaveAction::Execute(Event event) if (bot->InBattleground()) { - LOG_INFO("playerbots", "Bot {} {}:{} <{}> leaves {}", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG"); + LOG_INFO("playerbots", "Bot {} {}:{} <{}> leaves {}", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), + isArena ? "Arena" : "BG"); WorldPacket leave(CMSG_LEAVE_BATTLEFIELD); leave << uint8(0) << uint8(0) << uint32(0) << uint16(0); @@ -683,8 +714,9 @@ bool BGLeaveAction::Execute(Event event) if (!queueType) return false; - LOG_INFO("playerbots", "Bot {} {}:{} <{}> leaves {} queue", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str(), isArena ? "Arena" : "BG"); + LOG_INFO("playerbots", "Bot {} {}:{} <{}> leaves {} queue", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str(), + isArena ? "Arena" : "BG"); WorldPacket packet(CMSG_BATTLEFIELD_PORT, 20); packet << type << unk2 << (uint32)_bgTypeId << unk << uint8(0); @@ -701,10 +733,7 @@ bool BGLeaveAction::Execute(Event event) return true; } -bool BGStatusAction::isUseful() -{ - return bot->InBattlegroundQueue(); -} +bool BGStatusAction::isUseful() { return bot->InBattlegroundQueue(); } bool BGStatusAction::Execute(Event event) { @@ -725,7 +754,7 @@ bool BGStatusAction::Execute(Event event) WorldPacket p(event.getPacket()); statusid = 0; - p >> QueueSlot; // queue id (0...2) - player can be in 3 queues in time + p >> QueueSlot; // queue id (0...2) - player can be in 3 queues in time p >> arenaByte; if (arenaByte == 0) return false; @@ -738,20 +767,20 @@ bool BGStatusAction::Execute(Event event) // check status switch (statusid) { - case STATUS_WAIT_QUEUE: // status_in_queue - p >> Time1; // average wait time, milliseconds - p >> Time2; // time in queue, updated every minute!, milliseconds + case STATUS_WAIT_QUEUE: // status_in_queue + p >> Time1; // average wait time, milliseconds + p >> Time2; // time in queue, updated every minute!, milliseconds break; - case STATUS_WAIT_JOIN: // status_invite - p >> mapId; // map id + case STATUS_WAIT_JOIN: // status_invite + p >> mapId; // map id p >> unk0; - p >> Time1; // time to remove from queue, milliseconds + p >> Time1; // time to remove from queue, milliseconds break; - case STATUS_IN_PROGRESS: // status_in_progress - p >> mapId; // map id + case STATUS_IN_PROGRESS: // status_in_progress + p >> mapId; // map id p >> unk0; - p >> Time1; // time to bg auto leave, 0 at bg start, 120000 after bg end, milliseconds - p >> Time2; // time from bg start, milliseconds + p >> Time1; // time to bg auto leave, 0 at bg start, 120000 after bg end, milliseconds + p >> Time2; // time from bg start, milliseconds p >> arenaTeam; break; default: @@ -773,7 +802,7 @@ bool BGStatusAction::Execute(Event event) bracketId = pvpDiff->GetBracketId(); bool isArena = false; - uint8 type = false; // arenatype if arena + uint8 type = false; // arenatype if arena uint16 unk = 0x1F90; uint8 unk2 = 0x0; uint8 action = 0x1; @@ -829,10 +858,11 @@ bool BGStatusAction::Execute(Event event) TeamId teamId = bot->GetTeamId(); - if (Time1 == TIME_TO_AUTOREMOVE) //Battleground is over, bot needs to leave + if (Time1 == TIME_TO_AUTOREMOVE) // Battleground is over, bot needs to leave { LOG_INFO("playerbots", "Bot {} <{}> ({} {}): Received BG status TIME_REMOVE for {} {}", - bot->GetGUID().ToString().c_str(), bot->GetName(), bot->GetLevel(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", isArena ? "Arena" : "BG", _bgType); + bot->GetGUID().ToString().c_str(), bot->GetName(), bot->GetLevel(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", isArena ? "Arena" : "BG", _bgType); // remove warsong strategy if (IsRandomBot) @@ -851,12 +881,13 @@ bool BGStatusAction::Execute(Event event) botAI->ChangeStrategy("-arena", BOT_STATE_COMBAT); botAI->ChangeStrategy("-arena", BOT_STATE_NON_COMBAT); - LOG_INFO("playerbots", "Bot {} {}:{} <{}> leaves {} - {}", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType); + LOG_INFO("playerbots", "Bot {} {}:{} <{}> leaves {} - {}", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), + isArena ? "Arena" : "BG", _bgType); WorldPacket packet(CMSG_LEAVE_BATTLEFIELD); packet << uint8(0); - packet << uint8(0); // BattlegroundTypeId-1 ? + packet << uint8(0); // BattlegroundTypeId-1 ? packet << uint32(0); packet << uint16(0); @@ -872,12 +903,13 @@ bool BGStatusAction::Execute(Event event) posMap["bg objective"] = pos; } - if (statusid == STATUS_WAIT_QUEUE) // bot is in queue + if (statusid == STATUS_WAIT_QUEUE) // bot is in queue { LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Received BG status WAIT_QUEUE (wait time: {}) for {} {}", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), Time2, isArena ? "Arena" : "BG", _bgType); + bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + bot->GetName(), Time2, isArena ? "Arena" : "BG", _bgType); // temp fix for crash - //return true; + // return true; BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(queueTypeId); GroupQueueInfo ginfo; @@ -886,7 +918,8 @@ bool BGStatusAction::Execute(Event event) if (ginfo.IsInvitedToBGInstanceGUID && !bot->InBattleground()) { // BattlegroundMgr::GetBattleground() does not return battleground if bgTypeId==BATTLEGROUND_AA - Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, _bgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : _bgTypeId); + Battleground* bg = sBattlegroundMgr->GetBattleground( + ginfo.IsInvitedToBGInstanceGUID, _bgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : _bgTypeId); if (bg) { if (isArena) @@ -894,8 +927,9 @@ bool BGStatusAction::Execute(Event event) _bgTypeId = bg->GetBgTypeID(); } - LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Force join {} {}", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType); + LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Force join {} {}", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), + isArena ? "Arena" : "BG", _bgType); WorldPacket emptyPacket; bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket); action = 0x1; @@ -905,8 +939,10 @@ bool BGStatusAction::Execute(Event event) bot->GetSession()->HandleBattleFieldPortOpcode(packet); botAI->ResetStrategies(false); - if (!bot->GetBattleground()) { - // first bot to join wont have battleground and PlayerbotAI::ResetStrategies() wont set them up properly, set bg for "bg strategy check" to fix that + if (!bot->GetBattleground()) + { + // first bot to join wont have battleground and PlayerbotAI::ResetStrategies() wont set them up + // properly, set bg for "bg strategy check" to fix that botAI->ChangeStrategy("+bg", BOT_STATE_NON_COMBAT); } context->GetValue("bg role")->Set(urand(0, 9)); @@ -931,23 +967,26 @@ bool BGStatusAction::Execute(Event event) else timer = TIME_TO_AUTOREMOVE + 1000 * (bg->GetMaxPlayersPerTeam() * 8); - if (Time2 > timer && isArena) // disabled for BG + if (Time2 > timer && isArena) // disabled for BG leaveQ = true; - if (leaveQ && ((bot->GetGroup() && bot->GetGroup()->IsLeader(bot->GetGUID())) || !(bot->GetGroup() || botAI->GetMaster()))) + if (leaveQ && ((bot->GetGroup() && bot->GetGroup()->IsLeader(bot->GetGUID())) || + !(bot->GetGroup() || botAI->GetMaster()))) { TeamId teamId = bot->GetTeamId(); bool realPlayers = false; if (isRated) realPlayers = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount > 0; else - realPlayers = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount > 0; + realPlayers = + sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount > 0; if (realPlayers) return false; LOG_INFO("playerbots", "Bot {} {}:{} <{}> waited too long and leaves queue ({} {}).", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType); + bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + bot->GetName(), isArena ? "Arena" : "BG", _bgType); WorldPacket packet(CMSG_BATTLEFIELD_PORT, 20); action = 0; @@ -963,17 +1002,19 @@ bool BGStatusAction::Execute(Event event) } } - if (statusid == STATUS_IN_PROGRESS) // placeholder for Leave BG if it takes too long + if (statusid == STATUS_IN_PROGRESS) // placeholder for Leave BG if it takes too long { LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Received BG status IN_PROGRESS for {} {}", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType); + bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + bot->GetName(), isArena ? "Arena" : "BG", _bgType); return false; } - if (statusid == STATUS_WAIT_JOIN) //bot may join + if (statusid == STATUS_WAIT_JOIN) // bot may join { LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Received BG status WAIT_JOIN for {} {}", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType); + bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + bot->GetName(), isArena ? "Arena" : "BG", _bgType); if (isArena) { @@ -984,18 +1025,21 @@ bool BGStatusAction::Execute(Event event) if (!bgQueue.GetPlayerGroupInfoData(bot->GetGUID(), &ginfo)) { LOG_ERROR("playerbots", "Bot {} {}:{} <{}>: Missing QueueInfo for {} {}", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType); + bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", + bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType); return false; } if (ginfo.IsInvitedToBGInstanceGUID) { // BattlegroundMgr::GetBattleground() does not return battleground if bgTypeId==BATTLEGROUND_AA - Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, _bgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : _bgTypeId); + Battleground* bg = sBattlegroundMgr->GetBattleground( + ginfo.IsInvitedToBGInstanceGUID, _bgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : _bgTypeId); if (!bg) { LOG_ERROR("playerbots", "Bot {} {}:{} <{}>: Missing QueueInfo for {} {}", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType); + bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", + bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType); return false; } @@ -1003,8 +1047,9 @@ bool BGStatusAction::Execute(Event event) } } - LOG_INFO("playerbots", "Bot {} {}:{} <{}> joined {} - {}", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), isArena ? "Arena" : "BG", _bgType); + LOG_INFO("playerbots", "Bot {} {}:{} <{}> joined {} - {}", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), + isArena ? "Arena" : "BG", _bgType); WorldPacket emptyPacket; bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket); @@ -1016,8 +1061,10 @@ bool BGStatusAction::Execute(Event event) bot->GetSession()->HandleBattleFieldPortOpcode(packet); botAI->ResetStrategies(false); - if (!bot->GetBattleground()) { - // first bot to join wont have battleground and PlayerbotAI::ResetStrategies() wont set them up properly, set bg for "bg strategy check" to fix that + if (!bot->GetBattleground()) + { + // first bot to join wont have battleground and PlayerbotAI::ResetStrategies() wont set them up properly, + // set bg for "bg strategy check" to fix that botAI->ChangeStrategy("+bg", BOT_STATE_NON_COMBAT); } context->GetValue("bg role")->Set(urand(0, 9)); @@ -1043,25 +1090,25 @@ bool BGStatusCheckAction::Execute(Event event) WorldPacket packet(CMSG_BATTLEFIELD_STATUS); bot->GetSession()->HandleBattlefieldStatusOpcode(packet); - LOG_INFO("playerbots", "Bot {} <{}> ({} {}) : Checking BG invite status", - bot->GetGUID().ToString().c_str(), bot->GetName(), bot->GetLevel(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H"); + LOG_INFO("playerbots", "Bot {} <{}> ({} {}) : Checking BG invite status", bot->GetGUID().ToString().c_str(), + bot->GetName(), bot->GetLevel(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H"); return true; } -bool BGStatusCheckAction::isUseful() -{ - return bot->InBattlegroundQueue(); -} +bool BGStatusCheckAction::isUseful() { return bot->InBattlegroundQueue(); } bool BGStrategyCheckAction::Execute(Event event) { - bool inside_bg = bot->InBattleground() && bot->GetBattleground();; - if (!inside_bg && botAI->HasStrategy("battleground", BOT_STATE_NON_COMBAT)) { + bool inside_bg = bot->InBattleground() && bot->GetBattleground(); + ; + if (!inside_bg && botAI->HasStrategy("battleground", BOT_STATE_NON_COMBAT)) + { botAI->ResetStrategies(); return true; } - if (inside_bg && !botAI->HasStrategy("battleground", BOT_STATE_NON_COMBAT)) { + if (inside_bg && !botAI->HasStrategy("battleground", BOT_STATE_NON_COMBAT)) + { botAI->ResetStrategies(); return false; } diff --git a/src/strategy/actions/BattleGroundJoinAction.h b/src/strategy/actions/BattleGroundJoinAction.h index 8248ebac..0a548c58 100644 --- a/src/strategy/actions/BattleGroundJoinAction.h +++ b/src/strategy/actions/BattleGroundJoinAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_BATTLEGROUNDJOINACTION_H @@ -18,60 +19,60 @@ enum BattlegroundBracketId : uint8; class BGJoinAction : public Action { - public: - BGJoinAction(PlayerbotAI* botAI, std::string const name = "bg join") : Action(botAI, name) { } +public: + BGJoinAction(PlayerbotAI* botAI, std::string const name = "bg join") : Action(botAI, name) {} - bool isUseful() override; - bool canJoinBg(BattlegroundQueueTypeId queueTypeId, BattlegroundBracketId bracketId); - virtual bool shouldJoinBg(BattlegroundQueueTypeId queueTypeId, BattlegroundBracketId bracketId); - bool Execute(Event event) override; - virtual bool gatherArenaTeam(ArenaType type); + bool isUseful() override; + bool canJoinBg(BattlegroundQueueTypeId queueTypeId, BattlegroundBracketId bracketId); + virtual bool shouldJoinBg(BattlegroundQueueTypeId queueTypeId, BattlegroundBracketId bracketId); + bool Execute(Event event) override; + virtual bool gatherArenaTeam(ArenaType type); - protected: - bool JoinQueue(uint32 type); - std::vector bgList; - std::vector ratedList; +protected: + bool JoinQueue(uint32 type); + std::vector bgList; + std::vector ratedList; }; class FreeBGJoinAction : public BGJoinAction { - public: - FreeBGJoinAction(PlayerbotAI* botAI, std::string const name = "free bg join") : BGJoinAction(botAI, name) { } +public: + FreeBGJoinAction(PlayerbotAI* botAI, std::string const name = "free bg join") : BGJoinAction(botAI, name) {} - bool shouldJoinBg(BattlegroundQueueTypeId queueTypeId, BattlegroundBracketId bracketId) override; + bool shouldJoinBg(BattlegroundQueueTypeId queueTypeId, BattlegroundBracketId bracketId) override; }; class BGLeaveAction : public Action { public: - BGLeaveAction(PlayerbotAI* botAI, std::string const name = "bg leave") : Action(botAI, name) { } + BGLeaveAction(PlayerbotAI* botAI, std::string const name = "bg leave") : Action(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class BGStatusAction : public Action { public: - BGStatusAction(PlayerbotAI* botAI) : Action(botAI, "bg status") { } + BGStatusAction(PlayerbotAI* botAI) : Action(botAI, "bg status") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class BGStatusCheckAction : public Action { - public: - BGStatusCheckAction(PlayerbotAI* botAI, std::string const name = "bg status check") : Action(botAI, name) { } +public: + BGStatusCheckAction(PlayerbotAI* botAI, std::string const name = "bg status check") : Action(botAI, name) {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class BGStrategyCheckAction : public Action { - public: - BGStrategyCheckAction(PlayerbotAI* botAI, std::string const name = "bg strategy check") : Action(botAI, name) { } +public: + BGStrategyCheckAction(PlayerbotAI* botAI, std::string const name = "bg strategy check") : Action(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/BattleGroundTactics.cpp b/src/strategy/actions/BattleGroundTactics.cpp index 2c693a97..03b838d5 100644 --- a/src/strategy/actions/BattleGroundTactics.cpp +++ b/src/strategy/actions/BattleGroundTactics.cpp @@ -1,11 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "BattleGroundTactics.h" + #include "ArenaTeam.h" #include "ArenaTeamMgr.h" -#include "BattlegroundMgr.h" #include "BattlegroundAB.h" #include "BattlegroundAV.h" #include "BattlegroundBE.h" @@ -18,7 +19,6 @@ #include "BattlegroundRV.h" #include "BattlegroundSA.h" #include "BattlegroundWS.h" -#include "BattlegroundEY.h" #include "Event.h" #include "Playerbots.h" #include "PositionValue.h" @@ -26,55 +26,57 @@ #include "Vehicle.h" // common bg positions -Position const WS_WAITING_POS_HORDE_1 = { 944.981f, 1423.478f, 345.434f, 6.18f }; -Position const WS_WAITING_POS_HORDE_2 = { 948.488f, 1459.834f, 343.066f, 6.27f }; -Position const WS_WAITING_POS_ALLIANCE_1 = { 1510.502f, 1493.385f, 351.995f, 3.1f }; -Position const WS_WAITING_POS_ALLIANCE_2 = { 1496.578f, 1457.900f, 344.442f, 3.1f }; -Position const WS_FLAG_POS_HORDE = { 915.958f, 1433.925f, 346.193f, 0.0f }; -Position const WS_FLAG_POS_ALLIANCE = { 1539.219f, 1481.747f, 352.458f, 0.0f }; -Position const WS_FLAG_HIDE_HORDE_1 = { 928.178f, 1458.432f, 346.889f, 4.8f }; -Position const WS_FLAG_HIDE_HORDE_2 = { 914.954f, 1439.540f, 346.415f, 4.7f }; -Position const WS_FLAG_HIDE_HORDE_3 = { 1163.820f, 1373.625f, 312.23f, 4.7f }; -Position const WS_FLAG_HIDE_ALLIANCE_1 = { 1529.249f, 1456.470f, 353.04f, 1.25f }; -Position const WS_FLAG_HIDE_ALLIANCE_2 = { 1540.286f, 1476.026f, 352.692f, 2.91f }; -Position const WS_FLAG_HIDE_ALLIANCE_3 = { 1495.807f, 1466.774f, 352.350f, 1.50f }; -std::vector const WS_FLAG_HIDE_HORDE = { WS_FLAG_HIDE_HORDE_1 , WS_FLAG_HIDE_HORDE_2, WS_FLAG_HIDE_HORDE_3 }; -std::vector const WS_FLAG_HIDE_ALLIANCE = { WS_FLAG_HIDE_ALLIANCE_1 , WS_FLAG_HIDE_ALLIANCE_2, WS_FLAG_HIDE_ALLIANCE_3 }; +Position const WS_WAITING_POS_HORDE_1 = {944.981f, 1423.478f, 345.434f, 6.18f}; +Position const WS_WAITING_POS_HORDE_2 = {948.488f, 1459.834f, 343.066f, 6.27f}; +Position const WS_WAITING_POS_ALLIANCE_1 = {1510.502f, 1493.385f, 351.995f, 3.1f}; +Position const WS_WAITING_POS_ALLIANCE_2 = {1496.578f, 1457.900f, 344.442f, 3.1f}; +Position const WS_FLAG_POS_HORDE = {915.958f, 1433.925f, 346.193f, 0.0f}; +Position const WS_FLAG_POS_ALLIANCE = {1539.219f, 1481.747f, 352.458f, 0.0f}; +Position const WS_FLAG_HIDE_HORDE_1 = {928.178f, 1458.432f, 346.889f, 4.8f}; +Position const WS_FLAG_HIDE_HORDE_2 = {914.954f, 1439.540f, 346.415f, 4.7f}; +Position const WS_FLAG_HIDE_HORDE_3 = {1163.820f, 1373.625f, 312.23f, 4.7f}; +Position const WS_FLAG_HIDE_ALLIANCE_1 = {1529.249f, 1456.470f, 353.04f, 1.25f}; +Position const WS_FLAG_HIDE_ALLIANCE_2 = {1540.286f, 1476.026f, 352.692f, 2.91f}; +Position const WS_FLAG_HIDE_ALLIANCE_3 = {1495.807f, 1466.774f, 352.350f, 1.50f}; +std::vector const WS_FLAG_HIDE_HORDE = {WS_FLAG_HIDE_HORDE_1, WS_FLAG_HIDE_HORDE_2, WS_FLAG_HIDE_HORDE_3}; +std::vector const WS_FLAG_HIDE_ALLIANCE = {WS_FLAG_HIDE_ALLIANCE_1, WS_FLAG_HIDE_ALLIANCE_2, + WS_FLAG_HIDE_ALLIANCE_3}; -Position const AB_WAITING_POS_HORDE = { 702.884f, 703.045f, -16.115f, 0.77f }; -Position const AB_WAITING_POS_ALLIANCE = { 1286.054f, 1282.500f, -15.697f, 3.95f }; +Position const AB_WAITING_POS_HORDE = {702.884f, 703.045f, -16.115f, 0.77f}; +Position const AB_WAITING_POS_ALLIANCE = {1286.054f, 1282.500f, -15.697f, 3.95f}; -// the captains aren't the actual creatures but invisible trigger creatures - they still have correct death state and location (unless they move) +// the captains aren't the actual creatures but invisible trigger creatures - they still have correct death state and +// location (unless they move) uint32 const AV_CREATURE_A_CAPTAIN = AV_CPLACE_TRIGGER16; uint32 const AV_CREATURE_A_BOSS = AV_CPLACE_A_BOSS; uint32 const AV_CREATURE_H_CAPTAIN = AV_CPLACE_TRIGGER18; uint32 const AV_CREATURE_H_BOSS = AV_CPLACE_H_BOSS; -Position const AV_CAVE_SPAWN_ALLIANCE = { 872.460f, -491.571f, 96.546f, 0.0f }; -Position const AV_CAVE_SPAWN_HORDE = { -1437.127f, -608.382f, 51.185f, 0.0f }; -Position const AV_WAITING_POS_ALLIANCE = { 793.627f, -493.814f, 99.689f, 3.09f }; -Position const AV_WAITING_POS_HORDE = { -1381.865f, -544.872f, 54.773f, 0.76f }; -Position const AV_ICEBLOOD_GARRISON_WAITING_ALLIANCE = { -523.105f, -182.178f, 57.956f, 0.0f }; -Position const AV_ICEBLOOD_GARRISON_ATTACKING_ALLIANCE = { -545.288f, -167.932f, 57.012f, 0.0f }; -Position const AV_STONEHEARTH_WAITING_HORDE = { -36.399f, -306.403f, 15.565f, 0.0f }; -Position const AV_STONEHEARTH_ATTACKING_HORDE = { -55.210f, -288.546f, 15.578f, 0.0f }; +Position const AV_CAVE_SPAWN_ALLIANCE = {872.460f, -491.571f, 96.546f, 0.0f}; +Position const AV_CAVE_SPAWN_HORDE = {-1437.127f, -608.382f, 51.185f, 0.0f}; +Position const AV_WAITING_POS_ALLIANCE = {793.627f, -493.814f, 99.689f, 3.09f}; +Position const AV_WAITING_POS_HORDE = {-1381.865f, -544.872f, 54.773f, 0.76f}; +Position const AV_ICEBLOOD_GARRISON_WAITING_ALLIANCE = {-523.105f, -182.178f, 57.956f, 0.0f}; +Position const AV_ICEBLOOD_GARRISON_ATTACKING_ALLIANCE = {-545.288f, -167.932f, 57.012f, 0.0f}; +Position const AV_STONEHEARTH_WAITING_HORDE = {-36.399f, -306.403f, 15.565f, 0.0f}; +Position const AV_STONEHEARTH_ATTACKING_HORDE = {-55.210f, -288.546f, 15.578f, 0.0f}; -Position const EY_WAITING_POS_HORDE = { 1809.102f, 1540.854f, 1267.142f, 6.18f }; -Position const EY_WAITING_POS_ALLIANCE = { 2526.020f, 1596.787f, 1270.127f, 3.14f }; -Position const EY_FLAG_RETURN_POS_RETREAT_HORDE = { 1885.529f, 1532.157f, 1200.635f, 0.0f }; -Position const EY_FLAG_RETURN_POS_RETREAT_ALLIANCE = { 2452.253f, 1602.356f, 1203.617f, 0.0f }; +Position const EY_WAITING_POS_HORDE = {1809.102f, 1540.854f, 1267.142f, 6.18f}; +Position const EY_WAITING_POS_ALLIANCE = {2526.020f, 1596.787f, 1270.127f, 3.14f}; +Position const EY_FLAG_RETURN_POS_RETREAT_HORDE = {1885.529f, 1532.157f, 1200.635f, 0.0f}; +Position const EY_FLAG_RETURN_POS_RETREAT_ALLIANCE = {2452.253f, 1602.356f, 1203.617f, 0.0f}; -Position const IC_WAITING_POS_HORDE = { 1166.322f, -762.402f, 48.628f, 3.14f }; -Position const IC_WAITING_POS_ALLIANCE = { 387.893f, -833.384f, 48.714f, 6.28f }; +Position const IC_WAITING_POS_HORDE = {1166.322f, -762.402f, 48.628f, 3.14f}; +Position const IC_WAITING_POS_ALLIANCE = {387.893f, -833.384f, 48.714f, 6.28f}; -Position const IC_WEST_WAITING_POS_HORDE = { 1217.666f, -685.449f, 48.915f, 1.54f }; -Position const IC_EAST_WAITING_POS_HORDE = { 1219.068f, -838.791f, 48.916f, 4.72f }; -Position const IC_SIDE_WAITING_POS_ALLIANCE = { 351.517f, -882.477f, 48.916f, 4.68f }; +Position const IC_WEST_WAITING_POS_HORDE = {1217.666f, -685.449f, 48.915f, 1.54f}; +Position const IC_EAST_WAITING_POS_HORDE = {1219.068f, -838.791f, 48.916f, 4.72f}; +Position const IC_SIDE_WAITING_POS_ALLIANCE = {351.517f, -882.477f, 48.916f, 4.68f}; -Position const IC_CANNON_POS_HORDE1 = { 1140.938f, -838.685f, 88.124f, 2.30f }; -Position const IC_CANNON_POS_HORDE2 = { 1139.695f, -686.574f, 88.173f, 3.95f }; -Position const IC_CANNON_POS_ALLIANCE1 = { 424.860f, -855.795f, 87.96f, 0.44f }; -Position const IC_CANNON_POS_ALLIANCE2 = { 425.525f, -779.538f, 87.717f, 5.88f }; +Position const IC_CANNON_POS_HORDE1 = {1140.938f, -838.685f, 88.124f, 2.30f}; +Position const IC_CANNON_POS_HORDE2 = {1139.695f, -686.574f, 88.173f, 3.95f}; +Position const IC_CANNON_POS_ALLIANCE1 = {424.860f, -855.795f, 87.96f, 0.44f}; +Position const IC_CANNON_POS_ALLIANCE2 = {425.525f, -779.538f, 87.717f, 5.88f}; enum BattleBotWsgWaitSpot { @@ -83,2113 +85,1269 @@ enum BattleBotWsgWaitSpot BB_WSG_WAIT_SPOT_RIGHT }; -std::vector const vFlagsAV = { BG_AV_OBJECTID_BANNER_H_B , BG_AV_OBJECTID_BANNER_H , BG_AV_OBJECTID_BANNER_A_B , BG_AV_OBJECTID_BANNER_A , - BG_AV_OBJECTID_BANNER_CONT_A , BG_AV_OBJECTID_BANNER_CONT_A_B , BG_AV_OBJECTID_BANNER_CONT_H_B , - BG_AV_OBJECTID_BANNER_CONT_H , BG_AV_OBJECTID_BANNER_SNOWFALL_N }; +std::vector const vFlagsAV = { + BG_AV_OBJECTID_BANNER_H_B, BG_AV_OBJECTID_BANNER_H, BG_AV_OBJECTID_BANNER_A_B, + BG_AV_OBJECTID_BANNER_A, BG_AV_OBJECTID_BANNER_CONT_A, BG_AV_OBJECTID_BANNER_CONT_A_B, + BG_AV_OBJECTID_BANNER_CONT_H_B, BG_AV_OBJECTID_BANNER_CONT_H, BG_AV_OBJECTID_BANNER_SNOWFALL_N}; -std::vector const vFlagsAB = { BG_AB_OBJECTID_BANNER_A , BG_AB_OBJECTID_BANNER_CONT_A , BG_AB_OBJECTID_BANNER_H , BG_AB_OBJECTID_BANNER_CONT_H , - BG_AB_OBJECTID_NODE_BANNER_0, BG_AB_OBJECTID_NODE_BANNER_1, BG_AB_OBJECTID_NODE_BANNER_2, BG_AB_OBJECTID_NODE_BANNER_3, - BG_AB_OBJECTID_NODE_BANNER_4 }; +std::vector const vFlagsAB = { + BG_AB_OBJECTID_BANNER_A, BG_AB_OBJECTID_BANNER_CONT_A, BG_AB_OBJECTID_BANNER_H, + BG_AB_OBJECTID_BANNER_CONT_H, BG_AB_OBJECTID_NODE_BANNER_0, BG_AB_OBJECTID_NODE_BANNER_1, + BG_AB_OBJECTID_NODE_BANNER_2, BG_AB_OBJECTID_NODE_BANNER_3, BG_AB_OBJECTID_NODE_BANNER_4}; -std::vector const vFlagsWS = { BG_OBJECT_A_FLAG_WS_ENTRY, BG_OBJECT_H_FLAG_WS_ENTRY, BG_OBJECT_A_FLAG_GROUND_WS_ENTRY, BG_OBJECT_H_FLAG_GROUND_WS_ENTRY }; +std::vector const vFlagsWS = {BG_OBJECT_A_FLAG_WS_ENTRY, BG_OBJECT_H_FLAG_WS_ENTRY, + BG_OBJECT_A_FLAG_GROUND_WS_ENTRY, BG_OBJECT_H_FLAG_GROUND_WS_ENTRY}; -std::vector const vFlagsEY = { BG_OBJECT_FLAG2_EY_ENTRY, BG_OBJECT_FLAG3_EY_ENTRY }; +std::vector const vFlagsEY = {BG_OBJECT_FLAG2_EY_ENTRY, BG_OBJECT_FLAG3_EY_ENTRY}; -std::vector const vFlagsIC = { BG_IC_GO_HORDE_BANNER, BG_IC_GO_ALLIANCE_BANNER, BG_IC_GO_WORKSHOP_BANNER, BG_IC_GO_DOCKS_BANNER, BG_IC_GO_HANGAR_BANNER, - BG_IC_GO_QUARRY_BANNER, BG_IC_GO_REFINERY_BANNER }; +std::vector const vFlagsIC = {BG_IC_GO_HORDE_BANNER, BG_IC_GO_ALLIANCE_BANNER, BG_IC_GO_WORKSHOP_BANNER, + BG_IC_GO_DOCKS_BANNER, BG_IC_GO_HANGAR_BANNER, BG_IC_GO_QUARRY_BANNER, + BG_IC_GO_REFINERY_BANNER}; // BG Waypoints (vmangos) // Horde Flag Room to Horde Graveyard -BattleBotPath vPath_WSG_HordeFlagRoom_to_HordeGraveyard = -{ - { 933.331f, 1433.72f, 345.536f, nullptr }, - { 944.859f, 1423.05f, 345.437f, nullptr }, - { 966.691f, 1422.53f, 345.223f, nullptr }, - { 979.588f, 1422.84f, 345.46f, nullptr }, - { 997.806f, 1422.52f, 344.623f, nullptr }, - { 1008.53f, 1417.02f, 343.206f, nullptr }, - { 1016.42f, 1402.33f, 341.352f, nullptr }, - { 1029.14f, 1387.49f, 340.836f, nullptr }, +BattleBotPath vPath_WSG_HordeFlagRoom_to_HordeGraveyard = { + {933.331f, 1433.72f, 345.536f, nullptr}, {944.859f, 1423.05f, 345.437f, nullptr}, + {966.691f, 1422.53f, 345.223f, nullptr}, {979.588f, 1422.84f, 345.46f, nullptr}, + {997.806f, 1422.52f, 344.623f, nullptr}, {1008.53f, 1417.02f, 343.206f, nullptr}, + {1016.42f, 1402.33f, 341.352f, nullptr}, {1029.14f, 1387.49f, 340.836f, nullptr}, }; // Horde Graveyard to Horde Tunnel -BattleBotPath vPath_WSG_HordeGraveyard_to_HordeTunnel = -{ - { 1029.14f, 1387.49f, 340.836f, nullptr }, - { 1034.95f, 1392.62f, 340.856f, nullptr }, - { 1038.21f, 1406.43f, 341.562f, nullptr }, - { 1043.87f, 1426.9f, 339.197f, nullptr }, - { 1054.53f, 1441.47f, 339.725f, nullptr }, - { 1056.33f, 1456.03f, 341.463f, nullptr }, - { 1057.39f, 1469.98f, 342.148f, nullptr }, - { 1057.67f, 1487.55f, 342.537f, nullptr }, - { 1048.7f, 1505.37f, 341.117f, nullptr }, - { 1042.19f, 1521.69f, 338.003f, nullptr }, - { 1050.01f, 1538.22f, 332.43f, nullptr }, - { 1068.15f, 1548.1f, 321.446f, nullptr }, - { 1088.14f, 1538.45f, 316.398f, nullptr }, - { 1101.26f, 1522.79f, 314.918f, nullptr }, - { 1114.67f, 1503.18f, 312.947f, nullptr }, - { 1126.45f, 1487.4f, 314.136f, nullptr }, - { 1124.37f, 1462.28f, 315.853f, nullptr }, +BattleBotPath vPath_WSG_HordeGraveyard_to_HordeTunnel = { + {1029.14f, 1387.49f, 340.836f, nullptr}, {1034.95f, 1392.62f, 340.856f, nullptr}, + {1038.21f, 1406.43f, 341.562f, nullptr}, {1043.87f, 1426.9f, 339.197f, nullptr}, + {1054.53f, 1441.47f, 339.725f, nullptr}, {1056.33f, 1456.03f, 341.463f, nullptr}, + {1057.39f, 1469.98f, 342.148f, nullptr}, {1057.67f, 1487.55f, 342.537f, nullptr}, + {1048.7f, 1505.37f, 341.117f, nullptr}, {1042.19f, 1521.69f, 338.003f, nullptr}, + {1050.01f, 1538.22f, 332.43f, nullptr}, {1068.15f, 1548.1f, 321.446f, nullptr}, + {1088.14f, 1538.45f, 316.398f, nullptr}, {1101.26f, 1522.79f, 314.918f, nullptr}, + {1114.67f, 1503.18f, 312.947f, nullptr}, {1126.45f, 1487.4f, 314.136f, nullptr}, + {1124.37f, 1462.28f, 315.853f, nullptr}, }; // Horde Tunnel to Horde Flag Room -BattleBotPath vPath_WSG_HordeTunnel_to_HordeFlagRoom = -{ - { 1124.37f, 1462.28f, 315.853f, nullptr }, - { 1106.87f, 1462.13f, 316.558f, nullptr }, - { 1089.44f, 1461.04f, 316.332f, nullptr }, - { 1072.07f, 1459.46f, 317.449f, nullptr }, - { 1051.09f, 1459.89f, 323.126f, nullptr }, - { 1030.1f, 1459.58f, 330.204f, nullptr }, - { 1010.76f, 1457.49f, 334.896f, nullptr }, - { 1005.47f, 1448.19f, 335.864f, nullptr }, - { 999.974f, 1458.49f, 335.632f, nullptr }, - { 982.632f, 1459.18f, 336.127f, nullptr }, - { 965.049f, 1459.15f, 338.076f, nullptr }, - { 944.526f, 1459.0f, 344.207f, nullptr }, - { 937.479f, 1451.12f, 345.553f, nullptr }, - { 933.331f, 1433.72f, 345.536f, nullptr }, +BattleBotPath vPath_WSG_HordeTunnel_to_HordeFlagRoom = { + {1124.37f, 1462.28f, 315.853f, nullptr}, {1106.87f, 1462.13f, 316.558f, nullptr}, + {1089.44f, 1461.04f, 316.332f, nullptr}, {1072.07f, 1459.46f, 317.449f, nullptr}, + {1051.09f, 1459.89f, 323.126f, nullptr}, {1030.1f, 1459.58f, 330.204f, nullptr}, + {1010.76f, 1457.49f, 334.896f, nullptr}, {1005.47f, 1448.19f, 335.864f, nullptr}, + {999.974f, 1458.49f, 335.632f, nullptr}, {982.632f, 1459.18f, 336.127f, nullptr}, + {965.049f, 1459.15f, 338.076f, nullptr}, {944.526f, 1459.0f, 344.207f, nullptr}, + {937.479f, 1451.12f, 345.553f, nullptr}, {933.331f, 1433.72f, 345.536f, nullptr}, }; // Horde Tunnel to Alliance Tunnel 1 -BattleBotPath vPath_WSG_HordeTunnel_to_AllianceTunnel_1 = -{ - { 1124.37f, 1462.28f, 315.853f, nullptr }, - { 1135.07f, 1462.43f, 315.569f, nullptr }, - { 1152.2f, 1465.51f, 311.056f, nullptr }, - { 1172.62f, 1470.34f, 306.812f, nullptr }, - { 1193.1f, 1475.0f, 305.155f, nullptr }, - { 1212.99f, 1477.94f, 306.929f, nullptr }, - { 1233.88f, 1476.29f, 308.015f, nullptr }, - { 1250.52f, 1470.94f, 309.8f, nullptr }, - { 1266.09f, 1465.75f, 312.242f, nullptr }, - { 1283.31f, 1463.55f, 311.819f, nullptr }, - { 1297.11f, 1461.2f, 315.485f, nullptr }, - { 1314.31f, 1460.76f, 317.926f, nullptr }, - { 1329.8f, 1461.24f, 320.267f, nullptr }, - { 1348.02f, 1461.06f, 323.167f, nullptr }, +BattleBotPath vPath_WSG_HordeTunnel_to_AllianceTunnel_1 = { + {1124.37f, 1462.28f, 315.853f, nullptr}, {1135.07f, 1462.43f, 315.569f, nullptr}, + {1152.2f, 1465.51f, 311.056f, nullptr}, {1172.62f, 1470.34f, 306.812f, nullptr}, + {1193.1f, 1475.0f, 305.155f, nullptr}, {1212.99f, 1477.94f, 306.929f, nullptr}, + {1233.88f, 1476.29f, 308.015f, nullptr}, {1250.52f, 1470.94f, 309.8f, nullptr}, + {1266.09f, 1465.75f, 312.242f, nullptr}, {1283.31f, 1463.55f, 311.819f, nullptr}, + {1297.11f, 1461.2f, 315.485f, nullptr}, {1314.31f, 1460.76f, 317.926f, nullptr}, + {1329.8f, 1461.24f, 320.267f, nullptr}, {1348.02f, 1461.06f, 323.167f, nullptr}, }; // Horde Tunnel to Alliance Tunnel 2 -BattleBotPath vPath_WSG_HordeTunnel_to_AllianceTunnel_2 = -{ - { 1124.37f, 1462.28f, 315.853f, nullptr }, - { 1138.61f, 1452.12f, 312.988f, nullptr }, - { 1154.35f, 1442.42f, 310.728f, nullptr }, - { 1171.29f, 1438.04f, 307.462f, nullptr }, - { 1185.03f, 1435.43f, 309.484f, nullptr }, - { 1202.24f, 1432.26f, 310.193f, nullptr }, - { 1219.48f, 1429.2f, 310.301f, nullptr }, - { 1235.94f, 1429.97f, 309.727f, nullptr }, - { 1249.3f, 1434.12f, 312.37f, nullptr }, - { 1265.88f, 1439.71f, 314.373f, nullptr }, - { 1282.87f, 1443.85f, 314.907f, nullptr }, - { 1300.06f, 1447.16f, 316.737f, nullptr }, - { 1313.79f, 1449.86f, 317.651f, nullptr }, - { 1329.76f, 1457.36f, 320.37f, nullptr }, - { 1348.02f, 1461.06f, 323.167f, nullptr }, +BattleBotPath vPath_WSG_HordeTunnel_to_AllianceTunnel_2 = { + {1124.37f, 1462.28f, 315.853f, nullptr}, {1138.61f, 1452.12f, 312.988f, nullptr}, + {1154.35f, 1442.42f, 310.728f, nullptr}, {1171.29f, 1438.04f, 307.462f, nullptr}, + {1185.03f, 1435.43f, 309.484f, nullptr}, {1202.24f, 1432.26f, 310.193f, nullptr}, + {1219.48f, 1429.2f, 310.301f, nullptr}, {1235.94f, 1429.97f, 309.727f, nullptr}, + {1249.3f, 1434.12f, 312.37f, nullptr}, {1265.88f, 1439.71f, 314.373f, nullptr}, + {1282.87f, 1443.85f, 314.907f, nullptr}, {1300.06f, 1447.16f, 316.737f, nullptr}, + {1313.79f, 1449.86f, 317.651f, nullptr}, {1329.76f, 1457.36f, 320.37f, nullptr}, + {1348.02f, 1461.06f, 323.167f, nullptr}, }; // Horde GY Jump to Horde Tunnel -BattleBotPath vPath_WSG_HordeGYJump_to_HordeTunnel = -{ - { 1077.87f, 1400.27f, 323.153f, nullptr }, - { 1088.42f, 1402.68f, 319.605f, nullptr }, - { 1104.34f, 1409.4f, 315.304f, nullptr }, - { 1115.4f, 1418.91f, 313.772f, nullptr }, - { 1122.83f, 1430.74f, 312.765f, nullptr }, - { 1125.26f, 1442.56f, 313.996f, nullptr }, - { 1124.37f, 1462.28f, 315.853f, nullptr }, +BattleBotPath vPath_WSG_HordeGYJump_to_HordeTunnel = { + {1077.87f, 1400.27f, 323.153f, nullptr}, {1088.42f, 1402.68f, 319.605f, nullptr}, + {1104.34f, 1409.4f, 315.304f, nullptr}, {1115.4f, 1418.91f, 313.772f, nullptr}, + {1122.83f, 1430.74f, 312.765f, nullptr}, {1125.26f, 1442.56f, 313.996f, nullptr}, + {1124.37f, 1462.28f, 315.853f, nullptr}, }; // Horde GY Jump to Alliance Tunnel -BattleBotPath vPath_WSG_HordeGYJump_to_AllianceTunnel = -{ - { 1077.87f, 1400.27f, 323.153f, nullptr }, - { 1091.57f, 1397.37f, 317.739f, nullptr }, - { 1113.14f, 1398.07f, 314.937f, nullptr }, - { 1133.88f, 1401.36f, 314.333f, nullptr }, - { 1151.25f, 1403.39f, 310.679f, nullptr }, - { 1172.17f, 1405.13f, 308.046f, nullptr }, - { 1192.63f, 1409.01f, 306.914f, nullptr }, - { 1212.59f, 1415.38f, 308.805f, nullptr }, - { 1228.5f, 1422.68f, 309.404f, nullptr }, - { 1242.89f, 1431.01f, 310.664f, nullptr }, - { 1259.33f, 1436.99f, 314.488f, nullptr }, - { 1276.1f, 1442.0f, 314.162f, nullptr }, - { 1299.13f, 1450.26f, 317.148f, nullptr }, - { 1315.54f, 1456.24f, 318.449f, nullptr }, - { 1330.63f, 1460.27f, 320.435f, nullptr }, - { 1348.02f, 1461.06f, 323.167f, nullptr }, +BattleBotPath vPath_WSG_HordeGYJump_to_AllianceTunnel = { + {1077.87f, 1400.27f, 323.153f, nullptr}, {1091.57f, 1397.37f, 317.739f, nullptr}, + {1113.14f, 1398.07f, 314.937f, nullptr}, {1133.88f, 1401.36f, 314.333f, nullptr}, + {1151.25f, 1403.39f, 310.679f, nullptr}, {1172.17f, 1405.13f, 308.046f, nullptr}, + {1192.63f, 1409.01f, 306.914f, nullptr}, {1212.59f, 1415.38f, 308.805f, nullptr}, + {1228.5f, 1422.68f, 309.404f, nullptr}, {1242.89f, 1431.01f, 310.664f, nullptr}, + {1259.33f, 1436.99f, 314.488f, nullptr}, {1276.1f, 1442.0f, 314.162f, nullptr}, + {1299.13f, 1450.26f, 317.148f, nullptr}, {1315.54f, 1456.24f, 318.449f, nullptr}, + {1330.63f, 1460.27f, 320.435f, nullptr}, {1348.02f, 1461.06f, 323.167f, nullptr}, }; // Alliance Flag Room to Alliance Graveyard -BattleBotPath vPath_WSG_AllianceFlagRoom_to_AllianceGraveyard = -{ - { 1519.53f, 1481.87f, 352.024f, nullptr }, - { 1508.27f, 1493.17f, 352.005f, nullptr }, - { 1490.78f, 1493.51f, 352.141f, nullptr }, - { 1469.79f, 1494.13f, 351.774f, nullptr }, - { 1453.65f, 1494.39f, 350.614f, nullptr }, - { 1443.51f, 1501.75f, 348.317f, nullptr }, - { 1443.33f, 1517.78f, 345.534f, nullptr }, - { 1443.55f, 1533.4f, 343.148f, nullptr }, - { 1441.47f, 1548.12f, 342.752f, nullptr }, - { 1433.79f, 1552.67f, 342.763f, nullptr }, - { 1422.88f, 1552.37f, 342.751f, nullptr }, - { 1415.33f, 1554.79f, 343.156f, nullptr }, +BattleBotPath vPath_WSG_AllianceFlagRoom_to_AllianceGraveyard = { + {1519.53f, 1481.87f, 352.024f, nullptr}, {1508.27f, 1493.17f, 352.005f, nullptr}, + {1490.78f, 1493.51f, 352.141f, nullptr}, {1469.79f, 1494.13f, 351.774f, nullptr}, + {1453.65f, 1494.39f, 350.614f, nullptr}, {1443.51f, 1501.75f, 348.317f, nullptr}, + {1443.33f, 1517.78f, 345.534f, nullptr}, {1443.55f, 1533.4f, 343.148f, nullptr}, + {1441.47f, 1548.12f, 342.752f, nullptr}, {1433.79f, 1552.67f, 342.763f, nullptr}, + {1422.88f, 1552.37f, 342.751f, nullptr}, {1415.33f, 1554.79f, 343.156f, nullptr}, }; // Alliance Graveyard to Alliance Tunnel -BattleBotPath vPath_WSG_AllianceGraveyard_to_AllianceTunnel = -{ - { 1415.33f, 1554.79f, 343.156f, nullptr }, - { 1428.29f, 1551.79f, 342.751f, nullptr }, - { 1441.51f, 1545.79f, 342.757f, nullptr }, - { 1441.15f, 1530.35f, 343.712f, nullptr }, - { 1435.53f, 1517.29f, 346.698f, nullptr }, - { 1424.81f, 1499.24f, 349.486f, nullptr }, - { 1416.31f, 1483.94f, 348.536f, nullptr }, - { 1408.83f, 1468.4f, 347.648f, nullptr }, - { 1404.64f, 1449.79f, 347.279f, nullptr }, - { 1405.34f, 1432.33f, 345.792f, nullptr }, - { 1406.38f, 1416.18f, 344.755f, nullptr }, - { 1400.22f, 1401.87f, 340.496f, nullptr }, - { 1385.96f, 1394.15f, 333.829f, nullptr }, - { 1372.38f, 1390.75f, 328.722f, nullptr }, - { 1362.93f, 1390.02f, 327.034f, nullptr }, - { 1357.91f, 1398.07f, 325.674f, nullptr }, - { 1354.17f, 1411.56f, 324.327f, nullptr }, - { 1351.44f, 1430.38f, 323.506f, nullptr }, - { 1350.36f, 1444.43f, 323.388f, nullptr }, - { 1348.02f, 1461.06f, 323.167f, nullptr }, +BattleBotPath vPath_WSG_AllianceGraveyard_to_AllianceTunnel = { + {1415.33f, 1554.79f, 343.156f, nullptr}, {1428.29f, 1551.79f, 342.751f, nullptr}, + {1441.51f, 1545.79f, 342.757f, nullptr}, {1441.15f, 1530.35f, 343.712f, nullptr}, + {1435.53f, 1517.29f, 346.698f, nullptr}, {1424.81f, 1499.24f, 349.486f, nullptr}, + {1416.31f, 1483.94f, 348.536f, nullptr}, {1408.83f, 1468.4f, 347.648f, nullptr}, + {1404.64f, 1449.79f, 347.279f, nullptr}, {1405.34f, 1432.33f, 345.792f, nullptr}, + {1406.38f, 1416.18f, 344.755f, nullptr}, {1400.22f, 1401.87f, 340.496f, nullptr}, + {1385.96f, 1394.15f, 333.829f, nullptr}, {1372.38f, 1390.75f, 328.722f, nullptr}, + {1362.93f, 1390.02f, 327.034f, nullptr}, {1357.91f, 1398.07f, 325.674f, nullptr}, + {1354.17f, 1411.56f, 324.327f, nullptr}, {1351.44f, 1430.38f, 323.506f, nullptr}, + {1350.36f, 1444.43f, 323.388f, nullptr}, {1348.02f, 1461.06f, 323.167f, nullptr}, }; // Alliance Tunnel to Alliance Flag Room -BattleBotPath vPath_WSG_AllianceTunnel_to_AllianceFlagRoom = -{ - { 1348.02f, 1461.06f, 323.167f, nullptr }, - { 1359.8f, 1461.49f, 324.527f, nullptr }, - { 1372.47f, 1461.61f, 324.354f, nullptr }, - { 1389.08f, 1461.12f, 325.913f, nullptr }, - { 1406.57f, 1460.48f, 330.615f, nullptr }, - { 1424.04f, 1459.57f, 336.029f, nullptr }, - { 1442.5f, 1459.7f, 342.024f, nullptr }, - { 1449.59f, 1469.14f, 342.65f, nullptr }, - { 1458.03f, 1458.43f, 342.746f, nullptr }, - { 1469.4f, 1458.14f, 342.794f, nullptr }, - { 1489.06f, 1457.86f, 342.794f, nullptr }, - { 1502.27f, 1457.52f, 347.589f, nullptr }, - { 1512.87f, 1457.81f, 352.039f, nullptr }, - { 1517.53f, 1468.79f, 352.033f, nullptr }, - { 1519.53f, 1481.87f, 352.024f, nullptr }, +BattleBotPath vPath_WSG_AllianceTunnel_to_AllianceFlagRoom = { + {1348.02f, 1461.06f, 323.167f, nullptr}, {1359.8f, 1461.49f, 324.527f, nullptr}, + {1372.47f, 1461.61f, 324.354f, nullptr}, {1389.08f, 1461.12f, 325.913f, nullptr}, + {1406.57f, 1460.48f, 330.615f, nullptr}, {1424.04f, 1459.57f, 336.029f, nullptr}, + {1442.5f, 1459.7f, 342.024f, nullptr}, {1449.59f, 1469.14f, 342.65f, nullptr}, + {1458.03f, 1458.43f, 342.746f, nullptr}, {1469.4f, 1458.14f, 342.794f, nullptr}, + {1489.06f, 1457.86f, 342.794f, nullptr}, {1502.27f, 1457.52f, 347.589f, nullptr}, + {1512.87f, 1457.81f, 352.039f, nullptr}, {1517.53f, 1468.79f, 352.033f, nullptr}, + {1519.53f, 1481.87f, 352.024f, nullptr}, }; // Alliance GY Jump to Alliance Tunnel -BattleBotPath vPath_WSG_AllianceGYJump_to_AllianceTunnel = -{ - { 1387.85f, 1538.06f, 321.854f, nullptr }, - { 1376.87f, 1529.48f, 321.66f, nullptr }, - { 1369.76f, 1521.76f, 318.544f, nullptr }, - { 1360.97f, 1508.68f, 320.007f, nullptr }, - { 1355.78f, 1495.7f, 323.959f, nullptr }, - { 1351.58f, 1482.36f, 324.189f, nullptr }, - { 1348.02f, 1461.06f, 323.167f, nullptr }, +BattleBotPath vPath_WSG_AllianceGYJump_to_AllianceTunnel = { + {1387.85f, 1538.06f, 321.854f, nullptr}, {1376.87f, 1529.48f, 321.66f, nullptr}, + {1369.76f, 1521.76f, 318.544f, nullptr}, {1360.97f, 1508.68f, 320.007f, nullptr}, + {1355.78f, 1495.7f, 323.959f, nullptr}, {1351.58f, 1482.36f, 324.189f, nullptr}, + {1348.02f, 1461.06f, 323.167f, nullptr}, }; // Alliance GY Jump to Horde Tunnel -BattleBotPath vPath_WSG_AllianceGYJump_to_HordeTunnel = -{ - { 1387.85f, 1538.06f, 321.855f, nullptr }, - { 1377.58f, 1535.88f, 321.053f, nullptr }, - { 1363.98f, 1532.59f, 319.913f, nullptr }, - { 1353.94f, 1529.5f, 316.643f, nullptr }, - { 1340.71f, 1524.94f, 315.246f, nullptr }, - { 1330.75f, 1521.6f, 314.868f, nullptr }, - { 1320.73f, 1518.48f, 316.097f, nullptr }, - { 1307.28f, 1514.6f, 318.134f, nullptr }, - { 1297.12f, 1511.95f, 318.073f, nullptr }, - { 1283.61f, 1508.28f, 316.707f, nullptr }, - { 1273.51f, 1505.39f, 314.615f, nullptr }, - { 1263.49f, 1502.27f, 311.343f, nullptr }, - { 1250.22f, 1497.81f, 309.106f, nullptr }, - { 1237.31f, 1492.4f, 307.577f, nullptr }, - { 1224.04f, 1487.97f, 306.302f, nullptr }, - { 1213.89f, 1485.29f, 305.739f, nullptr }, - { 1203.69f, 1482.8f, 306.177f, nullptr }, - { 1190.05f, 1479.62f, 303.89f, nullptr }, - { 1179.83f, 1477.22f, 303.686f, nullptr }, - { 1169.65f, 1474.65f, 305.842f, nullptr }, - { 1156.05f, 1471.33f, 310.002f, nullptr }, - { 1142.54f, 1467.68f, 311.727f, nullptr }, - { 1135.4f, 1465.54f, 315.622f, nullptr }, - { 1124.37f, 1462.28f, 315.853f, nullptr }, +BattleBotPath vPath_WSG_AllianceGYJump_to_HordeTunnel = { + {1387.85f, 1538.06f, 321.855f, nullptr}, {1377.58f, 1535.88f, 321.053f, nullptr}, + {1363.98f, 1532.59f, 319.913f, nullptr}, {1353.94f, 1529.5f, 316.643f, nullptr}, + {1340.71f, 1524.94f, 315.246f, nullptr}, {1330.75f, 1521.6f, 314.868f, nullptr}, + {1320.73f, 1518.48f, 316.097f, nullptr}, {1307.28f, 1514.6f, 318.134f, nullptr}, + {1297.12f, 1511.95f, 318.073f, nullptr}, {1283.61f, 1508.28f, 316.707f, nullptr}, + {1273.51f, 1505.39f, 314.615f, nullptr}, {1263.49f, 1502.27f, 311.343f, nullptr}, + {1250.22f, 1497.81f, 309.106f, nullptr}, {1237.31f, 1492.4f, 307.577f, nullptr}, + {1224.04f, 1487.97f, 306.302f, nullptr}, {1213.89f, 1485.29f, 305.739f, nullptr}, + {1203.69f, 1482.8f, 306.177f, nullptr}, {1190.05f, 1479.62f, 303.89f, nullptr}, + {1179.83f, 1477.22f, 303.686f, nullptr}, {1169.65f, 1474.65f, 305.842f, nullptr}, + {1156.05f, 1471.33f, 310.002f, nullptr}, {1142.54f, 1467.68f, 311.727f, nullptr}, + {1135.4f, 1465.54f, 315.622f, nullptr}, {1124.37f, 1462.28f, 315.853f, nullptr}, }; // Horde GY Jump to Alliance Flag Room through Side Entrance -BattleBotPath vPath_WSG_HordeGYJump_to_AllianceFlagRoom = -{ - { 1077.87f, 1400.27f, 323.153f, nullptr }, - { 1084.45f, 1388.76f, 319.724f, nullptr }, - { 1088.27f, 1371.39f, 319.17f, nullptr }, - { 1090.71f, 1350.54f, 316.097f, nullptr }, - { 1098.71f, 1332.2f, 317.792f, nullptr }, - { 1109.45f, 1320.92f, 318.267f, nullptr }, - { 1123.49f, 1311.38f, 317.472f, nullptr }, - { 1145.46f, 1302.64f, 317.741f, nullptr }, - { 1168.4f, 1288.85f, 318.053f, nullptr }, - { 1186.49f, 1284.27f, 316.972f, nullptr }, - { 1199.4f, 1286.83f, 317.377f, nullptr }, - { 1215.89f, 1304.02f, 312.822f, nullptr }, - { 1232.18f, 1324.73f, 312.345f, nullptr }, - { 1247.16f, 1329.97f, 315.095f, nullptr }, - { 1269.9f, 1335.18f, 311.879f, nullptr }, - { 1289.97f, 1341.28f, 318.625f, nullptr }, - { 1305.99f, 1347.63f, 321.123f, nullptr }, - { 1325.81f, 1361.58f, 319.39f, nullptr }, - { 1337.48f, 1371.68f, 318.706f, nullptr }, - { 1342.62f, 1390.03f, 321.435f, nullptr }, - { 1352.23f, 1397.97f, 325.547f, nullptr }, - { 1366.38f, 1385.61f, 328.196f, nullptr }, - { 1382.67f, 1380.56f, 332.371f, nullptr }, - { 1395.17f, 1393.12f, 336.183f, nullptr }, - { 1409.03f, 1411.5f, 344.626f, nullptr }, - { 1405.12f, 1438.81f, 346.533f, nullptr }, - { 1409.95f, 1460.93f, 347.687f, nullptr }, - { 1430.87f, 1461.08f, 353.992f, nullptr }, - { 1449.36f, 1459.44f, 358.499f, nullptr }, - { 1471.4f, 1458.48f, 362.557f, nullptr }, - { 1488.64f, 1464.01f, 362.454f, nullptr }, - { 1488.75f, 1474.6f, 358.79f, nullptr }, - { 1490.44f, 1485.99f, 352.112f, nullptr }, - { 1502.97f, 1493.87f, 352.199f, nullptr }, - { 1519.53f, 1481.87f, 352.024f, nullptr }, +BattleBotPath vPath_WSG_HordeGYJump_to_AllianceFlagRoom = { + {1077.87f, 1400.27f, 323.153f, nullptr}, {1084.45f, 1388.76f, 319.724f, nullptr}, + {1088.27f, 1371.39f, 319.17f, nullptr}, {1090.71f, 1350.54f, 316.097f, nullptr}, + {1098.71f, 1332.2f, 317.792f, nullptr}, {1109.45f, 1320.92f, 318.267f, nullptr}, + {1123.49f, 1311.38f, 317.472f, nullptr}, {1145.46f, 1302.64f, 317.741f, nullptr}, + {1168.4f, 1288.85f, 318.053f, nullptr}, {1186.49f, 1284.27f, 316.972f, nullptr}, + {1199.4f, 1286.83f, 317.377f, nullptr}, {1215.89f, 1304.02f, 312.822f, nullptr}, + {1232.18f, 1324.73f, 312.345f, nullptr}, {1247.16f, 1329.97f, 315.095f, nullptr}, + {1269.9f, 1335.18f, 311.879f, nullptr}, {1289.97f, 1341.28f, 318.625f, nullptr}, + {1305.99f, 1347.63f, 321.123f, nullptr}, {1325.81f, 1361.58f, 319.39f, nullptr}, + {1337.48f, 1371.68f, 318.706f, nullptr}, {1342.62f, 1390.03f, 321.435f, nullptr}, + {1352.23f, 1397.97f, 325.547f, nullptr}, {1366.38f, 1385.61f, 328.196f, nullptr}, + {1382.67f, 1380.56f, 332.371f, nullptr}, {1395.17f, 1393.12f, 336.183f, nullptr}, + {1409.03f, 1411.5f, 344.626f, nullptr}, {1405.12f, 1438.81f, 346.533f, nullptr}, + {1409.95f, 1460.93f, 347.687f, nullptr}, {1430.87f, 1461.08f, 353.992f, nullptr}, + {1449.36f, 1459.44f, 358.499f, nullptr}, {1471.4f, 1458.48f, 362.557f, nullptr}, + {1488.64f, 1464.01f, 362.454f, nullptr}, {1488.75f, 1474.6f, 358.79f, nullptr}, + {1490.44f, 1485.99f, 352.112f, nullptr}, {1502.97f, 1493.87f, 352.199f, nullptr}, + {1519.53f, 1481.87f, 352.024f, nullptr}, }; // Alliance GY Jump to Horde Flag Room through Side Entrance -BattleBotPath vPath_WSG_AllianceGYJump_to_HordeFlagRoom = -{ - { 1387.85f, 1538.06f, 321.855f, nullptr }, - { 1370.13f, 1549.33f, 321.122f, nullptr }, - { 1346.7f, 1564.64f, 316.708f, nullptr }, - { 1324.23f, 1574.24f, 317.11f, nullptr }, - { 1304.03f, 1576.06f, 314.625f, nullptr }, - { 1277.44f, 1569.2f, 312.201f, nullptr }, - { 1249.2f, 1555.53f, 309.172f, nullptr }, - { 1229.95f, 1558.21f, 306.936f, nullptr }, - { 1209.65f, 1573.56f, 308.95f, nullptr }, - { 1189.93f, 1587.73f, 309.608f, nullptr }, - { 1173.76f, 1592.66f, 309.805f, nullptr }, - { 1147.86f, 1590.75f, 310.37f, nullptr }, - { 1124.1f, 1579.89f, 314.881f, nullptr }, +BattleBotPath vPath_WSG_AllianceGYJump_to_HordeFlagRoom = { + {1387.85f, 1538.06f, 321.855f, nullptr}, + {1370.13f, 1549.33f, 321.122f, nullptr}, + {1346.7f, 1564.64f, 316.708f, nullptr}, + {1324.23f, 1574.24f, 317.11f, nullptr}, + {1304.03f, 1576.06f, 314.625f, nullptr}, + {1277.44f, 1569.2f, 312.201f, nullptr}, + {1249.2f, 1555.53f, 309.172f, nullptr}, + {1229.95f, 1558.21f, 306.936f, nullptr}, + {1209.65f, 1573.56f, 308.95f, nullptr}, + {1189.93f, 1587.73f, 309.608f, nullptr}, + {1173.76f, 1592.66f, 309.805f, nullptr}, + {1147.86f, 1590.75f, 310.37f, nullptr}, + {1124.1f, 1579.89f, 314.881f, nullptr}, //{ 1102.61f, 1573.98f, 315.804f, nullptr }, - { 1091.28f, 1558.56f, 316.451f, nullptr }, - { 1092.6f, 1547.71f, 316.709f, nullptr }, - { 1086.22f, 1541.5f, 316.924f, nullptr }, - { 1071.64f, 1548.25f, 319.88f, nullptr }, - { 1054.86f, 1544.78f, 328.415f, nullptr }, - { 1043.08f, 1528.67f, 336.984f, nullptr }, - { 1043.21f, 1512.43f, 339.099f, nullptr }, - { 1050.71f, 1485.48f, 342.852f, nullptr }, - { 1042.67f, 1461.07f, 342.305f, nullptr }, - { 1023.13f, 1457.49f, 345.535f, nullptr }, - { 992.797f, 1458.42f, 354.84f, nullptr }, - { 967.257f, 1458.84f, 356.131f, nullptr }, - { 964.566f, 1450.29f, 354.865f, nullptr }, - { 963.586f, 1432.46f, 345.206f, nullptr }, - { 953.017f, 1423.3f, 345.835f, nullptr }, - { 933.331f, 1433.72f, 345.536f, nullptr }, + {1091.28f, 1558.56f, 316.451f, nullptr}, + {1092.6f, 1547.71f, 316.709f, nullptr}, + {1086.22f, 1541.5f, 316.924f, nullptr}, + {1071.64f, 1548.25f, 319.88f, nullptr}, + {1054.86f, 1544.78f, 328.415f, nullptr}, + {1043.08f, 1528.67f, 336.984f, nullptr}, + {1043.21f, 1512.43f, 339.099f, nullptr}, + {1050.71f, 1485.48f, 342.852f, nullptr}, + {1042.67f, 1461.07f, 342.305f, nullptr}, + {1023.13f, 1457.49f, 345.535f, nullptr}, + {992.797f, 1458.42f, 354.84f, nullptr}, + {967.257f, 1458.84f, 356.131f, nullptr}, + {964.566f, 1450.29f, 354.865f, nullptr}, + {963.586f, 1432.46f, 345.206f, nullptr}, + {953.017f, 1423.3f, 345.835f, nullptr}, + {933.331f, 1433.72f, 345.536f, nullptr}, }; // Horde Tunnel to Horde Base Roof -BattleBotPath vPath_WSG_HordeTunnel_to_HordeBaseRoof = -{ - { 1124.37f, 1462.28f, 315.853f, nullptr }, - { 1106.87f, 1462.13f, 316.558f, nullptr }, - { 1089.44f, 1461.04f, 316.332f, nullptr }, - { 1072.07f, 1459.46f, 317.449f, nullptr }, - { 1051.09f, 1459.89f, 323.126f, nullptr }, - { 1030.1f, 1459.58f, 330.204f, nullptr }, - { 1010.76f, 1457.49f, 334.896f, nullptr }, - { 981.948f, 1459.07f, 336.154f, nullptr }, - { 981.768f, 1480.46f, 335.976f, nullptr }, - { 974.664f, 1495.9f, 340.837f, nullptr }, - { 964.661f, 1510.21f, 347.509f, nullptr }, - { 951.188f, 1520.99f, 356.377f, nullptr }, - { 937.37f, 1513.27f, 362.589f, nullptr }, - { 935.947f, 1499.58f, 364.199f, nullptr }, - { 935.9f, 1482.08f, 366.396f, nullptr }, - { 937.564f, 1462.81f, 367.287f, nullptr }, - { 945.871f, 1458.65f, 367.287f, nullptr }, - { 956.972f, 1459.48f, 367.291f, nullptr }, - { 968.317f, 1459.71f, 367.291f, nullptr }, - { 979.934f, 1454.58f, 367.078f, nullptr }, - { 979.99f, 1442.87f, 367.093f, nullptr }, - { 978.632f, 1430.71f, 367.125f, nullptr }, - { 970.395f, 1422.32f, 367.289f, nullptr }, - { 956.338f, 1425.09f, 367.293f, nullptr }, - { 952.778f, 1433.0f, 367.604f, nullptr }, - { 952.708f, 1445.01f, 367.604f, nullptr }, +BattleBotPath vPath_WSG_HordeTunnel_to_HordeBaseRoof = { + {1124.37f, 1462.28f, 315.853f, nullptr}, {1106.87f, 1462.13f, 316.558f, nullptr}, + {1089.44f, 1461.04f, 316.332f, nullptr}, {1072.07f, 1459.46f, 317.449f, nullptr}, + {1051.09f, 1459.89f, 323.126f, nullptr}, {1030.1f, 1459.58f, 330.204f, nullptr}, + {1010.76f, 1457.49f, 334.896f, nullptr}, {981.948f, 1459.07f, 336.154f, nullptr}, + {981.768f, 1480.46f, 335.976f, nullptr}, {974.664f, 1495.9f, 340.837f, nullptr}, + {964.661f, 1510.21f, 347.509f, nullptr}, {951.188f, 1520.99f, 356.377f, nullptr}, + {937.37f, 1513.27f, 362.589f, nullptr}, {935.947f, 1499.58f, 364.199f, nullptr}, + {935.9f, 1482.08f, 366.396f, nullptr}, {937.564f, 1462.81f, 367.287f, nullptr}, + {945.871f, 1458.65f, 367.287f, nullptr}, {956.972f, 1459.48f, 367.291f, nullptr}, + {968.317f, 1459.71f, 367.291f, nullptr}, {979.934f, 1454.58f, 367.078f, nullptr}, + {979.99f, 1442.87f, 367.093f, nullptr}, {978.632f, 1430.71f, 367.125f, nullptr}, + {970.395f, 1422.32f, 367.289f, nullptr}, {956.338f, 1425.09f, 367.293f, nullptr}, + {952.778f, 1433.0f, 367.604f, nullptr}, {952.708f, 1445.01f, 367.604f, nullptr}, }; // Alliance Tunnel to Alliance Base Roof -BattleBotPath vPath_WSG_AllianceTunnel_to_AllianceBaseRoof = -{ - { 1348.02f, 1461.06f, 323.167f, nullptr }, - { 1359.8f, 1461.49f, 324.527f, nullptr }, - { 1372.47f, 1461.61f, 324.354f, nullptr }, - { 1389.08f, 1461.12f, 325.913f, nullptr }, - { 1406.57f, 1460.48f, 330.615f, nullptr }, - { 1424.04f, 1459.57f, 336.029f, nullptr }, - { 1442.5f, 1459.7f, 342.024f, nullptr }, - { 1471.86f, 1456.65f, 342.794f, nullptr }, - { 1470.93f, 1440.5f, 342.794f, nullptr }, - { 1472.24f, 1427.49f, 342.06f, nullptr }, - { 1476.86f, 1412.46f, 341.426f, nullptr }, - { 1484.42f, 1396.69f, 346.117f, nullptr }, - { 1490.7f, 1387.59f, 351.861f, nullptr }, - { 1500.79f, 1382.98f, 357.784f, nullptr }, - { 1511.08f, 1391.29f, 364.444f, nullptr }, - { 1517.85f, 1403.18f, 370.336f, nullptr }, - { 1517.99f, 1417.59f, 371.636f, nullptr }, - { 1517.07f, 1431.56f, 372.106f, nullptr }, - { 1516.66f, 1445.55f, 372.939f, nullptr }, - { 1514.23f, 1457.37f, 373.689f, nullptr }, - { 1503.73f, 1457.67f, 373.684f, nullptr }, - { 1486.24f, 1457.8f, 373.718f, nullptr }, - { 1476.78f, 1460.35f, 373.711f, nullptr }, - { 1477.37f, 1470.83f, 373.709f, nullptr }, - { 1477.5f, 1484.83f, 373.715f, nullptr }, - { 1480.53f, 1495.26f, 373.721f, nullptr }, - { 1492.61f, 1494.72f, 373.721f, nullptr }, - { 1499.37f, 1489.02f, 373.718f, nullptr }, - { 1500.63f, 1472.89f, 373.707f, nullptr }, +BattleBotPath vPath_WSG_AllianceTunnel_to_AllianceBaseRoof = { + {1348.02f, 1461.06f, 323.167f, nullptr}, {1359.8f, 1461.49f, 324.527f, nullptr}, + {1372.47f, 1461.61f, 324.354f, nullptr}, {1389.08f, 1461.12f, 325.913f, nullptr}, + {1406.57f, 1460.48f, 330.615f, nullptr}, {1424.04f, 1459.57f, 336.029f, nullptr}, + {1442.5f, 1459.7f, 342.024f, nullptr}, {1471.86f, 1456.65f, 342.794f, nullptr}, + {1470.93f, 1440.5f, 342.794f, nullptr}, {1472.24f, 1427.49f, 342.06f, nullptr}, + {1476.86f, 1412.46f, 341.426f, nullptr}, {1484.42f, 1396.69f, 346.117f, nullptr}, + {1490.7f, 1387.59f, 351.861f, nullptr}, {1500.79f, 1382.98f, 357.784f, nullptr}, + {1511.08f, 1391.29f, 364.444f, nullptr}, {1517.85f, 1403.18f, 370.336f, nullptr}, + {1517.99f, 1417.59f, 371.636f, nullptr}, {1517.07f, 1431.56f, 372.106f, nullptr}, + {1516.66f, 1445.55f, 372.939f, nullptr}, {1514.23f, 1457.37f, 373.689f, nullptr}, + {1503.73f, 1457.67f, 373.684f, nullptr}, {1486.24f, 1457.8f, 373.718f, nullptr}, + {1476.78f, 1460.35f, 373.711f, nullptr}, {1477.37f, 1470.83f, 373.709f, nullptr}, + {1477.5f, 1484.83f, 373.715f, nullptr}, {1480.53f, 1495.26f, 373.721f, nullptr}, + {1492.61f, 1494.72f, 373.721f, nullptr}, {1499.37f, 1489.02f, 373.718f, nullptr}, + {1500.63f, 1472.89f, 373.707f, nullptr}, }; // Alliance Base to Stables -BattleBotPath vPath_AB_AllianceBase_to_Stables = -{ - { 1285.67f, 1282.14f, -15.8466f, nullptr }, - { 1272.52f, 1267.83f, -21.7811f, nullptr }, - { 1250.44f, 1248.09f, -33.3028f, nullptr }, - { 1232.56f, 1233.05f, -41.5241f, nullptr }, - { 1213.25f, 1224.93f, -47.5513f, nullptr }, - { 1189.29f, 1219.49f, -53.119f, nullptr }, - { 1177.17f, 1210.21f, -56.4593f, nullptr }, - { 1167.98f, 1202.9f, -56.4743f, nullptr }, +BattleBotPath vPath_AB_AllianceBase_to_Stables = { + {1285.67f, 1282.14f, -15.8466f, nullptr}, {1272.52f, 1267.83f, -21.7811f, nullptr}, + {1250.44f, 1248.09f, -33.3028f, nullptr}, {1232.56f, 1233.05f, -41.5241f, nullptr}, + {1213.25f, 1224.93f, -47.5513f, nullptr}, {1189.29f, 1219.49f, -53.119f, nullptr}, + {1177.17f, 1210.21f, -56.4593f, nullptr}, {1167.98f, 1202.9f, -56.4743f, nullptr}, }; // Blacksmith to Lumber Mill -BattleBotPath vPath_AB_Blacksmith_to_LumberMill = -{ - { 967.04f, 1039.03f, -45.091f, nullptr }, - { 933.67f, 1016.49f, -50.5154f, nullptr }, - { 904.02f, 996.63f, -62.3461f, nullptr }, - { 841.74f, 985.23f, -58.8920f, nullptr }, - { 796.25f, 1009.93f, -44.3286f, nullptr }, - { 781.29f, 1034.49f, -32.887f, nullptr }, - { 793.17f, 1107.21f, 5.5663f, nullptr }, - { 848.98f, 1155.9f, 11.3453f, nullptr }, +BattleBotPath vPath_AB_Blacksmith_to_LumberMill = { + {967.04f, 1039.03f, -45.091f, nullptr}, {933.67f, 1016.49f, -50.5154f, nullptr}, + {904.02f, 996.63f, -62.3461f, nullptr}, {841.74f, 985.23f, -58.8920f, nullptr}, + {796.25f, 1009.93f, -44.3286f, nullptr}, {781.29f, 1034.49f, -32.887f, nullptr}, + {793.17f, 1107.21f, 5.5663f, nullptr}, {848.98f, 1155.9f, 11.3453f, nullptr}, }; // Blacksmith to GoldMine -BattleBotPath vPath_AB_Blacksmith_to_GoldMine = -{ - { 1035.98f, 1015.66f, -46.0278f, nullptr }, - { 1096.86f, 1002.05f, -60.8013f, nullptr }, - { 1159.93f, 1003.69f, -63.8378f, nullptr }, - { 1198.03f, 1064.09f, -65.8385f, nullptr }, - { 1218.58f, 1016.96f, -76.9848f, nullptr }, - { 1192.83f, 956.25f, -93.6974f, nullptr }, - { 1162.93f, 908.92f, -108.6703f, nullptr }, - { 1144.94f, 860.09f, -111.2100f, nullptr }, +BattleBotPath vPath_AB_Blacksmith_to_GoldMine = { + {1035.98f, 1015.66f, -46.0278f, nullptr}, {1096.86f, 1002.05f, -60.8013f, nullptr}, + {1159.93f, 1003.69f, -63.8378f, nullptr}, {1198.03f, 1064.09f, -65.8385f, nullptr}, + {1218.58f, 1016.96f, -76.9848f, nullptr}, {1192.83f, 956.25f, -93.6974f, nullptr}, + {1162.93f, 908.92f, -108.6703f, nullptr}, {1144.94f, 860.09f, -111.2100f, nullptr}, }; // Farm to Stables -BattleBotPath vPath_AB_Farm_to_Stable = -{ - { 749.88f, 878.23f, -55.1523f, nullptr }, - { 819.77f, 931.13f, -57.5882f, nullptr }, - { 842.34f, 984.76f, -59.0333f, nullptr }, - { 863.03f, 1051.47f, -58.0495f, nullptr }, - { 899.28f, 1098.27f, -57.4149f, nullptr }, - { 949.22f, 1153.27f, -54.4464f, nullptr }, - { 999.07f, 1189.47f, -49.9125f, nullptr }, - { 1063.11f, 1211.55f, -53.4164f, nullptr }, - { 1098.45f, 1225.47f, -53.1301f, nullptr }, - { 1146.02f, 1226.34f, -53.8979f, nullptr }, - { 1167.10f, 1204.31f, -56.55f, nullptr }, +BattleBotPath vPath_AB_Farm_to_Stable = { + {749.88f, 878.23f, -55.1523f, nullptr}, {819.77f, 931.13f, -57.5882f, nullptr}, + {842.34f, 984.76f, -59.0333f, nullptr}, {863.03f, 1051.47f, -58.0495f, nullptr}, + {899.28f, 1098.27f, -57.4149f, nullptr}, {949.22f, 1153.27f, -54.4464f, nullptr}, + {999.07f, 1189.47f, -49.9125f, nullptr}, {1063.11f, 1211.55f, -53.4164f, nullptr}, + {1098.45f, 1225.47f, -53.1301f, nullptr}, {1146.02f, 1226.34f, -53.8979f, nullptr}, + {1167.10f, 1204.31f, -56.55f, nullptr}, }; // Alliance Base to Gold Mine -BattleBotPath vPath_AB_AllianceBase_to_GoldMine = -{ - { 1285.67f, 1282.14f, -15.8466f, nullptr }, - { 1276.41f, 1267.11f, -20.775f, nullptr }, - { 1261.34f, 1241.52f, -31.2971f, nullptr }, - { 1244.91f, 1219.03f, -41.9658f, nullptr }, - { 1232.25f, 1184.41f, -50.3348f, nullptr }, - { 1226.89f, 1150.82f, -55.7935f, nullptr }, - { 1224.09f, 1120.38f, -57.0633f, nullptr }, - { 1220.03f, 1092.72f, -59.1744f, nullptr }, - { 1216.05f, 1060.86f, -67.2771f, nullptr }, - { 1213.77f, 1027.96f, -74.429f, nullptr }, - { 1208.56f, 998.394f, -81.9493f, nullptr }, - { 1197.42f, 969.73f, -89.9385f, nullptr }, - { 1185.23f, 944.531f, -97.2433f, nullptr }, - { 1166.29f, 913.945f, -107.214f, nullptr }, - { 1153.17f, 887.863f, -112.34f, nullptr }, - { 1148.89f, 871.391f, -111.96f, nullptr }, - { 1145.24f, 850.82f, -110.514f, nullptr }, +BattleBotPath vPath_AB_AllianceBase_to_GoldMine = { + {1285.67f, 1282.14f, -15.8466f, nullptr}, {1276.41f, 1267.11f, -20.775f, nullptr}, + {1261.34f, 1241.52f, -31.2971f, nullptr}, {1244.91f, 1219.03f, -41.9658f, nullptr}, + {1232.25f, 1184.41f, -50.3348f, nullptr}, {1226.89f, 1150.82f, -55.7935f, nullptr}, + {1224.09f, 1120.38f, -57.0633f, nullptr}, {1220.03f, 1092.72f, -59.1744f, nullptr}, + {1216.05f, 1060.86f, -67.2771f, nullptr}, {1213.77f, 1027.96f, -74.429f, nullptr}, + {1208.56f, 998.394f, -81.9493f, nullptr}, {1197.42f, 969.73f, -89.9385f, nullptr}, + {1185.23f, 944.531f, -97.2433f, nullptr}, {1166.29f, 913.945f, -107.214f, nullptr}, + {1153.17f, 887.863f, -112.34f, nullptr}, {1148.89f, 871.391f, -111.96f, nullptr}, + {1145.24f, 850.82f, -110.514f, nullptr}, }; // Alliance Base to Lumber Mill -BattleBotPath vPath_AB_AllianceBase_to_LumberMill = -{ - { 1285.67f, 1282.14f, -15.8466f, nullptr }, - { 1269.13f, 1267.89f, -22.7764f, nullptr }, - { 1247.79f, 1249.77f, -33.2518f, nullptr }, - { 1226.29f, 1232.02f, -43.9193f, nullptr }, - { 1196.68f, 1230.15f, -50.4644f, nullptr }, - { 1168.72f, 1228.98f, -53.9329f, nullptr }, - { 1140.82f, 1226.7f, -53.6318f, nullptr }, - { 1126.85f, 1225.77f, -47.98f, nullptr }, - { 1096.5f, 1226.57f, -53.1769f, nullptr }, - { 1054.52f, 1226.14f, -49.2011f, nullptr }, - { 1033.52f, 1226.08f, -45.5968f, nullptr }, - { 1005.52f, 1226.08f, -43.2912f, nullptr }, - { 977.53f, 1226.68f, -40.16f, nullptr }, - { 957.242f, 1227.94f, -34.1487f, nullptr }, - { 930.689f, 1221.57f, -18.9588f, nullptr }, - { 918.202f, 1211.98f, -12.2494f, nullptr }, - { 880.329f, 1192.63f, 7.61168f, nullptr }, - { 869.965f, 1178.52f, 10.9678f, nullptr }, - { 864.74f, 1163.78f, 12.385f, nullptr }, - { 859.165f, 1148.84f, 11.5289f, nullptr }, +BattleBotPath vPath_AB_AllianceBase_to_LumberMill = { + {1285.67f, 1282.14f, -15.8466f, nullptr}, {1269.13f, 1267.89f, -22.7764f, nullptr}, + {1247.79f, 1249.77f, -33.2518f, nullptr}, {1226.29f, 1232.02f, -43.9193f, nullptr}, + {1196.68f, 1230.15f, -50.4644f, nullptr}, {1168.72f, 1228.98f, -53.9329f, nullptr}, + {1140.82f, 1226.7f, -53.6318f, nullptr}, {1126.85f, 1225.77f, -47.98f, nullptr}, + {1096.5f, 1226.57f, -53.1769f, nullptr}, {1054.52f, 1226.14f, -49.2011f, nullptr}, + {1033.52f, 1226.08f, -45.5968f, nullptr}, {1005.52f, 1226.08f, -43.2912f, nullptr}, + {977.53f, 1226.68f, -40.16f, nullptr}, {957.242f, 1227.94f, -34.1487f, nullptr}, + {930.689f, 1221.57f, -18.9588f, nullptr}, {918.202f, 1211.98f, -12.2494f, nullptr}, + {880.329f, 1192.63f, 7.61168f, nullptr}, {869.965f, 1178.52f, 10.9678f, nullptr}, + {864.74f, 1163.78f, 12.385f, nullptr}, {859.165f, 1148.84f, 11.5289f, nullptr}, }; // Stables to Blacksmith -BattleBotPath vPath_AB_Stables_to_Blacksmith = -{ - { 1169.52f, 1198.71f, -56.2742f, nullptr }, - { 1166.93f, 1185.2f, -56.3634f, nullptr }, - { 1173.84f, 1170.6f, -56.4094f, nullptr }, - { 1186.7f, 1163.92f, -56.3961f, nullptr }, - { 1189.7f, 1150.68f, -55.8664f, nullptr }, - { 1185.18f, 1129.31f, -58.1044f, nullptr }, - { 1181.7f, 1108.6f, -62.1797f, nullptr }, - { 1177.92f, 1087.95f, -63.5768f, nullptr }, - { 1174.52f, 1067.23f, -64.402f, nullptr }, - { 1171.27f, 1051.09f, -65.0833f, nullptr }, - { 1163.22f, 1031.7f, -64.954f, nullptr }, - { 1154.25f, 1010.25f, -63.5299f, nullptr }, - { 1141.07f, 999.479f, -63.3713f, nullptr }, - { 1127.12f, 1000.37f, -60.628f, nullptr }, - { 1106.17f, 1001.66f, -61.7457f, nullptr }, - { 1085.64f, 1005.62f, -58.5932f, nullptr }, - { 1064.88f, 1008.65f, -52.3547f, nullptr }, - { 1044.16f, 1011.96f, -47.2647f, nullptr }, - { 1029.72f, 1014.88f, -45.3546f, nullptr }, - { 1013.94f, 1028.7f, -43.9786f, nullptr }, - { 990.89f, 1039.3f, -42.7659f, nullptr }, - { 978.269f, 1043.84f, -44.4588f, nullptr }, +BattleBotPath vPath_AB_Stables_to_Blacksmith = { + {1169.52f, 1198.71f, -56.2742f, nullptr}, {1166.93f, 1185.2f, -56.3634f, nullptr}, + {1173.84f, 1170.6f, -56.4094f, nullptr}, {1186.7f, 1163.92f, -56.3961f, nullptr}, + {1189.7f, 1150.68f, -55.8664f, nullptr}, {1185.18f, 1129.31f, -58.1044f, nullptr}, + {1181.7f, 1108.6f, -62.1797f, nullptr}, {1177.92f, 1087.95f, -63.5768f, nullptr}, + {1174.52f, 1067.23f, -64.402f, nullptr}, {1171.27f, 1051.09f, -65.0833f, nullptr}, + {1163.22f, 1031.7f, -64.954f, nullptr}, {1154.25f, 1010.25f, -63.5299f, nullptr}, + {1141.07f, 999.479f, -63.3713f, nullptr}, {1127.12f, 1000.37f, -60.628f, nullptr}, + {1106.17f, 1001.66f, -61.7457f, nullptr}, {1085.64f, 1005.62f, -58.5932f, nullptr}, + {1064.88f, 1008.65f, -52.3547f, nullptr}, {1044.16f, 1011.96f, -47.2647f, nullptr}, + {1029.72f, 1014.88f, -45.3546f, nullptr}, {1013.94f, 1028.7f, -43.9786f, nullptr}, + {990.89f, 1039.3f, -42.7659f, nullptr}, {978.269f, 1043.84f, -44.4588f, nullptr}, }; // Horde Base to Farm -BattleBotPath vPath_AB_HordeBase_to_Farm = -{ - { 707.259f, 707.839f, -17.5318f, nullptr }, - { 712.063f, 712.928f, -20.1802f, nullptr }, - { 725.941f, 728.682f, -29.7536f, nullptr }, - { 734.715f, 739.591f, -35.2144f, nullptr }, - { 747.607f, 756.161f, -40.899f, nullptr }, - { 753.994f, 766.668f, -43.3049f, nullptr }, - { 758.715f, 787.106f, -46.7014f, nullptr }, - { 762.077f, 807.831f, -48.4721f, nullptr }, - { 764.132f, 821.68f, -49.656f, nullptr }, - { 767.947f, 839.274f, -50.8574f, nullptr }, - { 773.745f, 852.013f, -52.6226f, nullptr }, - { 785.123f, 869.103f, -54.2089f, nullptr }, - { 804.429f, 874.961f, -55.2691f, nullptr }, +BattleBotPath vPath_AB_HordeBase_to_Farm = { + {707.259f, 707.839f, -17.5318f, nullptr}, {712.063f, 712.928f, -20.1802f, nullptr}, + {725.941f, 728.682f, -29.7536f, nullptr}, {734.715f, 739.591f, -35.2144f, nullptr}, + {747.607f, 756.161f, -40.899f, nullptr}, {753.994f, 766.668f, -43.3049f, nullptr}, + {758.715f, 787.106f, -46.7014f, nullptr}, {762.077f, 807.831f, -48.4721f, nullptr}, + {764.132f, 821.68f, -49.656f, nullptr}, {767.947f, 839.274f, -50.8574f, nullptr}, + {773.745f, 852.013f, -52.6226f, nullptr}, {785.123f, 869.103f, -54.2089f, nullptr}, + {804.429f, 874.961f, -55.2691f, nullptr}, }; // Horde Base to Gold Mine -BattleBotPath vPath_AB_HordeBase_to_GoldMine = -{ - { 707.259f, 707.839f, -17.5318f, nullptr }, - { 717.935f, 716.874f, -23.3941f, nullptr }, - { 739.195f, 732.483f, -34.5791f, nullptr }, - { 757.087f, 742.008f, -38.1123f, nullptr }, - { 776.946f, 748.775f, -42.7346f, nullptr }, - { 797.138f, 754.539f, -46.3237f, nullptr }, - { 817.37f, 760.167f, -48.9235f, nullptr }, - { 837.638f, 765.664f, -49.7374f, nullptr }, - { 865.092f, 774.738f, -51.9831f, nullptr }, - { 878.86f, 777.149f, -47.2361f, nullptr }, - { 903.911f, 780.212f, -53.1424f, nullptr }, - { 923.454f, 787.888f, -54.7937f, nullptr }, - { 946.218f, 798.93f, -59.0904f, nullptr }, - { 978.1f, 813.321f, -66.7268f, nullptr }, - { 1002.94f, 817.895f, -77.3119f, nullptr }, - { 1030.77f, 820.92f, -88.7717f, nullptr }, - { 1058.61f, 823.889f, -94.1623f, nullptr }, - { 1081.6f, 828.32f, -99.4137f, nullptr }, - { 1104.64f, 844.773f, -106.387f, nullptr }, - { 1117.56f, 853.686f, -110.716f, nullptr }, - { 1144.9f, 850.049f, -110.522f, nullptr }, +BattleBotPath vPath_AB_HordeBase_to_GoldMine = { + {707.259f, 707.839f, -17.5318f, nullptr}, {717.935f, 716.874f, -23.3941f, nullptr}, + {739.195f, 732.483f, -34.5791f, nullptr}, {757.087f, 742.008f, -38.1123f, nullptr}, + {776.946f, 748.775f, -42.7346f, nullptr}, {797.138f, 754.539f, -46.3237f, nullptr}, + {817.37f, 760.167f, -48.9235f, nullptr}, {837.638f, 765.664f, -49.7374f, nullptr}, + {865.092f, 774.738f, -51.9831f, nullptr}, {878.86f, 777.149f, -47.2361f, nullptr}, + {903.911f, 780.212f, -53.1424f, nullptr}, {923.454f, 787.888f, -54.7937f, nullptr}, + {946.218f, 798.93f, -59.0904f, nullptr}, {978.1f, 813.321f, -66.7268f, nullptr}, + {1002.94f, 817.895f, -77.3119f, nullptr}, {1030.77f, 820.92f, -88.7717f, nullptr}, + {1058.61f, 823.889f, -94.1623f, nullptr}, {1081.6f, 828.32f, -99.4137f, nullptr}, + {1104.64f, 844.773f, -106.387f, nullptr}, {1117.56f, 853.686f, -110.716f, nullptr}, + {1144.9f, 850.049f, -110.522f, nullptr}, }; // Horde Base to Lumber Mill -BattleBotPath vPath_AB_HordeBase_to_LumberMill = -{ - { 707.259f, 707.839f, -17.5318f, nullptr }, - { 721.611f, 726.507f, -27.9646f, nullptr }, - { 733.846f, 743.573f, -35.8633f, nullptr }, - { 746.201f, 760.547f, -40.838f, nullptr }, - { 758.937f, 787.565f, -46.741f, nullptr }, - { 761.289f, 801.357f, -48.0037f, nullptr }, - { 764.341f, 822.128f, -49.6908f, nullptr }, - { 769.766f, 842.244f, -51.1239f, nullptr }, - { 775.322f, 855.093f, -53.1161f, nullptr }, - { 783.995f, 874.216f, -55.0822f, nullptr }, - { 789.917f, 886.902f, -56.2935f, nullptr }, - { 798.03f, 906.259f, -57.1162f, nullptr }, - { 803.183f, 919.266f, -57.6692f, nullptr }, - { 813.248f, 937.688f, -57.7106f, nullptr }, - { 820.412f, 958.712f, -56.1492f, nullptr }, - { 814.247f, 973.692f, -50.4602f, nullptr }, - { 807.697f, 985.502f, -47.2383f, nullptr }, - { 795.672f, 1002.69f, -44.9382f, nullptr }, - { 784.653f, 1020.77f, -38.6278f, nullptr }, - { 784.826f, 1037.34f, -31.5719f, nullptr }, - { 786.083f, 1051.28f, -24.0793f, nullptr }, - { 787.314f, 1065.23f, -16.8918f, nullptr }, - { 788.892f, 1086.17f, -6.42608f, nullptr }, - { 792.077f, 1106.53f, 4.81124f, nullptr }, - { 800.398f, 1119.48f, 8.5814f, nullptr }, - { 812.476f, 1131.1f, 10.439f, nullptr }, - { 829.704f, 1142.52f, 10.738f, nullptr }, - { 842.646f, 1143.51f, 11.9984f, nullptr }, - { 857.674f, 1146.16f, 11.529f, nullptr }, +BattleBotPath vPath_AB_HordeBase_to_LumberMill = { + {707.259f, 707.839f, -17.5318f, nullptr}, {721.611f, 726.507f, -27.9646f, nullptr}, + {733.846f, 743.573f, -35.8633f, nullptr}, {746.201f, 760.547f, -40.838f, nullptr}, + {758.937f, 787.565f, -46.741f, nullptr}, {761.289f, 801.357f, -48.0037f, nullptr}, + {764.341f, 822.128f, -49.6908f, nullptr}, {769.766f, 842.244f, -51.1239f, nullptr}, + {775.322f, 855.093f, -53.1161f, nullptr}, {783.995f, 874.216f, -55.0822f, nullptr}, + {789.917f, 886.902f, -56.2935f, nullptr}, {798.03f, 906.259f, -57.1162f, nullptr}, + {803.183f, 919.266f, -57.6692f, nullptr}, {813.248f, 937.688f, -57.7106f, nullptr}, + {820.412f, 958.712f, -56.1492f, nullptr}, {814.247f, 973.692f, -50.4602f, nullptr}, + {807.697f, 985.502f, -47.2383f, nullptr}, {795.672f, 1002.69f, -44.9382f, nullptr}, + {784.653f, 1020.77f, -38.6278f, nullptr}, {784.826f, 1037.34f, -31.5719f, nullptr}, + {786.083f, 1051.28f, -24.0793f, nullptr}, {787.314f, 1065.23f, -16.8918f, nullptr}, + {788.892f, 1086.17f, -6.42608f, nullptr}, {792.077f, 1106.53f, 4.81124f, nullptr}, + {800.398f, 1119.48f, 8.5814f, nullptr}, {812.476f, 1131.1f, 10.439f, nullptr}, + {829.704f, 1142.52f, 10.738f, nullptr}, {842.646f, 1143.51f, 11.9984f, nullptr}, + {857.674f, 1146.16f, 11.529f, nullptr}, }; // Farm to Blacksmith -BattleBotPath vPath_AB_Farm_to_Blacksmith = -{ - { 803.826f, 874.909f, -55.2547f, nullptr }, - { 808.763f, 887.991f, -57.4437f, nullptr }, - { 818.33f, 906.674f, -59.3554f, nullptr }, - { 828.634f, 924.972f, -60.5664f, nullptr }, - { 835.255f, 937.308f, -60.2915f, nullptr }, - { 845.244f, 955.78f, -60.4208f, nullptr }, - { 852.125f, 967.965f, -61.3135f, nullptr }, - { 863.232f, 983.109f, -62.6402f, nullptr }, - { 875.413f, 989.245f, -61.2916f, nullptr }, - { 895.765f, 994.41f, -63.6287f, nullptr }, - { 914.16f, 1001.09f, -58.37f, nullptr }, - { 932.418f, 1011.44f, -51.9225f, nullptr }, - { 944.244f, 1018.92f, -49.1438f, nullptr }, - { 961.55f, 1030.81f, -45.814f, nullptr }, - { 978.122f, 1043.87f, -44.4682f, nullptr }, +BattleBotPath vPath_AB_Farm_to_Blacksmith = { + {803.826f, 874.909f, -55.2547f, nullptr}, {808.763f, 887.991f, -57.4437f, nullptr}, + {818.33f, 906.674f, -59.3554f, nullptr}, {828.634f, 924.972f, -60.5664f, nullptr}, + {835.255f, 937.308f, -60.2915f, nullptr}, {845.244f, 955.78f, -60.4208f, nullptr}, + {852.125f, 967.965f, -61.3135f, nullptr}, {863.232f, 983.109f, -62.6402f, nullptr}, + {875.413f, 989.245f, -61.2916f, nullptr}, {895.765f, 994.41f, -63.6287f, nullptr}, + {914.16f, 1001.09f, -58.37f, nullptr}, {932.418f, 1011.44f, -51.9225f, nullptr}, + {944.244f, 1018.92f, -49.1438f, nullptr}, {961.55f, 1030.81f, -45.814f, nullptr}, + {978.122f, 1043.87f, -44.4682f, nullptr}, }; // Stables to Gold Mine -BattleBotPath vPath_AB_Stables_to_GoldMine = -{ - { 1169.52f, 1198.71f, -56.2742f, nullptr }, - { 1166.72f, 1183.58f, -56.3633f, nullptr }, - { 1172.14f, 1170.99f, -56.4735f, nullptr }, - { 1185.18f, 1164.02f, -56.4269f, nullptr }, - { 1193.98f, 1155.85f, -55.924f, nullptr }, - { 1201.51f, 1145.65f, -56.4733f, nullptr }, - { 1205.39f, 1134.81f, -56.2366f, nullptr }, - { 1207.57f, 1106.9f, -58.4748f, nullptr }, - { 1209.4f, 1085.98f, -63.4022f, nullptr }, - { 1212.68f, 1065.25f, -66.514f, nullptr }, - { 1216.42f, 1037.52f, -72.0457f, nullptr }, - { 1215.4f, 1011.56f, -78.3338f, nullptr }, - { 1209.8f, 992.293f, -83.2433f, nullptr }, - { 1201.23f, 973.121f, -88.5661f, nullptr }, - { 1192.16f, 954.183f, -94.2209f, nullptr }, - { 1181.88f, 935.894f, -99.5239f, nullptr }, - { 1169.86f, 918.68f, -105.588f, nullptr }, - { 1159.36f, 900.497f, -110.461f, nullptr }, - { 1149.32f, 874.429f, -112.142f, nullptr }, - { 1145.34f, 849.824f, -110.523f, nullptr }, +BattleBotPath vPath_AB_Stables_to_GoldMine = { + {1169.52f, 1198.71f, -56.2742f, nullptr}, {1166.72f, 1183.58f, -56.3633f, nullptr}, + {1172.14f, 1170.99f, -56.4735f, nullptr}, {1185.18f, 1164.02f, -56.4269f, nullptr}, + {1193.98f, 1155.85f, -55.924f, nullptr}, {1201.51f, 1145.65f, -56.4733f, nullptr}, + {1205.39f, 1134.81f, -56.2366f, nullptr}, {1207.57f, 1106.9f, -58.4748f, nullptr}, + {1209.4f, 1085.98f, -63.4022f, nullptr}, {1212.68f, 1065.25f, -66.514f, nullptr}, + {1216.42f, 1037.52f, -72.0457f, nullptr}, {1215.4f, 1011.56f, -78.3338f, nullptr}, + {1209.8f, 992.293f, -83.2433f, nullptr}, {1201.23f, 973.121f, -88.5661f, nullptr}, + {1192.16f, 954.183f, -94.2209f, nullptr}, {1181.88f, 935.894f, -99.5239f, nullptr}, + {1169.86f, 918.68f, -105.588f, nullptr}, {1159.36f, 900.497f, -110.461f, nullptr}, + {1149.32f, 874.429f, -112.142f, nullptr}, {1145.34f, 849.824f, -110.523f, nullptr}, }; // Stables to Lumber Mill -BattleBotPath vPath_AB_Stables_to_LumberMill = -{ - { 1169.52f, 1198.71f, -56.2742f, nullptr }, - { 1169.33f, 1203.43f, -56.5457f, nullptr }, - { 1164.77f, 1208.73f, -56.1907f, nullptr }, - { 1141.52f, 1224.99f, -53.8204f, nullptr }, - { 1127.54f, 1224.82f, -48.2081f, nullptr }, - { 1106.56f, 1225.58f, -50.5154f, nullptr }, - { 1085.6f, 1226.54f, -53.1863f, nullptr }, - { 1064.6f, 1226.82f, -50.4381f, nullptr }, - { 1043.6f, 1227.27f, -46.5439f, nullptr }, - { 1022.61f, 1227.72f, -44.7157f, nullptr }, - { 1001.61f, 1227.62f, -42.6876f, nullptr }, - { 980.623f, 1226.93f, -40.4687f, nullptr }, - { 959.628f, 1227.1f, -35.3838f, nullptr }, - { 938.776f, 1226.34f, -23.5399f, nullptr }, - { 926.138f, 1217.21f, -16.2176f, nullptr }, - { 911.966f, 1205.99f, -9.69655f, nullptr }, - { 895.135f, 1198.85f, -0.546275f, nullptr }, - { 873.419f, 1189.27f, 9.3466f, nullptr }, - { 863.821f, 1181.72f, 9.76912f, nullptr }, - { 851.803f, 1166.3f, 10.4423f, nullptr }, - { 853.921f, 1150.92f, 11.543f, nullptr }, +BattleBotPath vPath_AB_Stables_to_LumberMill = { + {1169.52f, 1198.71f, -56.2742f, nullptr}, {1169.33f, 1203.43f, -56.5457f, nullptr}, + {1164.77f, 1208.73f, -56.1907f, nullptr}, {1141.52f, 1224.99f, -53.8204f, nullptr}, + {1127.54f, 1224.82f, -48.2081f, nullptr}, {1106.56f, 1225.58f, -50.5154f, nullptr}, + {1085.6f, 1226.54f, -53.1863f, nullptr}, {1064.6f, 1226.82f, -50.4381f, nullptr}, + {1043.6f, 1227.27f, -46.5439f, nullptr}, {1022.61f, 1227.72f, -44.7157f, nullptr}, + {1001.61f, 1227.62f, -42.6876f, nullptr}, {980.623f, 1226.93f, -40.4687f, nullptr}, + {959.628f, 1227.1f, -35.3838f, nullptr}, {938.776f, 1226.34f, -23.5399f, nullptr}, + {926.138f, 1217.21f, -16.2176f, nullptr}, {911.966f, 1205.99f, -9.69655f, nullptr}, + {895.135f, 1198.85f, -0.546275f, nullptr}, {873.419f, 1189.27f, 9.3466f, nullptr}, + {863.821f, 1181.72f, 9.76912f, nullptr}, {851.803f, 1166.3f, 10.4423f, nullptr}, + {853.921f, 1150.92f, 11.543f, nullptr}, }; // Farm to Gold Mine -BattleBotPath vPath_AB_Farm_to_GoldMine = -{ - { 803.826f, 874.909f, -55.2547f, nullptr }, - { 801.662f, 865.689f, -56.9445f, nullptr }, - { 806.433f, 860.776f, -57.5899f, nullptr }, - { 816.236f, 857.397f, -57.7029f, nullptr }, - { 826.717f, 855.846f, -57.9914f, nullptr }, - { 836.128f, 851.257f, -57.8321f, nullptr }, - { 847.933f, 843.837f, -58.1296f, nullptr }, - { 855.08f, 832.688f, -57.7373f, nullptr }, - { 864.513f, 813.663f, -57.574f, nullptr }, - { 864.229f, 797.762f, -54.2057f, nullptr }, - { 862.967f, 787.372f, -53.0276f, nullptr }, - { 864.163f, 776.33f, -52.0372f, nullptr }, - { 872.583f, 777.391f, -48.5342f, nullptr }, - { 893.575f, 777.922f, -49.1826f, nullptr }, - { 915.941f, 783.534f, -53.6598f, nullptr }, - { 928.105f, 789.929f, -55.4802f, nullptr }, - { 946.263f, 800.46f, -59.166f, nullptr }, - { 958.715f, 806.845f, -62.1494f, nullptr }, - { 975.79f, 811.913f, -65.9648f, nullptr }, - { 989.468f, 814.883f, -71.3089f, nullptr }, - { 1010.13f, 818.643f, -80.0817f, nullptr }, - { 1023.97f, 820.667f, -86.1114f, nullptr }, - { 1044.84f, 823.011f, -92.0583f, nullptr }, - { 1058.77f, 824.482f, -94.1937f, nullptr }, - { 1079.13f, 829.402f, -99.1207f, nullptr }, - { 1092.85f, 836.986f, -102.755f, nullptr }, - { 1114.75f, 851.21f, -109.782f, nullptr }, - { 1128.22f, 851.928f, -111.078f, nullptr }, - { 1145.14f, 849.895f, -110.523f, nullptr }, +BattleBotPath vPath_AB_Farm_to_GoldMine = { + {803.826f, 874.909f, -55.2547f, nullptr}, {801.662f, 865.689f, -56.9445f, nullptr}, + {806.433f, 860.776f, -57.5899f, nullptr}, {816.236f, 857.397f, -57.7029f, nullptr}, + {826.717f, 855.846f, -57.9914f, nullptr}, {836.128f, 851.257f, -57.8321f, nullptr}, + {847.933f, 843.837f, -58.1296f, nullptr}, {855.08f, 832.688f, -57.7373f, nullptr}, + {864.513f, 813.663f, -57.574f, nullptr}, {864.229f, 797.762f, -54.2057f, nullptr}, + {862.967f, 787.372f, -53.0276f, nullptr}, {864.163f, 776.33f, -52.0372f, nullptr}, + {872.583f, 777.391f, -48.5342f, nullptr}, {893.575f, 777.922f, -49.1826f, nullptr}, + {915.941f, 783.534f, -53.6598f, nullptr}, {928.105f, 789.929f, -55.4802f, nullptr}, + {946.263f, 800.46f, -59.166f, nullptr}, {958.715f, 806.845f, -62.1494f, nullptr}, + {975.79f, 811.913f, -65.9648f, nullptr}, {989.468f, 814.883f, -71.3089f, nullptr}, + {1010.13f, 818.643f, -80.0817f, nullptr}, {1023.97f, 820.667f, -86.1114f, nullptr}, + {1044.84f, 823.011f, -92.0583f, nullptr}, {1058.77f, 824.482f, -94.1937f, nullptr}, + {1079.13f, 829.402f, -99.1207f, nullptr}, {1092.85f, 836.986f, -102.755f, nullptr}, + {1114.75f, 851.21f, -109.782f, nullptr}, {1128.22f, 851.928f, -111.078f, nullptr}, + {1145.14f, 849.895f, -110.523f, nullptr}, }; // Farm to Lumber Mill -BattleBotPath vPath_AB_Farm_to_LumberMill = -{ - { 803.826f, 874.909f, -55.2547f, nullptr }, - { 802.874f, 894.28f, -56.4661f, nullptr }, - { 806.844f, 920.39f, -57.3157f, nullptr }, - { 814.003f, 934.161f, -57.6065f, nullptr }, - { 824.594f, 958.47f, -58.4916f, nullptr }, - { 820.434f, 971.184f, -53.201f, nullptr }, - { 808.339f, 987.79f, -47.5705f, nullptr }, - { 795.98f, 1004.76f, -44.9189f, nullptr }, - { 785.497f, 1019.18f, -39.2806f, nullptr }, - { 783.94f, 1032.46f, -33.5692f, nullptr }, - { 784.956f, 1053.41f, -22.8368f, nullptr }, - { 787.499f, 1074.25f, -12.4232f, nullptr }, - { 789.406f, 1088.11f, -5.28606f, nullptr }, - { 794.617f, 1109.17f, 6.1966f, nullptr }, - { 801.514f, 1120.77f, 8.81455f, nullptr }, - { 817.3f, 1134.59f, 10.6064f, nullptr }, - { 828.961f, 1142.98f, 10.7354f, nullptr }, - { 841.63f, 1147.75f, 11.6916f, nullptr }, - { 854.326f, 1150.55f, 11.537f, nullptr }, +BattleBotPath vPath_AB_Farm_to_LumberMill = { + {803.826f, 874.909f, -55.2547f, nullptr}, {802.874f, 894.28f, -56.4661f, nullptr}, + {806.844f, 920.39f, -57.3157f, nullptr}, {814.003f, 934.161f, -57.6065f, nullptr}, + {824.594f, 958.47f, -58.4916f, nullptr}, {820.434f, 971.184f, -53.201f, nullptr}, + {808.339f, 987.79f, -47.5705f, nullptr}, {795.98f, 1004.76f, -44.9189f, nullptr}, + {785.497f, 1019.18f, -39.2806f, nullptr}, {783.94f, 1032.46f, -33.5692f, nullptr}, + {784.956f, 1053.41f, -22.8368f, nullptr}, {787.499f, 1074.25f, -12.4232f, nullptr}, + {789.406f, 1088.11f, -5.28606f, nullptr}, {794.617f, 1109.17f, 6.1966f, nullptr}, + {801.514f, 1120.77f, 8.81455f, nullptr}, {817.3f, 1134.59f, 10.6064f, nullptr}, + {828.961f, 1142.98f, 10.7354f, nullptr}, {841.63f, 1147.75f, 11.6916f, nullptr}, + {854.326f, 1150.55f, 11.537f, nullptr}, }; -BattleBotPath vPath_AV_Horde_Cave_to_Tower_Point_Crossroad = -{ - { -1362.395f, -529.615f, 52.636f, nullptr }, - { -1327.036f, -511.374f, 51.138f, nullptr }, - { -1277.047f, -516.327f, 50.667f, nullptr }, - { -1214.901f, -529.350f, 52.251f, nullptr }, - { -1151.129f, -545.598f, 51.990f, nullptr }, - { -1085.775f, -538.719f, 47.905f, nullptr }, - { -1038.552f, -517.946f, 43.876f, nullptr }, - { -981.371f, -494.593f, 41.127f, nullptr }, - { -930.598f, -463.751f, 43.060f, nullptr }, - { -887.138f, -475.816f, 44.374f, nullptr }, - { -880.957f, -525.119f, 53.6791f, nullptr }, - { -839.408f, -499.746f, 49.7505f, nullptr }, - { -820.21f, -469.193f, 49.4085f, nullptr }, - { -812.602f, -460.45f, 54.0872f, nullptr }, - { -789.646f, -441.864f, 57.8833f, nullptr }, - { -776.405f, -432.056f, 61.9256f, nullptr }, - { -760.773f, -430.154f, 64.8376f, nullptr }, - { -734.801f, -419.622f, 67.5354f, nullptr }, - { -718.313f, -404.674f, 67.5994f, nullptr }, - { -711.436f, -362.86f, 66.7543f, nullptr }, +BattleBotPath vPath_AV_Horde_Cave_to_Tower_Point_Crossroad = { + {-1362.395f, -529.615f, 52.636f, nullptr}, {-1327.036f, -511.374f, 51.138f, nullptr}, + {-1277.047f, -516.327f, 50.667f, nullptr}, {-1214.901f, -529.350f, 52.251f, nullptr}, + {-1151.129f, -545.598f, 51.990f, nullptr}, {-1085.775f, -538.719f, 47.905f, nullptr}, + {-1038.552f, -517.946f, 43.876f, nullptr}, {-981.371f, -494.593f, 41.127f, nullptr}, + {-930.598f, -463.751f, 43.060f, nullptr}, {-887.138f, -475.816f, 44.374f, nullptr}, + {-880.957f, -525.119f, 53.6791f, nullptr}, {-839.408f, -499.746f, 49.7505f, nullptr}, + {-820.21f, -469.193f, 49.4085f, nullptr}, {-812.602f, -460.45f, 54.0872f, nullptr}, + {-789.646f, -441.864f, 57.8833f, nullptr}, {-776.405f, -432.056f, 61.9256f, nullptr}, + {-760.773f, -430.154f, 64.8376f, nullptr}, {-734.801f, -419.622f, 67.5354f, nullptr}, + {-718.313f, -404.674f, 67.5994f, nullptr}, {-711.436f, -362.86f, 66.7543f, nullptr}, }; -BattleBotPath vPath_AV_Horde_Cave_to_Frostwolf_Graveyard_Flag = -{ - { -1362.530f, -529.904f, 52.687f, nullptr }, - { -1335.523f, -513.374f, 51.142f, nullptr }, - { -1303.788f, -522.090f, 51.872f, nullptr }, - { -1275.968f, -517.437f, 50.574f, nullptr }, - { -1250.891f, -514.016f, 50.603f, nullptr }, - { -1229.146f, -511.427f, 50.739f, nullptr }, - { -1202.997f, -505.638f, 51.577f, nullptr }, - { -1183.442f, -484.124f, 51.845f, nullptr }, - { -1150.984f, -464.204f, 55.353f, nullptr }, - { -1144.187f, -442.148f, 56.736f, nullptr }, - { -1036.291f, -409.307f, 56.365f, nullptr }, - { -1107.650f, -377.764f, 51.432f, nullptr }, - { -1081.32f, -348.198f, 54.5837f, nullptr }, +BattleBotPath vPath_AV_Horde_Cave_to_Frostwolf_Graveyard_Flag = { + {-1362.530f, -529.904f, 52.687f, nullptr}, {-1335.523f, -513.374f, 51.142f, nullptr}, + {-1303.788f, -522.090f, 51.872f, nullptr}, {-1275.968f, -517.437f, 50.574f, nullptr}, + {-1250.891f, -514.016f, 50.603f, nullptr}, {-1229.146f, -511.427f, 50.739f, nullptr}, + {-1202.997f, -505.638f, 51.577f, nullptr}, {-1183.442f, -484.124f, 51.845f, nullptr}, + {-1150.984f, -464.204f, 55.353f, nullptr}, {-1144.187f, -442.148f, 56.736f, nullptr}, + {-1036.291f, -409.307f, 56.365f, nullptr}, {-1107.650f, -377.764f, 51.432f, nullptr}, + {-1081.32f, -348.198f, 54.5837f, nullptr}, }; -BattleBotPath vPath_AV_Frostwolf_Graveyard_Flag_to_Coldtooth_Mine_Entrance = -{ - { -1081.32f, -348.198f, 54.5837f, nullptr }, - { -1065.539f, -333.798f, 56.316f, nullptr }, - { -1046.376f, -319.197f, 56.647f, nullptr }, - { -994.817f, -336.004f, 58.477f, nullptr }, - { -930.840f, -337.938f, 60.100f, nullptr }, - { -953.328f, -322.536f, 63.448f, nullptr }, - { -950.566f, -293.341f, 64.368f, nullptr }, - { -952.234f, -245.737f, 65.631f, nullptr }, +BattleBotPath vPath_AV_Frostwolf_Graveyard_Flag_to_Coldtooth_Mine_Entrance = { + {-1081.32f, -348.198f, 54.5837f, nullptr}, {-1065.539f, -333.798f, 56.316f, nullptr}, + {-1046.376f, -319.197f, 56.647f, nullptr}, {-994.817f, -336.004f, 58.477f, nullptr}, + {-930.840f, -337.938f, 60.100f, nullptr}, {-953.328f, -322.536f, 63.448f, nullptr}, + {-950.566f, -293.341f, 64.368f, nullptr}, {-952.234f, -245.737f, 65.631f, nullptr}, }; -BattleBotPath vPath_AV_Coldtooth_Mine_Entrance_to_Coldtooth_Mine_Boss = -{ - { -952.234f, -245.737f, 65.631f, nullptr }, - { -962.481f, -230.770f, 66.976f, nullptr }, - { -967.597f, -203.598f, 68.842f, nullptr }, - { -948.614f, -182.609f, 65.192f, nullptr }, - { -936.487f, -158.700f, 60.954f, nullptr }, - { -899.206f, -154.360f, 61.618f, nullptr }, - { -879.446f, -152.687f, 62.299f, nullptr }, - { -871.995f, -131.877f, 62.660f, nullptr }, - { -869.881f, -113.359f, 64.956f, nullptr }, - { -853.671f, -91.427f, 68.569f, nullptr }, +BattleBotPath vPath_AV_Coldtooth_Mine_Entrance_to_Coldtooth_Mine_Boss = { + {-952.234f, -245.737f, 65.631f, nullptr}, {-962.481f, -230.770f, 66.976f, nullptr}, + {-967.597f, -203.598f, 68.842f, nullptr}, {-948.614f, -182.609f, 65.192f, nullptr}, + {-936.487f, -158.700f, 60.954f, nullptr}, {-899.206f, -154.360f, 61.618f, nullptr}, + {-879.446f, -152.687f, 62.299f, nullptr}, {-871.995f, -131.877f, 62.660f, nullptr}, + {-869.881f, -113.359f, 64.956f, nullptr}, {-853.671f, -91.427f, 68.569f, nullptr}, }; -BattleBotPath vPath_AV_Frostwolf_Graveyard_Flag_to_Horde_Base_First_Crossroads = -{ - { -1081.32f, -348.198f, 54.5837f, nullptr }, - { -1085.54f, -349.316f, 54.5448f, nullptr }, - { -1096.08f, -339.028f, 54.5433f, nullptr }, - { -1112.8f, -338.773f, 53.4886f, nullptr }, - { -1137.95f, -349.136f, 51.1539f, nullptr }, - { -1160.92f, -352.495f, 51.7134f, nullptr }, - { -1181.12f, -360.f, 52.4494f, nullptr }, - { -1191.79f, -365.559f, 52.4952f, nullptr }, - { -1210.16f, -366.523f, 55.6316f, nullptr }, - { -1238.08f, -364.752f, 59.3705f, nullptr }, - { -1242.44f, -361.619f, 59.7433f, nullptr }, - { -1246.25f, -350.16f, 59.4911f, nullptr }, - { -1245.71f, -338.859f, 59.2882f, nullptr }, - { -1238.46f, -325.945f, 60.084f, nullptr }, - { -1227.58f, -312.249f, 63.2087f, nullptr }, - { -1216.36f, -296.148f, 70.0471f, nullptr }, - { -1210.f, -276.949f, 73.7288f, nullptr }, - { -1207.09f, -259.721f, 72.6882f, nullptr }, - { -1208.37f, -254.367f, 72.5688f, nullptr }, - { -1211.83f, -252.648f, 72.7613f, nullptr }, - { -1236.28f, -251.079f, 73.3273f, nullptr }, - { -1243.33f, -253.936f, 73.3273f, nullptr }, - { -1249.37f, -260.819f, 73.3704f, nullptr }, - { -1257.24f, -272.391f, 72.9263f, nullptr }, - { -1266.31f, -281.263f, 76.3849f, nullptr }, - { -1272.81f, -285.884f, 82.5902f, nullptr }, - { -1278.52f, -288.089f, 86.4665f, nullptr }, - { -1288.71f, -289.227f, 89.7414f, nullptr }, - { -1306.2f, -289.35f, 90.7095f, nullptr }, - { -1320.18f, -289.806f, 90.4719f, nullptr }, +BattleBotPath vPath_AV_Frostwolf_Graveyard_Flag_to_Horde_Base_First_Crossroads = { + {-1081.32f, -348.198f, 54.5837f, nullptr}, {-1085.54f, -349.316f, 54.5448f, nullptr}, + {-1096.08f, -339.028f, 54.5433f, nullptr}, {-1112.8f, -338.773f, 53.4886f, nullptr}, + {-1137.95f, -349.136f, 51.1539f, nullptr}, {-1160.92f, -352.495f, 51.7134f, nullptr}, + {-1181.12f, -360.f, 52.4494f, nullptr}, {-1191.79f, -365.559f, 52.4952f, nullptr}, + {-1210.16f, -366.523f, 55.6316f, nullptr}, {-1238.08f, -364.752f, 59.3705f, nullptr}, + {-1242.44f, -361.619f, 59.7433f, nullptr}, {-1246.25f, -350.16f, 59.4911f, nullptr}, + {-1245.71f, -338.859f, 59.2882f, nullptr}, {-1238.46f, -325.945f, 60.084f, nullptr}, + {-1227.58f, -312.249f, 63.2087f, nullptr}, {-1216.36f, -296.148f, 70.0471f, nullptr}, + {-1210.f, -276.949f, 73.7288f, nullptr}, {-1207.09f, -259.721f, 72.6882f, nullptr}, + {-1208.37f, -254.367f, 72.5688f, nullptr}, {-1211.83f, -252.648f, 72.7613f, nullptr}, + {-1236.28f, -251.079f, 73.3273f, nullptr}, {-1243.33f, -253.936f, 73.3273f, nullptr}, + {-1249.37f, -260.819f, 73.3704f, nullptr}, {-1257.24f, -272.391f, 72.9263f, nullptr}, + {-1266.31f, -281.263f, 76.3849f, nullptr}, {-1272.81f, -285.884f, 82.5902f, nullptr}, + {-1278.52f, -288.089f, 86.4665f, nullptr}, {-1288.71f, -289.227f, 89.7414f, nullptr}, + {-1306.2f, -289.35f, 90.7095f, nullptr}, {-1320.18f, -289.806f, 90.4719f, nullptr}, }; -BattleBotPath vPath_AV_Horde_Base_First_Crossroads_to_East_Frostwolf_Tower_Flag = -{ - { -1320.18f, -289.806f, 90.4719f, nullptr }, - { -1315.93f, -293.794f, 90.4653f, nullptr }, - { -1312.71f, -300.242f, 90.9343f, nullptr }, - { -1309.39f, -305.389f, 91.7743f, nullptr }, - { -1306.77f, -310.068f, 91.7371f, nullptr }, - { -1300.2f, -322.303f, 91.3631f, nullptr }, - { -1295.93f, -320.154f, 91.3596f, nullptr }, - { -1301.5f, -309.995f, 95.7382f, nullptr }, - { -1309.02f, -315.629f, 99.4271f, nullptr }, - { -1304.13f, -321.638f, 102.323f, nullptr }, - { -1298.43f, -317.239f, 104.769f, nullptr }, - { -1304.62f, -310.076f, 107.328f, nullptr }, - { -1306.73f, -316.046f, 107.328f, nullptr }, - { -1314.61f, -321.14f, 107.316f, nullptr }, - { -1311.92f, -324.548f, 109.202f, nullptr }, - { -1304.72f, -328.225f, 113.563f, nullptr }, - { -1301.77f, -326.848f, 113.84f, nullptr }, - { -1294.77f, -321.092f, 113.792f, nullptr }, - { -1294.33f, -312.247f, 113.794f, nullptr }, - { -1302.25f, -307.602f, 113.856f, nullptr }, - { -1305.22f, -311.212f, 113.864f, nullptr }, - { -1303.38f, -315.877f, 113.867f, nullptr }, +BattleBotPath vPath_AV_Horde_Base_First_Crossroads_to_East_Frostwolf_Tower_Flag = { + {-1320.18f, -289.806f, 90.4719f, nullptr}, {-1315.93f, -293.794f, 90.4653f, nullptr}, + {-1312.71f, -300.242f, 90.9343f, nullptr}, {-1309.39f, -305.389f, 91.7743f, nullptr}, + {-1306.77f, -310.068f, 91.7371f, nullptr}, {-1300.2f, -322.303f, 91.3631f, nullptr}, + {-1295.93f, -320.154f, 91.3596f, nullptr}, {-1301.5f, -309.995f, 95.7382f, nullptr}, + {-1309.02f, -315.629f, 99.4271f, nullptr}, {-1304.13f, -321.638f, 102.323f, nullptr}, + {-1298.43f, -317.239f, 104.769f, nullptr}, {-1304.62f, -310.076f, 107.328f, nullptr}, + {-1306.73f, -316.046f, 107.328f, nullptr}, {-1314.61f, -321.14f, 107.316f, nullptr}, + {-1311.92f, -324.548f, 109.202f, nullptr}, {-1304.72f, -328.225f, 113.563f, nullptr}, + {-1301.77f, -326.848f, 113.84f, nullptr}, {-1294.77f, -321.092f, 113.792f, nullptr}, + {-1294.33f, -312.247f, 113.794f, nullptr}, {-1302.25f, -307.602f, 113.856f, nullptr}, + {-1305.22f, -311.212f, 113.864f, nullptr}, {-1303.38f, -315.877f, 113.867f, nullptr}, }; -BattleBotPath vPath_AV_Horde_Base_First_Crossroads_to_West_Frostwolf_Tower_Flag = -{ - { -1320.18f, -289.806f, 90.4719f, nullptr }, - { -1318.43f, -283.088f, 90.5913f, nullptr }, - { -1315.58f, -275.043f, 91.1062f, nullptr }, - { -1311.21f, -271.424f, 91.8402f, nullptr }, - { -1306.39f, -269.65f, 92.0506f, nullptr }, - { -1292.18f, -264.937f, 91.6452f, nullptr }, - { -1292.76f, -261.18f, 91.6437f, nullptr }, - { -1296.92f, -261.369f, 92.6981f, nullptr }, - { -1303.73f, -263.629f, 95.987f, nullptr }, - { -1300.5f, -272.465f, 99.691f, nullptr }, - { -1293.33f, -269.5f, 102.51f, nullptr }, - { -1295.96f, -263.022f, 105.042f, nullptr }, - { -1304.46f, -266.371f, 107.612f, nullptr }, - { -1299.74f, -270.916f, 107.612f, nullptr }, - { -1296.95f, -279.413f, 107.585f, nullptr }, - { -1291.49f, -276.799f, 110.059f, nullptr }, - { -1286.89f, -269.783f, 114.142f, nullptr }, - { -1290.87f, -260.594f, 114.151f, nullptr }, - { -1299.88f, -257.96f, 114.111f, nullptr }, - { -1306.39f, -263.798f, 114.147f, nullptr }, - { -1305.91f, -269.074f, 114.066f, nullptr }, - { -1298.82f, -267.215f, 114.151f, nullptr }, +BattleBotPath vPath_AV_Horde_Base_First_Crossroads_to_West_Frostwolf_Tower_Flag = { + {-1320.18f, -289.806f, 90.4719f, nullptr}, {-1318.43f, -283.088f, 90.5913f, nullptr}, + {-1315.58f, -275.043f, 91.1062f, nullptr}, {-1311.21f, -271.424f, 91.8402f, nullptr}, + {-1306.39f, -269.65f, 92.0506f, nullptr}, {-1292.18f, -264.937f, 91.6452f, nullptr}, + {-1292.76f, -261.18f, 91.6437f, nullptr}, {-1296.92f, -261.369f, 92.6981f, nullptr}, + {-1303.73f, -263.629f, 95.987f, nullptr}, {-1300.5f, -272.465f, 99.691f, nullptr}, + {-1293.33f, -269.5f, 102.51f, nullptr}, {-1295.96f, -263.022f, 105.042f, nullptr}, + {-1304.46f, -266.371f, 107.612f, nullptr}, {-1299.74f, -270.916f, 107.612f, nullptr}, + {-1296.95f, -279.413f, 107.585f, nullptr}, {-1291.49f, -276.799f, 110.059f, nullptr}, + {-1286.89f, -269.783f, 114.142f, nullptr}, {-1290.87f, -260.594f, 114.151f, nullptr}, + {-1299.88f, -257.96f, 114.111f, nullptr}, {-1306.39f, -263.798f, 114.147f, nullptr}, + {-1305.91f, -269.074f, 114.066f, nullptr}, {-1298.82f, -267.215f, 114.151f, nullptr}, }; -BattleBotPath vPath_AV_Horde_Base_First_Crossroads_to_Horde_Base_Second_Crossroads = -{ - { -1320.18f, -289.806f, 90.4719f, nullptr }, - { -1334.14f, -290.898f, 90.8243f, nullptr }, - { -1344.61f, -291.546f, 90.8375f, nullptr }, +BattleBotPath vPath_AV_Horde_Base_First_Crossroads_to_Horde_Base_Second_Crossroads = { + {-1320.18f, -289.806f, 90.4719f, nullptr}, + {-1334.14f, -290.898f, 90.8243f, nullptr}, + {-1344.61f, -291.546f, 90.8375f, nullptr}, }; -BattleBotPath vPath_AV_Horde_Base_Second_Crossroads_to_Horde_Base_Entrance_DrekThar = -{ - { -1344.61f, -291.546f, 90.8375f, nullptr }, - { -1348.33f, -287.291f, 91.1178f, nullptr }, - { -1350.16f, -282.141f, 92.7105f, nullptr }, - { -1355.48f, -265.233f, 98.9033f, nullptr }, - { -1360.94f, -247.529f, 99.3667f, nullptr }, +BattleBotPath vPath_AV_Horde_Base_Second_Crossroads_to_Horde_Base_Entrance_DrekThar = { + {-1344.61f, -291.546f, 90.8375f, nullptr}, {-1348.33f, -287.291f, 91.1178f, nullptr}, + {-1350.16f, -282.141f, 92.7105f, nullptr}, {-1355.48f, -265.233f, 98.9033f, nullptr}, + {-1360.94f, -247.529f, 99.3667f, nullptr}, }; -BattleBotPath vPath_AV_Horde_Base_Second_Crossroads_to_Horde_Base_DrekThar1 = -{ - { -1360.94f, -247.529f, 99.3667f, nullptr }, - { -1354.74f, -242.226f, 99.3695f, nullptr }, - { -1348.1f, -235.612f, 99.3657f, nullptr }, - { -1349.98f, -229.222f, 99.3699f, nullptr }, - { -1366.23f, -223.049f, 98.4174f, nullptr }, +BattleBotPath vPath_AV_Horde_Base_Second_Crossroads_to_Horde_Base_DrekThar1 = { + {-1360.94f, -247.529f, 99.3667f, nullptr}, {-1354.74f, -242.226f, 99.3695f, nullptr}, + {-1348.1f, -235.612f, 99.3657f, nullptr}, {-1349.98f, -229.222f, 99.3699f, nullptr}, + {-1366.23f, -223.049f, 98.4174f, nullptr}, }; -BattleBotPath vPath_AV_Horde_Base_Second_Crossroads_to_Horde_Base_DrekThar2 = -{ - { -1360.94f, -247.529f, 99.3667f, nullptr }, - { -1368.08f, -247.832f, 99.3703f, nullptr }, - { -1377.83f, -245.929f, 99.3629f, nullptr }, - { -1381.21f, -239.565f, 99.3698f, nullptr }, - { -1372.52f, -225.593f, 98.4269f, nullptr }, +BattleBotPath vPath_AV_Horde_Base_Second_Crossroads_to_Horde_Base_DrekThar2 = { + {-1360.94f, -247.529f, 99.3667f, nullptr}, {-1368.08f, -247.832f, 99.3703f, nullptr}, + {-1377.83f, -245.929f, 99.3629f, nullptr}, {-1381.21f, -239.565f, 99.3698f, nullptr}, + {-1372.52f, -225.593f, 98.4269f, nullptr}, }; -BattleBotPath vPath_AV_Horde_Base_Second_Crossroads_to_Horde_Base_Graveyard_Flag = -{ - { -1344.61f, -291.546f, 90.8375f, nullptr }, - { -1353.15f, -296.183f, 90.6364f, nullptr }, - { -1360.12f, -302.321f, 91.5223f, nullptr }, - { -1372.69f, -308.451f, 91.2869f, nullptr }, - { -1392.43f, -318.109f, 88.7925f, nullptr }, - { -1400.8f, -314.327f, 89.0501f, nullptr }, - { -1401.94f, -310.103f, 89.3816f, nullptr }, +BattleBotPath vPath_AV_Horde_Base_Second_Crossroads_to_Horde_Base_Graveyard_Flag = { + {-1344.61f, -291.546f, 90.8375f, nullptr}, {-1353.15f, -296.183f, 90.6364f, nullptr}, + {-1360.12f, -302.321f, 91.5223f, nullptr}, {-1372.69f, -308.451f, 91.2869f, nullptr}, + {-1392.43f, -318.109f, 88.7925f, nullptr}, {-1400.8f, -314.327f, 89.0501f, nullptr}, + {-1401.94f, -310.103f, 89.3816f, nullptr}, }; -BattleBotPath vPath_AV_Tower_Point_Crossroads_to_Tower_Point_Bottom = -{ - { -711.436f, -362.86f, 66.7543f, nullptr }, - { -713.433f, -357.847f, 66.6605f, nullptr }, - { -726.362f, -345.477f, 66.8089f, nullptr }, - { -748.788f, -344.154f, 66.7348f, nullptr }, - { -759.771f, -342.304f, 67.2223f, nullptr }, +BattleBotPath vPath_AV_Tower_Point_Crossroads_to_Tower_Point_Bottom = { + {-711.436f, -362.86f, 66.7543f, nullptr}, {-713.433f, -357.847f, 66.6605f, nullptr}, + {-726.362f, -345.477f, 66.8089f, nullptr}, {-748.788f, -344.154f, 66.7348f, nullptr}, + {-759.771f, -342.304f, 67.2223f, nullptr}, }; -BattleBotPath vPath_AV_TowerPoint_Bottom_to_Tower_Point_Flag = -{ - { -759.771f, -342.304f, 67.2223f, nullptr }, - { -762.294f, -343.172f, 67.3607f, nullptr }, - { -764.151f, -350.571f, 68.7991f, nullptr }, - { -766.112f, -357.945f, 68.6996f, nullptr }, - { -770.997f, -370.089f, 68.3956f, nullptr }, - { -763.765f, -368.338f, 69.1196f, nullptr }, - { -761.735f, -359.76f, 72.7363f, nullptr }, - { -771.43f, -357.941f, 76.4841f, nullptr }, - { -773.925f, -365.214f, 79.2135f, nullptr }, - { -766.473f, -365.891f, 81.9322f, nullptr }, - { -765.147f, -355.981f, 84.3558f, nullptr }, - { -771.041f, -360.772f, 84.3558f, nullptr }, - { -779.831f, -356.316f, 84.3425f, nullptr }, - { -780.107f, -362.818f, 87.4599f, nullptr }, - { -775.392f, -371.248f, 90.8508f, nullptr }, - { -767.966f, -372.722f, 90.8949f, nullptr }, - { -759.167f, -366.147f, 90.8259f, nullptr }, - { -760.11f, -357.787f, 90.8949f, nullptr }, - { -764.399f, -355.108f, 90.8013f, nullptr }, - { -767.9f, -362.019f, 90.8949f, nullptr }, +BattleBotPath vPath_AV_TowerPoint_Bottom_to_Tower_Point_Flag = { + {-759.771f, -342.304f, 67.2223f, nullptr}, {-762.294f, -343.172f, 67.3607f, nullptr}, + {-764.151f, -350.571f, 68.7991f, nullptr}, {-766.112f, -357.945f, 68.6996f, nullptr}, + {-770.997f, -370.089f, 68.3956f, nullptr}, {-763.765f, -368.338f, 69.1196f, nullptr}, + {-761.735f, -359.76f, 72.7363f, nullptr}, {-771.43f, -357.941f, 76.4841f, nullptr}, + {-773.925f, -365.214f, 79.2135f, nullptr}, {-766.473f, -365.891f, 81.9322f, nullptr}, + {-765.147f, -355.981f, 84.3558f, nullptr}, {-771.041f, -360.772f, 84.3558f, nullptr}, + {-779.831f, -356.316f, 84.3425f, nullptr}, {-780.107f, -362.818f, 87.4599f, nullptr}, + {-775.392f, -371.248f, 90.8508f, nullptr}, {-767.966f, -372.722f, 90.8949f, nullptr}, + {-759.167f, -366.147f, 90.8259f, nullptr}, {-760.11f, -357.787f, 90.8949f, nullptr}, + {-764.399f, -355.108f, 90.8013f, nullptr}, {-767.9f, -362.019f, 90.8949f, nullptr}, }; -BattleBotPath vPath_AV_Tower_Point_Bottom_to_Frostwolf_Graveyard_Flag = -{ - { -759.771f, -342.304f, 67.2223f, nullptr }, - { -764.971f, -339.278f, 67.6875f, nullptr }, - { -773.394f, -335.633f, 66.4157f, nullptr }, - { -796.758f, -340.437f, 61.5754f, nullptr }, - { -828.745f, -348.592f, 50.1022f, nullptr }, - { -846.826f, -355.181f, 50.0754f, nullptr }, - { -869.897f, -359.01f, 50.9404f, nullptr }, - { -888.679f, -365.688f, 49.3732f, nullptr }, - { -908.082f, -381.24f, 48.9888f, nullptr }, - { -934.234f, -388.41f, 48.9912f, nullptr }, - { -960.683f, -395.321f, 49.028f, nullptr }, - { -970.161f, -397.02f, 49.2312f, nullptr }, - { -993.784f, -397.619f, 50.0896f, nullptr }, - { -1018.82f, -393.742f, 50.703f, nullptr }, - { -1047.38f, -380.337f, 51.1403f, nullptr }, - { -1066.7f, -361.097f, 51.3909f, nullptr }, - { -1079.61f, -345.548f, 55.1131f, nullptr }, +BattleBotPath vPath_AV_Tower_Point_Bottom_to_Frostwolf_Graveyard_Flag = { + {-759.771f, -342.304f, 67.2223f, nullptr}, {-764.971f, -339.278f, 67.6875f, nullptr}, + {-773.394f, -335.633f, 66.4157f, nullptr}, {-796.758f, -340.437f, 61.5754f, nullptr}, + {-828.745f, -348.592f, 50.1022f, nullptr}, {-846.826f, -355.181f, 50.0754f, nullptr}, + {-869.897f, -359.01f, 50.9404f, nullptr}, {-888.679f, -365.688f, 49.3732f, nullptr}, + {-908.082f, -381.24f, 48.9888f, nullptr}, {-934.234f, -388.41f, 48.9912f, nullptr}, + {-960.683f, -395.321f, 49.028f, nullptr}, {-970.161f, -397.02f, 49.2312f, nullptr}, + {-993.784f, -397.619f, 50.0896f, nullptr}, {-1018.82f, -393.742f, 50.703f, nullptr}, + {-1047.38f, -380.337f, 51.1403f, nullptr}, {-1066.7f, -361.097f, 51.3909f, nullptr}, + {-1079.61f, -345.548f, 55.1131f, nullptr}, }; -BattleBotPath vPath_AV_Frostwolf_Graveyard_to_Frostwolf_Graveyard_Flag = -{ - { -1089.6f, -268.375f, 57.038f, nullptr }, - { -1087.23f, -285.712f, 56.625f, nullptr }, - { -1084.83f, -307.023f, 56.5773f, nullptr }, - { -1082.81f, -327.926f, 54.863f, nullptr }, - { -1082.08f, -333.784f, 54.885f, nullptr }, - { -1079.61f, -345.548f, 55.1131f, nullptr }, +BattleBotPath vPath_AV_Frostwolf_Graveyard_to_Frostwolf_Graveyard_Flag = { + {-1089.6f, -268.375f, 57.038f, nullptr}, {-1087.23f, -285.712f, 56.625f, nullptr}, + {-1084.83f, -307.023f, 56.5773f, nullptr}, {-1082.81f, -327.926f, 54.863f, nullptr}, + {-1082.08f, -333.784f, 54.885f, nullptr}, {-1079.61f, -345.548f, 55.1131f, nullptr}, }; -BattleBotPath vPath_AV_Tower_Point_Crossroads_to_Iceblood_Graveyard_Flag = -{ - { -711.436f, -362.86f, 66.7543f, nullptr }, - { -703.169f, -363.672f, 66.3514f, nullptr }, - { -682.166f, -374.453f, 65.6513f, nullptr }, - { -653.798f, -387.044f, 62.0839f, nullptr }, - { -625.062f, -397.093f, 59.0311f, nullptr }, - { -614.138f, -396.501f, 60.8585f, nullptr }, +BattleBotPath vPath_AV_Tower_Point_Crossroads_to_Iceblood_Graveyard_Flag = { + {-711.436f, -362.86f, 66.7543f, nullptr}, {-703.169f, -363.672f, 66.3514f, nullptr}, + {-682.166f, -374.453f, 65.6513f, nullptr}, {-653.798f, -387.044f, 62.0839f, nullptr}, + {-625.062f, -397.093f, 59.0311f, nullptr}, {-614.138f, -396.501f, 60.8585f, nullptr}, }; -BattleBotPath vPath_AV_Iceblood_Graveyard_Flag_to_Iceblood_Tower_Crossroad = -{ - { -614.138f, -396.501f, 60.8585f, nullptr }, - { -620.856f, -389.074f, 58.4251f, nullptr }, - { -622.361f, -366.641f, 56.862f, nullptr }, - { -618.134f, -346.849f, 55.2242f, nullptr }, - { -586.744f, -317.327f, 48.149f, nullptr }, - { -579.697f, -315.037f, 46.345f, nullptr }, +BattleBotPath vPath_AV_Iceblood_Graveyard_Flag_to_Iceblood_Tower_Crossroad = { + {-614.138f, -396.501f, 60.8585f, nullptr}, {-620.856f, -389.074f, 58.4251f, nullptr}, + {-622.361f, -366.641f, 56.862f, nullptr}, {-618.134f, -346.849f, 55.2242f, nullptr}, + {-586.744f, -317.327f, 48.149f, nullptr}, {-579.697f, -315.037f, 46.345f, nullptr}, }; -BattleBotPath vPath_AV_Iceblood_Tower_Crossroad_to_Iceblood_Tower = -{ - { -579.697f, -315.037f, 46.345f, nullptr }, - { -579.747f, -308.986f, 46.6127f, nullptr }, - { -575.92f, -296.013f, 48.4349f, nullptr }, - { -567.029f, -286.975f, 50.7703f, nullptr }, - { -557.697f, -276.264f, 52.1503f, nullptr }, +BattleBotPath vPath_AV_Iceblood_Tower_Crossroad_to_Iceblood_Tower = { + {-579.697f, -315.037f, 46.345f, nullptr}, {-579.747f, -308.986f, 46.6127f, nullptr}, + {-575.92f, -296.013f, 48.4349f, nullptr}, {-567.029f, -286.975f, 50.7703f, nullptr}, + {-557.697f, -276.264f, 52.1503f, nullptr}, }; -BattleBotPath vPath_AV_Iceblood_Tower_to_Iceblood_Tower_Flag = -{ - { -557.697f, -276.264f, 52.1503f, nullptr }, - { -562.505f, -271.251f, 52.9165f, nullptr }, - { -575.986f, -258.447f, 52.5129f, nullptr }, - { -580.103f, -261.305f, 52.5013f, nullptr }, - { -571.844f, -269.038f, 56.8539f, nullptr }, - { -565.86f, -261.478f, 60.5514f, nullptr }, - { -572.102f, -256.66f, 63.3275f, nullptr }, - { -576.45f, -262.642f, 65.8959f, nullptr }, - { -568.831f, -268.036f, 68.4696f, nullptr }, - { -568.091f, -260.214f, 68.4696f, nullptr }, - { -561.978f, -254.631f, 68.4482f, nullptr }, - { -570.682f, -250.791f, 73.0299f, nullptr }, - { -576.069f, -252.266f, 74.9855f, nullptr }, - { -581.294f, -260.533f, 74.9366f, nullptr }, - { -579.309f, -268.79f, 74.9984f, nullptr }, - { -570.275f, -271.346f, 75.0083f, nullptr }, - { -566.436f, -268.102f, 74.9324f, nullptr }, - { -571.044f, -263.753f, 75.0087f, nullptr }, +BattleBotPath vPath_AV_Iceblood_Tower_to_Iceblood_Tower_Flag = { + {-557.697f, -276.264f, 52.1503f, nullptr}, {-562.505f, -271.251f, 52.9165f, nullptr}, + {-575.986f, -258.447f, 52.5129f, nullptr}, {-580.103f, -261.305f, 52.5013f, nullptr}, + {-571.844f, -269.038f, 56.8539f, nullptr}, {-565.86f, -261.478f, 60.5514f, nullptr}, + {-572.102f, -256.66f, 63.3275f, nullptr}, {-576.45f, -262.642f, 65.8959f, nullptr}, + {-568.831f, -268.036f, 68.4696f, nullptr}, {-568.091f, -260.214f, 68.4696f, nullptr}, + {-561.978f, -254.631f, 68.4482f, nullptr}, {-570.682f, -250.791f, 73.0299f, nullptr}, + {-576.069f, -252.266f, 74.9855f, nullptr}, {-581.294f, -260.533f, 74.9366f, nullptr}, + {-579.309f, -268.79f, 74.9984f, nullptr}, {-570.275f, -271.346f, 75.0083f, nullptr}, + {-566.436f, -268.102f, 74.9324f, nullptr}, {-571.044f, -263.753f, 75.0087f, nullptr}, }; -BattleBotPath vPath_AV_Iceblood_Tower_to_Iceblood_Garrison = -{ - { -557.697f, -276.264f, 52.1503f, nullptr }, - { -550.396f, -269.326f, 52.4539f, nullptr }, - { -542.628f, -254.901f, 54.7447f, nullptr }, - { -536.969f, -242.614f, 57.233f, nullptr }, - { -532.204f, -230.96f, 56.7126f, nullptr }, - { -499.532f, -204.606f, 57.4507f, nullptr }, - { -492.17f, -187.077f, 57.1342f, nullptr }, +BattleBotPath vPath_AV_Iceblood_Tower_to_Iceblood_Garrison = { + {-557.697f, -276.264f, 52.1503f, nullptr}, {-550.396f, -269.326f, 52.4539f, nullptr}, + {-542.628f, -254.901f, 54.7447f, nullptr}, {-536.969f, -242.614f, 57.233f, nullptr}, + {-532.204f, -230.96f, 56.7126f, nullptr}, {-499.532f, -204.606f, 57.4507f, nullptr}, + {-492.17f, -187.077f, 57.1342f, nullptr}, }; -BattleBotPath vPath_AV_Iceblood_Garrison_to_Captain_Galvangar = -{ - { -492.17f, -187.077f, 57.1342f, nullptr }, - { -496.52f, -186.015f, 57.4265f, nullptr }, - { -508.094f, -180.795f, 57.9437f, nullptr }, - { -519.813f, -179.116f, 57.9527f, nullptr }, - { -528.962f, -186.573f, 57.9513f, nullptr }, - { -538.064f, -186.984f, 57.9556f, nullptr }, - { -540.747f, -169.935f, 57.0124f, nullptr }, +BattleBotPath vPath_AV_Iceblood_Garrison_to_Captain_Galvangar = { + {-492.17f, -187.077f, 57.1342f, nullptr}, {-496.52f, -186.015f, 57.4265f, nullptr}, + {-508.094f, -180.795f, 57.9437f, nullptr}, {-519.813f, -179.116f, 57.9527f, nullptr}, + {-528.962f, -186.573f, 57.9513f, nullptr}, {-538.064f, -186.984f, 57.9556f, nullptr}, + {-540.747f, -169.935f, 57.0124f, nullptr}, }; -BattleBotPath vPath_AV_Iceblood_Garrison_to_Snowfall_Flag = -{ - { -492.17f, -187.077f, 57.1342f, nullptr }, - { -478.362f, -193.882f, 55.0986f, nullptr }, - { -463.702f, -196.051f, 48.5213f, nullptr }, - { -456.512f, -196.217f, 43.158f, nullptr }, - { -429.951f, -198.515f, 26.8893f, nullptr }, - { -412.975f, -190.921f, 25.7659f, nullptr }, - { -387.531f, -186.251f, 15.2001f, nullptr }, - { -370.088f, -186.351f, 12.8474f, nullptr }, - { -353.23f, -179.161f, 10.3823f, nullptr }, - { -319.906f, -162.842f, 9.26139f, nullptr }, - { -316.616f, -151.198f, 10.5439f, nullptr }, - { -307.702f, -133.042f, 14.3502f, nullptr }, - { -293.423f, -117.684f, 19.8246f, nullptr }, - { -274.446f, -97.1283f, 40.3783f, nullptr }, - { -256.993f, -83.0377f, 54.9012f, nullptr }, - { -249.129f, -80.3578f, 58.6962f, nullptr }, - { -237.627f, -84.7628f, 63.982f, nullptr }, - { -226.054f, -92.6308f, 75.1362f, nullptr }, - { -205.464f, -114.337f, 78.6167f, nullptr }, +BattleBotPath vPath_AV_Iceblood_Garrison_to_Snowfall_Flag = { + {-492.17f, -187.077f, 57.1342f, nullptr}, {-478.362f, -193.882f, 55.0986f, nullptr}, + {-463.702f, -196.051f, 48.5213f, nullptr}, {-456.512f, -196.217f, 43.158f, nullptr}, + {-429.951f, -198.515f, 26.8893f, nullptr}, {-412.975f, -190.921f, 25.7659f, nullptr}, + {-387.531f, -186.251f, 15.2001f, nullptr}, {-370.088f, -186.351f, 12.8474f, nullptr}, + {-353.23f, -179.161f, 10.3823f, nullptr}, {-319.906f, -162.842f, 9.26139f, nullptr}, + {-316.616f, -151.198f, 10.5439f, nullptr}, {-307.702f, -133.042f, 14.3502f, nullptr}, + {-293.423f, -117.684f, 19.8246f, nullptr}, {-274.446f, -97.1283f, 40.3783f, nullptr}, + {-256.993f, -83.0377f, 54.9012f, nullptr}, {-249.129f, -80.3578f, 58.6962f, nullptr}, + {-237.627f, -84.7628f, 63.982f, nullptr}, {-226.054f, -92.6308f, 75.1362f, nullptr}, + {-205.464f, -114.337f, 78.6167f, nullptr}, }; -BattleBotPath vPath_AV_Iceblood_Graveyard_to_Iceblood_Graveyard_Flag = -{ - { -536.289f, -397.294f, 49.7357f, nullptr }, - { -549.254f, -386.331f, 50.1129f, nullptr }, - { -558.918f, -388.345f, 50.7527f, nullptr }, - { -571.161f, -397.302f, 52.6324f, nullptr }, - { -590.297f, -409.179f, 56.239f, nullptr }, - { -602.969f, -411.808f, 59.1209f, nullptr }, - { -613.748f, -407.195f, 59.6702f, nullptr }, - { -614.138f, -396.501f, 60.8585f, nullptr }, +BattleBotPath vPath_AV_Iceblood_Graveyard_to_Iceblood_Graveyard_Flag = { + {-536.289f, -397.294f, 49.7357f, nullptr}, {-549.254f, -386.331f, 50.1129f, nullptr}, + {-558.918f, -388.345f, 50.7527f, nullptr}, {-571.161f, -397.302f, 52.6324f, nullptr}, + {-590.297f, -409.179f, 56.239f, nullptr}, {-602.969f, -411.808f, 59.1209f, nullptr}, + {-613.748f, -407.195f, 59.6702f, nullptr}, {-614.138f, -396.501f, 60.8585f, nullptr}, }; -BattleBotPath vPath_AV_Iceblood_Graveyard_to_Iceblood_Tower_Crossroad = -{ - { -536.599f, -373.801f, 49.599f, nullptr }, - { -527.204f, -355.746f, 37.897f, nullptr }, - { -514.888f, -345.189f, 33.675f, nullptr }, - { -579.697f, -315.037f, 46.345f, nullptr }, +BattleBotPath vPath_AV_Iceblood_Graveyard_to_Iceblood_Tower_Crossroad = { + {-536.599f, -373.801f, 49.599f, nullptr}, + {-527.204f, -355.746f, 37.897f, nullptr}, + {-514.888f, -345.189f, 33.675f, nullptr}, + {-579.697f, -315.037f, 46.345f, nullptr}, }; -BattleBotPath vPath_AV_Iceblood_Tower_Crossroad_to_Field_of_Strife_Stoneheart_Snowfall_Crossroad = -{ - { -579.697f, -315.037f, 46.345f, nullptr }, - { -572.416f, -317.133f, 43.9943f, nullptr }, - { -559.201f, -326.073f, 39.5171f, nullptr }, - { -544.32f, -335.203f, 37.6494f, nullptr }, - { -520.032f, -342.158f, 34.3473f, nullptr }, - { -486.033f, -344.504f, 29.4772f, nullptr }, - { -462.603f, -340.414f, 31.3555f, nullptr }, - { -455.422f, -336.249f, 30.5176f, nullptr }, - { -450.551f, -332.547f, 25.4498f, nullptr }, - { -440.977f, -326.828f, 18.9782f, nullptr }, - { -421.08f, -321.656f, 17.7909f, nullptr }, - { -398.601f, -318.181f, 18.5789f, nullptr }, - { -387.651f, -312.289f, 21.504f, nullptr }, - { -360.257f, -299.908f, 9.75685f, nullptr }, - { -294.669f, -283.616f, 6.66756f, nullptr }, - { -244.919f, -272.52f, 6.66754f, nullptr }, - { -206.645f, -264.661f, 6.66755f, nullptr }, - { -171.291f, -266.565f, 9.06823f, nullptr }, - { -147.596f, -253.494f, 6.78363f, nullptr }, +BattleBotPath vPath_AV_Iceblood_Tower_Crossroad_to_Field_of_Strife_Stoneheart_Snowfall_Crossroad = { + {-579.697f, -315.037f, 46.345f, nullptr}, {-572.416f, -317.133f, 43.9943f, nullptr}, + {-559.201f, -326.073f, 39.5171f, nullptr}, {-544.32f, -335.203f, 37.6494f, nullptr}, + {-520.032f, -342.158f, 34.3473f, nullptr}, {-486.033f, -344.504f, 29.4772f, nullptr}, + {-462.603f, -340.414f, 31.3555f, nullptr}, {-455.422f, -336.249f, 30.5176f, nullptr}, + {-450.551f, -332.547f, 25.4498f, nullptr}, {-440.977f, -326.828f, 18.9782f, nullptr}, + {-421.08f, -321.656f, 17.7909f, nullptr}, {-398.601f, -318.181f, 18.5789f, nullptr}, + {-387.651f, -312.289f, 21.504f, nullptr}, {-360.257f, -299.908f, 9.75685f, nullptr}, + {-294.669f, -283.616f, 6.66756f, nullptr}, {-244.919f, -272.52f, 6.66754f, nullptr}, + {-206.645f, -264.661f, 6.66755f, nullptr}, {-171.291f, -266.565f, 9.06823f, nullptr}, + {-147.596f, -253.494f, 6.78363f, nullptr}, }; -BattleBotPath vPath_AV_Iceblood_Tower_Crossroad_to_Stoneheart_Bunker = -{ - { -579.697f, -315.037f, 46.345f, nullptr }, - { -522.484f, -343.483f, 34.589f, nullptr }, - { -487.608f, -349.201f, 28.785f, nullptr }, - { -452.9f, -362.035f, 31.530f, nullptr }, - { -434.891f, -355.562f, 32.349f, nullptr }, - { -418.556f, -342.514f, 18.697f, nullptr }, - { -397.991f, -372.594f, 31.355f, nullptr }, - { -366.720f, -394.493f, 10.211f, nullptr }, - { -322.537f, -404.822f, 10.162f, nullptr }, - { -290.379f, -406.149f, 13.998f, nullptr }, - { -269.02f, -418.522f, 17.358f, nullptr }, - { -244.184f, -433.898f, 20.024f, nullptr }, - { -210.095f, -450.071f, 26.732f, nullptr }, - { -184.418f, -467.245f, 27.624f, nullptr }, - { -162.879f, -478.651f, 28.841f, nullptr }, - { -134.983f, -479.253f, 28.439f, nullptr }, +BattleBotPath vPath_AV_Iceblood_Tower_Crossroad_to_Stoneheart_Bunker = { + {-579.697f, -315.037f, 46.345f, nullptr}, {-522.484f, -343.483f, 34.589f, nullptr}, + {-487.608f, -349.201f, 28.785f, nullptr}, {-452.9f, -362.035f, 31.530f, nullptr}, + {-434.891f, -355.562f, 32.349f, nullptr}, {-418.556f, -342.514f, 18.697f, nullptr}, + {-397.991f, -372.594f, 31.355f, nullptr}, {-366.720f, -394.493f, 10.211f, nullptr}, + {-322.537f, -404.822f, 10.162f, nullptr}, {-290.379f, -406.149f, 13.998f, nullptr}, + {-269.02f, -418.522f, 17.358f, nullptr}, {-244.184f, -433.898f, 20.024f, nullptr}, + {-210.095f, -450.071f, 26.732f, nullptr}, {-184.418f, -467.245f, 27.624f, nullptr}, + {-162.879f, -478.651f, 28.841f, nullptr}, {-134.983f, -479.253f, 28.439f, nullptr}, //{ -104.292f, -455.243f, 22.3564f, nullptr}, }; -BattleBotPath vPath_AV_Snowfall_Flag_to_Field_of_Strife_Stoneheart_Snowfall_Crossroad = -{ - { -205.464f, -114.337f, 78.6167f, nullptr }, - { -196.784f, -127.119f, 78.1071f, nullptr }, - { -193.525f, -137.091f, 75.7275f, nullptr }, - { -180.605f, -153.454f, 63.4406f, nullptr }, - { -175.934f, -158.667f, 58.9224f, nullptr }, - { -169.015f, -173.639f, 46.3033f, nullptr }, - { -164.039f, -186.72f, 36.9312f, nullptr }, - { -159.523f, -203.286f, 27.413f, nullptr }, - { -154.95f, -220.108f, 16.6193f, nullptr }, - { -147.742f, -233.671f, 9.55408f, nullptr }, - { -134.536f, -243.891f, 7.96268f, nullptr }, - { -147.596f, -253.494f, 6.78363f, nullptr }, +BattleBotPath vPath_AV_Snowfall_Flag_to_Field_of_Strife_Stoneheart_Snowfall_Crossroad = { + {-205.464f, -114.337f, 78.6167f, nullptr}, {-196.784f, -127.119f, 78.1071f, nullptr}, + {-193.525f, -137.091f, 75.7275f, nullptr}, {-180.605f, -153.454f, 63.4406f, nullptr}, + {-175.934f, -158.667f, 58.9224f, nullptr}, {-169.015f, -173.639f, 46.3033f, nullptr}, + {-164.039f, -186.72f, 36.9312f, nullptr}, {-159.523f, -203.286f, 27.413f, nullptr}, + {-154.95f, -220.108f, 16.6193f, nullptr}, {-147.742f, -233.671f, 9.55408f, nullptr}, + {-134.536f, -243.891f, 7.96268f, nullptr}, {-147.596f, -253.494f, 6.78363f, nullptr}, }; -BattleBotPath vPath_AV_Field_of_Strife_Stoneheart_Snowfall_Crossroad_to_Stonehearth_Outpost = -{ - { -147.596f, -253.494f, 6.78363f, nullptr }, - { -119.031f, -245.732f, 9.12747f, nullptr }, - { -69.9914f, -241.707f, 8.7055f, nullptr }, - { -41.7233f, -231.875f, 10.2956f, nullptr }, - { -11.2685f, -237.666f, 10.7819f, nullptr }, - { 22.1935f, -244.842f, 14.09f, nullptr }, - { 33.7178f, -258.971f, 14.8231f, nullptr }, - { 29.4264f, -283.735f, 16.3003f, nullptr }, - { 28.1264f, -302.593f, 15.076f, nullptr }, +BattleBotPath vPath_AV_Field_of_Strife_Stoneheart_Snowfall_Crossroad_to_Stonehearth_Outpost = { + {-147.596f, -253.494f, 6.78363f, nullptr}, {-119.031f, -245.732f, 9.12747f, nullptr}, + {-69.9914f, -241.707f, 8.7055f, nullptr}, {-41.7233f, -231.875f, 10.2956f, nullptr}, + {-11.2685f, -237.666f, 10.7819f, nullptr}, {22.1935f, -244.842f, 14.09f, nullptr}, + {33.7178f, -258.971f, 14.8231f, nullptr}, {29.4264f, -283.735f, 16.3003f, nullptr}, + {28.1264f, -302.593f, 15.076f, nullptr}, }; -BattleBotPath vPath_AV_Stonehearth_Outpost_to_Captain_Balinda_Stonehearth = -{ - { 28.1264f, -302.593f, 15.076f, nullptr }, - { 19.509f, -300.648f, 14.02f, nullptr }, - { 11.9925f, -299.182f, 15.0127f, nullptr }, - { -2.23151f, -296.73f, 15.5632f, nullptr }, - { -20.1345f, -296.292f, 15.5632f, nullptr }, - { -25.8903f, -306.347f, 15.5632f, nullptr }, - { -31.9783f, -309.925f, 15.5632f, nullptr }, - { -46.5667f, -294.841f, 15.0786f, nullptr }, +BattleBotPath vPath_AV_Stonehearth_Outpost_to_Captain_Balinda_Stonehearth = { + {28.1264f, -302.593f, 15.076f, nullptr}, {19.509f, -300.648f, 14.02f, nullptr}, + {11.9925f, -299.182f, 15.0127f, nullptr}, {-2.23151f, -296.73f, 15.5632f, nullptr}, + {-20.1345f, -296.292f, 15.5632f, nullptr}, {-25.8903f, -306.347f, 15.5632f, nullptr}, + {-31.9783f, -309.925f, 15.5632f, nullptr}, {-46.5667f, -294.841f, 15.0786f, nullptr}, }; -BattleBotPath vPath_AV_Stonehearth_Outpost_to_Stonehearth_Bunker_First_Crossroad = -{ - { 28.1264f, -302.593f, 15.076f, nullptr }, - { 5.744f, -329.103f, 16.504f, nullptr }, - { -43.294f, -353.252f, 11.042f, nullptr }, - { -74.443f, -380.701f, 14.543f, nullptr }, - { -95.088f, -418.128f, 16.971f, nullptr }, - { -104.292f, -455.243f, 22.3564f, nullptr }, +BattleBotPath vPath_AV_Stonehearth_Outpost_to_Stonehearth_Bunker_First_Crossroad = { + {28.1264f, -302.593f, 15.076f, nullptr}, {5.744f, -329.103f, 16.504f, nullptr}, + {-43.294f, -353.252f, 11.042f, nullptr}, {-74.443f, -380.701f, 14.543f, nullptr}, + {-95.088f, -418.128f, 16.971f, nullptr}, {-104.292f, -455.243f, 22.3564f, nullptr}, }; -BattleBotPath vPath_AV_Stonehearth_Outpost_to_Stonehearth_Graveyard_Crossroad = -{ - { 28.1264f, -302.593f, 15.076f, nullptr }, - { 26.4279f, -302.732f, 14.7797f, nullptr }, - { 43.9172f, -312.202f, 18.0643f, nullptr }, - { 57.9471f, -317.071f, 25.175f, nullptr }, - { 82.0413f, -321.368f, 33.9446f, nullptr }, - { 102.051f, -333.675f, 39.3055f, nullptr }, - { 117.624f, -352.173f, 42.6668f, nullptr }, - { 121.462f, -367.206f, 43.1468f, nullptr }, - { 123.153f, -375.134f, 42.8991f, nullptr }, +BattleBotPath vPath_AV_Stonehearth_Outpost_to_Stonehearth_Graveyard_Crossroad = { + {28.1264f, -302.593f, 15.076f, nullptr}, {26.4279f, -302.732f, 14.7797f, nullptr}, + {43.9172f, -312.202f, 18.0643f, nullptr}, {57.9471f, -317.071f, 25.175f, nullptr}, + {82.0413f, -321.368f, 33.9446f, nullptr}, {102.051f, -333.675f, 39.3055f, nullptr}, + {117.624f, -352.173f, 42.6668f, nullptr}, {121.462f, -367.206f, 43.1468f, nullptr}, + {123.153f, -375.134f, 42.8991f, nullptr}, }; -BattleBotPath vPath_AV_Stonehearth_Graveyard_Crossroad_to_Stonehearth_Graveyard_Flag = -{ - { 123.153f, -375.134f, 42.8991f, nullptr }, - { 101.9f, -389.081f, 45.0974f, nullptr }, - { 89.1516f, -393.047f, 45.1475f, nullptr }, - { 79.8805f, -401.379f, 46.516f, nullptr }, +BattleBotPath vPath_AV_Stonehearth_Graveyard_Crossroad_to_Stonehearth_Graveyard_Flag = { + {123.153f, -375.134f, 42.8991f, nullptr}, + {101.9f, -389.081f, 45.0974f, nullptr}, + {89.1516f, -393.047f, 45.1475f, nullptr}, + {79.8805f, -401.379f, 46.516f, nullptr}, }; -BattleBotPath vPath_AV_Stonehearth_Graveyard_to_Stonehearth_Graveyard_Flag = -{ - { 73.8433f, -485.163f, 48.7233f, nullptr }, - { 74.4106f, -469.205f, 48.5722f, nullptr }, - { 74.0364f, -450.204f, 48.7063f, nullptr }, - { 73.3269f, -433.156f, 49.0149f, nullptr }, - { 73.6789f, -417.638f, 48.9345f, nullptr }, - { 79.8805f, -401.379f, 46.516f, nullptr }, +BattleBotPath vPath_AV_Stonehearth_Graveyard_to_Stonehearth_Graveyard_Flag = { + {73.8433f, -485.163f, 48.7233f, nullptr}, {74.4106f, -469.205f, 48.5722f, nullptr}, + {74.0364f, -450.204f, 48.7063f, nullptr}, {73.3269f, -433.156f, 49.0149f, nullptr}, + {73.6789f, -417.638f, 48.9345f, nullptr}, {79.8805f, -401.379f, 46.516f, nullptr}, }; -BattleBotPath vPath_AV_Stonehearth_Graveyard_Flag_to_Stonehearth_Graveyard_Second_Crossroad = -{ - { 79.8805f, -401.379f, 46.516f, nullptr }, - { 59.3904f, -396.459f, 46.3454f, nullptr }, - { 38.213f, -391.053f, 45.6625f, nullptr }, - { 18.563f, -398.416f, 45.6217f, nullptr }, - { -14.0184f, -419.609f, 44.4167f, nullptr }, +BattleBotPath vPath_AV_Stonehearth_Graveyard_Flag_to_Stonehearth_Graveyard_Second_Crossroad = { + {79.8805f, -401.379f, 46.516f, nullptr}, {59.3904f, -396.459f, 46.3454f, nullptr}, + {38.213f, -391.053f, 45.6625f, nullptr}, {18.563f, -398.416f, 45.6217f, nullptr}, + {-14.0184f, -419.609f, 44.4167f, nullptr}, }; -BattleBotPath vPath_AV_Stonehearth_Graveyard_Second_Crossroad_to_Stonehearth_Bunker_First_Crossroad = -{ - { -14.0184f, -419.609f, 44.4167f, nullptr }, - { -16.2311f, -430.739f, 45.9019f, nullptr }, - { -23.0513f, -442.558f, 46.1862f, nullptr }, - { -36.0353f, -454.259f, 45.1569f, nullptr }, - { -47.8724f, -462.469f, 41.2528f, nullptr }, - { -89.1045f, -457.978f, 24.1971f, nullptr }, - { -104.292f, -455.243f, 22.3564f, nullptr }, +BattleBotPath vPath_AV_Stonehearth_Graveyard_Second_Crossroad_to_Stonehearth_Bunker_First_Crossroad = { + {-14.0184f, -419.609f, 44.4167f, nullptr}, {-16.2311f, -430.739f, 45.9019f, nullptr}, + {-23.0513f, -442.558f, 46.1862f, nullptr}, {-36.0353f, -454.259f, 45.1569f, nullptr}, + {-47.8724f, -462.469f, 41.2528f, nullptr}, {-89.1045f, -457.978f, 24.1971f, nullptr}, + {-104.292f, -455.243f, 22.3564f, nullptr}, }; -BattleBotPath vPath_AV_Stonehearth_Graveyard_Second_Crossroad_to_Iceblood_Garrison = -{ - { -14.0184f, -419.609f, 44.4167f, nullptr }, - { -23.0625f, -414.929f, 39.5583f, nullptr }, - { -35.4078f, -408.859f, 30.7036f, nullptr }, - { -43.2854f, -396.271f, 21.1548f, nullptr }, - { -52.1465f, -377.477f, 13.6804f, nullptr }, - { -63.422f, -348.549f, 12.6189f, nullptr }, - { -70.7889f, -334.456f, 12.3143f, nullptr }, - { -87.3986f, -321.764f, 10.286f, nullptr }, - { -107.322f, -315.203f, 9.54238f, nullptr }, - { -127.844f, -310.833f, 13.4444f, nullptr }, - { -155.644f, -305.004f, 10.38f, nullptr }, - { -187.766f, -302.183f, 6.66806f, nullptr }, - { -227.675f, -300.517f, 6.66806f, nullptr }, - { -244.583f, -291.433f, 6.66806f, nullptr }, - { -265.603f, -272.943f, 6.66806f, nullptr }, - { -287.897f, -256.006f, 6.71878f, nullptr }, - { -310.325f, -239.243f, 11.8723f, nullptr }, - { -325.404f, -233.386f, 17.9203f, nullptr }, - { -345.71f, -232.887f, 12.1903f, nullptr }, - { -360.847f, -211.82f, 12.329f, nullptr }, - { -372.245f, -196.784f, 12.5248f, nullptr }, - { -391.209f, -185.399f, 15.9205f, nullptr }, - { -404.248f, -184.159f, 20.8763f, nullptr }, - { -425.522f, -195.322f, 26.2692f, nullptr }, - { -436.78f, -199.258f, 29.3854f, nullptr }, - { -464.585f, -196.566f, 49.1431f, nullptr }, - { -492.17f, -187.077f, 57.1342f, nullptr }, +BattleBotPath vPath_AV_Stonehearth_Graveyard_Second_Crossroad_to_Iceblood_Garrison = { + {-14.0184f, -419.609f, 44.4167f, nullptr}, {-23.0625f, -414.929f, 39.5583f, nullptr}, + {-35.4078f, -408.859f, 30.7036f, nullptr}, {-43.2854f, -396.271f, 21.1548f, nullptr}, + {-52.1465f, -377.477f, 13.6804f, nullptr}, {-63.422f, -348.549f, 12.6189f, nullptr}, + {-70.7889f, -334.456f, 12.3143f, nullptr}, {-87.3986f, -321.764f, 10.286f, nullptr}, + {-107.322f, -315.203f, 9.54238f, nullptr}, {-127.844f, -310.833f, 13.4444f, nullptr}, + {-155.644f, -305.004f, 10.38f, nullptr}, {-187.766f, -302.183f, 6.66806f, nullptr}, + {-227.675f, -300.517f, 6.66806f, nullptr}, {-244.583f, -291.433f, 6.66806f, nullptr}, + {-265.603f, -272.943f, 6.66806f, nullptr}, {-287.897f, -256.006f, 6.71878f, nullptr}, + {-310.325f, -239.243f, 11.8723f, nullptr}, {-325.404f, -233.386f, 17.9203f, nullptr}, + {-345.71f, -232.887f, 12.1903f, nullptr}, {-360.847f, -211.82f, 12.329f, nullptr}, + {-372.245f, -196.784f, 12.5248f, nullptr}, {-391.209f, -185.399f, 15.9205f, nullptr}, + {-404.248f, -184.159f, 20.8763f, nullptr}, {-425.522f, -195.322f, 26.2692f, nullptr}, + {-436.78f, -199.258f, 29.3854f, nullptr}, {-464.585f, -196.566f, 49.1431f, nullptr}, + {-492.17f, -187.077f, 57.1342f, nullptr}, }; -BattleBotPath vPath_AV_Stonehearth_Graveyard_Second_Crossroad_to_Iceblood_Tower_Crossroad = -{ - { -104.292f, -455.243f, 22.3564f, nullptr }, - { -95.7107f, -437.38f, 18.6408f, nullptr }, - { -96.426f, -395.254f, 14.7414f, nullptr }, - { -117.9f, -376.108f, 12.2937f, nullptr }, - { -170.065f, -344.859f, 10.1405f, nullptr }, - { -220.336f, -329.639f, 8.81655f, nullptr }, - { -273.738f, -342.925f, 6.66864f, nullptr }, - { -307.056f, -315.782f, 6.66756f, nullptr }, - { -329.567f, -296.801f, 6.66756f, nullptr }, - { -354.044f, -289.519f, 9.62051f, nullptr }, - { -384.954f, -283.819f, 12.0969f, nullptr }, - { -411.689f, -272.086f, 16.7252f, nullptr }, - { -432.235f, -273.793f, 20.6022f, nullptr }, - { -452.713f, -277.187f, 21.7067f, nullptr }, - { -489.158f, -284.974f, 28.429f, nullptr }, - { -499.066f, -302.407f, 31.48f, nullptr }, - { -505.393f, -314.896f, 31.9995f, nullptr }, - { -522.97f, -340.616f, 34.5491f, nullptr }, - { -542.124f, -333.426f, 37.6958f, nullptr }, - { -561.111f, -324.477f, 40.0344f, nullptr }, - { -579.697f, -315.037f, 46.345f, nullptr }, +BattleBotPath vPath_AV_Stonehearth_Graveyard_Second_Crossroad_to_Iceblood_Tower_Crossroad = { + {-104.292f, -455.243f, 22.3564f, nullptr}, {-95.7107f, -437.38f, 18.6408f, nullptr}, + {-96.426f, -395.254f, 14.7414f, nullptr}, {-117.9f, -376.108f, 12.2937f, nullptr}, + {-170.065f, -344.859f, 10.1405f, nullptr}, {-220.336f, -329.639f, 8.81655f, nullptr}, + {-273.738f, -342.925f, 6.66864f, nullptr}, {-307.056f, -315.782f, 6.66756f, nullptr}, + {-329.567f, -296.801f, 6.66756f, nullptr}, {-354.044f, -289.519f, 9.62051f, nullptr}, + {-384.954f, -283.819f, 12.0969f, nullptr}, {-411.689f, -272.086f, 16.7252f, nullptr}, + {-432.235f, -273.793f, 20.6022f, nullptr}, {-452.713f, -277.187f, 21.7067f, nullptr}, + {-489.158f, -284.974f, 28.429f, nullptr}, {-499.066f, -302.407f, 31.48f, nullptr}, + {-505.393f, -314.896f, 31.9995f, nullptr}, {-522.97f, -340.616f, 34.5491f, nullptr}, + {-542.124f, -333.426f, 37.6958f, nullptr}, {-561.111f, -324.477f, 40.0344f, nullptr}, + {-579.697f, -315.037f, 46.345f, nullptr}, }; -BattleBotPath vPath_AV_Stonehearth_Bunker_First_Crossroad_to_Stonehearth_Bunker_Flag = -{ - { -104.292f, -455.243f, 22.3564f, nullptr }, - { -111.899f, -466.777f, 24.0451f, nullptr }, - { -122.548f, -480.921f, 26.5748f, nullptr }, - { -133.831f, -478.232f, 28.1725f, nullptr }, - { -128.332f, -462.402f, 26.4943f, nullptr }, - { -156.579f, -449.815f, 29.0267f, nullptr }, - { -168.009f, -444.6f, 33.2796f, nullptr }, - { -160.378f, -440.192f, 33.2796f, nullptr }, - { -154.387f, -445.423f, 33.2796f, nullptr }, - { -159.655f, -458.512f, 40.395f, nullptr }, - { -165.724f, -454.853f, 40.403f, nullptr }, - { -165.652f, -447.139f, 40.403f, nullptr }, - { -161.038f, -440.504f, 40.403f, nullptr }, - { -153.491f, -441.386f, 40.3957f, nullptr }, +BattleBotPath vPath_AV_Stonehearth_Bunker_First_Crossroad_to_Stonehearth_Bunker_Flag = { + {-104.292f, -455.243f, 22.3564f, nullptr}, {-111.899f, -466.777f, 24.0451f, nullptr}, + {-122.548f, -480.921f, 26.5748f, nullptr}, {-133.831f, -478.232f, 28.1725f, nullptr}, + {-128.332f, -462.402f, 26.4943f, nullptr}, {-156.579f, -449.815f, 29.0267f, nullptr}, + {-168.009f, -444.6f, 33.2796f, nullptr}, {-160.378f, -440.192f, 33.2796f, nullptr}, + {-154.387f, -445.423f, 33.2796f, nullptr}, {-159.655f, -458.512f, 40.395f, nullptr}, + {-165.724f, -454.853f, 40.403f, nullptr}, {-165.652f, -447.139f, 40.403f, nullptr}, + {-161.038f, -440.504f, 40.403f, nullptr}, {-153.491f, -441.386f, 40.3957f, nullptr}, }; -BattleBotPath vPath_AV_Stonehearth_Graveyard_Crossroad_to_Icewing_Bunker_Crossroad = -{ - { 123.153f, -375.134f, 42.8991f, nullptr }, - { 132.848f, -385.475f, 42.2487f, nullptr }, - { 147.934f, -393.887f, 42.6617f, nullptr }, - { 170.279f, -400.056f, 42.802f, nullptr }, - { 209.274f, -410.47f, 42.15f, nullptr }, - { 232.206f, -406.171f, 41.2464f, nullptr }, +BattleBotPath vPath_AV_Stonehearth_Graveyard_Crossroad_to_Icewing_Bunker_Crossroad = { + {123.153f, -375.134f, 42.8991f, nullptr}, {132.848f, -385.475f, 42.2487f, nullptr}, + {147.934f, -393.887f, 42.6617f, nullptr}, {170.279f, -400.056f, 42.802f, nullptr}, + {209.274f, -410.47f, 42.15f, nullptr}, {232.206f, -406.171f, 41.2464f, nullptr}, }; -BattleBotPath vPath_AV_Icewing_Bunker_Crossroad_to_Icewing_Bunker_Flag = -{ - { 232.206f, -406.171f, 41.2464f, nullptr }, - { 232.415f, -399.32f, 43.0377f, nullptr }, - { 241.705f, -378.726f, 43.2973f, nullptr }, - { 243.685f, -361.498f, 43.2563f, nullptr }, - { 233.604f, -348.561f, 42.4664f, nullptr }, - { 208.557f, -367.638f, 44.8858f, nullptr }, - { 199.002f, -374.949f, 49.2678f, nullptr }, - { 197.929f, -366.972f, 49.2678f, nullptr }, - { 204.639f, -363.321f, 49.2678f, nullptr }, - { 214.635f, -374.753f, 56.3819f, nullptr }, - { 206.689f, -377.633f, 56.3917f, nullptr }, - { 199.606f, -370.834f, 56.3917f, nullptr }, - { 200.792f, -361.881f, 56.3798f, nullptr }, +BattleBotPath vPath_AV_Icewing_Bunker_Crossroad_to_Icewing_Bunker_Flag = { + {232.206f, -406.171f, 41.2464f, nullptr}, {232.415f, -399.32f, 43.0377f, nullptr}, + {241.705f, -378.726f, 43.2973f, nullptr}, {243.685f, -361.498f, 43.2563f, nullptr}, + {233.604f, -348.561f, 42.4664f, nullptr}, {208.557f, -367.638f, 44.8858f, nullptr}, + {199.002f, -374.949f, 49.2678f, nullptr}, {197.929f, -366.972f, 49.2678f, nullptr}, + {204.639f, -363.321f, 49.2678f, nullptr}, {214.635f, -374.753f, 56.3819f, nullptr}, + {206.689f, -377.633f, 56.3917f, nullptr}, {199.606f, -370.834f, 56.3917f, nullptr}, + {200.792f, -361.881f, 56.3798f, nullptr}, }; -BattleBotPath vPath_AV_Icewing_Bunker_Crossroad_to_Alliance_Slope_Crossroad = -{ - { 232.206f, -406.171f, 41.2464f, nullptr }, - { 245.764f, -414.729f, 34.8094f, nullptr }, - { 260.329f, -406.891f, 26.2452f, nullptr }, - { 277.874f, -393.876f, 11.3203f, nullptr }, - { 292.624f, -385.478f, 3.80607f, nullptr }, - { 315.119f, -384.083f, -0.803525f, nullptr }, - { 352.975f, -389.716f, -0.510339f, nullptr }, - { 383.883f, -393.12f, -1.07409f, nullptr }, - { 401.915f, -389.568f, -1.24385f, nullptr }, +BattleBotPath vPath_AV_Icewing_Bunker_Crossroad_to_Alliance_Slope_Crossroad = { + {232.206f, -406.171f, 41.2464f, nullptr}, {245.764f, -414.729f, 34.8094f, nullptr}, + {260.329f, -406.891f, 26.2452f, nullptr}, {277.874f, -393.876f, 11.3203f, nullptr}, + {292.624f, -385.478f, 3.80607f, nullptr}, {315.119f, -384.083f, -0.803525f, nullptr}, + {352.975f, -389.716f, -0.510339f, nullptr}, {383.883f, -393.12f, -1.07409f, nullptr}, + {401.915f, -389.568f, -1.24385f, nullptr}, }; -BattleBotPath vPath_AV_Alliance_Slope_Crossroad_to_Stormpike_Crossroad = -{ - { 401.915f, -389.568f, -1.24385f, nullptr }, - { 411.259f, -385.402f, -1.24337f, nullptr }, - { 424.079f, -380.069f, -1.24337f, nullptr }, - { 462.535f, -368.534f, -1.24387f, nullptr }, - { 508.895f, -330.261f, -1.08467f, nullptr }, - { 517.577f, -324.732f, -1.03504f, nullptr }, - { 536.967f, -321.273f, 3.75218f, nullptr }, - { 557.529f, -324.368f, 15.726f, nullptr }, - { 578.914f, -330.968f, 28.2467f, nullptr }, - { 597.588f, -336.744f, 30.2853f, nullptr }, - { 608.74f, -333.816f, 30.5787f, nullptr }, - { 621.331f, -324.856f, 30.1337f, nullptr }, - { 629.341f, -313.696f, 30.1337f, nullptr }, - { 638.087f, -287.84f, 30.1471f, nullptr }, +BattleBotPath vPath_AV_Alliance_Slope_Crossroad_to_Stormpike_Crossroad = { + {401.915f, -389.568f, -1.24385f, nullptr}, {411.259f, -385.402f, -1.24337f, nullptr}, + {424.079f, -380.069f, -1.24337f, nullptr}, {462.535f, -368.534f, -1.24387f, nullptr}, + {508.895f, -330.261f, -1.08467f, nullptr}, {517.577f, -324.732f, -1.03504f, nullptr}, + {536.967f, -321.273f, 3.75218f, nullptr}, {557.529f, -324.368f, 15.726f, nullptr}, + {578.914f, -330.968f, 28.2467f, nullptr}, {597.588f, -336.744f, 30.2853f, nullptr}, + {608.74f, -333.816f, 30.5787f, nullptr}, {621.331f, -324.856f, 30.1337f, nullptr}, + {629.341f, -313.696f, 30.1337f, nullptr}, {638.087f, -287.84f, 30.1471f, nullptr}, }; -BattleBotPath vPath_AV_Stormpike_Crossroad_to_Alliance_Base_Bunker_First_Crossroad = -{ - { 638.087f, -287.84f, 30.1471f, nullptr }, - { 635.381f, -271.761f, 30.1326f, nullptr }, - { 633.779f, -257.854f, 33.1093f, nullptr }, - { 631.23f, -233.502f, 37.2848f, nullptr }, - { 625.312f, -191.934f, 38.782f, nullptr }, - { 622.182f, -167.638f, 36.3214f, nullptr }, - { 619.956f, -150.28f, 33.3684f, nullptr }, - { 620.254f, -135.032f, 33.4412f, nullptr }, - { 629.777f, -99.9175f, 40.6453f, nullptr }, +BattleBotPath vPath_AV_Stormpike_Crossroad_to_Alliance_Base_Bunker_First_Crossroad = { + {638.087f, -287.84f, 30.1471f, nullptr}, {635.381f, -271.761f, 30.1326f, nullptr}, + {633.779f, -257.854f, 33.1093f, nullptr}, {631.23f, -233.502f, 37.2848f, nullptr}, + {625.312f, -191.934f, 38.782f, nullptr}, {622.182f, -167.638f, 36.3214f, nullptr}, + {619.956f, -150.28f, 33.3684f, nullptr}, {620.254f, -135.032f, 33.4412f, nullptr}, + {629.777f, -99.9175f, 40.6453f, nullptr}, }; -BattleBotPath vPath_AV_Alliance_Base_Bunker_First_Crossroad_to_Alliance_Base_North_Bunker = -{ - { 629.777f, -99.9175f, 40.6453f, nullptr }, - { 635.309f, -97.7424f, 41.9851f, nullptr }, - { 642.07f, -93.7443f, 46.1184f, nullptr }, - { 659.709f, -104.838f, 51.5034f, nullptr }, - { 654.41f, -118.753f, 49.7697f, nullptr }, - { 661.432f, -124.145f, 49.6422f, nullptr }, - { 679.011f, -135.631f, 51.9985f, nullptr }, - { 689.794f, -142.705f, 56.5425f, nullptr }, - { 683.375f, -145.993f, 56.5425f, nullptr }, - { 676.456f, -140.675f, 56.5425f, nullptr }, - { 684.145f, -127.197f, 63.6535f, nullptr }, - { 678.008f, -125.249f, 63.6667f, nullptr }, - { 671.246f, -128.806f, 63.665f, nullptr }, - { 669.384f, -135.545f, 63.6574f, nullptr }, - { 672.685f, -142.49f, 63.6571f, nullptr }, +BattleBotPath vPath_AV_Alliance_Base_Bunker_First_Crossroad_to_Alliance_Base_North_Bunker = { + {629.777f, -99.9175f, 40.6453f, nullptr}, {635.309f, -97.7424f, 41.9851f, nullptr}, + {642.07f, -93.7443f, 46.1184f, nullptr}, {659.709f, -104.838f, 51.5034f, nullptr}, + {654.41f, -118.753f, 49.7697f, nullptr}, {661.432f, -124.145f, 49.6422f, nullptr}, + {679.011f, -135.631f, 51.9985f, nullptr}, {689.794f, -142.705f, 56.5425f, nullptr}, + {683.375f, -145.993f, 56.5425f, nullptr}, {676.456f, -140.675f, 56.5425f, nullptr}, + {684.145f, -127.197f, 63.6535f, nullptr}, {678.008f, -125.249f, 63.6667f, nullptr}, + {671.246f, -128.806f, 63.665f, nullptr}, {669.384f, -135.545f, 63.6574f, nullptr}, + {672.685f, -142.49f, 63.6571f, nullptr}, }; -BattleBotPath vPath_AV_Alliance_Base_Bunker_First_Crossroad_to_Alliance_Base_Bunker_Second_Crossroad = -{ - { 629.777f, -99.9175f, 40.6453f, nullptr }, - { 633.117f, -67.768f, 41.3917f, nullptr }, +BattleBotPath vPath_AV_Alliance_Base_Bunker_First_Crossroad_to_Alliance_Base_Bunker_Second_Crossroad = { + {629.777f, -99.9175f, 40.6453f, nullptr}, + {633.117f, -67.768f, 41.3917f, nullptr}, }; -BattleBotPath vPath_AV_Alliance_Base_Bunker_Second_Crossroad_to_Alliance_Base_South_Bunker = -{ - { 633.117f, -67.768f, 41.3917f, nullptr }, - { 624.951f, -67.4683f, 40.4152f, nullptr }, - { 616.973f, -73.0334f, 38.8073f, nullptr }, - { 596.24f, -89.2897f, 38.855f, nullptr }, - { 591.941f, -86.7649f, 39.5782f, nullptr }, - { 585.983f, -74.2185f, 38.0143f, nullptr }, - { 557.244f, -87.113f, 40.4615f, nullptr }, - { 546.247f, -91.6955f, 44.8191f, nullptr }, - { 548.186f, -82.8881f, 44.8191f, nullptr }, - { 555.216f, -83.2067f, 44.8191f, nullptr }, - { 561.528f, -94.9507f, 51.9364f, nullptr }, - { 567.204f, -90.1402f, 51.9291f, nullptr }, - { 566.935f, -81.8903f, 51.9429f, nullptr }, - { 560.568f, -77.4604f, 51.9305f, nullptr }, - { 555.018f, -77.9842f, 51.9347f, nullptr }, +BattleBotPath vPath_AV_Alliance_Base_Bunker_Second_Crossroad_to_Alliance_Base_South_Bunker = { + {633.117f, -67.768f, 41.3917f, nullptr}, {624.951f, -67.4683f, 40.4152f, nullptr}, + {616.973f, -73.0334f, 38.8073f, nullptr}, {596.24f, -89.2897f, 38.855f, nullptr}, + {591.941f, -86.7649f, 39.5782f, nullptr}, {585.983f, -74.2185f, 38.0143f, nullptr}, + {557.244f, -87.113f, 40.4615f, nullptr}, {546.247f, -91.6955f, 44.8191f, nullptr}, + {548.186f, -82.8881f, 44.8191f, nullptr}, {555.216f, -83.2067f, 44.8191f, nullptr}, + {561.528f, -94.9507f, 51.9364f, nullptr}, {567.204f, -90.1402f, 51.9291f, nullptr}, + {566.935f, -81.8903f, 51.9429f, nullptr}, {560.568f, -77.4604f, 51.9305f, nullptr}, + {555.018f, -77.9842f, 51.9347f, nullptr}, }; -BattleBotPath vPath_AV_Alliance_Base_Bunker_Second_Crossroad_to_Alliance_Base_Bunker_Third_Crossroad = -{ - { 633.117f, -67.768f, 41.3917f, nullptr }, - { 635.133f, -51.7416f, 42.3031f, nullptr }, - { 648.593f, -33.8686f, 47.1592f, nullptr }, +BattleBotPath vPath_AV_Alliance_Base_Bunker_Second_Crossroad_to_Alliance_Base_Bunker_Third_Crossroad = { + {633.117f, -67.768f, 41.3917f, nullptr}, + {635.133f, -51.7416f, 42.3031f, nullptr}, + {648.593f, -33.8686f, 47.1592f, nullptr}, }; -BattleBotPath vPath_AV_Alliance_Base_Bunker_Third_Crossroad_to_Alliance_Base_Flag = -{ - { 648.593f, -33.8686f, 47.1592f, nullptr }, - { 640.404f, -32.0183f, 46.2328f, nullptr }, +BattleBotPath vPath_AV_Alliance_Base_Bunker_Third_Crossroad_to_Alliance_Base_Flag = { + {648.593f, -33.8686f, 47.1592f, nullptr}, + {640.404f, -32.0183f, 46.2328f, nullptr}, }; -BattleBotPath vPath_AV_Alliance_Base_Bunker_Third_Crossroad_to_Alliance_Base_Vanndar_Stormpike = -{ - { 648.593f, -33.8686f, 47.1592f, nullptr }, - { 664.325f, -28.0147f, 50.6198f, nullptr }, - { 690.605f, -20.6846f, 50.6198f, nullptr }, - { 696.331f, -27.5629f, 50.6198f, nullptr }, - { 699.006f, -31.7397f, 50.6198f, nullptr }, - { 704.958f, -34.5659f, 50.6198f, nullptr }, - { 717.709f, -16.6861f, 50.1354f, nullptr }, +BattleBotPath vPath_AV_Alliance_Base_Bunker_Third_Crossroad_to_Alliance_Base_Vanndar_Stormpike = { + {648.593f, -33.8686f, 47.1592f, nullptr}, {664.325f, -28.0147f, 50.6198f, nullptr}, + {690.605f, -20.6846f, 50.6198f, nullptr}, {696.331f, -27.5629f, 50.6198f, nullptr}, + {699.006f, -31.7397f, 50.6198f, nullptr}, {704.958f, -34.5659f, 50.6198f, nullptr}, + {717.709f, -16.6861f, 50.1354f, nullptr}, }; -BattleBotPath vPath_AV_Stormpike_Crossroad_to_Stormpike_Flag = -{ - { 638.087f, -287.84f, 30.1471f, nullptr }, - { 667.173f, -295.225f, 30.29f, nullptr }, +BattleBotPath vPath_AV_Stormpike_Crossroad_to_Stormpike_Flag = { + {638.087f, -287.84f, 30.1471f, nullptr}, + {667.173f, -295.225f, 30.29f, nullptr}, }; -BattleBotPath vPath_AV_Stormpike_Crossroad_to_Irontooth_Mine_Entrance = -{ - { 638.087f, -287.84f, 30.1471f, nullptr }, - { 665.708f, -283.570f, 29.187f, nullptr }, - { 685.958f, -274.358f, 23.618f, nullptr }, - { 701.911f, -271.504f, 28.409f, nullptr }, - { 715.155f, -276.190f, 36.108f, nullptr }, - { 727.653f, -288.440f, 43.433f, nullptr }, - { 742.260f, -305.039f, 51.649f, nullptr }, - { 753.219f, -314.030f, 56.008f, nullptr }, +BattleBotPath vPath_AV_Stormpike_Crossroad_to_Irontooth_Mine_Entrance = { + {638.087f, -287.84f, 30.1471f, nullptr}, {665.708f, -283.570f, 29.187f, nullptr}, + {685.958f, -274.358f, 23.618f, nullptr}, {701.911f, -271.504f, 28.409f, nullptr}, + {715.155f, -276.190f, 36.108f, nullptr}, {727.653f, -288.440f, 43.433f, nullptr}, + {742.260f, -305.039f, 51.649f, nullptr}, {753.219f, -314.030f, 56.008f, nullptr}, }; -BattleBotPath vPath_AV_Irontooth_Mine_Entrance_to_Irontooth_Mine_Boss = -{ - { 753.219f, -314.030f, 56.008f, nullptr }, - { 772.425f, -310.607f, 54.891f, nullptr }, - { 789.429f, -308.122f, 54.883f, nullptr }, - { 803.955f, -324.896f, 52.259f, nullptr }, - { 820.946f, -341.782f, 49.227f, nullptr }, - { 831.603f, -351.672f, 47.041f, nullptr }, - { 836.755f, -369.026f, 48.233f, nullptr }, - { 827.558f, -386.418f, 47.731f, nullptr }, - { 827.334f, -407.188f, 48.293f, nullptr }, - { 842.166f, -413.971f, 47.832f, nullptr }, - { 861.532f, -422.612f, 51.013f, nullptr }, - { 870.832f, -436.016f, 51.130f, nullptr }, - { 881.273f, -442.002f, 54.664f, nullptr }, +BattleBotPath vPath_AV_Irontooth_Mine_Entrance_to_Irontooth_Mine_Boss = { + {753.219f, -314.030f, 56.008f, nullptr}, {772.425f, -310.607f, 54.891f, nullptr}, + {789.429f, -308.122f, 54.883f, nullptr}, {803.955f, -324.896f, 52.259f, nullptr}, + {820.946f, -341.782f, 49.227f, nullptr}, {831.603f, -351.672f, 47.041f, nullptr}, + {836.755f, -369.026f, 48.233f, nullptr}, {827.558f, -386.418f, 47.731f, nullptr}, + {827.334f, -407.188f, 48.293f, nullptr}, {842.166f, -413.971f, 47.832f, nullptr}, + {861.532f, -422.612f, 51.013f, nullptr}, {870.832f, -436.016f, 51.130f, nullptr}, + {881.273f, -442.002f, 54.664f, nullptr}, }; -BattleBotPath vPath_AV_Alliance_Cave_Slop_Crossroad_to_Alliance_Slope_Crossroad = -{ - { 450.8f, -434.864f, 30.5126f, nullptr }, - { 442.575f, -430.266f, 26.6539f, nullptr }, - { 422.36f, -412.85f, 12.285f, nullptr }, - { 401.915f, -389.568f, -1.24385f, nullptr }, +BattleBotPath vPath_AV_Alliance_Cave_Slop_Crossroad_to_Alliance_Slope_Crossroad = { + {450.8f, -434.864f, 30.5126f, nullptr}, + {442.575f, -430.266f, 26.6539f, nullptr}, + {422.36f, -412.85f, 12.285f, nullptr}, + {401.915f, -389.568f, -1.24385f, nullptr}, }; -BattleBotPath vPath_AV_Alliance_Cave_to_Alliance_Cave_Slop_Crossroad = -{ - { 769.016f, -491.165f, 97.7772f, nullptr }, - { 758.026f, -489.447f, 95.9521f, nullptr }, - { 742.169f, -480.684f, 85.9649f, nullptr }, - { 713.063f, -467.311f, 71.0884f, nullptr }, - { 694.957f, -434.171f, 62.8627f, nullptr }, - { 686.386f, -420.276f, 64.5562f, nullptr }, - { 650.413f, -401.791f, 67.9546f, nullptr }, - { 626.412f, -384.308f, 67.5032f, nullptr }, - { 608.756f, -385.851f, 66.5105f, nullptr }, - { 576.021f, -395.976f, 63.5599f, nullptr }, - { 546.555f, -397.812f, 52.655f, nullptr }, - { 514.201f, -416.131f, 42.4508f, nullptr }, - { 450.8f, -434.864f, 30.5126f, nullptr }, +BattleBotPath vPath_AV_Alliance_Cave_to_Alliance_Cave_Slop_Crossroad = { + {769.016f, -491.165f, 97.7772f, nullptr}, {758.026f, -489.447f, 95.9521f, nullptr}, + {742.169f, -480.684f, 85.9649f, nullptr}, {713.063f, -467.311f, 71.0884f, nullptr}, + {694.957f, -434.171f, 62.8627f, nullptr}, {686.386f, -420.276f, 64.5562f, nullptr}, + {650.413f, -401.791f, 67.9546f, nullptr}, {626.412f, -384.308f, 67.5032f, nullptr}, + {608.756f, -385.851f, 66.5105f, nullptr}, {576.021f, -395.976f, 63.5599f, nullptr}, + {546.555f, -397.812f, 52.655f, nullptr}, {514.201f, -416.131f, 42.4508f, nullptr}, + {450.8f, -434.864f, 30.5126f, nullptr}, }; -BattleBotPath vPath_AV_Frostdagger_Pass = -{ - { 28.1264f, -302.593f, 15.076f, nullptr }, - { 30.003f, -272.591f, 16.040f, nullptr }, - { 4.098f, -240.224f, 12.074f, nullptr }, - { -32.843f, -218.981f, 12.105f, nullptr }, - { -48.354f, -201.129f, 18.081f, nullptr }, - { -119.068f, -154.929f, 17.319f, nullptr }, - { -141.732f, -99.318f, 28.793f, nullptr }, - { -196.539f, -60.374f, 35.725f, nullptr }, - { -268.161f, -41.602f, 35.928f, nullptr }, - { -326.121f, -52.747f, 30.200f, nullptr }, - { -367.047f, -81.467f, 26.416f, nullptr }, +BattleBotPath vPath_AV_Frostdagger_Pass = { + {28.1264f, -302.593f, 15.076f, nullptr}, {30.003f, -272.591f, 16.040f, nullptr}, + {4.098f, -240.224f, 12.074f, nullptr}, {-32.843f, -218.981f, 12.105f, nullptr}, + {-48.354f, -201.129f, 18.081f, nullptr}, {-119.068f, -154.929f, 17.319f, nullptr}, + {-141.732f, -99.318f, 28.793f, nullptr}, {-196.539f, -60.374f, 35.725f, nullptr}, + {-268.161f, -41.602f, 35.928f, nullptr}, {-326.121f, -52.747f, 30.200f, nullptr}, + {-367.047f, -81.467f, 26.416f, nullptr}, }; -BattleBotPath vPath_AV_Frostdagger_Pass_Lower_to_Iceblood_Garrison = -{ - { -367.047f, -81.467f, 26.416f, nullptr }, - { -380.850f, -111.038f, 23.634f, nullptr }, - { -419.830f, -152.710f, 23.922f, nullptr }, - { -422.173f, -189.060f, 25.747f, nullptr }, - { -492.17f, -187.077f, 57.1342f, nullptr }, +BattleBotPath vPath_AV_Frostdagger_Pass_Lower_to_Iceblood_Garrison = { + {-367.047f, -81.467f, 26.416f, nullptr}, {-380.850f, -111.038f, 23.634f, nullptr}, + {-419.830f, -152.710f, 23.922f, nullptr}, {-422.173f, -189.060f, 25.747f, nullptr}, + {-492.17f, -187.077f, 57.1342f, nullptr}, }; // path that allows alliance to bypass the mid on way to horde captain -BattleBotPath vPath_AV_Icewing_Bunker_Crossroad_to_Frostdagger_Pass_Lower = -{ - //these are to cause bot to pick this when resurrecting at stonehearth (not really needed anymore as they get captain down in first wave since uneeded dismounting was fixed) - { 68.793f, -396.742f, 45.299f, nullptr }, - { 99.042f, -389.310f, 45.101f, nullptr }, - { 123.787f, -373.551f, 42.893f, nullptr }, - { 119.693f, -351.311f, 42.728f, nullptr }, - { 107.710f, -321.162f, 37.168f, nullptr }, - { 84.953f, -273.434f, 23.944f, nullptr }, - { 47.073f, -245.696f, 15.417f, nullptr }, - { 2.455f, -240.346f, 11.867f, nullptr }, - { -38.451f, -231.493f, 10.284f, nullptr }, - { -70.606f, -230.758f, 9.919f, nullptr }, - { -83.955f, -214.666f, 12.873f, nullptr }, - { -111.412f, -175.575f, 13.515f, nullptr }, - { -129.634f, -141.359f, 20.921f, nullptr }, - { -140.904f, -105.104f, 28.097f, nullptr }, - { -167.552f, -74.891f, 31.524f, nullptr }, - { -210.442f, -54.664f, 37.525f, nullptr }, - { -247.372f, -38.489f, 36.438f, nullptr }, - { -280.423f, -48.095f, 32.709f, nullptr }, - { -309.757f, -58.032f, 28.778f, nullptr }, - { -345.274f, -71.566f, 28.005f, nullptr }, +BattleBotPath vPath_AV_Icewing_Bunker_Crossroad_to_Frostdagger_Pass_Lower = { + // these are to cause bot to pick this when resurrecting at stonehearth (not really needed anymore as they get + // captain down in first wave since uneeded dismounting was fixed) + {68.793f, -396.742f, 45.299f, nullptr}, {99.042f, -389.310f, 45.101f, nullptr}, + {123.787f, -373.551f, 42.893f, nullptr}, {119.693f, -351.311f, 42.728f, nullptr}, + {107.710f, -321.162f, 37.168f, nullptr}, {84.953f, -273.434f, 23.944f, nullptr}, + {47.073f, -245.696f, 15.417f, nullptr}, {2.455f, -240.346f, 11.867f, nullptr}, + {-38.451f, -231.493f, 10.284f, nullptr}, {-70.606f, -230.758f, 9.919f, nullptr}, + {-83.955f, -214.666f, 12.873f, nullptr}, {-111.412f, -175.575f, 13.515f, nullptr}, + {-129.634f, -141.359f, 20.921f, nullptr}, {-140.904f, -105.104f, 28.097f, nullptr}, + {-167.552f, -74.891f, 31.524f, nullptr}, {-210.442f, -54.664f, 37.525f, nullptr}, + {-247.372f, -38.489f, 36.438f, nullptr}, {-280.423f, -48.095f, 32.709f, nullptr}, + {-309.757f, -58.032f, 28.778f, nullptr}, {-345.274f, -71.566f, 28.005f, nullptr}, }; // path for horde to get from cave to their own base (without this they try and do impossible climb into base) -BattleBotPath vPath_AV_Horde_Cave_to_Horde_Base_DrekThar = -{ - { -1361.209f, -529.061f, 52.447f, nullptr }, - { -1342.169f, -520.541f, 51.460f, nullptr }, - { -1312.566f, -504.299f, 51.962f, nullptr }, - { -1257.378f, -483.990f, 49.967f, nullptr }, - { -1203.739f, -470.903f, 53.064f, nullptr }, - { -1178.448f, -463.916f, 53.604f, nullptr }, - { -1145.804f, -442.760f, 56.724f, nullptr }, - { -1136.175f, -403.217f, 56.216f, nullptr }, - { -1134.374f, -381.372f, 54.052f, nullptr }, - { -1133.174f, -349.631f, 51.297f, nullptr }, - { -1162.345f, -352.746f, 51.798f, nullptr }, - { -1200.468f, -367.018f, 54.048f, nullptr }, - { -1245.986f, -361.634f, 59.862f, nullptr }, - { -1242.319f, -333.333f, 59.469f, nullptr }, - { -1218.883f, -301.577f, 68.204f, nullptr }, - { -1198.963f, -277.565f, 72.121f, nullptr }, - { -1202.834f, -256.893f, 72.455f, nullptr }, - { -1236.450f, -249.518f, 73.326f, nullptr }, - { -1249.806f, -261.023f, 73.298f, nullptr }, - { -1272.039f, -284.608f, 81.547f, nullptr }, - { -1287.808f, -289.069f, 89.560f, nullptr }, - { -1308.419f, -289.375f, 90.714f, nullptr }, - { -1321.996f, -289.660f, 90.585f, nullptr }, +BattleBotPath vPath_AV_Horde_Cave_to_Horde_Base_DrekThar = { + {-1361.209f, -529.061f, 52.447f, nullptr}, {-1342.169f, -520.541f, 51.460f, nullptr}, + {-1312.566f, -504.299f, 51.962f, nullptr}, {-1257.378f, -483.990f, 49.967f, nullptr}, + {-1203.739f, -470.903f, 53.064f, nullptr}, {-1178.448f, -463.916f, 53.604f, nullptr}, + {-1145.804f, -442.760f, 56.724f, nullptr}, {-1136.175f, -403.217f, 56.216f, nullptr}, + {-1134.374f, -381.372f, 54.052f, nullptr}, {-1133.174f, -349.631f, 51.297f, nullptr}, + {-1162.345f, -352.746f, 51.798f, nullptr}, {-1200.468f, -367.018f, 54.048f, nullptr}, + {-1245.986f, -361.634f, 59.862f, nullptr}, {-1242.319f, -333.333f, 59.469f, nullptr}, + {-1218.883f, -301.577f, 68.204f, nullptr}, {-1198.963f, -277.565f, 72.121f, nullptr}, + {-1202.834f, -256.893f, 72.455f, nullptr}, {-1236.450f, -249.518f, 73.326f, nullptr}, + {-1249.806f, -261.023f, 73.298f, nullptr}, {-1272.039f, -284.608f, 81.547f, nullptr}, + {-1287.808f, -289.069f, 89.560f, nullptr}, {-1308.419f, -289.375f, 90.714f, nullptr}, + {-1321.996f, -289.660f, 90.585f, nullptr}, }; -BattleBotPath vPath_EY_Horde_Spawn_to_Crossroad1Horde = -{ - { 1809.102f, 1540.854f, 1267.142f, nullptr }, - { 1832.335f, 1539.495f, 1256.417f, nullptr }, - { 1846.995f, 1539.792f, 1243.077f, nullptr }, - { 1846.243f, 1530.716f, 1238.477f, nullptr }, - { 1883.154f, 1532.143f, 1202.143f, nullptr }, - { 1941.452f, 1549.086f, 1176.700f, nullptr } +BattleBotPath vPath_EY_Horde_Spawn_to_Crossroad1Horde = { + {1809.102f, 1540.854f, 1267.142f, nullptr}, {1832.335f, 1539.495f, 1256.417f, nullptr}, + {1846.995f, 1539.792f, 1243.077f, nullptr}, {1846.243f, 1530.716f, 1238.477f, nullptr}, + {1883.154f, 1532.143f, 1202.143f, nullptr}, {1941.452f, 1549.086f, 1176.700f, nullptr}}; + +BattleBotPath vPath_EY_Horde_Crossroad1Horde_to_Crossroad2Horde = {{1951.647f, 1545.187f, 1174.831f, nullptr}, + {1992.266f, 1546.962f, 1169.816f, nullptr}, + {2045.865f, 1543.925f, 1163.759f, nullptr}}; + +BattleBotPath vPath_EY_Crossroad1Horde_to_Blood_Elf_Tower = {{1952.907f, 1539.857f, 1174.638f, nullptr}, + {2000.130f, 1508.182f, 1169.778f, nullptr}, + {2044.239f, 1483.860f, 1166.165f, nullptr}, + {2048.773f, 1389.578f, 1193.903f, nullptr}}; + +BattleBotPath vPath_EY_Crossroad1Horde_to_Fel_Reaver_Ruins = {{1944.301f, 1557.170f, 1176.370f, nullptr}, + {1992.953f, 1625.188f, 1173.616f, nullptr}, + {2040.421f, 1676.989f, 1177.079f, nullptr}, + {2045.527f, 1736.398f, 1189.661f, nullptr}}; + +BattleBotPath vPath_EY_Crossroad2Horde_to_Blood_Elf_Tower = {{2049.363f, 1532.337f, 1163.178f, nullptr}, + {2050.149f, 1484.721f, 1165.099f, nullptr}, + {2046.865f, 1423.937f, 1188.882f, nullptr}, + {2048.478f, 1389.491f, 1193.878f, nullptr}}; + +BattleBotPath vPath_EY_Crossroad2Horde_to_Fel_Reaver_Ruins = {{2052.267f, 1555.692f, 1163.147f, nullptr}, + {2047.684f, 1614.272f, 1165.397f, nullptr}, + {2045.993f, 1668.937f, 1174.978f, nullptr}, + {2044.286f, 1733.128f, 1189.739f, nullptr}}; + +BattleBotPath vPath_EY_Crossroad2Horde_to_Flag = {{2059.276f, 1546.143f, 1162.394f, nullptr}, + {2115.978f, 1559.244f, 1156.362f, nullptr}, + {2149.140f, 1556.570f, 1158.412f, nullptr}, + {2170.601f, 1567.113f, 1159.456f, nullptr}}; + +BattleBotPath vPath_EY_Alliance_Spawn_to_Crossroad1Alliance = { + {2502.110f, 1604.330f, 1260.750f, nullptr}, {2497.077f, 1596.198f, 1257.302f, nullptr}, + {2483.930f, 1597.062f, 1244.660f, nullptr}, {2486.549f, 1617.651f, 1225.837f, nullptr}, + {2449.150f, 1601.792f, 1201.552f, nullptr}, {2395.737f, 1588.287f, 1176.570f, nullptr}}; + +BattleBotPath vPath_EY_Alliance_Crossroad1Alliance_to_Crossroad2Alliance = { + {2380.262f, 1586.757f, 1173.567f, nullptr}, + {2333.956f, 1586.052f, 1169.873f, nullptr}, + {2291.210f, 1591.435f, 1166.048f, nullptr}, }; -BattleBotPath vPath_EY_Horde_Crossroad1Horde_to_Crossroad2Horde = -{ - { 1951.647f, 1545.187f, 1174.831f, nullptr }, - { 1992.266f, 1546.962f, 1169.816f, nullptr }, - { 2045.865f, 1543.925f, 1163.759f, nullptr } -}; +BattleBotPath vPath_EY_Crossroad1Alliance_to_Mage_Tower = {{2380.973f, 1593.445f, 1173.189f, nullptr}, + {2335.762f, 1621.922f, 1169.007f, nullptr}, + {2293.526f, 1643.972f, 1166.501f, nullptr}, + {2288.198f, 1688.568f, 1172.790f, nullptr}, + {2284.286f, 1737.889f, 1189.708f, nullptr}}; -BattleBotPath vPath_EY_Crossroad1Horde_to_Blood_Elf_Tower = -{ - { 1952.907f, 1539.857f, 1174.638f, nullptr }, - { 2000.130f, 1508.182f, 1169.778f, nullptr }, - { 2044.239f, 1483.860f, 1166.165f, nullptr }, - { 2048.773f, 1389.578f, 1193.903f, nullptr } -}; +BattleBotPath vPath_EY_Crossroad1Alliance_to_Draenei_Ruins = {{2388.687f, 1576.089f, 1175.975f, nullptr}, + {2354.921f, 1522.763f, 1176.060f, nullptr}, + {2300.056f, 1459.208f, 1184.181f, nullptr}, + {2289.880f, 1415.640f, 1196.755f, nullptr}, + {2279.870f, 1387.461f, 1195.003f, nullptr}}; -BattleBotPath vPath_EY_Crossroad1Horde_to_Fel_Reaver_Ruins = -{ - { 1944.301f, 1557.170f, 1176.370f, nullptr }, - { 1992.953f, 1625.188f, 1173.616f, nullptr }, - { 2040.421f, 1676.989f, 1177.079f, nullptr }, - { 2045.527f, 1736.398f, 1189.661f, nullptr } -}; +BattleBotPath vPath_EY_Crossroad2Alliance_to_Mage_Tower = {{2282.525f, 1597.721f, 1164.553f, nullptr}, + {2281.028f, 1651.310f, 1165.426f, nullptr}, + {2284.633f, 1736.082f, 1189.708f, nullptr}}; -BattleBotPath vPath_EY_Crossroad2Horde_to_Blood_Elf_Tower = -{ - { 2049.363f, 1532.337f, 1163.178f, nullptr }, - { 2050.149f, 1484.721f, 1165.099f, nullptr }, - { 2046.865f, 1423.937f, 1188.882f, nullptr }, - { 2048.478f, 1389.491f, 1193.878f, nullptr } -}; +BattleBotPath vPath_EY_Crossroad2Alliance_to_Draenei_Ruins = {{2282.487f, 1581.630f, 1165.318f, nullptr}, + {2284.728f, 1525.618f, 1170.812f, nullptr}, + {2287.697f, 1461.228f, 1183.450f, nullptr}, + {2290.861f, 1413.606f, 1197.115f, nullptr}}; -BattleBotPath vPath_EY_Crossroad2Horde_to_Fel_Reaver_Ruins = -{ - { 2052.267f, 1555.692f, 1163.147f, nullptr }, - { 2047.684f, 1614.272f, 1165.397f, nullptr }, - { 2045.993f, 1668.937f, 1174.978f, nullptr }, - { 2044.286f, 1733.128f, 1189.739f, nullptr } -}; +BattleBotPath vPath_EY_Crossroad2Alliance_to_Flag = {{2275.622f, 1586.123f, 1164.469f, nullptr}, + {2221.334f, 1575.123f, 1158.277f, nullptr}, + {2178.372f, 1572.144f, 1159.462f, nullptr}}; -BattleBotPath vPath_EY_Crossroad2Horde_to_Flag = -{ - { 2059.276f, 1546.143f, 1162.394f, nullptr }, - { 2115.978f, 1559.244f, 1156.362f, nullptr }, - { 2149.140f, 1556.570f, 1158.412f, nullptr }, - { 2170.601f, 1567.113f, 1159.456f, nullptr } -}; +BattleBotPath vPath_EY_Draenei_Ruins_to_Blood_Elf_Tower = { + {2287.925f, 1406.976f, 1197.004f, nullptr}, {2283.283f, 1454.769f, 1184.243f, nullptr}, + {2237.519f, 1398.161f, 1178.191f, nullptr}, {2173.150f, 1388.084f, 1170.185f, nullptr}, + {2105.039f, 1381.507f, 1162.911f, nullptr}, {2074.315f, 1404.387f, 1178.141f, nullptr}, + {2047.649f, 1411.681f, 1192.032f, nullptr}, {2049.197f, 1387.392f, 1193.799f, nullptr}}; -BattleBotPath vPath_EY_Alliance_Spawn_to_Crossroad1Alliance = -{ - { 2502.110f, 1604.330f, 1260.750f, nullptr }, - { 2497.077f, 1596.198f, 1257.302f, nullptr }, - { 2483.930f, 1597.062f, 1244.660f, nullptr }, - { 2486.549f, 1617.651f, 1225.837f, nullptr }, - { 2449.150f, 1601.792f, 1201.552f, nullptr }, - { 2395.737f, 1588.287f, 1176.570f, nullptr } -}; +BattleBotPath vPath_EY_Fel_Reaver_to_Mage_Tower = { + {2044.519f, 1726.113f, 1189.395f, nullptr}, {2045.408f, 1682.986f, 1177.574f, nullptr}, + {2097.595f, 1736.117f, 1170.419f, nullptr}, {2158.866f, 1746.998f, 1161.184f, nullptr}, + {2220.635f, 1757.837f, 1151.886f, nullptr}, {2249.922f, 1721.807f, 1161.550f, nullptr}, + {2281.021f, 1694.735f, 1174.020f, nullptr}, {2284.522f, 1728.234f, 1189.015f, nullptr}}; -BattleBotPath vPath_EY_Alliance_Crossroad1Alliance_to_Crossroad2Alliance = -{ - { 2380.262f, 1586.757f, 1173.567f, nullptr }, - { 2333.956f, 1586.052f, 1169.873f, nullptr }, - { 2291.210f, 1591.435f, 1166.048f, nullptr }, -}; - -BattleBotPath vPath_EY_Crossroad1Alliance_to_Mage_Tower = -{ - { 2380.973f, 1593.445f, 1173.189f, nullptr }, - { 2335.762f, 1621.922f, 1169.007f, nullptr }, - { 2293.526f, 1643.972f, 1166.501f, nullptr }, - { 2288.198f, 1688.568f, 1172.790f, nullptr }, - { 2284.286f, 1737.889f, 1189.708f, nullptr } -}; - -BattleBotPath vPath_EY_Crossroad1Alliance_to_Draenei_Ruins = -{ - { 2388.687f, 1576.089f, 1175.975f, nullptr }, - { 2354.921f, 1522.763f, 1176.060f, nullptr }, - { 2300.056f, 1459.208f, 1184.181f, nullptr }, - { 2289.880f, 1415.640f, 1196.755f, nullptr }, - { 2279.870f, 1387.461f, 1195.003f, nullptr } -}; - -BattleBotPath vPath_EY_Crossroad2Alliance_to_Mage_Tower = -{ - { 2282.525f, 1597.721f, 1164.553f, nullptr }, - { 2281.028f, 1651.310f, 1165.426f, nullptr }, - { 2284.633f, 1736.082f, 1189.708f, nullptr } -}; - -BattleBotPath vPath_EY_Crossroad2Alliance_to_Draenei_Ruins = -{ - { 2282.487f, 1581.630f, 1165.318f, nullptr }, - { 2284.728f, 1525.618f, 1170.812f, nullptr }, - { 2287.697f, 1461.228f, 1183.450f, nullptr }, - { 2290.861f, 1413.606f, 1197.115f, nullptr } -}; - -BattleBotPath vPath_EY_Crossroad2Alliance_to_Flag = -{ - { 2275.622f, 1586.123f, 1164.469f, nullptr }, - { 2221.334f, 1575.123f, 1158.277f, nullptr }, - { 2178.372f, 1572.144f, 1159.462f, nullptr } -}; - -BattleBotPath vPath_EY_Draenei_Ruins_to_Blood_Elf_Tower = -{ - { 2287.925f, 1406.976f, 1197.004f, nullptr }, - { 2283.283f, 1454.769f, 1184.243f, nullptr }, - { 2237.519f, 1398.161f, 1178.191f, nullptr }, - { 2173.150f, 1388.084f, 1170.185f, nullptr }, - { 2105.039f, 1381.507f, 1162.911f, nullptr }, - { 2074.315f, 1404.387f, 1178.141f, nullptr }, - { 2047.649f, 1411.681f, 1192.032f, nullptr }, - { 2049.197f, 1387.392f, 1193.799f, nullptr } -}; - -BattleBotPath vPath_EY_Fel_Reaver_to_Mage_Tower = -{ - { 2044.519f, 1726.113f, 1189.395f, nullptr }, - { 2045.408f, 1682.986f, 1177.574f, nullptr }, - { 2097.595f, 1736.117f, 1170.419f, nullptr }, - { 2158.866f, 1746.998f, 1161.184f, nullptr }, - { 2220.635f, 1757.837f, 1151.886f, nullptr }, - { 2249.922f, 1721.807f, 1161.550f, nullptr }, - { 2281.021f, 1694.735f, 1174.020f, nullptr }, - { 2284.522f, 1728.234f, 1189.015f, nullptr } -}; - -BattleBotPath vPath_IC_Ally_Keep_to_Ally_Front_Crossroad = -{ +BattleBotPath vPath_IC_Ally_Keep_to_Ally_Front_Crossroad = { //{ 351.652f, -834.837f, 48.916f, nullptr }, - { 434.768f, -833.976f, 46.090f, nullptr }, - { 506.782f, -828.594f, 24.313f, nullptr }, - { 524.955f, -799.002f, 19.498f, nullptr } + {434.768f, -833.976f, 46.090f, nullptr}, + {506.782f, -828.594f, 24.313f, nullptr}, + {524.955f, -799.002f, 19.498f, nullptr}}; + +BattleBotPath vPath_IC_Ally_Front_Crossroad_to_Workshop = { + {524.955f, -799.002f, 19.498f, nullptr}, {573.557f, -804.838f, 9.6291f, nullptr}, + {627.977f, -810.197f, 3.5154f, nullptr}, {681.501f, -805.208f, 3.1464f, nullptr}, + {721.905f, -797.917f, 4.5112f, nullptr}, {774.466f, -801.058f, 6.3428f, nullptr}}; + +BattleBotPath vPath_IC_Ally_Keep_to_Ally_Dock_Crossroad = {{434.768f, -833.976f, 46.090f, nullptr}, + {446.710f, -776.008f, 48.783f, nullptr}, + {463.745f, -742.368f, 48.584f, nullptr}, + {488.201f, -714.563f, 36.564f, nullptr}, + {525.923f, -666.880f, 25.425f, nullptr}}; + +BattleBotPath vPath_IC_Ally_Front_Crossroad_to_Ally_Dock_Crossroad = {{524.955f, -799.002f, 19.498f, nullptr}, + {542.225f, -745.142f, 18.348f, nullptr}, + {545.309f, -712.497f, 22.005f, nullptr}, + {538.678f, -748.361f, 18.261f, nullptr}, + {525.923f, -666.880f, 25.425f, nullptr}}; + +BattleBotPath vPath_IC_Lower_Graveyard_to_Lower_Graveyard_Crossroad = {{443.095f, -310.797f, 51.749f, nullptr}, + {462.733f, -323.587f, 48.706f, nullptr}, + {471.540f, -343.914f, 40.706f, nullptr}, + {475.622f, -360.728f, 34.384f, nullptr}, + {484.458f, -379.796f, 33.122f, nullptr}}; + +BattleBotPath vPath_IC_Lower_Graveyard_Crossroad_to_Ally_Docks_Crossroad = { + {484.458f, -379.796f, 33.122f, nullptr}, {509.786f, -380.592f, 33.122f, nullptr}, + {532.549f, -381.576f, 33.122f, nullptr}, {553.506f, -386.102f, 33.507f, nullptr}, + {580.533f, -398.536f, 33.416f, nullptr}, {605.112f, -409.843f, 33.121f, nullptr}, + {619.212f, -419.169f, 33.121f, nullptr}, {631.702f, -428.763f, 33.070f, nullptr}, + {648.483f, -444.714f, 28.629f, nullptr}}; + +BattleBotPath vPath_IC_Lower_Graveyard_Crossroad_to_Ally_Docks_Second_Crossroad = { + {484.458f, -379.796f, 33.122f, nullptr}, {470.771f, -394.789f, 33.112f, nullptr}, + {461.191f, -409.475f, 33.120f, nullptr}, {452.794f, -431.842f, 33.120f, nullptr}, + {452.794f, -456.896f, 33.658f, nullptr}, {453.279f, -481.742f, 33.052f, nullptr}, + {453.621f, -504.979f, 32.956f, nullptr}, {452.006f, -526.792f, 32.221f, nullptr}, + {453.150f, -548.212f, 29.133f, nullptr}, {455.224f, -571.323f, 26.119f, nullptr}, + {465.486f, -585.424f, 25.756f, nullptr}, {475.366f, -598.414f, 25.784f, nullptr}, + {477.702f, -605.757f, 25.714f, nullptr}}; + +BattleBotPath vPath_IC_Ally_Dock_Crossroad_to_Ally_Docks_Second_Crossroad = {{525.923f, -666.880f, 25.425f, nullptr}, + {497.190f, -630.709f, 25.626f, nullptr}, + {477.702f, -605.757f, 25.714f, nullptr}}; + +BattleBotPath vPath_IC_Ally_Docks_Second_Crossroad_to_Ally_Docks_Crossroad = {{477.702f, -605.757f, 25.714f, nullptr}, + {493.697f, -555.838f, 26.014f, nullptr}, + {522.939f, -525.199f, 26.014f, nullptr}, + {580.398f, -486.274f, 26.013f, nullptr}, + {650.132f, -445.811f, 28.503f, nullptr}}; + +BattleBotPath vPath_IC_Ally_Docks_Crossroad_to_Docks_Flag = {{650.132f, -445.811f, 28.503f, nullptr}, + {690.527f, -452.961f, 18.039f, nullptr}, + {706.813f, -430.003f, 13.797f, nullptr}, + {726.427f, -364.849f, 17.815f, nullptr}}; + +BattleBotPath vPath_IC_Docks_Graveyard_to_Docks_Flag = { + {638.142f, -283.782f, 11.512f, nullptr}, {655.760f, -284.433f, 13.220f, nullptr}, + {661.656f, -299.912f, 12.756f, nullptr}, {675.068f, -317.192f, 12.627f, nullptr}, + {692.712f, -323.866f, 12.686f, nullptr}, {712.968f, -341.285f, 13.350f, nullptr}, + {726.427f, -364.849f, 17.815f, nullptr}}; + +BattleBotPath vPath_IC_Ally_Keep_to_Quarry_Crossroad = { + {320.547f, -919.896f, 48.481f, nullptr}, {335.384f, -922.371f, 49.518f, nullptr}, + {353.471f, -920.316f, 48.660f, nullptr}, {353.305f, -958.823f, 47.665f, nullptr}, + {369.196f, -989.960f, 37.719f, nullptr}, {380.671f, -1023.51f, 29.369f, nullptr}}; + +BattleBotPath vPath_IC_Quarry_Crossroad_to_Quarry_Flag = { + {380.671f, -1023.51f, 29.369f, nullptr}, {361.584f, -1052.89f, 27.445f, nullptr}, + {341.853f, -1070.17f, 24.024f, nullptr}, {295.845f, -1075.22f, 16.164f, nullptr}, + {253.030f, -1094.06f, 4.1517f, nullptr}, {211.391f, -1121.80f, 1.9591f, nullptr}, + {187.836f, -1155.66f, 1.9749f, nullptr}, {221.193f, -1186.87f, 8.0247f, nullptr}, + {249.181f, -1162.09f, 16.687f, nullptr}}; + +BattleBotPath vPath_IC_Ally_Front_Crossroad_to_Hangar_First_Crossroad = {{524.955f, -799.002f, 19.498f, nullptr}, + {512.563f, -840.166f, 23.913f, nullptr}, + {513.418f, -877.726f, 26.333f, nullptr}, + {512.962f, -945.951f, 39.382f, nullptr}}; + +BattleBotPath vPath_IC_Ally_Keep_to_Hangar_First_Crossroad = {{434.768f, -833.976f, 46.090f, nullptr}, + {486.355f, -909.736f, 26.112f, nullptr}, + {512.962f, -945.951f, 39.382f, nullptr}}; + +BattleBotPath vPath_IC_Hangar_First_Crossroad_to_Hangar_Second_Crossroad = {{512.962f, -945.951f, 39.382f, nullptr}, + {499.525f, -985.850f, 47.659f, nullptr}, + {492.794f, -1016.36f, 49.834f, nullptr}, + {481.738f, -1052.67f, 60.190f, nullptr}}; + +BattleBotPath vPath_IC_Quarry_Crossroad_to_Hangar_Second_Crossroad = {{380.671f, -1023.51f, 29.369f, nullptr}, + {430.997f, -1021.72f, 31.021f, nullptr}, + {439.528f, -1044.88f, 41.827f, nullptr}, + {455.062f, -1060.67f, 67.209f, nullptr}, + {481.738f, -1052.67f, 60.190f, nullptr}}; + +BattleBotPath vPath_IC_Hangar_Second_Crossroad_to_Hangar_Flag = { + {508.945f, -1103.30f, 79.054f, nullptr}, {536.397f, -1145.79f, 95.478f, nullptr}, + {573.242f, -1138.19f, 109.26f, nullptr}, {609.051f, -1112.93f, 128.31f, nullptr}, + {645.569f, -1094.58f, 132.13f, nullptr}, {689.621f, -1068.33f, 132.87f, nullptr}, + {730.045f, -1042.67f, 133.03f, nullptr}, {755.322f, -1030.28f, 133.30f, nullptr}, + {801.685f, -1005.46f, 132.39f, nullptr}, {806.404f, -1001.709f, 132.382f, nullptr}}; + +BattleBotPath vPath_IC_Horde_Keep_to_Horde_Front_Crossroad = {{1128.646f, -763.221f, 48.385f, nullptr}, + {1091.273f, -763.619f, 42.352f, nullptr}, + {1032.825f, -763.024f, 30.420f, nullptr}, + {991.4235f, -807.672f, 21.788f, nullptr}}; + +BattleBotPath vPath_IC_Horde_Front_Crossroad_to_Horde_Hangar_Crossroad = {{991.4235f, -807.672f, 21.788f, nullptr}, + {999.1844f, -855.182f, 21.484f, nullptr}, + {1012.089f, -923.098f, 19.296f, nullptr}}; + +BattleBotPath vPath_IC_Horde_Keep_to_Horde_Hangar_Crossroad = {{1128.646f, -763.221f, 48.385f, nullptr}, + {1121.090f, -816.666f, 49.008f, nullptr}, + {1107.106f, -851.459f, 48.804f, nullptr}, + {1072.313f, -888.355f, 30.853f, nullptr}, + {1012.089f, -923.098f, 19.296f, nullptr}}; + +BattleBotPath vPath_IC_Horde_Hangar_Crossroad_to_Hangar_Flag = { + {1001.745f, -973.174f, 15.784f, nullptr}, {1015.437f, -1019.47f, 15.578f, nullptr}, + {1009.622f, -1067.78f, 15.777f, nullptr}, {988.0692f, -1113.32f, 18.254f, nullptr}, + {943.7221f, -1134.50f, 32.296f, nullptr}, {892.2205f, -1115.16f, 63.319f, nullptr}, + {849.6576f, -1090.88f, 91.943f, nullptr}, {814.9168f, -1056.42f, 117.275f, nullptr}, + {799.0856f, -1034.62f, 129.000f, nullptr}, {801.685f, -1005.46f, 132.39f, nullptr}}; + +BattleBotPath vPath_IC_Horde_Keep_to_Horde_Dock_Crossroad = {{1128.646f, -763.221f, 48.385f, nullptr}, + {1116.203f, -723.328f, 48.655f, nullptr}, + {1093.246f, -696.880f, 37.041f, nullptr}, + {1034.226f, -653.581f, 24.432f, nullptr}}; + +BattleBotPath vPath_IC_Horde_Front_Crossroad_to_Horde_Dock_Crossroad = {{991.4235f, -807.672f, 21.788f, nullptr}, + {1025.305f, -757.165f, 29.241f, nullptr}, + {1029.308f, -710.366f, 26.366f, nullptr}, + {1034.226f, -653.581f, 24.432f, nullptr}}; + +BattleBotPath vPath_IC_Horde_Dock_Crossroad_to_Refinery_Crossroad = {{1034.226f, -653.581f, 24.432f, nullptr}, + {1102.358f, -617.505f, 5.4963f, nullptr}, + {1116.255f, -580.956f, 18.184f, nullptr}, + {1114.414f, -546.731f, 23.422f, nullptr}, + {1148.358f, -503.947f, 23.423f, nullptr}}; + +BattleBotPath vPath_IC_Refinery_Crossroad_to_Refinery_Base = {{1148.358f, -503.947f, 23.423f, nullptr}, + {1201.885f, -500.425f, 4.7262f, nullptr}, + {1240.595f, -471.971f, 0.8933f, nullptr}, + {1265.993f, -435.419f, 10.669f, nullptr}}; + +BattleBotPath vPath_IC_Horde_Side_Gate_to_Refinery_Base = { + {1218.676f, -660.487f, 47.870f, nullptr}, {1211.677f, -626.181f, 46.085f, nullptr}, + {1212.720f, -562.300f, 19.514f, nullptr}, {1238.803f, -538.997f, 3.9892f, nullptr}, + {1248.875f, -482.852f, 0.8933f, nullptr}, {1265.993f, -435.419f, 10.669f, nullptr}}; + +BattleBotPath vPath_IC_Refinery_Crossroad_to_Docks_Crossroad = { + {1148.358f, -503.947f, 23.423f, nullptr}, {1127.010f, -469.451f, 23.422f, nullptr}, + {1100.976f, -431.146f, 21.312f, nullptr}, {1053.812f, -405.457f, 12.749f, nullptr}, + {1005.570f, -375.439f, 12.695f, nullptr}, {963.4349f, -353.282f, 12.356f, nullptr}, + {907.1394f, -380.470f, 11.912f, nullptr}}; + +BattleBotPath vPath_IC_Horde_Dock_Crossroad_to_Docks_Crossroad = { + {1034.226f, -653.581f, 24.432f, nullptr}, {1013.435f, -622.066f, 24.486f, nullptr}, + {988.1990f, -547.937f, 24.424f, nullptr}, {982.4955f, -508.332f, 24.524f, nullptr}, + {982.5065f, -462.920f, 16.833f, nullptr}, {948.8842f, -421.200f, 16.877f, nullptr}, + {907.1394f, -380.470f, 11.912f, nullptr}}; + +BattleBotPath vPath_IC_Docks_Crossroad_to_Docks_Flag = {{907.1394f, -380.470f, 11.912f, nullptr}, + {851.5726f, -382.503f, 11.906f, nullptr}, + {808.1441f, -381.199f, 11.906f, nullptr}, + {761.1740f, -381.854f, 14.504f, nullptr}, + {726.427f, -364.849f, 17.815f, nullptr}}; + +BattleBotPath vPath_IC_Horde_Front_Crossroad_to_Workshop = { + {991.4235f, -807.672f, 21.788f, nullptr}, {944.5518f, -800.344f, 13.155f, nullptr}, + {907.1300f, -798.892f, 8.3237f, nullptr}, {842.9721f, -795.224f, 5.2007f, nullptr}, + {804.5959f, -794.269f, 5.9836f, nullptr}, {774.466f, -801.058f, 6.3428f, nullptr}}; + +BattleBotPath vPath_IC_Central_Graveyard_to_Workshop = { + {775.377f, -664.151f, 8.388f, nullptr}, {776.299f, -684.079f, 5.036f, nullptr}, + {777.451f, -707.525f, 0.051f, nullptr}, {779.059f, -734.611f, 1.695f, nullptr}, + {779.643f, -767.010f, 4.843f, nullptr}, {774.466f, -801.058f, 6.3428f, nullptr}}; + +BattleBotPath vPath_IC_Horde_East_Gate_to_Horde_Keep = { + {1216.1918f, -864.922f, 48.852f, nullptr}, {1197.3117f, -866.054f, 48.916f, nullptr}, + {1174.195f, -867.931f, 48.621f, nullptr}, {1149.671f, -869.240f, 48.096f, nullptr}, + {1128.257f, -860.087f, 49.562f, nullptr}, {1118.730f, -829.959f, 49.074f, nullptr}, + {1123.201f, -806.498f, 48.896f, nullptr}, {1129.685f, -787.156f, 48.680f, nullptr}, + {1128.646f, -763.221f, 48.385f, nullptr}}; + +BattleBotPath vPath_IC_Workshop_to_Workshop_Keep = {{773.792f, -825.637f, 8.127f, nullptr}, + {772.706f, -841.881f, 11.622f, nullptr}, + {773.057f, -859.936f, 12.418f, nullptr}}; + +std::vector const vPaths_WS = { + &vPath_WSG_HordeFlagRoom_to_HordeGraveyard, &vPath_WSG_HordeGraveyard_to_HordeTunnel, + &vPath_WSG_HordeTunnel_to_HordeFlagRoom, &vPath_WSG_HordeTunnel_to_AllianceTunnel_1, + &vPath_WSG_HordeTunnel_to_AllianceTunnel_2, &vPath_WSG_HordeGYJump_to_HordeTunnel, + &vPath_WSG_HordeGYJump_to_AllianceTunnel, &vPath_WSG_AllianceFlagRoom_to_AllianceGraveyard, + &vPath_WSG_AllianceGraveyard_to_AllianceTunnel, &vPath_WSG_AllianceTunnel_to_AllianceFlagRoom, + &vPath_WSG_AllianceGYJump_to_AllianceTunnel, &vPath_WSG_AllianceGYJump_to_HordeTunnel, + &vPath_WSG_HordeGYJump_to_AllianceFlagRoom, &vPath_WSG_AllianceGYJump_to_HordeFlagRoom, + &vPath_WSG_HordeTunnel_to_HordeBaseRoof, &vPath_WSG_AllianceTunnel_to_AllianceBaseRoof, }; -BattleBotPath vPath_IC_Ally_Front_Crossroad_to_Workshop = -{ - { 524.955f, -799.002f, 19.498f, nullptr }, - { 573.557f, -804.838f, 9.6291f, nullptr }, - { 627.977f, -810.197f, 3.5154f, nullptr }, - { 681.501f, -805.208f, 3.1464f, nullptr }, - { 721.905f, -797.917f, 4.5112f, nullptr }, - { 774.466f, -801.058f, 6.3428f, nullptr } +std::vector const vPaths_AB = { + &vPath_AB_AllianceBase_to_Stables, &vPath_AB_AllianceBase_to_GoldMine, &vPath_AB_AllianceBase_to_LumberMill, + &vPath_AB_Stables_to_Blacksmith, &vPath_AB_HordeBase_to_Farm, &vPath_AB_HordeBase_to_GoldMine, + &vPath_AB_HordeBase_to_LumberMill, &vPath_AB_Farm_to_Blacksmith, &vPath_AB_Stables_to_GoldMine, + &vPath_AB_Stables_to_LumberMill, &vPath_AB_Farm_to_GoldMine, &vPath_AB_Farm_to_LumberMill, + &vPath_AB_Blacksmith_to_LumberMill, &vPath_AB_Blacksmith_to_GoldMine, &vPath_AB_Farm_to_Stable, }; -BattleBotPath vPath_IC_Ally_Keep_to_Ally_Dock_Crossroad = -{ - { 434.768f, -833.976f, 46.090f, nullptr }, - { 446.710f, -776.008f, 48.783f, nullptr }, - { 463.745f, -742.368f, 48.584f, nullptr }, - { 488.201f, -714.563f, 36.564f, nullptr }, - { 525.923f, -666.880f, 25.425f, nullptr } -}; - -BattleBotPath vPath_IC_Ally_Front_Crossroad_to_Ally_Dock_Crossroad = -{ - { 524.955f, -799.002f, 19.498f, nullptr }, - { 542.225f, -745.142f, 18.348f, nullptr }, - { 545.309f, -712.497f, 22.005f, nullptr }, - { 538.678f, -748.361f, 18.261f, nullptr }, - { 525.923f, -666.880f, 25.425f, nullptr } -}; - -BattleBotPath vPath_IC_Lower_Graveyard_to_Lower_Graveyard_Crossroad = -{ - { 443.095f, -310.797f, 51.749f, nullptr }, - { 462.733f, -323.587f, 48.706f, nullptr }, - { 471.540f, -343.914f, 40.706f, nullptr }, - { 475.622f, -360.728f, 34.384f, nullptr }, - { 484.458f, -379.796f, 33.122f, nullptr } -}; - -BattleBotPath vPath_IC_Lower_Graveyard_Crossroad_to_Ally_Docks_Crossroad = -{ - { 484.458f, -379.796f, 33.122f, nullptr }, - { 509.786f, -380.592f, 33.122f, nullptr }, - { 532.549f, -381.576f, 33.122f, nullptr }, - { 553.506f, -386.102f, 33.507f, nullptr }, - { 580.533f, -398.536f, 33.416f, nullptr }, - { 605.112f, -409.843f, 33.121f, nullptr }, - { 619.212f, -419.169f, 33.121f, nullptr }, - { 631.702f, -428.763f, 33.070f, nullptr }, - { 648.483f, -444.714f, 28.629f, nullptr } -}; - -BattleBotPath vPath_IC_Lower_Graveyard_Crossroad_to_Ally_Docks_Second_Crossroad = -{ - { 484.458f, -379.796f, 33.122f, nullptr }, - { 470.771f, -394.789f, 33.112f, nullptr }, - { 461.191f, -409.475f, 33.120f, nullptr }, - { 452.794f, -431.842f, 33.120f, nullptr }, - { 452.794f, -456.896f, 33.658f, nullptr }, - { 453.279f, -481.742f, 33.052f, nullptr }, - { 453.621f, -504.979f, 32.956f, nullptr }, - { 452.006f, -526.792f, 32.221f, nullptr }, - { 453.150f, -548.212f, 29.133f, nullptr }, - { 455.224f, -571.323f, 26.119f, nullptr }, - { 465.486f, -585.424f, 25.756f, nullptr }, - { 475.366f, -598.414f, 25.784f, nullptr }, - { 477.702f, -605.757f, 25.714f, nullptr } -}; - -BattleBotPath vPath_IC_Ally_Dock_Crossroad_to_Ally_Docks_Second_Crossroad = -{ - { 525.923f, -666.880f, 25.425f, nullptr }, - { 497.190f, -630.709f, 25.626f, nullptr }, - { 477.702f, -605.757f, 25.714f, nullptr } -}; - -BattleBotPath vPath_IC_Ally_Docks_Second_Crossroad_to_Ally_Docks_Crossroad = -{ - { 477.702f, -605.757f, 25.714f, nullptr }, - { 493.697f, -555.838f, 26.014f, nullptr }, - { 522.939f, -525.199f, 26.014f, nullptr }, - { 580.398f, -486.274f, 26.013f, nullptr }, - { 650.132f, -445.811f, 28.503f, nullptr } -}; - -BattleBotPath vPath_IC_Ally_Docks_Crossroad_to_Docks_Flag = -{ - { 650.132f, -445.811f, 28.503f, nullptr }, - { 690.527f, -452.961f, 18.039f, nullptr }, - { 706.813f, -430.003f, 13.797f, nullptr }, - { 726.427f, -364.849f, 17.815f, nullptr } -}; - -BattleBotPath vPath_IC_Docks_Graveyard_to_Docks_Flag = -{ - { 638.142f, -283.782f, 11.512f, nullptr }, - { 655.760f, -284.433f, 13.220f, nullptr }, - { 661.656f, -299.912f, 12.756f, nullptr }, - { 675.068f, -317.192f, 12.627f, nullptr }, - { 692.712f, -323.866f, 12.686f, nullptr }, - { 712.968f, -341.285f, 13.350f, nullptr }, - { 726.427f, -364.849f, 17.815f, nullptr } -}; - -BattleBotPath vPath_IC_Ally_Keep_to_Quarry_Crossroad = -{ - { 320.547f, -919.896f, 48.481f, nullptr }, - { 335.384f, -922.371f, 49.518f, nullptr }, - { 353.471f, -920.316f, 48.660f, nullptr }, - { 353.305f, -958.823f, 47.665f, nullptr }, - { 369.196f, -989.960f, 37.719f, nullptr }, - { 380.671f, -1023.51f, 29.369f, nullptr } -}; - -BattleBotPath vPath_IC_Quarry_Crossroad_to_Quarry_Flag = -{ - { 380.671f, -1023.51f, 29.369f, nullptr }, - { 361.584f, -1052.89f, 27.445f, nullptr }, - { 341.853f, -1070.17f, 24.024f, nullptr }, - { 295.845f, -1075.22f, 16.164f, nullptr }, - { 253.030f, -1094.06f, 4.1517f, nullptr }, - { 211.391f, -1121.80f, 1.9591f, nullptr }, - { 187.836f, -1155.66f, 1.9749f, nullptr }, - { 221.193f, -1186.87f, 8.0247f, nullptr }, - { 249.181f, -1162.09f, 16.687f, nullptr } -}; - -BattleBotPath vPath_IC_Ally_Front_Crossroad_to_Hangar_First_Crossroad = -{ - { 524.955f, -799.002f, 19.498f, nullptr }, - { 512.563f, -840.166f, 23.913f, nullptr }, - { 513.418f, -877.726f, 26.333f, nullptr }, - { 512.962f, -945.951f, 39.382f, nullptr } -}; - -BattleBotPath vPath_IC_Ally_Keep_to_Hangar_First_Crossroad = -{ - { 434.768f, -833.976f, 46.090f, nullptr }, - { 486.355f, -909.736f, 26.112f, nullptr }, - { 512.962f, -945.951f, 39.382f, nullptr } -}; - -BattleBotPath vPath_IC_Hangar_First_Crossroad_to_Hangar_Second_Crossroad = -{ - { 512.962f, -945.951f, 39.382f, nullptr }, - { 499.525f, -985.850f, 47.659f, nullptr }, - { 492.794f, -1016.36f, 49.834f, nullptr }, - { 481.738f, -1052.67f, 60.190f, nullptr } -}; - -BattleBotPath vPath_IC_Quarry_Crossroad_to_Hangar_Second_Crossroad = -{ - { 380.671f, -1023.51f, 29.369f, nullptr }, - { 430.997f, -1021.72f, 31.021f, nullptr }, - { 439.528f, -1044.88f, 41.827f, nullptr }, - { 455.062f, -1060.67f, 67.209f, nullptr }, - { 481.738f, -1052.67f, 60.190f, nullptr } -}; - -BattleBotPath vPath_IC_Hangar_Second_Crossroad_to_Hangar_Flag = -{ - { 508.945f, -1103.30f, 79.054f, nullptr }, - { 536.397f, -1145.79f, 95.478f, nullptr }, - { 573.242f, -1138.19f, 109.26f, nullptr }, - { 609.051f, -1112.93f, 128.31f, nullptr }, - { 645.569f, -1094.58f, 132.13f, nullptr }, - { 689.621f, -1068.33f, 132.87f, nullptr }, - { 730.045f, -1042.67f, 133.03f, nullptr }, - { 755.322f, -1030.28f, 133.30f, nullptr }, - { 801.685f, -1005.46f, 132.39f, nullptr }, - { 806.404f, -1001.709f, 132.382f, nullptr } -}; - -BattleBotPath vPath_IC_Horde_Keep_to_Horde_Front_Crossroad = -{ - { 1128.646f, -763.221f, 48.385f, nullptr }, - { 1091.273f, -763.619f, 42.352f, nullptr }, - { 1032.825f, -763.024f, 30.420f, nullptr }, - { 991.4235f, -807.672f, 21.788f, nullptr } -}; - -BattleBotPath vPath_IC_Horde_Front_Crossroad_to_Horde_Hangar_Crossroad = -{ - { 991.4235f, -807.672f, 21.788f, nullptr }, - { 999.1844f, -855.182f, 21.484f, nullptr }, - { 1012.089f, -923.098f, 19.296f, nullptr } -}; - -BattleBotPath vPath_IC_Horde_Keep_to_Horde_Hangar_Crossroad = -{ - { 1128.646f, -763.221f, 48.385f, nullptr }, - { 1121.090f, -816.666f, 49.008f, nullptr }, - { 1107.106f, -851.459f, 48.804f, nullptr }, - { 1072.313f, -888.355f, 30.853f, nullptr }, - { 1012.089f, -923.098f, 19.296f, nullptr } -}; - -BattleBotPath vPath_IC_Horde_Hangar_Crossroad_to_Hangar_Flag = -{ - { 1001.745f, -973.174f, 15.784f, nullptr }, - { 1015.437f, -1019.47f, 15.578f, nullptr }, - { 1009.622f, -1067.78f, 15.777f, nullptr }, - { 988.0692f, -1113.32f, 18.254f, nullptr }, - { 943.7221f, -1134.50f, 32.296f, nullptr }, - { 892.2205f, -1115.16f, 63.319f, nullptr }, - { 849.6576f, -1090.88f, 91.943f, nullptr }, - { 814.9168f, -1056.42f, 117.275f, nullptr }, - { 799.0856f, -1034.62f, 129.000f, nullptr }, - { 801.685f, -1005.46f, 132.39f, nullptr } -}; - -BattleBotPath vPath_IC_Horde_Keep_to_Horde_Dock_Crossroad = -{ - { 1128.646f, -763.221f, 48.385f, nullptr }, - { 1116.203f, -723.328f, 48.655f, nullptr }, - { 1093.246f, -696.880f, 37.041f, nullptr }, - { 1034.226f, -653.581f, 24.432f, nullptr } -}; - -BattleBotPath vPath_IC_Horde_Front_Crossroad_to_Horde_Dock_Crossroad = -{ - { 991.4235f, -807.672f, 21.788f, nullptr }, - { 1025.305f, -757.165f, 29.241f, nullptr }, - { 1029.308f, -710.366f, 26.366f, nullptr }, - { 1034.226f, -653.581f, 24.432f, nullptr } -}; - -BattleBotPath vPath_IC_Horde_Dock_Crossroad_to_Refinery_Crossroad = -{ - { 1034.226f, -653.581f, 24.432f, nullptr }, - { 1102.358f, -617.505f, 5.4963f, nullptr }, - { 1116.255f, -580.956f, 18.184f, nullptr }, - { 1114.414f, -546.731f, 23.422f, nullptr }, - { 1148.358f, -503.947f, 23.423f, nullptr } -}; - -BattleBotPath vPath_IC_Refinery_Crossroad_to_Refinery_Base = -{ - { 1148.358f, -503.947f, 23.423f, nullptr }, - { 1201.885f, -500.425f, 4.7262f, nullptr }, - { 1240.595f, -471.971f, 0.8933f, nullptr }, - { 1265.993f, -435.419f, 10.669f, nullptr } -}; - -BattleBotPath vPath_IC_Horde_Side_Gate_to_Refinery_Base = -{ - { 1218.676f, -660.487f, 47.870f, nullptr }, - { 1211.677f, -626.181f, 46.085f, nullptr }, - { 1212.720f, -562.300f, 19.514f, nullptr }, - { 1238.803f, -538.997f, 3.9892f, nullptr }, - { 1248.875f, -482.852f, 0.8933f, nullptr }, - { 1265.993f, -435.419f, 10.669f, nullptr } -}; - -BattleBotPath vPath_IC_Refinery_Crossroad_to_Docks_Crossroad = -{ - { 1148.358f, -503.947f, 23.423f, nullptr }, - { 1127.010f, -469.451f, 23.422f, nullptr }, - { 1100.976f, -431.146f, 21.312f, nullptr }, - { 1053.812f, -405.457f, 12.749f, nullptr }, - { 1005.570f, -375.439f, 12.695f, nullptr }, - { 963.4349f, -353.282f, 12.356f, nullptr }, - { 907.1394f, -380.470f, 11.912f, nullptr } -}; - -BattleBotPath vPath_IC_Horde_Dock_Crossroad_to_Docks_Crossroad = -{ - { 1034.226f, -653.581f, 24.432f, nullptr }, - { 1013.435f, -622.066f, 24.486f, nullptr }, - { 988.1990f, -547.937f, 24.424f, nullptr }, - { 982.4955f, -508.332f, 24.524f, nullptr }, - { 982.5065f, -462.920f, 16.833f, nullptr }, - { 948.8842f, -421.200f, 16.877f, nullptr }, - { 907.1394f, -380.470f, 11.912f, nullptr } -}; - -BattleBotPath vPath_IC_Docks_Crossroad_to_Docks_Flag = -{ - { 907.1394f, -380.470f, 11.912f, nullptr }, - { 851.5726f, -382.503f, 11.906f, nullptr }, - { 808.1441f, -381.199f, 11.906f, nullptr }, - { 761.1740f, -381.854f, 14.504f, nullptr }, - { 726.427f, -364.849f, 17.815f, nullptr } -}; - -BattleBotPath vPath_IC_Horde_Front_Crossroad_to_Workshop = -{ - { 991.4235f, -807.672f, 21.788f, nullptr }, - { 944.5518f, -800.344f, 13.155f, nullptr }, - { 907.1300f, -798.892f, 8.3237f, nullptr }, - { 842.9721f, -795.224f, 5.2007f, nullptr }, - { 804.5959f, -794.269f, 5.9836f, nullptr }, - { 774.466f, -801.058f, 6.3428f, nullptr } -}; - -BattleBotPath vPath_IC_Central_Graveyard_to_Workshop = -{ - { 775.377f, -664.151f, 8.388f, nullptr }, - { 776.299f, -684.079f, 5.036f, nullptr }, - { 777.451f, -707.525f, 0.051f, nullptr }, - { 779.059f, -734.611f, 1.695f, nullptr }, - { 779.643f, -767.010f, 4.843f, nullptr }, - { 774.466f, -801.058f, 6.3428f, nullptr } -}; - -BattleBotPath vPath_IC_Horde_East_Gate_to_Horde_Keep = -{ - { 1216.1918f, -864.922f, 48.852f, nullptr }, - { 1197.3117f, -866.054f, 48.916f, nullptr }, - { 1174.195f, -867.931f, 48.621f, nullptr }, - { 1149.671f, -869.240f, 48.096f, nullptr }, - { 1128.257f, -860.087f, 49.562f, nullptr }, - { 1118.730f, -829.959f, 49.074f, nullptr }, - { 1123.201f, -806.498f, 48.896f, nullptr }, - { 1129.685f, -787.156f, 48.680f, nullptr}, - { 1128.646f, -763.221f, 48.385f, nullptr } -}; - -BattleBotPath vPath_IC_Workshop_to_Workshop_Keep = -{ - { 773.792f, -825.637f, 8.127f, nullptr }, - { 772.706f, -841.881f, 11.622f, nullptr }, - { 773.057f, -859.936f, 12.418f, nullptr } -}; - -std::vector const vPaths_WS = -{ - &vPath_WSG_HordeFlagRoom_to_HordeGraveyard, - &vPath_WSG_HordeGraveyard_to_HordeTunnel, - &vPath_WSG_HordeTunnel_to_HordeFlagRoom, - &vPath_WSG_HordeTunnel_to_AllianceTunnel_1, - &vPath_WSG_HordeTunnel_to_AllianceTunnel_2, - &vPath_WSG_HordeGYJump_to_HordeTunnel, - &vPath_WSG_HordeGYJump_to_AllianceTunnel, - &vPath_WSG_AllianceFlagRoom_to_AllianceGraveyard, - &vPath_WSG_AllianceGraveyard_to_AllianceTunnel, - &vPath_WSG_AllianceTunnel_to_AllianceFlagRoom, - &vPath_WSG_AllianceGYJump_to_AllianceTunnel, - &vPath_WSG_AllianceGYJump_to_HordeTunnel, - &vPath_WSG_HordeGYJump_to_AllianceFlagRoom, - &vPath_WSG_AllianceGYJump_to_HordeFlagRoom, - &vPath_WSG_HordeTunnel_to_HordeBaseRoof, - &vPath_WSG_AllianceTunnel_to_AllianceBaseRoof, -}; - -std::vector const vPaths_AB = -{ - &vPath_AB_AllianceBase_to_Stables, - &vPath_AB_AllianceBase_to_GoldMine, - &vPath_AB_AllianceBase_to_LumberMill, - &vPath_AB_Stables_to_Blacksmith, - &vPath_AB_HordeBase_to_Farm, - &vPath_AB_HordeBase_to_GoldMine, - &vPath_AB_HordeBase_to_LumberMill, - &vPath_AB_Farm_to_Blacksmith, - &vPath_AB_Stables_to_GoldMine, - &vPath_AB_Stables_to_LumberMill, - &vPath_AB_Farm_to_GoldMine, - &vPath_AB_Farm_to_LumberMill, - &vPath_AB_Blacksmith_to_LumberMill, - &vPath_AB_Blacksmith_to_GoldMine, - &vPath_AB_Farm_to_Stable, -}; - -std::vector const vPaths_AV = -{ +std::vector const vPaths_AV = { &vPath_AV_Horde_Cave_to_Tower_Point_Crossroad, &vPath_AV_Tower_Point_Crossroads_to_Tower_Point_Bottom, //&vPath_AV_TowerPoint_Bottom_to_Tower_Point_Flag, @@ -2251,8 +1409,7 @@ std::vector const vPaths_AV = &vPath_AV_Horde_Cave_to_Horde_Base_DrekThar, }; -std::vector const vPaths_EY = -{ +std::vector const vPaths_EY = { &vPath_EY_Horde_Spawn_to_Crossroad1Horde, &vPath_EY_Horde_Crossroad1Horde_to_Crossroad2Horde, &vPath_EY_Crossroad1Horde_to_Blood_Elf_Tower, @@ -2271,8 +1428,7 @@ std::vector const vPaths_EY = &vPath_EY_Fel_Reaver_to_Mage_Tower, }; -std::vector const vPaths_IC = -{ +std::vector const vPaths_IC = { &vPath_IC_Ally_Dock_Crossroad_to_Ally_Docks_Second_Crossroad, &vPath_IC_Ally_Docks_Crossroad_to_Docks_Flag, &vPath_IC_Ally_Docks_Second_Crossroad_to_Ally_Docks_Crossroad, @@ -2309,8 +1465,7 @@ std::vector const vPaths_IC = &vPath_IC_Workshop_to_Workshop_Keep, }; -std::vector const vPaths_NoReverseAllowed = -{ +std::vector const vPaths_NoReverseAllowed = { &vPath_AV_Horde_Cave_to_Tower_Point_Crossroad, &vPath_AV_Frostwolf_Graveyard_to_Frostwolf_Graveyard_Flag, &vPath_AV_Iceblood_Graveyard_to_Iceblood_Graveyard_Flag, @@ -2323,83 +1478,71 @@ std::vector const vPaths_NoReverseAllowed = &vPath_IC_Docks_Graveyard_to_Docks_Flag, }; -std::vector const vPaths_AllyMine = -{ +std::vector const vPaths_AllyMine = { &vPath_AV_Stormpike_Crossroad_to_Irontooth_Mine_Entrance, &vPath_AV_Irontooth_Mine_Entrance_to_Irontooth_Mine_Boss, }; -std::vector const vPaths_HordeMine = -{ +std::vector const vPaths_HordeMine = { &vPath_AV_Frostwolf_Graveyard_Flag_to_Coldtooth_Mine_Entrance, &vPath_AV_Coldtooth_Mine_Entrance_to_Coldtooth_Mine_Boss, }; -static std::pair AV_HordeAttackObjectives[] = -{ +static std::pair AV_HordeAttackObjectives[] = { // Attack - these are in order they should be attacked - { BG_AV_NODES_STONEHEART_GRAVE, BG_AV_OBJECT_FLAG_A_STONEHEART_GRAVE }, - { BG_AV_NODES_STONEHEART_BUNKER, BG_AV_OBJECT_FLAG_A_STONEHEART_BUNKER }, - { BG_AV_NODES_ICEWING_BUNKER, BG_AV_OBJECT_FLAG_A_ICEWING_BUNKER }, - { BG_AV_NODES_STORMPIKE_GRAVE, BG_AV_OBJECT_FLAG_A_STORMPIKE_GRAVE }, - { BG_AV_NODES_DUNBALDAR_NORTH, BG_AV_OBJECT_FLAG_A_DUNBALDAR_NORTH }, - { BG_AV_NODES_DUNBALDAR_SOUTH, BG_AV_OBJECT_FLAG_A_DUNBALDAR_SOUTH }, - { BG_AV_NODES_FIRSTAID_STATION, BG_AV_OBJECT_FLAG_A_FIRSTAID_STATION }, + {BG_AV_NODES_STONEHEART_GRAVE, BG_AV_OBJECT_FLAG_A_STONEHEART_GRAVE}, + {BG_AV_NODES_STONEHEART_BUNKER, BG_AV_OBJECT_FLAG_A_STONEHEART_BUNKER}, + {BG_AV_NODES_ICEWING_BUNKER, BG_AV_OBJECT_FLAG_A_ICEWING_BUNKER}, + {BG_AV_NODES_STORMPIKE_GRAVE, BG_AV_OBJECT_FLAG_A_STORMPIKE_GRAVE}, + {BG_AV_NODES_DUNBALDAR_NORTH, BG_AV_OBJECT_FLAG_A_DUNBALDAR_NORTH}, + {BG_AV_NODES_DUNBALDAR_SOUTH, BG_AV_OBJECT_FLAG_A_DUNBALDAR_SOUTH}, + {BG_AV_NODES_FIRSTAID_STATION, BG_AV_OBJECT_FLAG_A_FIRSTAID_STATION}, }; -static std::pair AV_HordeDefendObjectives[] = -{ +static std::pair AV_HordeDefendObjectives[] = { // Defend - these are in order they should be protected - { BG_AV_NODES_FROSTWOLF_HUT, BG_AV_OBJECT_FLAG_H_FROSTWOLF_HUT }, - { BG_AV_NODES_FROSTWOLF_WTOWER, BG_AV_OBJECT_FLAG_H_FROSTWOLF_WTOWER }, - { BG_AV_NODES_FROSTWOLF_ETOWER, BG_AV_OBJECT_FLAG_H_FROSTWOLF_ETOWER }, - { BG_AV_NODES_FROSTWOLF_GRAVE, BG_AV_OBJECT_FLAG_H_FROSTWOLF_GRAVE }, - { BG_AV_NODES_TOWER_POINT, BG_AV_OBJECT_FLAG_H_TOWER_POINT }, - { BG_AV_NODES_ICEBLOOD_TOWER, BG_AV_OBJECT_FLAG_H_ICEBLOOD_TOWER }, - //{ BG_AV_NODES_ICEBLOOD_GRAVE, BG_AV_OBJECT_FLAG_H_ICEBLOOD_GRAVE},//defending this makes it more likely for game to end due to loss of supplies + {BG_AV_NODES_FROSTWOLF_HUT, BG_AV_OBJECT_FLAG_H_FROSTWOLF_HUT}, + {BG_AV_NODES_FROSTWOLF_WTOWER, BG_AV_OBJECT_FLAG_H_FROSTWOLF_WTOWER}, + {BG_AV_NODES_FROSTWOLF_ETOWER, BG_AV_OBJECT_FLAG_H_FROSTWOLF_ETOWER}, + {BG_AV_NODES_FROSTWOLF_GRAVE, BG_AV_OBJECT_FLAG_H_FROSTWOLF_GRAVE}, + {BG_AV_NODES_TOWER_POINT, BG_AV_OBJECT_FLAG_H_TOWER_POINT}, + {BG_AV_NODES_ICEBLOOD_TOWER, BG_AV_OBJECT_FLAG_H_ICEBLOOD_TOWER}, + //{ BG_AV_NODES_ICEBLOOD_GRAVE, BG_AV_OBJECT_FLAG_H_ICEBLOOD_GRAVE},//defending this makes it more likely for game + // to end due to loss of supplies }; -static std::pair AV_AllianceAttackObjectives[] = -{ +static std::pair AV_AllianceAttackObjectives[] = { // Attack - these are in order they should be attacked - { BG_AV_NODES_ICEBLOOD_GRAVE, BG_AV_OBJECT_FLAG_H_ICEBLOOD_GRAVE}, - { BG_AV_NODES_ICEBLOOD_TOWER, BG_AV_OBJECT_FLAG_H_ICEBLOOD_TOWER}, - { BG_AV_NODES_TOWER_POINT, BG_AV_OBJECT_FLAG_H_TOWER_POINT }, - { BG_AV_NODES_FROSTWOLF_GRAVE, BG_AV_OBJECT_FLAG_H_FROSTWOLF_GRAVE }, - { BG_AV_NODES_FROSTWOLF_ETOWER, BG_AV_OBJECT_FLAG_H_FROSTWOLF_ETOWER }, - { BG_AV_NODES_FROSTWOLF_WTOWER, BG_AV_OBJECT_FLAG_H_FROSTWOLF_WTOWER }, - { BG_AV_NODES_FROSTWOLF_HUT, BG_AV_OBJECT_FLAG_H_FROSTWOLF_HUT }, + {BG_AV_NODES_ICEBLOOD_GRAVE, BG_AV_OBJECT_FLAG_H_ICEBLOOD_GRAVE}, + {BG_AV_NODES_ICEBLOOD_TOWER, BG_AV_OBJECT_FLAG_H_ICEBLOOD_TOWER}, + {BG_AV_NODES_TOWER_POINT, BG_AV_OBJECT_FLAG_H_TOWER_POINT}, + {BG_AV_NODES_FROSTWOLF_GRAVE, BG_AV_OBJECT_FLAG_H_FROSTWOLF_GRAVE}, + {BG_AV_NODES_FROSTWOLF_ETOWER, BG_AV_OBJECT_FLAG_H_FROSTWOLF_ETOWER}, + {BG_AV_NODES_FROSTWOLF_WTOWER, BG_AV_OBJECT_FLAG_H_FROSTWOLF_WTOWER}, + {BG_AV_NODES_FROSTWOLF_HUT, BG_AV_OBJECT_FLAG_H_FROSTWOLF_HUT}, }; -static std::pair AV_AllianceDefendObjectives[] = -{ +static std::pair AV_AllianceDefendObjectives[] = { // Defend - these are in order they should be protected - { BG_AV_NODES_FIRSTAID_STATION, BG_AV_OBJECT_FLAG_A_FIRSTAID_STATION }, - { BG_AV_NODES_DUNBALDAR_SOUTH, BG_AV_OBJECT_FLAG_A_DUNBALDAR_SOUTH }, - { BG_AV_NODES_DUNBALDAR_NORTH, BG_AV_OBJECT_FLAG_A_DUNBALDAR_NORTH }, - { BG_AV_NODES_STORMPIKE_GRAVE, BG_AV_OBJECT_FLAG_A_STORMPIKE_GRAVE }, - { BG_AV_NODES_ICEWING_BUNKER, BG_AV_OBJECT_FLAG_A_ICEWING_BUNKER }, - { BG_AV_NODES_STONEHEART_BUNKER, BG_AV_OBJECT_FLAG_A_STONEHEART_BUNKER }, - //{ BG_AV_NODES_STONEHEART_GRAVE, BG_AV_OBJECT_FLAG_A_STONEHEART_GRAVE },//defending this makes it more likely for game to end due to loss of supplies + {BG_AV_NODES_FIRSTAID_STATION, BG_AV_OBJECT_FLAG_A_FIRSTAID_STATION}, + {BG_AV_NODES_DUNBALDAR_SOUTH, BG_AV_OBJECT_FLAG_A_DUNBALDAR_SOUTH}, + {BG_AV_NODES_DUNBALDAR_NORTH, BG_AV_OBJECT_FLAG_A_DUNBALDAR_NORTH}, + {BG_AV_NODES_STORMPIKE_GRAVE, BG_AV_OBJECT_FLAG_A_STORMPIKE_GRAVE}, + {BG_AV_NODES_ICEWING_BUNKER, BG_AV_OBJECT_FLAG_A_ICEWING_BUNKER}, + {BG_AV_NODES_STONEHEART_BUNKER, BG_AV_OBJECT_FLAG_A_STONEHEART_BUNKER}, + //{ BG_AV_NODES_STONEHEART_GRAVE, BG_AV_OBJECT_FLAG_A_STONEHEART_GRAVE },//defending this makes it more likely for + // game to end due to loss of supplies }; -static uint32 AB_AttackObjectives[] = -{ +static uint32 AB_AttackObjectives[] = { // Attack - BG_AB_NODE_STABLES, - BG_AB_NODE_BLACKSMITH, - BG_AB_NODE_FARM, - BG_AB_NODE_LUMBER_MILL, - BG_AB_NODE_GOLD_MINE -}; + BG_AB_NODE_STABLES, BG_AB_NODE_BLACKSMITH, BG_AB_NODE_FARM, BG_AB_NODE_LUMBER_MILL, BG_AB_NODE_GOLD_MINE}; -static std::tuple EY_AttackObjectives[] = -{ - { POINT_FEL_REAVER, BG_EY_OBJECT_FLAG_FEL_REAVER, AT_FEL_REAVER_POINT }, - { POINT_BLOOD_ELF, BG_EY_OBJECT_FLAG_BLOOD_ELF, AT_BLOOD_ELF_POINT }, - { POINT_DRAENEI_RUINS, BG_EY_OBJECT_FLAG_DRAENEI_RUINS, AT_DRAENEI_RUINS_POINT }, - { POINT_MAGE_TOWER, BG_EY_OBJECT_FLAG_MAGE_TOWER, AT_MAGE_TOWER_POINT } -}; +static std::tuple EY_AttackObjectives[] = { + {POINT_FEL_REAVER, BG_EY_OBJECT_FLAG_FEL_REAVER, AT_FEL_REAVER_POINT}, + {POINT_BLOOD_ELF, BG_EY_OBJECT_FLAG_BLOOD_ELF, AT_BLOOD_ELF_POINT}, + {POINT_DRAENEI_RUINS, BG_EY_OBJECT_FLAG_DRAENEI_RUINS, AT_DRAENEI_RUINS_POINT}, + {POINT_MAGE_TOWER, BG_EY_OBJECT_FLAG_MAGE_TOWER, AT_MAGE_TOWER_POINT}}; // useful commands for fixing BG bugs and checking waypoints/paths bool BGTactics::HandleConsoleCommand(ChatHandler* handler, char const* args) @@ -2436,7 +1579,7 @@ std::string const BGTactics::HandleConsoleCommandPrivate(WorldSession* session, if (bgType == BATTLEGROUND_RB) bgType = bg->GetBgTypeID(true); char* cmd = strtok((char*)args, " "); - //char* charname = strtok(nullptr, " "); + // char* charname = strtok(nullptr, " "); if (!strncmp(cmd, "showpath", 8)) { @@ -2449,16 +1592,29 @@ std::string const BGTactics::HandleConsoleCommandPrivate(WorldSession* session, std::vector const* vPaths; switch (bgType) { - case BATTLEGROUND_AB: vPaths = &vPaths_AB; break; - case BATTLEGROUND_AV: vPaths = &vPaths_AV; break; - case BATTLEGROUND_WS: vPaths = &vPaths_WS; break; - case BATTLEGROUND_EY: vPaths = &vPaths_EY; break; - case BATTLEGROUND_IC: vPaths = &vPaths_IC; break; - default: vPaths = nullptr; break; + case BATTLEGROUND_AB: + vPaths = &vPaths_AB; + break; + case BATTLEGROUND_AV: + vPaths = &vPaths_AV; + break; + case BATTLEGROUND_WS: + vPaths = &vPaths_WS; + break; + case BATTLEGROUND_EY: + vPaths = &vPaths_EY; + break; + case BATTLEGROUND_IC: + vPaths = &vPaths_IC; + break; + default: + vPaths = nullptr; + break; } if (!vPaths) return "This battleground has no paths and is unsupported"; - if (num == -1) { + if (num == -1) + { float closestPoint = FLT_MAX; for (uint32 j = 0; j < vPaths->size(); j++) { @@ -2467,7 +1623,8 @@ std::string const BGTactics::HandleConsoleCommandPrivate(WorldSession* session, { BattleBotWaypoint& waypoint = ((*path)[i]); float dist = player->GetDistance(waypoint.x, waypoint.y, waypoint.z); - if (closestPoint > dist) { + if (closestPoint > dist) + { closestPoint = dist; num = j; } @@ -2480,7 +1637,8 @@ std::string const BGTactics::HandleConsoleCommandPrivate(WorldSession* session, for (uint32 i = 0; i < path->size(); i++) { BattleBotWaypoint& waypoint = ((*path)[i]); - Creature* wpCreature = player->SummonCreature(15631, waypoint.x, waypoint.y, waypoint.z, 0, TEMPSUMMON_TIMED_DESPAWN, 15000u); + Creature* wpCreature = + player->SummonCreature(15631, waypoint.x, waypoint.y, waypoint.z, 0, TEMPSUMMON_TIMED_DESPAWN, 15000u); wpCreature->SetOwnerGUID(player->GetGUID()); } return fmt::format("Showing path {}", num); @@ -2496,7 +1654,8 @@ std::string const BGTactics::HandleConsoleCommandPrivate(WorldSession* session, Creature* c = bg->GetBGCreature(num); if (!c) return "Creature not found"; - Creature* wpCreature = player->SummonCreature(15631, c->GetPositionX(), c->GetPositionY(), c->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 15000u); + Creature* wpCreature = player->SummonCreature(15631, c->GetPositionX(), c->GetPositionY(), c->GetPositionZ(), 0, + TEMPSUMMON_TIMED_DESPAWN, 15000u); wpCreature->SetOwnerGUID(player->GetGUID()); return fmt::format("Showing location of Creature {}", num); } @@ -2511,7 +1670,8 @@ std::string const BGTactics::HandleConsoleCommandPrivate(WorldSession* session, GameObject* o = bg->GetBGObject(num); if (!o) return "GameObject not found"; - Creature* wpCreature = player->SummonCreature(15631, o->GetPositionX(), o->GetPositionY(), o->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 15000u); + Creature* wpCreature = player->SummonCreature(15631, o->GetPositionX(), o->GetPositionY(), o->GetPositionZ(), 0, + TEMPSUMMON_TIMED_DESPAWN, 15000u); wpCreature->SetOwnerGUID(player->GetGUID()); return fmt::format("Showing location of GameObject {}", num); } @@ -2522,7 +1682,7 @@ std::string const BGTactics::HandleConsoleCommandPrivate(WorldSession* session, // // old wsg waypoints // -//cross the Battleground to get to flags or flag carriers +// cross the Battleground to get to flags or flag carriers bool BGTactics::wsgPaths() { Battleground* bg = bot->GetBattleground(); @@ -2533,153 +1693,155 @@ bool BGTactics::wsgPaths() uint32 Preference = context->GetValue("bg role")->Get(); - if (pos.x > bot->GetPositionX()) //He's somewhere at the alliance side + if (pos.x > bot->GetPositionX()) // He's somewhere at the alliance side { - if (Preference < 4) //preference < 4 = move through tunnel (< 6 becuse GY disabled) + if (Preference < 4) // preference < 4 = move through tunnel (< 6 becuse GY disabled) { - if (bot->GetPositionX() < 1006.f) //to the fasty + if (bot->GetPositionX() < 1006.f) // to the fasty { MoveTo(bg->GetMapId(), 1006.590210f, 1450.435059f, 335.721283f); - return true; + return true; } - else if (bot->GetPositionX() < 1125.f) //to the horde entrance + else if (bot->GetPositionX() < 1125.f) // to the horde entrance { if (bot->GetPositionY() < 1400.f) MoveTo(bg->GetMapId(), 1125.778076f, bot->GetPositionY(), 316.567047f); else MoveTo(bg->GetMapId(), 1125.778076f, 1452.059937f, 315.698883f); - return true; + return true; } } else if (Preference < 7) { // preference < 7 = move through graveyard (BUGGED) - if (bot->GetPositionX() < 985.f) //to the gate at the upper tunnel + if (bot->GetPositionX() < 985.f) // to the gate at the upper tunnel { MoveTo(bg->GetMapId(), 985.940125f, 1423.260254f, 345.418121f); - return true; + return true; } - else if (bot->GetPositionX() < 1054.5f) //to the gate at the upper tunnel + else if (bot->GetPositionX() < 1054.5f) // to the gate at the upper tunnel { MoveTo(bg->GetMapId(), 1055.182251f, 1396.967529f, 339.361511f); - return true; + return true; } - else if (bot->GetPositionX() < 1125.f) //to the horde entrance + else if (bot->GetPositionX() < 1125.f) // to the horde entrance { MoveTo(bg->GetMapId(), 1125.778076f, bot->GetPositionY(), 316.567047f); - return true; + return true; } } else { // all other preference: run down the ramp - if (bot->GetPositionX() < 985.f) //to the gate at the upper tunnel + if (bot->GetPositionX() < 985.f) // to the gate at the upper tunnel { MoveTo(bg->GetMapId(), 985.940125f, 1423.260254f, 345.418121f); - return true; + return true; } - else if (bot->GetPositionX() < 1031.f) //to the first step of the ramp from the tunnel + else if (bot->GetPositionX() < 1031.f) // to the first step of the ramp from the tunnel { MoveTo(bg->GetMapId(), 1031.764282f, 1454.516235f, 343.337860f); - return true; + return true; } - else if (bot->GetPositionX() < 1051.f && bot->GetPositionY() < 1494.f) //to the second step of the ramp from the tunnel + else if (bot->GetPositionX() < 1051.f && + bot->GetPositionY() < 1494.f) // to the second step of the ramp from the tunnel { MoveTo(bg->GetMapId(), 1051.304810f, 1494.917725f, 342.043518f); - return true; + return true; } - else if (bot->GetPositionX() < 1050.f && bot->GetPositionY() < 1538.f) //down the ramp + else if (bot->GetPositionX() < 1050.f && bot->GetPositionY() < 1538.f) // down the ramp { MoveTo(bg->GetMapId(), 1050.089478f, 1538.054443f, 332.460388f); - return true; + return true; } - else if (bot->GetPositionX() < 1050.f && bot->GetPositionY() < 1560.f) //down the ramp + else if (bot->GetPositionX() < 1050.f && bot->GetPositionY() < 1560.f) // down the ramp { MoveTo(bg->GetMapId(), 1050.089478f, 1560.054443f, 332.460388f); - return true; + return true; } - else if (bot->GetPositionX() < 1098.f) //at the ground now + else if (bot->GetPositionX() < 1098.f) // at the ground now { MoveTo(bg->GetMapId(), 1098.716797f, 1535.618652f, 315.727539f); - return true; + return true; } else if (bot->GetPositionX() < 1239.f) { MoveTo(bg->GetMapId(), 1239.085693f, 1541.408569f + frand(-2, +2), 306.491791f); - return true; + return true; } } - if (bot->GetPositionX() < 1227.f) //move to a more random location in the middle part + if (bot->GetPositionX() < 1227.f) // move to a more random location in the middle part { if (bot->GetPositionY() < 1400.f) MoveTo(bg->GetMapId(), 1269.962158f, 1382.655640f + frand(-2, +2), 308.545288f); else MoveTo(bg->GetMapId(), 1227.446289f, 1476.235718f + frand(-2, +2), 307.484589f); - return true; + return true; } - if (Preference < 5) //through the tunnel + if (Preference < 5) // through the tunnel { - if (bot->GetPositionX() < 1351.f) //move to the alliance entrance + if (bot->GetPositionX() < 1351.f) // move to the alliance entrance { MoveTo(bg->GetMapId(), 1351.759155f + frand(0, 2), 1462.368042f + frand(-2, +2), 323.673737f); - return true; + return true; } - else if (bot->GetPositionX() < 1449.f) //move to the alliance fasty + else if (bot->GetPositionX() < 1449.f) // move to the alliance fasty { MoveTo(bg->GetMapId(), 1449.574219f, 1470.698608f, 342.675476f); - return true; + return true; } - else { //move to the flag position + else + { // move to the flag position MoveTo(bg->GetMapId(), 1538.387207f, 1480.903198f, 352.576385f); - return true; + return true; } } else { // up the ramp - if (bot->GetPositionX() < 1360.f) //gate at the ramp + if (bot->GetPositionX() < 1360.f) // gate at the ramp { MoveTo(bg->GetMapId(), 1360.088501f, 1393.451660f + frand(-2, +2), 326.183624f); - return true; + return true; } - if (bot->GetPositionX() < 1399.f) //half way up + if (bot->GetPositionX() < 1399.f) // half way up { MoveTo(bg->GetMapId(), 1399.362061f, 1405.105347f + frand(-2, +2), 341.481476f); - return true; + return true; } - if (bot->GetPositionX() < 1417.f) //first halway + if (bot->GetPositionX() < 1417.f) // first halway { MoveTo(bg->GetMapId(), 1417.096191f, 1459.552368f + frand(-2, +2), 349.591827f); - return true; + return true; } - if (bot->GetPositionX() < 1500.2f) //gate to the flag room + if (bot->GetPositionX() < 1500.2f) // gate to the flag room { MoveTo(bg->GetMapId(), 1505.045654f, 1493.787231f, 352.017670f); - return true; + return true; } else { // move to the flag position MoveTo(bg->GetMapId(), 1538.387207f, 1480.903198f, 352.576385f); - return true; + return true; } } } - else //move towards horde base + else // move towards horde base { - if (Preference < 4) //through the tunnel + if (Preference < 4) // through the tunnel { - if (bot->GetPositionX() > 1449.7f) //to the fasty + if (bot->GetPositionX() > 1449.7f) // to the fasty { MoveTo(bg->GetMapId(), 1449.574219f, 1470.698608f, 342.675476f); - return true; + return true; } else if (bot->GetPositionX() > 1443.9f) { @@ -2691,137 +1853,137 @@ bool BGTactics::wsgPaths() // move into the tunnel MoveTo(bg->GetMapId(), 1380.761963f, 1457.581909f, 329.115417f); } - else if (bot->GetPositionX() > 1351.9f) //to the alliance entrance + else if (bot->GetPositionX() > 1351.9f) // to the alliance entrance { if (bot->GetPositionY() > 1500.f) MoveTo(bg->GetMapId(), 1125.778076f, bot->GetPositionY(), 315.698883f); else MoveTo(bg->GetMapId(), 1125.778076f, 1452.059937f, 315.698883f); - return true; + return true; } - if (bot->GetPositionX() > 1240.f) //move to a more random location in the middle part + if (bot->GetPositionX() > 1240.f) // move to a more random location in the middle part { if (bot->GetPositionY() > 1500.f) MoveTo(bg->GetMapId(), 1239.085693f, 1541.408569f + frand(-2, +2), 306.491791f); else MoveTo(bg->GetMapId(), 1227.446289f, 1476.235718f + frand(-2, +2), 307.484589f); - return true; + return true; } } - else if (Preference < 7) // through the graveyard + else if (Preference < 7) // through the graveyard { - if (bot->GetPositionX() > 1510.2f) //To the first gate + if (bot->GetPositionX() > 1510.2f) // To the first gate { MoveTo(bg->GetMapId(), 1500.045654f, 1493.787231f, 352.017670f); - return true; + return true; } - else if (bot->GetPositionX() > 1460.f) //to the second gate + else if (bot->GetPositionX() > 1460.f) // to the second gate { MoveTo(bg->GetMapId(), 1459.490234f, 1494.175072f, 351.565155f); - return true; + return true; } - else if (bot->GetPositionX() > 1424.f) //to the graveyard + else if (bot->GetPositionX() > 1424.f) // to the graveyard { MoveTo(bg->GetMapId(), 1423.106201f + frand(-2, +2), 1532.851196f, 342.152100f); - return true; + return true; } - else if (bot->GetPositionX() > 1345.f) // to the field + else if (bot->GetPositionX() > 1345.f) // to the field { MoveTo(bg->GetMapId(), 1344.334595f + frand(-2, +2), 1514.917236f, 319.081726f); - return true; + return true; } } else { - if (bot->GetPositionX() > 1505.2f) //To the first gate + if (bot->GetPositionX() > 1505.2f) // To the first gate { MoveTo(bg->GetMapId(), 1500.045654f, 1493.787231f, 352.017670f); - return true; + return true; } - else if (bot->GetPositionX() > 1460.f) //to the second gate + else if (bot->GetPositionX() > 1460.f) // to the second gate { MoveTo(bg->GetMapId(), 1459.490234f, 1494.175072f, 351.565155f); - return true; + return true; } - else if (bot->GetPositionX() > 1418.f) //half on the upper ramp + else if (bot->GetPositionX() > 1418.f) // half on the upper ramp { MoveTo(bg->GetMapId(), 1417.096191f, 1459.552368f, 349.591827f); - return true; + return true; } - else if (bot->GetPositionX() > 1400.f) //middle down the ramp + else if (bot->GetPositionX() > 1400.f) // middle down the ramp { MoveTo(bg->GetMapId(), 1399.362061f, 1405.105347f, 341.481476f); - return true; + return true; } - else if (bot->GetPositionX() > 1357.f) //at the gate + else if (bot->GetPositionX() > 1357.f) // at the gate { MoveTo(bg->GetMapId(), 1356.088501f, 1393.451660f, 326.183624f); - return true; + return true; } - else if (bot->GetPositionX() > 1270.f) // run the gate side way to the middle field + else if (bot->GetPositionX() > 1270.f) // run the gate side way to the middle field { MoveTo(bg->GetMapId(), 1269.962158f, 1398.655640f + frand(-2, +2), 309.945288f); - //MoveTo(bg->GetMapId(), 1269.962158f, 1382.655640f + frand(-2, +2), 308.545288f); + // MoveTo(bg->GetMapId(), 1269.962158f, 1382.655640f + frand(-2, +2), 308.545288f); return true; } } - if (Preference < 5) //horde ramp + if (Preference < 5) // horde ramp { - if (bot->GetPositionX() > 1099.f) //move to the horde ramp gate + if (bot->GetPositionX() > 1099.f) // move to the horde ramp gate { MoveTo(bg->GetMapId(), 1096.716797f, 1535.618652f, 315.727539f); - return true; + return true; } - if (bot->GetPositionX() > 1071.f) //move the ramp up a piece + if (bot->GetPositionX() > 1071.f) // move the ramp up a piece { MoveTo(bg->GetMapId(), 1070.089478f, 1538.054443f, 332.460388f); - return true; + return true; } - if (bot->GetPositionX() > 1050.2f) //move the ramp up a piece + if (bot->GetPositionX() > 1050.2f) // move the ramp up a piece { MoveTo(bg->GetMapId(), 1050.089478f, 1538.054443f, 332.460388f); - return true; + return true; } - if (bot->GetPositionX() > 1032.f) //up in front of first entrance + if (bot->GetPositionX() > 1032.f) // up in front of first entrance { MoveTo(bg->GetMapId(), 1031.764282f, 1454.516235f, 343.337860f); - return true; + return true; } - if (bot->GetPositionX() > 986.f) //up in front of first entrance + if (bot->GetPositionX() > 986.f) // up in front of first entrance { MoveTo(bg->GetMapId(), 985.940125f, 1423.260254f, 345.418121f); - return true; + return true; } MoveTo(bg->GetMapId(), 919.161316f, 1433.871338f, 345.902771f); - return true; + return true; } else { // horde tunnel - if (bot->GetPositionX() > 1125.9f) //move to the horde entrance + if (bot->GetPositionX() > 1125.9f) // move to the horde entrance { MoveTo(bg->GetMapId(), 1125.778076f, 1452.059937f, 315.698883f); - return true; + return true; } - else if (bot->GetPositionX() > 1006.7f) //move to the horde fasty + else if (bot->GetPositionX() > 1006.7f) // move to the horde fasty { MoveTo(bg->GetMapId(), 1006.590210f, 1450.435059f, 335.721283f); - return true; + return true; } else { - //move to the flag position + // move to the flag position MoveTo(bg->GetMapId(), 919.161316f, 1433.871338f, 345.902771f); - return true; + return true; } } } @@ -2834,23 +1996,18 @@ bool BGTactics::eyJumpDown() Battleground* bg = bot->GetBattleground(); if (!bg) return false; - Position const hordeJumpPositions[] = - { + Position const hordeJumpPositions[] = { EY_WAITING_POS_HORDE, - { 1838.007f, 1539.856f, 1253.383f }, - { 1846.264f, 1535.062f, 1240.796f }, - { 1849.813f, 1527.303f, 1237.262f }, - { 1849.041f, 1518.884f, 1223.624f }, + {1838.007f, 1539.856f, 1253.383f}, + {1846.264f, 1535.062f, 1240.796f}, + {1849.813f, 1527.303f, 1237.262f}, + {1849.041f, 1518.884f, 1223.624f}, }; - Position const allianceJumpPositions[] = - { - EY_WAITING_POS_ALLIANCE, - { 2492.955f, 1597.769f, 1254.828f }, - { 2484.601f, 1598.209f, 1244.344f }, - { 2478.424f, 1609.539f, 1238.651f }, - { 2475.926f, 1619.658f, 1218.706f }, + Position const allianceJumpPositions[] = { + EY_WAITING_POS_ALLIANCE, {2492.955f, 1597.769f, 1254.828f}, {2484.601f, 1598.209f, 1244.344f}, + {2478.424f, 1609.539f, 1238.651f}, {2475.926f, 1619.658f, 1218.706f}, }; - Position const *positons = bot->GetTeamId() == TEAM_HORDE ? hordeJumpPositions : allianceJumpPositions; + Position const* positons = bot->GetTeamId() == TEAM_HORDE ? hordeJumpPositions : allianceJumpPositions; { if (bot->GetDistance(positons[0]) < 16.0f) { @@ -2978,7 +2135,7 @@ bool BGTactics::Execute(Event event) switch (bot->GetMotionMaster()->GetCurrentMovementGeneratorType()) { - //TODO: should ESCORT_MOTION_TYPE be here seeing as bots use it by default? + // TODO: should ESCORT_MOTION_TYPE be here seeing as bots use it by default? case IDLE_MOTION_TYPE: case CHASE_MOTION_TYPE: case POINT_MOTION_TYPE: @@ -2993,9 +2150,11 @@ bool BGTactics::Execute(Event event) if (useBuff()) return true; - if (bot->IsInCombat() && !(bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))) + if (bot->IsInCombat() && + !(bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || + bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))) { - //bot->GetMotionMaster()->MovementExpired(); + // bot->GetMotionMaster()->MovementExpired(); return false; } @@ -3008,7 +2167,8 @@ bool BGTactics::Execute(Event event) return true; // bot with flag should only move to objective - if (bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL)) + if (bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || + bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL)) return false; if (startNewPathBegin(*vPaths)) @@ -3042,7 +2202,7 @@ bool BGTactics::Execute(Event event) bool BGTactics::moveToStart(bool force) { - Battleground *bg = bot->GetBattleground(); + Battleground* bg = bot->GetBattleground(); if (!bg) return false; @@ -3061,38 +2221,52 @@ bool BGTactics::moveToStart(bool force) if (startSpot == BB_WSG_WAIT_SPOT_RIGHT) { if (bot->GetTeamId() == TEAM_HORDE) - MoveTo(bg->GetMapId(), WS_WAITING_POS_HORDE_1.GetPositionX() + frand(-2.0f, 2.0f), WS_WAITING_POS_HORDE_1.GetPositionY() + frand(-2.0f, 2.0f), WS_WAITING_POS_HORDE_1.GetPositionZ()); + MoveTo(bg->GetMapId(), WS_WAITING_POS_HORDE_1.GetPositionX() + frand(-2.0f, 2.0f), + WS_WAITING_POS_HORDE_1.GetPositionY() + frand(-2.0f, 2.0f), + WS_WAITING_POS_HORDE_1.GetPositionZ()); else - MoveTo(bg->GetMapId(), WS_WAITING_POS_ALLIANCE_1.GetPositionX() + frand(-2.0f, 2.0f), WS_WAITING_POS_ALLIANCE_1.GetPositionY() + frand(-2.0f, 2.0f), WS_WAITING_POS_ALLIANCE_1.GetPositionZ()); + MoveTo(bg->GetMapId(), WS_WAITING_POS_ALLIANCE_1.GetPositionX() + frand(-2.0f, 2.0f), + WS_WAITING_POS_ALLIANCE_1.GetPositionY() + frand(-2.0f, 2.0f), + WS_WAITING_POS_ALLIANCE_1.GetPositionZ()); } else if (startSpot == BB_WSG_WAIT_SPOT_LEFT) { if (bot->GetTeamId() == TEAM_HORDE) - MoveTo(bg->GetMapId(), WS_WAITING_POS_HORDE_2.GetPositionX() + frand(-2.0f, 2.0f), WS_WAITING_POS_HORDE_2.GetPositionY() + frand(-2.0f, 2.0f), WS_WAITING_POS_HORDE_2.GetPositionZ()); + MoveTo(bg->GetMapId(), WS_WAITING_POS_HORDE_2.GetPositionX() + frand(-2.0f, 2.0f), + WS_WAITING_POS_HORDE_2.GetPositionY() + frand(-2.0f, 2.0f), + WS_WAITING_POS_HORDE_2.GetPositionZ()); else - MoveTo(bg->GetMapId(), WS_WAITING_POS_ALLIANCE_2.GetPositionX() + frand(-2.0f, 2.0f), WS_WAITING_POS_ALLIANCE_2.GetPositionY() + frand(-2.0f, 2.0f), WS_WAITING_POS_ALLIANCE_2.GetPositionZ()); + MoveTo(bg->GetMapId(), WS_WAITING_POS_ALLIANCE_2.GetPositionX() + frand(-2.0f, 2.0f), + WS_WAITING_POS_ALLIANCE_2.GetPositionY() + frand(-2.0f, 2.0f), + WS_WAITING_POS_ALLIANCE_2.GetPositionZ()); } } else if (bgType == BATTLEGROUND_AB) { if (bot->GetTeamId() == TEAM_HORDE) - MoveTo(bg->GetMapId(), AB_WAITING_POS_HORDE.GetPositionX() + frand(-2.0f, 2.0f), AB_WAITING_POS_HORDE.GetPositionY() + frand(-2.0f, 2.0f), AB_WAITING_POS_HORDE.GetPositionZ()); + MoveTo(bg->GetMapId(), AB_WAITING_POS_HORDE.GetPositionX() + frand(-2.0f, 2.0f), + AB_WAITING_POS_HORDE.GetPositionY() + frand(-2.0f, 2.0f), AB_WAITING_POS_HORDE.GetPositionZ()); else - MoveTo(bg->GetMapId(), AB_WAITING_POS_ALLIANCE.GetPositionX() + frand(-2.0f, 2.0f), AB_WAITING_POS_ALLIANCE.GetPositionY() + frand(-2.0f, 2.0f), AB_WAITING_POS_ALLIANCE.GetPositionZ()); + MoveTo(bg->GetMapId(), AB_WAITING_POS_ALLIANCE.GetPositionX() + frand(-2.0f, 2.0f), + AB_WAITING_POS_ALLIANCE.GetPositionY() + frand(-2.0f, 2.0f), AB_WAITING_POS_ALLIANCE.GetPositionZ()); } else if (bgType == BATTLEGROUND_AV) { if (bot->GetTeamId() == TEAM_HORDE) - MoveTo(bg->GetMapId(), AV_WAITING_POS_HORDE.GetPositionX() + frand(-3.0f, 3.0f), AV_WAITING_POS_HORDE.GetPositionY() + frand(-3.0f, 3.0f), AV_WAITING_POS_HORDE.GetPositionZ()); + MoveTo(bg->GetMapId(), AV_WAITING_POS_HORDE.GetPositionX() + frand(-3.0f, 3.0f), + AV_WAITING_POS_HORDE.GetPositionY() + frand(-3.0f, 3.0f), AV_WAITING_POS_HORDE.GetPositionZ()); else - MoveTo(bg->GetMapId(), AV_WAITING_POS_ALLIANCE.GetPositionX() + frand(-3.0f, 3.0f), AV_WAITING_POS_ALLIANCE.GetPositionY() + frand(-3.0f, 3.0f), AV_WAITING_POS_ALLIANCE.GetPositionZ()); + MoveTo(bg->GetMapId(), AV_WAITING_POS_ALLIANCE.GetPositionX() + frand(-3.0f, 3.0f), + AV_WAITING_POS_ALLIANCE.GetPositionY() + frand(-3.0f, 3.0f), AV_WAITING_POS_ALLIANCE.GetPositionZ()); } else if (bgType == BATTLEGROUND_EY) { if (bot->GetTeamId() == TEAM_HORDE) - MoveTo(bg->GetMapId(), EY_WAITING_POS_HORDE.GetPositionX() + frand(-3.0f, 3.0f), EY_WAITING_POS_HORDE.GetPositionY() + frand(-3.0f, 3.0f), EY_WAITING_POS_HORDE.GetPositionZ()); + MoveTo(bg->GetMapId(), EY_WAITING_POS_HORDE.GetPositionX() + frand(-3.0f, 3.0f), + EY_WAITING_POS_HORDE.GetPositionY() + frand(-3.0f, 3.0f), EY_WAITING_POS_HORDE.GetPositionZ()); else - MoveTo(bg->GetMapId(), EY_WAITING_POS_ALLIANCE.GetPositionX() + frand(-3.0f, 3.0f), EY_WAITING_POS_ALLIANCE.GetPositionZ() + frand(-3.0f, 3.0f), EY_WAITING_POS_ALLIANCE.GetPositionZ()); + MoveTo(bg->GetMapId(), EY_WAITING_POS_ALLIANCE.GetPositionX() + frand(-3.0f, 3.0f), + EY_WAITING_POS_ALLIANCE.GetPositionZ() + frand(-3.0f, 3.0f), EY_WAITING_POS_ALLIANCE.GetPositionZ()); } else if (bgType == BATTLEGROUND_IC) { @@ -3103,16 +2277,24 @@ bool BGTactics::moveToStart(bool force) if (role < 3) { if (urand(0, 1)) - MoveTo(bg->GetMapId(), IC_WEST_WAITING_POS_HORDE.GetPositionX() + frand(-5.0f, 5.0f), IC_WEST_WAITING_POS_HORDE.GetPositionY() + frand(-5.0f, 5.0f), IC_WEST_WAITING_POS_HORDE.GetPositionZ()); + MoveTo(bg->GetMapId(), IC_WEST_WAITING_POS_HORDE.GetPositionX() + frand(-5.0f, 5.0f), + IC_WEST_WAITING_POS_HORDE.GetPositionY() + frand(-5.0f, 5.0f), + IC_WEST_WAITING_POS_HORDE.GetPositionZ()); else - MoveTo(bg->GetMapId(), IC_WAITING_POS_HORDE.GetPositionX() + frand(-5.0f, 5.0f), IC_WAITING_POS_HORDE.GetPositionY() + frand(-5.0f, 5.0f), IC_WAITING_POS_HORDE.GetPositionZ()); + MoveTo(bg->GetMapId(), IC_WAITING_POS_HORDE.GetPositionX() + frand(-5.0f, 5.0f), + IC_WAITING_POS_HORDE.GetPositionY() + frand(-5.0f, 5.0f), + IC_WAITING_POS_HORDE.GetPositionZ()); } else { if (urand(0, 1)) - MoveTo(bg->GetMapId(), IC_EAST_WAITING_POS_HORDE.GetPositionX() + frand(-5.0f, 5.0f), IC_EAST_WAITING_POS_HORDE.GetPositionY() + frand(-5.0f, 5.0f), IC_EAST_WAITING_POS_HORDE.GetPositionZ()); + MoveTo(bg->GetMapId(), IC_EAST_WAITING_POS_HORDE.GetPositionX() + frand(-5.0f, 5.0f), + IC_EAST_WAITING_POS_HORDE.GetPositionY() + frand(-5.0f, 5.0f), + IC_EAST_WAITING_POS_HORDE.GetPositionZ()); else - MoveTo(bg->GetMapId(), IC_WAITING_POS_HORDE.GetPositionX() + frand(-5.0f, 5.0f), IC_WAITING_POS_HORDE.GetPositionY() + frand(-5.0f, 5.0f), IC_WAITING_POS_HORDE.GetPositionZ()); + MoveTo(bg->GetMapId(), IC_WAITING_POS_HORDE.GetPositionX() + frand(-5.0f, 5.0f), + IC_WAITING_POS_HORDE.GetPositionY() + frand(-5.0f, 5.0f), + IC_WAITING_POS_HORDE.GetPositionZ()); } } else @@ -3120,16 +2302,24 @@ bool BGTactics::moveToStart(bool force) if (role < 3) { if (urand(0, 1)) - MoveTo(bg->GetMapId(), IC_SIDE_WAITING_POS_ALLIANCE.GetPositionX() + frand(-5.0f, 5.0f), IC_SIDE_WAITING_POS_ALLIANCE.GetPositionY() + frand(-5.0f, 5.0f), IC_SIDE_WAITING_POS_ALLIANCE.GetPositionZ()); + MoveTo(bg->GetMapId(), IC_SIDE_WAITING_POS_ALLIANCE.GetPositionX() + frand(-5.0f, 5.0f), + IC_SIDE_WAITING_POS_ALLIANCE.GetPositionY() + frand(-5.0f, 5.0f), + IC_SIDE_WAITING_POS_ALLIANCE.GetPositionZ()); else - MoveTo(bg->GetMapId(), IC_WAITING_POS_ALLIANCE.GetPositionX() + frand(-5.0f, 5.0f), IC_WAITING_POS_ALLIANCE.GetPositionY() + frand(-5.0f, 5.0f), IC_WAITING_POS_ALLIANCE.GetPositionZ()); + MoveTo(bg->GetMapId(), IC_WAITING_POS_ALLIANCE.GetPositionX() + frand(-5.0f, 5.0f), + IC_WAITING_POS_ALLIANCE.GetPositionY() + frand(-5.0f, 5.0f), + IC_WAITING_POS_ALLIANCE.GetPositionZ()); } else { if (urand(0, 1)) - MoveTo(bg->GetMapId(), IC_SIDE_WAITING_POS_ALLIANCE.GetPositionX() + frand(-5.0f, 5.0f), IC_SIDE_WAITING_POS_ALLIANCE.GetPositionY() + frand(-5.0f, 5.0f), IC_SIDE_WAITING_POS_ALLIANCE.GetPositionZ()); + MoveTo(bg->GetMapId(), IC_SIDE_WAITING_POS_ALLIANCE.GetPositionX() + frand(-5.0f, 5.0f), + IC_SIDE_WAITING_POS_ALLIANCE.GetPositionY() + frand(-5.0f, 5.0f), + IC_SIDE_WAITING_POS_ALLIANCE.GetPositionZ()); else - MoveTo(bg->GetMapId(), IC_WAITING_POS_ALLIANCE.GetPositionX() + frand(-5.0f, 5.0f), IC_WAITING_POS_ALLIANCE.GetPositionY() + frand(-5.0f, 5.0f), IC_WAITING_POS_ALLIANCE.GetPositionZ()); + MoveTo(bg->GetMapId(), IC_WAITING_POS_ALLIANCE.GetPositionX() + frand(-5.0f, 5.0f), + IC_WAITING_POS_ALLIANCE.GetPositionY() + frand(-5.0f, 5.0f), + IC_WAITING_POS_ALLIANCE.GetPositionZ()); } } } @@ -3162,16 +2352,17 @@ bool BGTactics::selectObjective(bool reset) { BattlegroundAV* alterValleyBG = (BattlegroundAV*)bg; uint32 role = context->GetValue("bg role")->Get(); - bool supportDefense = role < 3;//defensive role and mine capture (mine capture disabled for now) - bool advancedAttack = role > 5;//doesnt wait for point to be fully captured before moving on + bool supportDefense = role < 3; // defensive role and mine capture (mine capture disabled for now) + bool advancedAttack = role > 5; // doesnt wait for point to be fully captured before moving on - // some of the code below is a bit inefficent (lots of rechecking same variables, could be made more efficient with a refactor) - // but it's been left this way so it can be easily reordered. in future we could implement different strategies (eg: focus on - // defense, rush to boss, etc), by re-ordering at runtime + // some of the code below is a bit inefficent (lots of rechecking same variables, could be made more + // efficient with a refactor) but it's been left this way so it can be easily reordered. in future we could + // implement different strategies (eg: focus on defense, rush to boss, etc), by re-ordering at runtime if (bot->GetTeamId() == TEAM_HORDE) { - bool enemyTowersDown = alterValleyBG->GetAVNodeInfo(BG_AV_NODES_DUNBALDAR_NORTH).State == POINT_DESTROYED && + bool enemyTowersDown = + alterValleyBG->GetAVNodeInfo(BG_AV_NODES_DUNBALDAR_NORTH).State == POINT_DESTROYED && alterValleyBG->GetAVNodeInfo(BG_AV_NODES_DUNBALDAR_SOUTH).State == POINT_DESTROYED && alterValleyBG->GetAVNodeInfo(BG_AV_NODES_ICEWING_BUNKER).State == POINT_DESTROYED && alterValleyBG->GetAVNodeInfo(BG_AV_NODES_STONEHEART_BUNKER).State == POINT_DESTROYED; @@ -3186,7 +2377,8 @@ bool BGTactics::selectObjective(bool reset) } } - // if towers all down only worry about attacking/holding final GY (this prevents them running all the way back to recap previous GY's when they're close to boss) + // if towers all down only worry about attacking/holding final GY (this prevents them running all the + // way back to recap previous GY's when they're close to boss) if (!BgObjective && enemyTowersDown) { if (GameObject* pGO = bg->GetBGObject(BG_AV_OBJECT_FLAG_A_FIRSTAID_STATION)) @@ -3225,7 +2417,9 @@ bool BGTactics::selectObjective(bool reset) } } - // attack or prepare to attack enemy captain if alive (this takes priority over other supportDefense tasks to avoid endless middle fighting and/or one side losing too many GY's before getting captain down) + // attack or prepare to attack enemy captain if alive (this takes priority over other supportDefense + // tasks to avoid endless middle fighting and/or one side losing too many GY's before getting captain + // down) if (!BgObjective && alterValleyBG->IsCaptainAlive(TEAM_ALLIANCE)) { if (Creature* enemyCaptain = bg->GetBGCreature(AV_CREATURE_A_CAPTAIN)) @@ -3233,17 +2427,24 @@ bool BGTactics::selectObjective(bool reset) if (enemyCaptain->getDeathState() != DeathState::Dead) { BgObjective = enemyCaptain; - uint32 attackCount = getPlayersInArea(bot->GetTeamId(), AV_STONEHEARTH_WAITING_HORDE, 10.0f, false) + getPlayersInArea(bot->GetTeamId(), AV_STONEHEARTH_ATTACKING_HORDE, 10.0f, false); + uint32 attackCount = + getPlayersInArea(bot->GetTeamId(), AV_STONEHEARTH_WAITING_HORDE, 10.0f, false) + + getPlayersInArea(bot->GetTeamId(), AV_STONEHEARTH_ATTACKING_HORDE, 10.0f, false); // prepare to attack Captain if (attackCount < 15 && !enemyCaptain->IsInCombat()) { // get in position to attack Captain - pos.Set(AV_STONEHEARTH_WAITING_HORDE.GetPositionX(), AV_STONEHEARTH_WAITING_HORDE.GetPositionY(), AV_STONEHEARTH_WAITING_HORDE.GetPositionZ(), bg->GetMapId()); + pos.Set(AV_STONEHEARTH_WAITING_HORDE.GetPositionX(), + AV_STONEHEARTH_WAITING_HORDE.GetPositionY(), + AV_STONEHEARTH_WAITING_HORDE.GetPositionZ(), bg->GetMapId()); } else { - // they need help getting there (or did before I fixed the target creature, will leave in anyway, as it probably makes it more robust) - pos.Set(AV_STONEHEARTH_ATTACKING_HORDE.GetPositionX(), AV_STONEHEARTH_ATTACKING_HORDE.GetPositionY(), AV_STONEHEARTH_ATTACKING_HORDE.GetPositionZ(), bg->GetMapId()); + // they need help getting there (or did before I fixed the target creature, will leave + // in anyway, as it probably makes it more robust) + pos.Set(AV_STONEHEARTH_ATTACKING_HORDE.GetPositionX(), + AV_STONEHEARTH_ATTACKING_HORDE.GetPositionY(), + AV_STONEHEARTH_ATTACKING_HORDE.GetPositionZ(), bg->GetMapId()); } } } @@ -3259,10 +2460,11 @@ bool BGTactics::selectObjective(bool reset) } } - // (supportDefense) go to last defence objective that isn't destroyed (ie: next objective they'll attack) + // (supportDefense) go to last defence objective that isn't destroyed (ie: next objective they'll + // attack) if (!BgObjective && supportDefense) { - for (const auto& objective : AV_HordeDefendObjectives)//TODO go reverse instead of not breaking + for (const auto& objective : AV_HordeDefendObjectives) // TODO go reverse instead of not breaking { if (alterValleyBG->GetAVNodeInfo(objective.first).State != POINT_DESTROYED) { @@ -3274,38 +2476,46 @@ bool BGTactics::selectObjective(bool reset) // (supportDefense) Mine capture (disabled for now) if (false && !BgObjective && supportDefense && - (alterValleyBG->GetMineOwner(AV_NORTH_MINE) == TEAM_ALLIANCE || alterValleyBG->GetMineOwner(AV_NORTH_MINE) == TEAM_NEUTRAL) && + (alterValleyBG->GetMineOwner(AV_NORTH_MINE) == TEAM_ALLIANCE || + alterValleyBG->GetMineOwner(AV_NORTH_MINE) == TEAM_NEUTRAL) && alterValleyBG->GetAVNodeInfo(BG_AV_NODES_STORMPIKE_GRAVE).OwnerId != TEAM_ALLIANCE) { if (Creature* mBossNeutral = bg->GetBGCreature(AV_CPLACE_MINE_N_3)) { - if (bot->IsWithinDist(mBossNeutral, 400.0f) && mBossNeutral->getDeathState() != DeathState::Dead && alterValleyBG->GetMineOwner(AV_NORTH_MINE) == TEAM_NEUTRAL) + if (bot->IsWithinDist(mBossNeutral, 400.0f) && + mBossNeutral->getDeathState() != DeathState::Dead && + alterValleyBG->GetMineOwner(AV_NORTH_MINE) == TEAM_NEUTRAL) { BgObjective = mBossNeutral; LOG_INFO("playerbots", "HORDE bot={} Attacking Neutral Mine Boss!", bot->GetName()); - //std::ostringstream out; - //out << "Attacking Neutral Mine Boss!"; - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Attacking Neutral Mine Boss!"; + // bot->Say(out.str(), LANG_UNIVERSAL); } } // um isnt this checking same creature twice? if (Creature* mBossAlly = bg->GetBGCreature(AV_CPLACE_MINE_N_3)) { - if (!BgObjective && bot->IsWithinDist(mBossAlly, 400.0f) && mBossAlly->getDeathState() != DeathState::Dead && alterValleyBG->GetMineOwner(AV_NORTH_MINE) == TEAM_NEUTRAL) + if (!BgObjective && bot->IsWithinDist(mBossAlly, 400.0f) && + mBossAlly->getDeathState() != DeathState::Dead && + alterValleyBG->GetMineOwner(AV_NORTH_MINE) == TEAM_NEUTRAL) { BgObjective = mBossAlly; LOG_INFO("playerbots", "HORDE bot={} Attacking Ally Mine Boss!", bot->GetName()); - //std::ostringstream out; - //out << "Attacking Ally Mine Boss!"; - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Attacking Ally Mine Boss!"; + // bot->Say(out.str(), LANG_UNIVERSAL); } } } - // Attack first objective if close (this is mostly to help ally out by steering them toward getting GY first) - if (!BgObjective && alterValleyBG->GetAVNodeInfo(AV_HordeAttackObjectives[0].first).OwnerId == TEAM_ALLIANCE) + // Attack first objective if close (this is mostly to help ally out by steering them toward getting GY + // first) + if (!BgObjective && + alterValleyBG->GetAVNodeInfo(AV_HordeAttackObjectives[0].first).OwnerId == TEAM_ALLIANCE) { - if (GameObject* pGO = bg->GetBGObject(AV_HordeAttackObjectives[0].second)) { + if (GameObject* pGO = bg->GetBGObject(AV_HordeAttackObjectives[0].second)) + { float const distance = sqrt(bot->GetDistance(pGO)); if (distance < 20.0f) BgObjective = pGO; @@ -3318,8 +2528,12 @@ bool BGTactics::selectObjective(bool reset) float attackObjectiveDistance = FLT_MAX; for (const auto& objective : AV_HordeAttackObjectives) { - if ((!advancedAttack && alterValleyBG->GetAVNodeInfo(objective.first).TotalOwnerId == TEAM_ALLIANCE) || - (alterValleyBG->GetAVNodeInfo(objective.first).OwnerId == TEAM_ALLIANCE))//OwnerId changes when objective partially captured, TotalOwnerId only changes when its fully captured/destroyed (so this code will allow advancedAttack bots move on to next point) + if ((!advancedAttack && + alterValleyBG->GetAVNodeInfo(objective.first).TotalOwnerId == TEAM_ALLIANCE) || + (alterValleyBG->GetAVNodeInfo(objective.first).OwnerId == + TEAM_ALLIANCE)) // OwnerId changes when objective partially captured, TotalOwnerId only + // changes when its fully captured/destroyed (so this code will allow + // advancedAttack bots move on to next point) { if (GameObject* pGO = bg->GetBGObject(objective.second)) { @@ -3334,15 +2548,15 @@ bool BGTactics::selectObjective(bool reset) } } } - else //TEAM_ALLIANCE + else // TEAM_ALLIANCE { - bool enemyTowersDown = alterValleyBG->GetAVNodeInfo(BG_AV_NODES_FROSTWOLF_WTOWER).State == POINT_DESTROYED && + bool enemyTowersDown = + alterValleyBG->GetAVNodeInfo(BG_AV_NODES_FROSTWOLF_WTOWER).State == POINT_DESTROYED && alterValleyBG->GetAVNodeInfo(BG_AV_NODES_FROSTWOLF_ETOWER).State == POINT_DESTROYED && alterValleyBG->GetAVNodeInfo(BG_AV_NODES_TOWER_POINT).State == POINT_DESTROYED && alterValleyBG->GetAVNodeInfo(BG_AV_NODES_ICEBLOOD_TOWER).State == POINT_DESTROYED; // End Boss - if (enemyTowersDown && - alterValleyBG->GetAVNodeInfo(BG_AV_NODES_FROSTWOLF_HUT).OwnerId != TEAM_HORDE && + if (enemyTowersDown && alterValleyBG->GetAVNodeInfo(BG_AV_NODES_FROSTWOLF_HUT).OwnerId != TEAM_HORDE && alterValleyBG->GetAVNodeInfo(BG_AV_NODES_FROSTWOLF_HUT).TotalOwnerId != TEAM_HORDE) { if (Creature* enemyBoss = bg->GetBGCreature(AV_CREATURE_H_BOSS)) @@ -3351,7 +2565,8 @@ bool BGTactics::selectObjective(bool reset) } } - // if towers all down only worry about attacking/holding final GY (this prevents them running all the way back to recap previous GY's when they're close to boss) + // if towers all down only worry about attacking/holding final GY (this prevents them running all the + // way back to recap previous GY's when they're close to boss) if (!BgObjective && enemyTowersDown) { if (GameObject* pGO = bg->GetBGObject(BG_AV_OBJECT_FLAG_H_FROSTWOLF_HUT)) @@ -3390,7 +2605,9 @@ bool BGTactics::selectObjective(bool reset) } } - // attack or prepare to attack enemy captain if alive (this takes priority over other supportDefense tasks to avoid endless middle fighting and/or one side losing too many GY's before getting captain down) + // attack or prepare to attack enemy captain if alive (this takes priority over other supportDefense + // tasks to avoid endless middle fighting and/or one side losing too many GY's before getting captain + // down) if (!BgObjective && alterValleyBG->IsCaptainAlive(TEAM_HORDE)) { if (Creature* enemyCaptain = bg->GetBGCreature(AV_CREATURE_H_CAPTAIN)) @@ -3398,17 +2615,26 @@ bool BGTactics::selectObjective(bool reset) if (enemyCaptain->getDeathState() != DeathState::Dead) { BgObjective = enemyCaptain; - uint32 attackCount = getPlayersInArea(bot->GetTeamId(), AV_ICEBLOOD_GARRISON_WAITING_ALLIANCE, 10.0f, false) + getPlayersInArea(bot->GetTeamId(), AV_ICEBLOOD_GARRISON_ATTACKING_ALLIANCE, 10.0f, false); + uint32 attackCount = + getPlayersInArea(bot->GetTeamId(), AV_ICEBLOOD_GARRISON_WAITING_ALLIANCE, 10.0f, + false) + + getPlayersInArea(bot->GetTeamId(), AV_ICEBLOOD_GARRISON_ATTACKING_ALLIANCE, 10.0f, + false); // prepare to attack Captain if (attackCount < 15 && !enemyCaptain->IsInCombat()) { // get in position to attack Captain - pos.Set(AV_ICEBLOOD_GARRISON_WAITING_ALLIANCE.GetPositionX(), AV_ICEBLOOD_GARRISON_WAITING_ALLIANCE.GetPositionY(), AV_ICEBLOOD_GARRISON_WAITING_ALLIANCE.GetPositionZ(), bg->GetMapId()); + pos.Set(AV_ICEBLOOD_GARRISON_WAITING_ALLIANCE.GetPositionX(), + AV_ICEBLOOD_GARRISON_WAITING_ALLIANCE.GetPositionY(), + AV_ICEBLOOD_GARRISON_WAITING_ALLIANCE.GetPositionZ(), bg->GetMapId()); } else { - // they need help getting there (or did before I fixed the target creature, will leave in anyway, as it probably makes it more robust) - pos.Set(AV_ICEBLOOD_GARRISON_ATTACKING_ALLIANCE.GetPositionX(), AV_ICEBLOOD_GARRISON_ATTACKING_ALLIANCE.GetPositionY(), AV_ICEBLOOD_GARRISON_ATTACKING_ALLIANCE.GetPositionZ(), bg->GetMapId()); + // they need help getting there (or did before I fixed the target creature, will leave + // in anyway, as it probably makes it more robust) + pos.Set(AV_ICEBLOOD_GARRISON_ATTACKING_ALLIANCE.GetPositionX(), + AV_ICEBLOOD_GARRISON_ATTACKING_ALLIANCE.GetPositionY(), + AV_ICEBLOOD_GARRISON_ATTACKING_ALLIANCE.GetPositionZ(), bg->GetMapId()); } } } @@ -3424,10 +2650,12 @@ bool BGTactics::selectObjective(bool reset) } } - // (supportDefense) go to last defence objective that isn't destroyed (ie: next objective they'll attack) + // (supportDefense) go to last defence objective that isn't destroyed (ie: next objective they'll + // attack) if (!BgObjective && supportDefense) { - for (const auto& objective : AV_AllianceDefendObjectives)//TODO go reverse instead of not breaking + for (const auto& objective : AV_AllianceDefendObjectives) // TODO go reverse instead of not + // breaking { if (alterValleyBG->GetAVNodeInfo(objective.first).State != POINT_DESTROYED) { @@ -3439,38 +2667,46 @@ bool BGTactics::selectObjective(bool reset) // (supportDefense) Mine capture (disabled for now) if (false && !BgObjective && supportDefense && - (alterValleyBG->GetMineOwner(AV_SOUTH_MINE) == TEAM_HORDE || alterValleyBG->GetMineOwner(AV_SOUTH_MINE) == TEAM_NEUTRAL) && + (alterValleyBG->GetMineOwner(AV_SOUTH_MINE) == TEAM_HORDE || + alterValleyBG->GetMineOwner(AV_SOUTH_MINE) == TEAM_NEUTRAL) && alterValleyBG->GetAVNodeInfo(BG_AV_NODES_FROSTWOLF_GRAVE).TotalOwnerId != TEAM_HORDE) { if (Creature* mBossNeutral = bg->GetBGCreature(AV_CPLACE_MINE_S_3)) { - if (bot->IsWithinDist(mBossNeutral, 400.0f) && mBossNeutral->getDeathState() != DeathState::Dead && alterValleyBG->GetMineOwner(AV_SOUTH_MINE) == TEAM_NEUTRAL) + if (bot->IsWithinDist(mBossNeutral, 400.0f) && + mBossNeutral->getDeathState() != DeathState::Dead && + alterValleyBG->GetMineOwner(AV_SOUTH_MINE) == TEAM_NEUTRAL) { BgObjective = mBossNeutral; LOG_INFO("playerbots", "ALLIANCE bot={} Attacking Neutral Mine Boss!", bot->GetName()); - //std::ostringstream out; - //out << "Attacking Neutral Mine Boss!"; - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Attacking Neutral Mine Boss!"; + // bot->Say(out.str(), LANG_UNIVERSAL); } } // um isnt this checking same creature twice? if (Creature* mBossHorde = bg->GetBGCreature(AV_CPLACE_MINE_S_3)) { - if (!BgObjective && bot->IsWithinDist(mBossHorde, 400.0f) && mBossHorde->getDeathState() != DeathState::Dead && alterValleyBG->GetMineOwner(AV_SOUTH_MINE) == TEAM_HORDE) + if (!BgObjective && bot->IsWithinDist(mBossHorde, 400.0f) && + mBossHorde->getDeathState() != DeathState::Dead && + alterValleyBG->GetMineOwner(AV_SOUTH_MINE) == TEAM_HORDE) { BgObjective = mBossHorde; LOG_INFO("playerbots", "ALLIANCE bot={} Attacking Horde Mine Boss!", bot->GetName()); - //std::ostringstream out; - //out << "Attacking Horde Mine Boss!"; - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Attacking Horde Mine Boss!"; + // bot->Say(out.str(), LANG_UNIVERSAL); } } } - // Attack first objective if close (this is mostly to help ally out by steering them toward getting GY first) - if (!BgObjective && alterValleyBG->GetAVNodeInfo(AV_AllianceAttackObjectives[0].first).OwnerId == TEAM_HORDE) + // Attack first objective if close (this is mostly to help ally out by steering them toward getting GY + // first) + if (!BgObjective && + alterValleyBG->GetAVNodeInfo(AV_AllianceAttackObjectives[0].first).OwnerId == TEAM_HORDE) { - if (GameObject* pGO = bg->GetBGObject(AV_AllianceAttackObjectives[0].second)) { + if (GameObject* pGO = bg->GetBGObject(AV_AllianceAttackObjectives[0].second)) + { float const distance = sqrt(bot->GetDistance(pGO)); if (distance < 20.0f) BgObjective = pGO; @@ -3483,8 +2719,12 @@ bool BGTactics::selectObjective(bool reset) float attackObjectiveDistance = FLT_MAX; for (const auto& objective : AV_AllianceAttackObjectives) { - if ((!advancedAttack && alterValleyBG->GetAVNodeInfo(objective.first).TotalOwnerId == TEAM_HORDE) || - (alterValleyBG->GetAVNodeInfo(objective.first).OwnerId == TEAM_HORDE))//OwnerId changes when objective partially captured, TotalOwnerId only changes when its fully captured/destroyed (so this code will allow advancedAttack bots move on to next point) + if ((!advancedAttack && + alterValleyBG->GetAVNodeInfo(objective.first).TotalOwnerId == TEAM_HORDE) || + (alterValleyBG->GetAVNodeInfo(objective.first).OwnerId == + TEAM_HORDE)) // OwnerId changes when objective partially captured, TotalOwnerId only + // changes when its fully captured/destroyed (so this code will allow + // advancedAttack bots move on to next point) { if (GameObject* pGO = bg->GetBGObject(objective.second)) { @@ -3502,7 +2742,8 @@ bool BGTactics::selectObjective(bool reset) if (BgObjective) { if (!pos.isSet()) - pos.Set(BgObjective->GetPositionX(), BgObjective->GetPositionY(), BgObjective->GetPositionZ(), BgObjective->GetMapId()); + pos.Set(BgObjective->GetPositionX(), BgObjective->GetPositionY(), BgObjective->GetPositionZ(), + BgObjective->GetMapId()); posMap["bg objective"] = pos; return true; @@ -3521,49 +2762,56 @@ bool BGTactics::selectObjective(bool reset) { if (teamFlagTaken()) { - //Position hidePos = WS_FLAG_HIDE_ALLIANCE[urand(0, 2)]; + // Position hidePos = WS_FLAG_HIDE_ALLIANCE[urand(0, 2)]; Position hidePos = WS_FLAG_HIDE_ALLIANCE[0]; - pos.Set(hidePos.GetPositionX(), hidePos.GetPositionY(), hidePos.GetPositionZ(), bot->GetMapId()); + pos.Set(hidePos.GetPositionX(), hidePos.GetPositionY(), hidePos.GetPositionZ(), + bot->GetMapId()); } else - pos.Set(WS_FLAG_POS_ALLIANCE.GetPositionX(), WS_FLAG_POS_ALLIANCE.GetPositionY(), WS_FLAG_POS_ALLIANCE.GetPositionZ(), bot->GetMapId()); + pos.Set(WS_FLAG_POS_ALLIANCE.GetPositionX(), WS_FLAG_POS_ALLIANCE.GetPositionY(), + WS_FLAG_POS_ALLIANCE.GetPositionZ(), bot->GetMapId()); } else { if (teamFlagTaken()) { - //Position hidePos = WS_FLAG_HIDE_HORDE[urand(0, 2)]; + // Position hidePos = WS_FLAG_HIDE_HORDE[urand(0, 2)]; Position hidePos = WS_FLAG_HIDE_HORDE[0]; - pos.Set(hidePos.GetPositionX(), hidePos.GetPositionY(), hidePos.GetPositionZ(), bot->GetMapId()); + pos.Set(hidePos.GetPositionX(), hidePos.GetPositionY(), hidePos.GetPositionZ(), + bot->GetMapId()); } else - pos.Set(WS_FLAG_POS_HORDE.GetPositionX(), WS_FLAG_POS_HORDE.GetPositionY(), WS_FLAG_POS_HORDE.GetPositionZ(), bot->GetMapId()); + pos.Set(WS_FLAG_POS_HORDE.GetPositionX(), WS_FLAG_POS_HORDE.GetPositionY(), + WS_FLAG_POS_HORDE.GetPositionZ(), bot->GetMapId()); } - //std::ostringstream out; - //if (teamFlagTaken()) - // out << "Hiding with flag" << (bot->GetTeamId() == TEAM_ALLIANCE ? "in Alliance base" : "in Horde base"); - //else - // out << "Taking " << (bot->GetTeamId() == TEAM_ALLIANCE ? "Horde flag to base" : "Alliance flag to base"); - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // if (teamFlagTaken()) + // out << "Hiding with flag" << (bot->GetTeamId() == TEAM_ALLIANCE ? "in Alliance base" : "in Horde + // base"); + // else + // out << "Taking " << (bot->GetTeamId() == TEAM_ALLIANCE ? "Horde flag to base" : "Alliance flag to + // base"); + // bot->Say(out.str(), LANG_UNIVERSAL); } else { uint32 role = context->GetValue("bg role")->Get(); bool supporter = role < 4; - //std::ostringstream out; - //out << "Role: " << role; - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Role: " << role; + // bot->Say(out.str(), LANG_UNIVERSAL); if (supporter) { if (Unit* teamFC = AI_VALUE(Unit*, "team flag carrier")) { - //std::ostringstream out; - //out << "Protecting " << (bot->GetTeamId() == TEAM_ALLIANCE ? "Alliance FC" : "Horde FC"); - //bot->Say(out.str(), LANG_UNIVERSAL); - pos.Set(teamFC->GetPositionX(), teamFC->GetPositionY(), teamFC->GetPositionZ(), bot->GetMapId()); + // std::ostringstream out; + // out << "Protecting " << (bot->GetTeamId() == TEAM_ALLIANCE ? "Alliance FC" : "Horde FC"); + // bot->Say(out.str(), LANG_UNIVERSAL); + pos.Set(teamFC->GetPositionX(), teamFC->GetPositionY(), teamFC->GetPositionZ(), + bot->GetMapId()); if (sServerFacade->GetDistance2d(bot, teamFC) < 50.0f) Follow(teamFC); } @@ -3571,22 +2819,25 @@ bool BGTactics::selectObjective(bool reset) { if (Unit* enemyFC = AI_VALUE(Unit*, "enemy flag carrier")) { - pos.Set(enemyFC->GetPositionX(), enemyFC->GetPositionY(), enemyFC->GetPositionZ(), bot->GetMapId()); + pos.Set(enemyFC->GetPositionX(), enemyFC->GetPositionY(), enemyFC->GetPositionZ(), + bot->GetMapId()); - //std::ostringstream out; - //out << "Attacking " << (bot->GetTeamId() == TEAM_ALLIANCE ? "Horde FC" : "Alliance FC"); - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Attacking " << (bot->GetTeamId() == TEAM_ALLIANCE ? "Horde FC" : "Alliance FC"); + // bot->Say(out.str(), LANG_UNIVERSAL); } else { if (bot->GetTeamId() == TEAM_ALLIANCE) - pos.Set(WS_FLAG_POS_HORDE.GetPositionX(), WS_FLAG_POS_HORDE.GetPositionY(), WS_FLAG_POS_HORDE.GetPositionZ(), bot->GetMapId()); + pos.Set(WS_FLAG_POS_HORDE.GetPositionX(), WS_FLAG_POS_HORDE.GetPositionY(), + WS_FLAG_POS_HORDE.GetPositionZ(), bot->GetMapId()); else - pos.Set(WS_FLAG_POS_ALLIANCE.GetPositionX(), WS_FLAG_POS_ALLIANCE.GetPositionY(), WS_FLAG_POS_ALLIANCE.GetPositionZ(), bot->GetMapId()); + pos.Set(WS_FLAG_POS_ALLIANCE.GetPositionX(), WS_FLAG_POS_ALLIANCE.GetPositionY(), + WS_FLAG_POS_ALLIANCE.GetPositionZ(), bot->GetMapId()); - //std::ostringstream out; - //out << "Going to " << (bot->GetTeamId() == TEAM_ALLIANCE ? "take Horde flag" : "take Alliance flag"); - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Going to " << (bot->GetTeamId() == TEAM_ALLIANCE ? "take Horde flag" : "take + // Alliance flag"); bot->Say(out.str(), LANG_UNIVERSAL); } } } @@ -3595,11 +2846,12 @@ bool BGTactics::selectObjective(bool reset) Unit* enemyFC = AI_VALUE(Unit*, "enemy flag carrier"); if (enemyFC) { - pos.Set(enemyFC->GetPositionX(), enemyFC->GetPositionY(), enemyFC->GetPositionZ(), bot->GetMapId()); + pos.Set(enemyFC->GetPositionX(), enemyFC->GetPositionY(), enemyFC->GetPositionZ(), + bot->GetMapId()); - //std::ostringstream out; - //out << "Attacking " << (bot->GetTeamId() == TEAM_ALLIANCE ? "Horde FC" : "Alliance FC"); - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Attacking " << (bot->GetTeamId() == TEAM_ALLIANCE ? "Horde FC" : "Alliance FC"); + // bot->Say(out.str(), LANG_UNIVERSAL); } else { @@ -3609,20 +2861,22 @@ bool BGTactics::selectObjective(bool reset) Position staticPos(1227.446f, 1476.235f, 307.484f); bot->GetRandomPoint(staticPos, 150.0f, rx, ry, rz); pos.Set(rx, ry, rz, bot->GetMapId()); - //std::ostringstream out; - //out << "Patrolling battlefield"; - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Patrolling battlefield"; + // bot->Say(out.str(), LANG_UNIVERSAL); } else { if (bot->GetTeamId() == TEAM_ALLIANCE) - pos.Set(WS_FLAG_POS_HORDE.GetPositionX(), WS_FLAG_POS_HORDE.GetPositionY(), WS_FLAG_POS_HORDE.GetPositionZ(), bot->GetMapId()); + pos.Set(WS_FLAG_POS_HORDE.GetPositionX(), WS_FLAG_POS_HORDE.GetPositionY(), + WS_FLAG_POS_HORDE.GetPositionZ(), bot->GetMapId()); else - pos.Set(WS_FLAG_POS_ALLIANCE.GetPositionX(), WS_FLAG_POS_ALLIANCE.GetPositionY(), WS_FLAG_POS_ALLIANCE.GetPositionZ(), bot->GetMapId()); + pos.Set(WS_FLAG_POS_ALLIANCE.GetPositionX(), WS_FLAG_POS_ALLIANCE.GetPositionY(), + WS_FLAG_POS_ALLIANCE.GetPositionZ(), bot->GetMapId()); - //std::ostringstream out; - //out << "Going to " << (bot->GetTeamId() == TEAM_ALLIANCE ? "take Horde flag" : "take Alliance flag"); - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Going to " << (bot->GetTeamId() == TEAM_ALLIANCE ? "take Horde flag" : "take + // Alliance flag"); bot->Say(out.str(), LANG_UNIVERSAL); } } } @@ -3640,7 +2894,7 @@ bool BGTactics::selectObjective(bool reset) { BattlegroundAB* arathiBasinBG = (BattlegroundAB*)bg; - if (bot->GetTeamId() == TEAM_HORDE) // HORDE + if (bot->GetTeamId() == TEAM_HORDE) // HORDE { if (!BgObjective) { @@ -3658,8 +2912,12 @@ bool BGTactics::selectObjective(bool reset) for (auto const& objective : AB_AttackObjectives) { if (arathiBasinBG->GetCapturePointInfo(objective)._state == BG_AB_NODE_STATE_NEUTRAL || - ((!defender || !objectives.size()) && arathiBasinBG->GetCapturePointInfo(objective)._state == BG_AB_NODE_STATE_ALLY_OCCUPIED) || - ((defender || !objectives.size()) && arathiBasinBG->GetCapturePointInfo(objective)._state == BG_AB_NODE_STATE_ALLY_CONTESTED)) + ((!defender || !objectives.size()) && + arathiBasinBG->GetCapturePointInfo(objective)._state == + BG_AB_NODE_STATE_ALLY_OCCUPIED) || + ((defender || !objectives.size()) && + arathiBasinBG->GetCapturePointInfo(objective)._state == + BG_AB_NODE_STATE_ALLY_CONTESTED)) { if (GameObject* pGO = bg->GetBGObject(objective * BG_AB_OBJECTS_PER_NODE)) { @@ -3667,15 +2925,16 @@ bool BGTactics::selectObjective(bool reset) if (attackObjectiveDistance > distance) { // do not pick if already in list - std::vector::iterator f = find(objectives.begin(), objectives.end(), pGO); + std::vector::iterator f = + find(objectives.begin(), objectives.end(), pGO); if (f != objectives.end()) continue; objectives.push_back(pGO); attackObjectiveDistance = distance; - //std::ostringstream out; - // out << "Possible Attack Point #" << objective.first; - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Possible Attack Point #" << objective.first; + // bot->Say(out.str(), LANG_UNIVERSAL); } } } @@ -3689,7 +2948,7 @@ bool BGTactics::selectObjective(bool reset) } } } - else // ALLIANCE + else // ALLIANCE { uint32 role = context->GetValue("bg role")->Get(); bool defender = role < 4; @@ -3704,8 +2963,10 @@ bool BGTactics::selectObjective(bool reset) for (const auto& objective : AB_AttackObjectives) { if (arathiBasinBG->GetCapturePointInfo(objective)._state == BG_AB_NODE_STATE_NEUTRAL || - ((!defender || !objectives.size()) && arathiBasinBG->GetCapturePointInfo(objective)._state == BG_AB_NODE_STATE_HORDE_OCCUPIED) || - ((defender || !objectives.size()) && arathiBasinBG->GetCapturePointInfo(objective)._state == BG_AB_NODE_STATE_HORDE_CONTESTED)) + ((!defender || !objectives.size()) && + arathiBasinBG->GetCapturePointInfo(objective)._state == BG_AB_NODE_STATE_HORDE_OCCUPIED) || + ((defender || !objectives.size()) && + arathiBasinBG->GetCapturePointInfo(objective)._state == BG_AB_NODE_STATE_HORDE_CONTESTED)) { if (GameObject* pGO = bg->GetBGObject(objective * BG_AB_OBJECTS_PER_NODE)) { @@ -3713,16 +2974,17 @@ bool BGTactics::selectObjective(bool reset) if (attackObjectiveDistance > distance) { // do not pick if already in list - std::vector::iterator f = find(objectives.begin(), objectives.end(), pGO); + std::vector::iterator f = + find(objectives.begin(), objectives.end(), pGO); if (f != objectives.end()) continue; objectives.push_back(pGO); - //pAttackObjectiveObject = pGO; + // pAttackObjectiveObject = pGO; attackObjectiveDistance = distance; - //std::ostringstream out; - //out << "Possible Attack Point #" << objective.first; - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Possible Attack Point #" << objective.first; + // bot->Say(out.str(), LANG_UNIVERSAL); } } } @@ -3738,26 +3000,28 @@ bool BGTactics::selectObjective(bool reset) if (BgObjective) { - pos.Set(BgObjective->GetPositionX(), BgObjective->GetPositionY(), BgObjective->GetPositionZ(), BgObjective->GetMapId()); + pos.Set(BgObjective->GetPositionX(), BgObjective->GetPositionY(), BgObjective->GetPositionZ(), + BgObjective->GetMapId()); posMap["bg objective"] = pos; - //std::ostringstream out; - //out << "BG objective set to " << BgObjective->GetName() << " " << pos.x << " " << pos.y; - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "BG objective set to " << BgObjective->GetName() << " " << pos.x << " " << pos.y; + // bot->Say(out.str(), LANG_UNIVERSAL); return true; } break; } - case BATTLEGROUND_EY: // Role < 4: Defender, else Attacker. In the beginning split for all points. Afterwards pick random strategies + case BATTLEGROUND_EY: // Role < 4: Defender, else Attacker. In the beginning split for all points. Afterwards + // pick random strategies { BattlegroundEY* eyeOfTheStormBG = (BattlegroundEY*)bg; TeamId botTeam = bot->GetTeamId(); - if (bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))//has flag + if (bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL)) // has flag { BgObjective = nullptr; uint32 areaTrigger = 0; - uint8 closestObjectiveOwnership = 0;//(2 == owned 1 == neutral 0 == enemy) + uint8 closestObjectiveOwnership = 0; //(2 == owned 1 == neutral 0 == enemy) float closestObjectiveDist = FLT_MAX; // find the closest objective, prioritising friendly objectives over neutral over enemy for (const auto& objective : EY_AttackObjectives) @@ -3769,7 +3033,13 @@ bool BGTactics::selectObjective(bool reset) if (closestObjectiveOwnership > ownership) continue; float dist = sqrt(bot->GetDistance(go)); - if (closestObjectiveOwnership < ownership || (closestObjectiveDist > dist && (closestObjectiveDist - dist > 1 || urand(0, 1))))//if distance difference is minor (as it will be when they first pick flag up from middle) add some randomness so its not going to same point every time + if (closestObjectiveOwnership < ownership || + (closestObjectiveDist > dist && + (closestObjectiveDist - dist > 1 || + urand( + 0, + 1)))) // if distance difference is minor (as it will be when they first pick flag up + // from middle) add some randomness so its not going to same point every time { closestObjectiveOwnership = ownership; closestObjectiveDist = dist; @@ -3781,19 +3051,22 @@ bool BGTactics::selectObjective(bool reset) if (BgObjective) { - pos.Set(BgObjective->GetPositionX(), BgObjective->GetPositionY(), BgObjective->GetPositionZ(), bg->GetMapId()); + pos.Set(BgObjective->GetPositionX(), BgObjective->GetPositionY(), BgObjective->GetPositionZ(), + bg->GetMapId()); } else { - //old fallback method that has them cowering in corner, shouldn't happen anymore + // old fallback method that has them cowering in corner, shouldn't happen anymore areaTrigger = 0; - Position const retreatPos = botTeam == TEAM_HORDE ? EY_FLAG_RETURN_POS_RETREAT_HORDE : EY_FLAG_RETURN_POS_RETREAT_ALLIANCE; - pos.Set(retreatPos.GetPositionX(), retreatPos.GetPositionY(), retreatPos.GetPositionZ(), bg->GetMapId()); + Position const retreatPos = + botTeam == TEAM_HORDE ? EY_FLAG_RETURN_POS_RETREAT_HORDE : EY_FLAG_RETURN_POS_RETREAT_ALLIANCE; + pos.Set(retreatPos.GetPositionX(), retreatPos.GetPositionY(), retreatPos.GetPositionZ(), + bg->GetMapId()); } if (areaTrigger && bot->IsWithinDist3d(pos.x, pos.y, pos.z, INTERACTION_DISTANCE)) { - if (closestObjectiveOwnership == 2)//means we own the objective, so capture flag at point + if (closestObjectiveOwnership == 2) // means we own the objective, so capture flag at point { WorldPacket data(CMSG_AREATRIGGER); data << uint32(areaTrigger); @@ -3801,7 +3074,7 @@ bool BGTactics::selectObjective(bool reset) pos.Reset(); posMap["bg objective"] = pos; } - else//wait until point is yours + else // wait until point is yours { botAI->SetNextCheckDelay(500); } @@ -3813,7 +3086,7 @@ bool BGTactics::selectObjective(bool reset) return true; } - else//does not have flag + else // does not have flag { uint32 role = context->GetValue("bg role")->Get(); @@ -3821,7 +3094,7 @@ bool BGTactics::selectObjective(bool reset) std::tuple attackObjectivesBack[2]; TeamId rootTeam = bot->GetTeamId(); - //Set attackobjectives for teams + // Set attackobjectives for teams if (rootTeam == TEAM_HORDE) { attackObjectivesFront[0] = EY_AttackObjectives[0]; @@ -3836,27 +3109,36 @@ bool BGTactics::selectObjective(bool reset) attackObjectivesBack[0] = EY_AttackObjectives[0]; attackObjectivesBack[1] = EY_AttackObjectives[1]; } - if (role == 0) //Harass left back + if (role == 0) // Harass left back { BgObjective = bg->GetBGObject(std::get<1>(attackObjectivesBack[0])); } - else if (role == 1) //Harass right back + else if (role == 1) // Harass right back { BgObjective = bg->GetBGObject(std::get<1>(attackObjectivesBack[1])); } - else if (role < 8) //2,3,4,5,6,7 - Attack and Defend + else if (role < 8) // 2,3,4,5,6,7 - Attack and Defend { while (BgObjective == nullptr) { - bool front0Owned = eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesFront[0]))._ownerTeamId == botTeam; - bool front1Owned = eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesFront[1]))._ownerTeamId == botTeam; + bool front0Owned = + eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesFront[0]))._ownerTeamId == + botTeam; + bool front1Owned = + eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesFront[1]))._ownerTeamId == + botTeam; if (!front0Owned || !front1Owned) { // Capture front objectives before attacking back objectives // LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Get Front Objectives", - // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName()); - if (role < (front1Owned ? 7 : front0Owned ? 3 : 5))//if we own one put most on the point we dont have, otherwise split evenly + // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", + // bot->GetLevel(), bot->GetName()); + if (role < + (front1Owned ? 7 + : front0Owned + ? 3 + : 5)) // if we own one put most on the point we dont have, otherwise split evenly { BgObjective = bg->GetBGObject(std::get<1>(attackObjectivesFront[0])); } @@ -3869,46 +3151,54 @@ bool BGTactics::selectObjective(bool reset) { // Now capture all objectives // LOG_INFO("playerbots", "Bot {} {}:{} <{}>: Get All Objectives", - // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName()); - if (role < 4)//2,3 - Defend + // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", + // bot->GetLevel(), bot->GetName()); + if (role < 4) // 2,3 - Defend { BgObjective = bg->GetBGObject(std::get<1>(attackObjectivesFront[0])); } - else if (role < 6)//4,5 - Defend + else if (role < 6) // 4,5 - Defend { BgObjective = bg->GetBGObject(std::get<1>(attackObjectivesFront[1])); } - else//6,7 - Attack (along with 0,1) + else // 6,7 - Attack (along with 0,1) { - if (eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesBack[0]))._ownerTeamId != botTeam) + if (eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesBack[0])) + ._ownerTeamId != botTeam) { BgObjective = bg->GetBGObject(std::get<1>(attackObjectivesBack[0])); } - else if (eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesBack[1]))._ownerTeamId != botTeam) + else if (eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesBack[1])) + ._ownerTeamId != botTeam) { BgObjective = bg->GetBGObject(std::get<1>(attackObjectivesBack[1])); } } } - if (eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesFront[0]))._ownerTeamId == botTeam && - eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesFront[1]))._ownerTeamId == botTeam && - eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesBack[0]))._ownerTeamId == botTeam && - eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesBack[1]))._ownerTeamId == botTeam) + if (eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesFront[0]))._ownerTeamId == + botTeam && + eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesFront[1]))._ownerTeamId == + botTeam && + eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesBack[0]))._ownerTeamId == + botTeam && + eyeOfTheStormBG->GetCapturePointInfo(std::get<0>(attackObjectivesBack[1]))._ownerTeamId == + botTeam) { // TODO: what's the point of this? we dont store it back in bg role role = urand(0, 9); } } } - else//8,9 - flag cap + else // 8,9 - flag cap { - //Get the flag or defend flag carrier + // Get the flag or defend flag carrier Unit* teamFC = AI_VALUE(Unit*, "team flag carrier"); if (teamFC) { BgObjective = teamFC; - //pos.Set(teamFC->GetPositionX(), teamFC->GetPositionY(), teamFC->GetPositionZ(), bot->GetMapId()); + // pos.Set(teamFC->GetPositionX(), teamFC->GetPositionY(), teamFC->GetPositionZ(), + // bot->GetMapId()); if (sServerFacade->GetDistance2d(bot, teamFC) < 50.0f) Follow(teamFC); } @@ -3918,7 +3208,8 @@ bool BGTactics::selectObjective(bool reset) if (enemyFC) { BgObjective = enemyFC; - //pos.Set(enemyFC->GetPositionX(), enemyFC->GetPositionY(), enemyFC->GetPositionZ(), bot->GetMapId()); + // pos.Set(enemyFC->GetPositionX(), enemyFC->GetPositionY(), enemyFC->GetPositionZ(), + // bot->GetMapId()); } else { @@ -3936,7 +3227,8 @@ bool BGTactics::selectObjective(bool reset) if (BgObjective) { - pos.Set(BgObjective->GetPositionX(), BgObjective->GetPositionY(), BgObjective->GetPositionZ(), BgObjective->GetMapId()); + pos.Set(BgObjective->GetPositionX(), BgObjective->GetPositionY(), BgObjective->GetPositionZ(), + BgObjective->GetMapId()); posMap["bg objective"] = pos; return true; } @@ -3957,7 +3249,7 @@ bool BGTactics::selectObjective(bool reset) return false; /* TACTICS */ - if (bot->GetTeamId() == TEAM_HORDE) // HORDE + if (bot->GetTeamId() == TEAM_HORDE) // HORDE { // If all bases are captured, go to enemy boss bool allCaptured = true; @@ -3975,16 +3267,16 @@ bool BGTactics::selectObjective(bool reset) } } - if (allCaptured) // target enemy boss + if (allCaptured) // target enemy boss { if (Creature* allyboss = bg->GetBGCreature(BG_IC_NPC_HIGH_COMMANDER_HALFORD_WYRMBANE)) { if (allyboss->IsVisible()) { BgObjective = allyboss; - //ostringstream out; - //out << "Attackign BOSS! BG objective set to " << BgObjective->GetName(); - //bot->Say(out.str(), LANG_UNIVERSAL); + // ostringstream out; + // out << "Attackign BOSS! BG objective set to " << BgObjective->GetName(); + // bot->Say(out.str(), LANG_UNIVERSAL); } } } @@ -3994,29 +3286,32 @@ bool BGTactics::selectObjective(bool reset) { bool foundTask = false; // mount defensive cannons - if (role > 10) // disabled + if (role > 10) // disabled { uint32 firstTower = getPlayersInArea(bot->GetTeamId(), IC_CANNON_POS_HORDE1, 10.0f); uint32 secondTower = getPlayersInArea(bot->GetTeamId(), IC_CANNON_POS_HORDE2, 10.0f); if (firstTower < 2) { - pos.Set(IC_CANNON_POS_HORDE1.GetPositionX(), IC_CANNON_POS_HORDE1.GetPositionY(), IC_CANNON_POS_HORDE1.GetPositionZ(), bg->GetMapId()); + pos.Set(IC_CANNON_POS_HORDE1.GetPositionX(), IC_CANNON_POS_HORDE1.GetPositionY(), + IC_CANNON_POS_HORDE1.GetPositionZ(), bg->GetMapId()); posMap["bg objective"] = pos; return true; } if (secondTower < 2) { - pos.Set(IC_CANNON_POS_HORDE2.GetPositionX(), IC_CANNON_POS_HORDE2.GetPositionY(), IC_CANNON_POS_HORDE2.GetPositionZ(), bg->GetMapId()); + pos.Set(IC_CANNON_POS_HORDE2.GetPositionX(), IC_CANNON_POS_HORDE2.GetPositionY(), + IC_CANNON_POS_HORDE2.GetPositionZ(), bg->GetMapId()); posMap["bg objective"] = pos; return true; } } - if (role < 3) // Capture Side base or Docks + if (role < 3) // Capture Side base or Docks { // Capture Refinery ICNodePoint const& nodePoint = isleOfConquestBG->GetICNodePoint(NODE_TYPE_REFINERY); - if (nodePoint.nodeState != NODE_STATE_CONFLICT_H && nodePoint.nodeState != NODE_STATE_CONTROLLED_H) + if (nodePoint.nodeState != NODE_STATE_CONFLICT_H && + nodePoint.nodeState != NODE_STATE_CONTROLLED_H) { BgObjective = bg->GetBGObject(BG_IC_GO_REFINERY_BANNER); currentObjective = BG_IC_GO_REFINERY_BANNER; @@ -4024,11 +3319,12 @@ bool BGTactics::selectObjective(bool reset) } } - if (!BgObjective && role < 6 && urand(0, 1)) // Capture Docks + if (!BgObjective && role < 6 && urand(0, 1)) // Capture Docks { // Capture Docks ICNodePoint const& nodePoint = isleOfConquestBG->GetICNodePoint(NODE_TYPE_DOCKS); - if (nodePoint.nodeState != NODE_STATE_CONFLICT_H && nodePoint.nodeState != NODE_STATE_CONTROLLED_H) + if (nodePoint.nodeState != NODE_STATE_CONFLICT_H && + nodePoint.nodeState != NODE_STATE_CONTROLLED_H) { if (GameObject* pGO = bg->GetBGObject(BG_IC_GO_DOCKS_BANNER)) { @@ -4036,9 +3332,9 @@ bool BGTactics::selectObjective(bool reset) currentObjective = BG_IC_GO_DOCKS_BANNER; foundTask = true; - //ostringstream out; - //out << "DOCKS! BG objective set to " << BgObjective->GetName(); - //bot->Say(out.str(), LANG_UNIVERSAL); + // ostringstream out; + // out << "DOCKS! BG objective set to " << BgObjective->GetName(); + // bot->Say(out.str(), LANG_UNIVERSAL); } } } @@ -4046,7 +3342,8 @@ bool BGTactics::selectObjective(bool reset) if (!BgObjective && role < 3) { ICNodePoint const& nodePoint = isleOfConquestBG->GetICNodePoint(NODE_TYPE_WORKSHOP); - if (nodePoint.nodeState != NODE_STATE_CONFLICT_H && nodePoint.nodeState != NODE_STATE_CONTROLLED_H) + if (nodePoint.nodeState != NODE_STATE_CONFLICT_H && + nodePoint.nodeState != NODE_STATE_CONTROLLED_H) { if (GameObject* pGO = bg->GetBGObject(BG_IC_GO_WORKSHOP_BANNER)) { @@ -4054,30 +3351,31 @@ bool BGTactics::selectObjective(bool reset) currentObjective = BG_IC_GO_WORKSHOP_BANNER; foundTask = true; - //ostringstream out; - //out << "WORKSHOP! BG objective set to " << BgObjective->GetName(); - //bot->Say(out.str(), LANG_UNIVERSAL); + // ostringstream out; + // out << "WORKSHOP! BG objective set to " << BgObjective->GetName(); + // bot->Say(out.str(), LANG_UNIVERSAL); } } } - if (!BgObjective && role < 6) // Capture Hangar + if (!BgObjective && role < 6) // Capture Hangar { ICNodePoint const& nodePoint = isleOfConquestBG->GetICNodePoint(NODE_TYPE_HANGAR); - if (nodePoint.nodeState != NODE_STATE_CONFLICT_H && nodePoint.nodeState != NODE_STATE_CONTROLLED_H) + if (nodePoint.nodeState != NODE_STATE_CONFLICT_H && + nodePoint.nodeState != NODE_STATE_CONTROLLED_H) { if (GameObject* pGO = bg->GetBGObject(BG_IC_GO_HANGAR_BANNER)) { BgObjective = pGO; currentObjective = BG_IC_GO_HANGAR_BANNER; foundTask = true; - //ostringstream out; - //out << "HANGAR! BG objective set to " << BgObjective->GetName(); - //bot->Say(out.str(), LANG_UNIVERSAL); + // ostringstream out; + // out << "HANGAR! BG objective set to " << BgObjective->GetName(); + // bot->Say(out.str(), LANG_UNIVERSAL); } } } bool gateOpen = false; - if (!BgObjective || controlsVehicle) // Check gates + if (!BgObjective || controlsVehicle) // Check gates { // Keep Gates open if any wall is destroyed, check it if (GameObject* pGO = bg->GetBGObject(BG_IC_GO_DOODAD_PORTCULLISACTIVE01)) @@ -4100,28 +3398,32 @@ bool BGTactics::selectObjective(bool reset) else { // take a siege position - pos.Set(506.782f + frand(-5, +5), -828.594f + frand(-5, +5), 24.313f, bot->GetMapId()); + pos.Set(506.782f + frand(-5, +5), -828.594f + frand(-5, +5), 24.313f, + bot->GetMapId()); posMap["bg objective"] = pos; // set siege position - PositionInfo siegePos = context->GetValue("position")->Get()["bg siege"]; - siegePos.Set(gate->GetPositionX(), gate->GetPositionY(), gate->GetPositionZ(), bot->GetMapId()); + PositionInfo siegePos = + context->GetValue("position")->Get()["bg siege"]; + siegePos.Set(gate->GetPositionX(), gate->GetPositionY(), + gate->GetPositionZ(), bot->GetMapId()); posMap["bg siege"] = siegePos; return true; } } else { - pos.Set(506.782f + frand(-5, +5), -828.594f + frand(-5, +5), 24.313f, bot->GetMapId()); + pos.Set(506.782f + frand(-5, +5), -828.594f + frand(-5, +5), 24.313f, + bot->GetMapId()); posMap["bg objective"] = pos; return true; - //BgObjective = gate; + // BgObjective = gate; } } } } } - if (!BgObjective && gateOpen) // Capture Keep + if (!BgObjective && gateOpen) // Capture Keep { // reset siege position PositionInfo siegePos = context->GetValue("position")->Get()["bg siege"]; @@ -4129,7 +3431,8 @@ bool BGTactics::selectObjective(bool reset) posMap["bg siege"] = siegePos; ICNodePoint const& nodePoint = isleOfConquestBG->GetICNodePoint(NODE_TYPE_GRAVEYARD_A); - if (nodePoint.nodeState != NODE_STATE_CONFLICT_H && nodePoint.nodeState != NODE_STATE_CONTROLLED_H) + if (nodePoint.nodeState != NODE_STATE_CONFLICT_H && + nodePoint.nodeState != NODE_STATE_CONTROLLED_H) { if (GameObject* pGO = bg->GetBGObject(BG_IC_GO_ALLIANCE_BANNER)) { @@ -4137,16 +3440,16 @@ bool BGTactics::selectObjective(bool reset) currentObjective = BG_IC_GO_ALLIANCE_BANNER; foundTask = true; - //ostringstream out; - //out << "ALLY KEEP! BG objective set to " << BgObjective->GetName(); - //bot->Say(out.str(), LANG_UNIVERSAL); + // ostringstream out; + // out << "ALLY KEEP! BG objective set to " << BgObjective->GetName(); + // bot->Say(out.str(), LANG_UNIVERSAL); } } } } } - if (bot->GetTeamId() == TEAM_ALLIANCE) // ALLIANCE + if (bot->GetTeamId() == TEAM_ALLIANCE) // ALLIANCE { // If all bases are captured, go to enemy boss bool allCaptured = true; @@ -4164,16 +3467,16 @@ bool BGTactics::selectObjective(bool reset) } } - if (allCaptured) // target enemy boss + if (allCaptured) // target enemy boss { if (Creature* hordeboss = bg->GetBGCreature(BG_IC_NPC_OVERLORD_AGMAR)) { if (!hordeboss->IsVisible()) { BgObjective = hordeboss; - //ostringstream out; - //out << "HORDE BOSS! BG objective set to " << BgObjective->GetName(); - //bot->Say(out.str(), LANG_UNIVERSAL); + // ostringstream out; + // out << "HORDE BOSS! BG objective set to " << BgObjective->GetName(); + // bot->Say(out.str(), LANG_UNIVERSAL); } } } @@ -4183,30 +3486,33 @@ bool BGTactics::selectObjective(bool reset) { bool foundTask = false; // mount defensive cannons - if (role > 10) // disabled + if (role > 10) // disabled { uint32 firstTower = getPlayersInArea(bot->GetTeamId(), IC_CANNON_POS_ALLIANCE1, 10.0f); uint32 secondTower = getPlayersInArea(bot->GetTeamId(), IC_CANNON_POS_ALLIANCE2, 10.0f); if (firstTower < 3) { - pos.Set(IC_CANNON_POS_ALLIANCE1.GetPositionX(), IC_CANNON_POS_ALLIANCE1.GetPositionY(), IC_CANNON_POS_ALLIANCE1.GetPositionZ(), bg->GetMapId()); + pos.Set(IC_CANNON_POS_ALLIANCE1.GetPositionX(), IC_CANNON_POS_ALLIANCE1.GetPositionY(), + IC_CANNON_POS_ALLIANCE1.GetPositionZ(), bg->GetMapId()); posMap["bg objective"] = pos; return true; } if (secondTower < 3) { - pos.Set(IC_CANNON_POS_ALLIANCE2.GetPositionX(), IC_CANNON_POS_ALLIANCE2.GetPositionY(), IC_CANNON_POS_ALLIANCE2.GetPositionZ(), bg->GetMapId()); + pos.Set(IC_CANNON_POS_ALLIANCE2.GetPositionX(), IC_CANNON_POS_ALLIANCE2.GetPositionY(), + IC_CANNON_POS_ALLIANCE2.GetPositionZ(), bg->GetMapId()); posMap["bg objective"] = pos; return true; } } - if (role < 3) // Capture Side base or Docks + if (role < 3) // Capture Side base or Docks { // Capture Quarry ICNodePoint const& nodePoint = isleOfConquestBG->GetICNodePoint(NODE_TYPE_QUARRY); - if (nodePoint.nodeState != NODE_STATE_CONFLICT_A && nodePoint.nodeState != NODE_STATE_CONTROLLED_A) + if (nodePoint.nodeState != NODE_STATE_CONFLICT_A && + nodePoint.nodeState != NODE_STATE_CONTROLLED_A) { if (GameObject* pGO = bg->GetBGObject(BG_IC_GO_QUARRY_BANNER)) { @@ -4214,9 +3520,9 @@ bool BGTactics::selectObjective(bool reset) currentObjective = BG_IC_GO_QUARRY_BANNER; foundTask = true; - //ostringstream out; - //out << "QUARRY! BG objective set to " << BgObjective->GetName(); - //bot->Say(out.str(), LANG_UNIVERSAL); + // ostringstream out; + // out << "QUARRY! BG objective set to " << BgObjective->GetName(); + // bot->Say(out.str(), LANG_UNIVERSAL); } } } @@ -4233,7 +3539,8 @@ bool BGTactics::selectObjective(bool reset) { // Capture Docks ICNodePoint const& nodePoint = isleOfConquestBG->GetICNodePoint(NODE_TYPE_DOCKS); - if (nodePoint.nodeState != NODE_STATE_CONFLICT_A && nodePoint.nodeState != NODE_STATE_CONTROLLED_A) + if (nodePoint.nodeState != NODE_STATE_CONFLICT_A && + nodePoint.nodeState != NODE_STATE_CONTROLLED_A) { if (GameObject* pGO = bg->GetBGObject(BG_IC_GO_DOCKS_BANNER)) { @@ -4241,9 +3548,9 @@ bool BGTactics::selectObjective(bool reset) currentObjective = BG_IC_GO_DOCKS_BANNER; foundTask = true; - //ostringstream out; - //out << "DOCKS! BG objective set to " << BgObjective->GetName(); - //bot->Say(out.str(), LANG_UNIVERSAL); + // ostringstream out; + // out << "DOCKS! BG objective set to " << BgObjective->GetName(); + // bot->Say(out.str(), LANG_UNIVERSAL); } } } @@ -4251,7 +3558,8 @@ bool BGTactics::selectObjective(bool reset) if (!BgObjective && role < 3) { ICNodePoint const& nodePoint = isleOfConquestBG->GetICNodePoint(NODE_TYPE_WORKSHOP); - if (nodePoint.nodeState != NODE_STATE_CONFLICT_A && nodePoint.nodeState != NODE_STATE_CONTROLLED_A) + if (nodePoint.nodeState != NODE_STATE_CONFLICT_A && + nodePoint.nodeState != NODE_STATE_CONTROLLED_A) { if (GameObject* pGO = bg->GetBGObject(BG_IC_GO_WORKSHOP_BANNER)) { @@ -4259,16 +3567,17 @@ bool BGTactics::selectObjective(bool reset) currentObjective = BG_IC_GO_WORKSHOP_BANNER; foundTask = true; - //ostringstream out; - //out << "WORKSHOP! BG objective set to " << BgObjective->GetName(); - //bot->Say(out.str(), LANG_UNIVERSAL); + // ostringstream out; + // out << "WORKSHOP! BG objective set to " << BgObjective->GetName(); + // bot->Say(out.str(), LANG_UNIVERSAL); } } } - if (!BgObjective && role < 6) // Capture Hangar + if (!BgObjective && role < 6) // Capture Hangar { ICNodePoint const& nodePoint = isleOfConquestBG->GetICNodePoint(NODE_TYPE_HANGAR); - if (nodePoint.nodeState != NODE_STATE_CONFLICT_A && nodePoint.nodeState != NODE_STATE_CONTROLLED_A) + if (nodePoint.nodeState != NODE_STATE_CONFLICT_A && + nodePoint.nodeState != NODE_STATE_CONTROLLED_A) { if (GameObject* pGO = bg->GetBGObject(BG_IC_GO_HANGAR_BANNER)) { @@ -4276,15 +3585,15 @@ bool BGTactics::selectObjective(bool reset) currentObjective = BG_IC_GO_HANGAR_BANNER; foundTask = true; - //ostringstream out; - //out << "HANGAR! BG objective set to " << BgObjective->GetName(); - //bot->Say(out.str(), LANG_UNIVERSAL); + // ostringstream out; + // out << "HANGAR! BG objective set to " << BgObjective->GetName(); + // bot->Say(out.str(), LANG_UNIVERSAL); } } } bool gateOpen = false; - if (!BgObjective || controlsVehicle) // Check gates + if (!BgObjective || controlsVehicle) // Check gates { // Keep Gates open if any wall is destroyed, check it if (GameObject* pGO = bg->GetBGObject(BG_IC_GO_HORDE_KEEP_PORTCULLIS)) @@ -4307,29 +3616,33 @@ bool BGTactics::selectObjective(bool reset) else { // take a siege position - pos.Set(1091.273f + frand(-5, +5), -763.619f + frand(-5, +5), 42.352f, bot->GetMapId()); + pos.Set(1091.273f + frand(-5, +5), -763.619f + frand(-5, +5), 42.352f, + bot->GetMapId()); posMap["bg objective"] = pos; // set siege position - PositionInfo siegePos = context->GetValue("position")->Get()["bg siege"]; - siegePos.Set(gate->GetPositionX(), gate->GetPositionY(), gate->GetPositionZ(), bot->GetMapId()); + PositionInfo siegePos = + context->GetValue("position")->Get()["bg siege"]; + siegePos.Set(gate->GetPositionX(), gate->GetPositionY(), + gate->GetPositionZ(), bot->GetMapId()); posMap["bg siege"] = siegePos; return true; } } else { - pos.Set(1091.273f + frand(-5, +5), -763.619f + frand(-5, +5), 42.352f, bot->GetMapId()); + pos.Set(1091.273f + frand(-5, +5), -763.619f + frand(-5, +5), 42.352f, + bot->GetMapId()); posMap["bg objective"] = pos; return true; // take a siege position - //BgObjective = gate; + // BgObjective = gate; } } } } } - if (!BgObjective && gateOpen) // Capture Keep + if (!BgObjective && gateOpen) // Capture Keep { // reset siege position PositionInfo siegePos = context->GetValue("position")->Get()["bg siege"]; @@ -4337,7 +3650,8 @@ bool BGTactics::selectObjective(bool reset) posMap["bg siege"] = siegePos; ICNodePoint const& nodePoint = isleOfConquestBG->GetICNodePoint(NODE_TYPE_GRAVEYARD_H); - if (nodePoint.nodeState != NODE_STATE_CONFLICT_A && nodePoint.nodeState != NODE_STATE_CONTROLLED_A) + if (nodePoint.nodeState != NODE_STATE_CONFLICT_A && + nodePoint.nodeState != NODE_STATE_CONTROLLED_A) { if (GameObject* pGO = bg->GetBGObject(BG_IC_GO_HORDE_BANNER)) { @@ -4345,9 +3659,9 @@ bool BGTactics::selectObjective(bool reset) currentObjective = BG_IC_GO_HORDE_BANNER; foundTask = true; - //ostringstream out; - //out << "HORDE KEEP! BG objective set to " << BgObjective->GetName(); - //bot->Say(out.str(), LANG_UNIVERSAL); + // ostringstream out; + // out << "HORDE KEEP! BG objective set to " << BgObjective->GetName(); + // bot->Say(out.str(), LANG_UNIVERSAL); } } } @@ -4356,7 +3670,8 @@ bool BGTactics::selectObjective(bool reset) if (BgObjective) { - pos.Set(BgObjective->GetPositionX(), BgObjective->GetPositionY(), BgObjective->GetPositionZ(), bot->GetMapId()); + pos.Set(BgObjective->GetPositionX(), BgObjective->GetPositionY(), BgObjective->GetPositionZ(), + bot->GetMapId()); posMap["bg objective"] = pos; return true; } @@ -4371,7 +3686,7 @@ bool BGTactics::selectObjective(bool reset) bool BGTactics::moveToObjective() { - Battleground *bg = bot->GetBattleground(); + Battleground* bg = bot->GetBattleground(); if (!bg) return false; @@ -4393,9 +3708,9 @@ bool BGTactics::moveToObjective() if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, pos.x, pos.y), 100.0f)) { - //std::ostringstream out; - //out << "It is too far away! " << pos.x << ", " << pos.y << ", Distance: " << sServerFacade->GetDistance2d(bot, pos.x, pos.y); - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "It is too far away! " << pos.x << ", " << pos.y << ", Distance: " << + // sServerFacade->GetDistance2d(bot, pos.x, pos.y); bot->Say(out.str(), LANG_UNIVERSAL); return false; } @@ -4407,14 +3722,16 @@ bool BGTactics::moveToObjective() return true; } - //std::ostringstream out; out << "Moving to objective " << pos.x << ", " << pos.y << ", Distance: " << sServerFacade->GetDistance2d(bot, pos.x, pos.y); - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; out << "Moving to objective " << pos.x << ", " << pos.y << ", Distance: " << + // sServerFacade->GetDistance2d(bot, pos.x, pos.y); bot->Say(out.str(), LANG_UNIVERSAL); // more precise position for wsg if (bgType == BATTLEGROUND_WS) return MoveTo(bot->GetMapId(), pos.x, pos.y, pos.z); else - return MoveNear(bot->GetMapId(), pos.x, pos.y, pos.z, 1.5f);//note - don't make distance too large or horde bots may struggle to get flags in alliance AV towers (because they'll be targetting a spot in midair) + return MoveNear(bot->GetMapId(), pos.x, pos.y, pos.z, + 1.5f); // note - don't make distance too large or horde bots may struggle to get flags in + // alliance AV towers (because they'll be targetting a spot in midair) } return false; } @@ -4435,13 +3752,16 @@ bool BGTactics::selectObjectiveWp(std::vector const& vPaths) return false; // use Rym's waypoints for WSG - if (bgType == BATTLEGROUND_WS /* && (bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG))*/) + if (bgType == + BATTLEGROUND_WS /* && (bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG))*/) return wsgPaths(); else if (bgType == BATTLEGROUND_AV) { - // get bots out of cave when they respawn there (otherwise path selection happens while they're deep within cave and the results arent good) + // get bots out of cave when they respawn there (otherwise path selection happens while they're deep within cave + // and the results arent good) Position const caveSpawn = bot->GetTeamId() == TEAM_ALLIANCE ? AV_CAVE_SPAWN_ALLIANCE : AV_CAVE_SPAWN_HORDE; - if (sqrt(bot->GetDistance(caveSpawn)) < 4.0f) { + if (sqrt(bot->GetDistance(caveSpawn)) < 4.0f) + { return moveToStart(true); } } @@ -4451,14 +3771,17 @@ bool BGTactics::selectObjectiveWp(std::vector const& vPaths) return true; } - float chosenPathScore = FLT_MAX;//lower score is better + float chosenPathScore = FLT_MAX; // lower score is better BattleBotPath* chosenPath = nullptr; uint32 chosenPathPoint = 0; bool chosenPathReverse = false; - float botDistanceLimit = 50.0f; // limit for how far path can be from bot - float botDistanceScoreSubtract = 8.0f; // path score modifier - lower = less likely to chose a further path (it's basically the distance from bot that's ignored) - float botDistanceScoreMultiply = 3.0f; // path score modifier - higher = less likely to chose a further path (it's basically a multiplier on distance from bot - makes distance from bot more signifcant than distance from destination) + float botDistanceLimit = 50.0f; // limit for how far path can be from bot + float botDistanceScoreSubtract = 8.0f; // path score modifier - lower = less likely to chose a further path (it's + // basically the distance from bot that's ignored) + float botDistanceScoreMultiply = + 3.0f; // path score modifier - higher = less likely to chose a further path (it's basically a multiplier on + // distance from bot - makes distance from bot more signifcant than distance from destination) if (bgType == BATTLEGROUND_IC) botDistanceLimit = 80.0f; @@ -4468,27 +3791,32 @@ bool BGTactics::selectObjectiveWp(std::vector const& vPaths) botDistanceScoreMultiply = 4.0f; } - //uint32 index = -1; - //uint32 chosenPathIndex = -1; + // uint32 index = -1; + // uint32 chosenPathIndex = -1; for (auto const& path : vPaths) { - //index++; - // skip mine paths of own faction - if (bot->GetTeamId() == TEAM_ALLIANCE && std::find(vPaths_AllyMine.begin(), vPaths_AllyMine.end(), path) != vPaths_AllyMine.end()) + // index++; + // skip mine paths of own faction + if (bot->GetTeamId() == TEAM_ALLIANCE && + std::find(vPaths_AllyMine.begin(), vPaths_AllyMine.end(), path) != vPaths_AllyMine.end()) continue; - if (bot->GetTeamId() == TEAM_HORDE && std::find(vPaths_HordeMine.begin(), vPaths_HordeMine.end(), path) != vPaths_HordeMine.end()) + if (bot->GetTeamId() == TEAM_HORDE && + std::find(vPaths_HordeMine.begin(), vPaths_HordeMine.end(), path) != vPaths_HordeMine.end()) continue; BattleBotWaypoint& startPoint = ((*path)[0]); - float const startPointDistToDestination = sqrt(Position(pos.x, pos.y, pos.z, 0.f).GetExactDist(startPoint.x, startPoint.y, startPoint.z)); + float const startPointDistToDestination = + sqrt(Position(pos.x, pos.y, pos.z, 0.f).GetExactDist(startPoint.x, startPoint.y, startPoint.z)); BattleBotWaypoint& endPoint = ((*path)[path->size() - 1]); - float const endPointDistToDestination = sqrt(Position(pos.x, pos.y, pos.z, 0.f).GetExactDist(endPoint.x, endPoint.y, endPoint.z)); + float const endPointDistToDestination = + sqrt(Position(pos.x, pos.y, pos.z, 0.f).GetExactDist(endPoint.x, endPoint.y, endPoint.z)); bool reverse = startPointDistToDestination < endPointDistToDestination; // dont travel reverse if it's a reverse paths - if (reverse && std::find(vPaths_NoReverseAllowed.begin(), vPaths_NoReverseAllowed.end(), path) != vPaths_NoReverseAllowed.end()) + if (reverse && std::find(vPaths_NoReverseAllowed.begin(), vPaths_NoReverseAllowed.end(), path) != + vPaths_NoReverseAllowed.end()) continue; int closestPointIndex = -1; @@ -4504,33 +3832,39 @@ bool BGTactics::selectObjectiveWp(std::vector const& vPaths) } } - // don't pick path where bot is already closest to the paths closest point to target (it means path cant lead it anywhere) - // don't pick path where closest point is too far away + // don't pick path where bot is already closest to the paths closest point to target (it means path cant lead it + // anywhere) don't pick path where closest point is too far away if (closestPointIndex == (reverse ? 0 : path->size() - 1) || closestPointDistToBot > botDistanceLimit) continue; - - // creates a score based on dist-to-bot and dist-to-destination, where lower is better, and dist-to-bot is more important (when its beyond a certain distance) - // dist-to-bot is more important because otherwise they cant reach it at all (or will fly through air with MM::MovePoint()), also bot may need to use multiple - // paths (one after another) anyway + // creates a score based on dist-to-bot and dist-to-destination, where lower is better, and dist-to-bot is more + // important (when its beyond a certain distance) dist-to-bot is more important because otherwise they cant + // reach it at all (or will fly through air with MM::MovePoint()), also bot may need to use multiple paths (one + // after another) anyway float distToDestination = reverse ? startPointDistToDestination : endPointDistToDestination; - float pathScore = (closestPointDistToBot < botDistanceScoreSubtract ? 0.0f : ((closestPointDistToBot - botDistanceScoreSubtract) * botDistanceScoreMultiply)) + distToDestination; + float pathScore = (closestPointDistToBot < botDistanceScoreSubtract + ? 0.0f + : ((closestPointDistToBot - botDistanceScoreSubtract) * botDistanceScoreMultiply)) + + distToDestination; - //LOG_INFO("playerbots", "bot={}\t{:6.1f}\t{:4.1f}\t{:4.1f}\t{}", bot->GetName(), pathScore, closestPointDistToBot, distToDestination, vPaths_AB_name[pathNum]); + // LOG_INFO("playerbots", "bot={}\t{:6.1f}\t{:4.1f}\t{:4.1f}\t{}", bot->GetName(), pathScore, + // closestPointDistToBot, distToDestination, vPaths_AB_name[pathNum]); - if (chosenPathScore > pathScore) { + if (chosenPathScore > pathScore) + { chosenPathScore = pathScore; chosenPath = path; chosenPathPoint = closestPointIndex; chosenPathReverse = reverse; - //chosenPathIndex = index; + // chosenPathIndex = index; } } if (!chosenPath) return false; - //LOG_INFO("playerbots", "{} bot={} path={}", (bot->GetTeamId() == TEAM_HORDE ? "HORDE" : "ALLIANCE"), bot->GetName(), chosenPathIndex); + // LOG_INFO("playerbots", "{} bot={} path={}", (bot->GetTeamId() == TEAM_HORDE ? "HORDE" : "ALLIANCE"), + // bot->GetName(), chosenPathIndex); return moveToObjectiveWp(chosenPath, chosenPathPoint, chosenPathReverse); @@ -4543,9 +3877,12 @@ bool BGTactics::resetObjective() if (!bg) return false; - // sometimes change role - should do so less often on larger BG's otherwise bots will spend too much time running around map instead of doing something useful + // sometimes change role - should do so less often on larger BG's otherwise bots will spend too much time running + // around map instead of doing something useful uint32 rollChangeOdds = BATTLEGROUND_AV == bg->GetBgTypeID() ? 63 : BATTLEGROUND_EY == bg->GetBgTypeID() ? 31 : 5; - if (!urand(0, rollChangeOdds) && !(bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))) + if (!urand(0, rollChangeOdds) && + !(bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || + bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))) context->GetValue("bg role")->Set(urand(0, 9)); PositionMap& posMap = context->GetValue("position")->Get(); @@ -4564,11 +3901,14 @@ bool BGTactics::moveToObjectiveWp(BattleBotPath* const& currentPath, uint32 curr uint32 const lastPointInPath = reverse ? 0 : ((*currentPath).size() - 1); if ((currentPoint == lastPointInPath) || - (bot->IsInCombat() && !(bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))) || !bot->IsAlive()) { + (bot->IsInCombat() && !(bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || + bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL))) || + !bot->IsAlive()) + { // Path is over. - //std::ostringstream out; - //out << "Reached path end!"; - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Reached path end!"; + // bot->Say(out.str(), LANG_UNIVERSAL); resetObjective(); return false; } @@ -4580,17 +3920,18 @@ bool BGTactics::moveToObjectiveWp(BattleBotPath* const& currentPath, uint32 curr else currPoint++; - uint32 nPoint = reverse ? std::max((int)(currPoint - urand(1, 5)), 0) : std::min((uint32)(currPoint + urand(1, 5)), lastPointInPath); + uint32 nPoint = reverse ? std::max((int)(currPoint - urand(1, 5)), 0) + : std::min((uint32)(currPoint + urand(1, 5)), lastPointInPath); if (reverse && nPoint < 0) nPoint = 0; BattleBotWaypoint& nextPoint = currentPath->at(nPoint); - //std::ostringstream out; - //out << "WP: "; - //reverse ? out << currPoint << " <<< -> " << nPoint : out << currPoint << ">>> ->" << nPoint; - //out << ", " << nextPoint.x << ", " << nextPoint.y << " Path Size: " << currentPath->size() << ", Dist: " << sServerFacade->GetDistance2d(bot, nextPoint.x, nextPoint.y); - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "WP: "; + // reverse ? out << currPoint << " <<< -> " << nPoint : out << currPoint << ">>> ->" << nPoint; + // out << ", " << nextPoint.x << ", " << nextPoint.y << " Path Size: " << currentPath->size() << ", Dist: " << + // sServerFacade->GetDistance2d(bot, nextPoint.x, nextPoint.y); bot->Say(out.str(), LANG_UNIVERSAL); return MoveTo(bot->GetMapId(), nextPoint.x + frand(-2, 2), nextPoint.y + frand(-2, 2), nextPoint.z); } @@ -4610,7 +3951,7 @@ bool BGTactics::startNewPathBegin(std::vector const& vPaths) struct AvailablePath { - AvailablePath(BattleBotPath* pPath_, bool reverse_) : pPath(pPath_), reverse(reverse_) { } + AvailablePath(BattleBotPath* pPath_, bool reverse_) : pPath(pPath_), reverse(reverse_) {} BattleBotPath* pPath = nullptr; bool reverse = false; @@ -4620,10 +3961,12 @@ bool BGTactics::startNewPathBegin(std::vector const& vPaths) for (auto const& pPath : vPaths) { // skip mine paths of own faction - if (bot->GetTeamId() == TEAM_ALLIANCE && std::find(vPaths_AllyMine.begin(), vPaths_AllyMine.end(), pPath) != vPaths_AllyMine.end()) + if (bot->GetTeamId() == TEAM_ALLIANCE && + std::find(vPaths_AllyMine.begin(), vPaths_AllyMine.end(), pPath) != vPaths_AllyMine.end()) continue; - if (bot->GetTeamId() == TEAM_HORDE && std::find(vPaths_HordeMine.begin(), vPaths_HordeMine.end(), pPath) != vPaths_HordeMine.end()) + if (bot->GetTeamId() == TEAM_HORDE && + std::find(vPaths_HordeMine.begin(), vPaths_HordeMine.end(), pPath) != vPaths_HordeMine.end()) continue; BattleBotWaypoint* pStart = &((*pPath)[0]); @@ -4631,7 +3974,8 @@ bool BGTactics::startNewPathBegin(std::vector const& vPaths) availablePaths.emplace_back(AvailablePath(pPath, false)); // Some paths are not allowed backwards. - if (std::find(vPaths_NoReverseAllowed.begin(), vPaths_NoReverseAllowed.end(), pPath) != vPaths_NoReverseAllowed.end()) + if (std::find(vPaths_NoReverseAllowed.begin(), vPaths_NoReverseAllowed.end(), pPath) != + vPaths_NoReverseAllowed.end()) continue; BattleBotWaypoint* pEnd = &((*pPath)[(*pPath).size() - 1]); @@ -4672,10 +4016,12 @@ bool BGTactics::startNewPathFree(std::vector const& vPaths) for (auto const& pPath : vPaths) { // skip mine paths of own faction - if (bot->GetTeamId() == TEAM_ALLIANCE && std::find(vPaths_AllyMine.begin(), vPaths_AllyMine.end(), pPath) != vPaths_AllyMine.end()) + if (bot->GetTeamId() == TEAM_ALLIANCE && + std::find(vPaths_AllyMine.begin(), vPaths_AllyMine.end(), pPath) != vPaths_AllyMine.end()) continue; - if (bot->GetTeamId() == TEAM_HORDE && std::find(vPaths_HordeMine.begin(), vPaths_HordeMine.end(), pPath) != vPaths_HordeMine.end()) + if (bot->GetTeamId() == TEAM_HORDE && + std::find(vPaths_HordeMine.begin(), vPaths_HordeMine.end(), pPath) != vPaths_HordeMine.end()) continue; for (uint32 i = 0; i < pPath->size(); i++) @@ -4743,10 +4089,11 @@ bool BGTactics::atFlag(std::vector const& vPaths, std::vectorGetUnit(guid); - if (pFriend->GetCurrentSpell(CURRENT_GENERIC_SPELL) && pFriend->GetCurrentSpell(CURRENT_GENERIC_SPELL)->m_spellInfo->Id == SPELL_CAPTURE_BANNER) + if (pFriend->GetCurrentSpell(CURRENT_GENERIC_SPELL) && + pFriend->GetCurrentSpell(CURRENT_GENERIC_SPELL)->m_spellInfo->Id == SPELL_CAPTURE_BANNER) { resetObjective(); startNewPathBegin(vPaths); @@ -4755,8 +4102,8 @@ bool BGTactics::atFlag(std::vector const& vPaths, std::vectorSay(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; out << "Found " << closeObjects.size() << " nearby objects"; + // bot->Say(out.str(), LANG_UNIVERSAL); for (ObjectGuid const guid : closeObjects) { @@ -4778,9 +4125,12 @@ bool BGTactics::atFlag(std::vector const& vPaths, std::vector flagRange) continue; - bool atBase = bgType == BATTLEGROUND_WS ? go->GetEntry() == vFlagsWS[bot->GetTeamId()] : bgType == BATTLEGROUND_EY ? go->GetEntry() == vFlagsEY[0] : false; + bool atBase = bgType == BATTLEGROUND_WS ? go->GetEntry() == vFlagsWS[bot->GetTeamId()] + : bgType == BATTLEGROUND_EY ? go->GetEntry() == vFlagsEY[0] + : false; - if (atBase && bgType == BATTLEGROUND_WS && !(bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG))) + if (atBase && bgType == BATTLEGROUND_WS && + !(bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG))) continue; switch (bgType) @@ -4791,10 +4141,12 @@ bool BGTactics::atFlag(std::vector const& vPaths, std::vectorGetObjectSize() + go->GetObjectSize() + 0.1f; - return MoveTo(bot->GetMapId(), go->GetPositionX() + (urand(0, 1) ? -moveDist : moveDist), go->GetPositionY() + (urand(0, 1) ? -moveDist : moveDist), go->GetPositionZ()); + return MoveTo(bot->GetMapId(), go->GetPositionX() + (urand(0, 1) ? -moveDist : moveDist), + go->GetPositionY() + (urand(0, 1) ? -moveDist : moveDist), go->GetPositionZ()); } if (bot->IsMounted()) bot->RemoveAurasByType(SPELL_AURA_MOUNTED); @@ -4802,25 +4154,25 @@ bool BGTactics::atFlag(std::vector const& vPaths, std::vectorIsInDisallowedMountForm()) bot->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT); - //std::ostringstream out; - //out << "Flag is nearby, using " << go->GetName(); - //bot->Say(out.str(), LANG_UNIVERSAL); - //botAI->SetNextCheckDelay(10000); + // std::ostringstream out; + // out << "Flag is nearby, using " << go->GetName(); + // bot->Say(out.str(), LANG_UNIVERSAL); + // botAI->SetNextCheckDelay(10000); // cast banner spell SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_CAPTURE_BANNER); if (!spellInfo) return false; - Spell *spell = new Spell(bot, spellInfo, TRIGGERED_NONE); + Spell* spell = new Spell(bot, spellInfo, TRIGGERED_NONE); spell->m_targets.SetGOTarget(go); spell->prepare(&spell->m_targets); botAI->WaitForSpellCast(spell); - //WorldPacket data(CMSG_GAMEOBJ_USE); - //data << go->GetGUID(); - //bot->GetSession()->HandleGameObjectUseOpcode(data); + // WorldPacket data(CMSG_GAMEOBJ_USE); + // data << go->GetGUID(); + // bot->GetSession()->HandleGameObjectUseOpcode(data); resetObjective(); return true; break; @@ -4843,9 +4195,9 @@ bool BGTactics::atFlag(std::vector const& vPaths, std::vectorGetSession()->HandleAreaTriggerOpcode(data); } - //std::ostringstream out; - // out << "Capturing flag!"; - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Capturing flag!"; + // bot->Say(out.str(), LANG_UNIVERSAL); return true; } @@ -4855,8 +4207,8 @@ bool BGTactics::atFlag(std::vector const& vPaths, std::vectorIsInDisallowedMountForm()) bot->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT); - //std::ostringstream out; out << "Flag is nearby, using " << go->GetName(); - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; out << "Flag is nearby, using " << go->GetName(); + // bot->Say(out.str(), LANG_UNIVERSAL); WorldPacket data(CMSG_GAMEOBJ_USE); data << go->GetGUID(); bot->GetSession()->HandleGameObjectUseOpcode(data); @@ -4866,9 +4218,10 @@ bool BGTactics::atFlag(std::vector const& vPaths, std::vectorGetName() << " " << go->GetPositionX() << " " << go->GetPositionY() << " Distance:" << sServerFacade->GetDistance2d(bot, go->GetPositionX(), go->GetPositionY()); - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Flag is far, moving to " << go->GetName() << " " << go->GetPositionX() << " " << + // go->GetPositionY() << " Distance:" << sServerFacade->GetDistance2d(bot, go->GetPositionX(), + // go->GetPositionY()); bot->Say(out.str(), LANG_UNIVERSAL); return MoveTo(bot->GetMapId(), go->GetPositionX(), go->GetPositionY(), go->GetPositionZ()); } break; @@ -4940,7 +4293,7 @@ bool BGTactics::teamFlagTaken() bool BGTactics::protectFC() { - Battleground *bg = bot->GetBattleground(); + Battleground* bg = bot->GetBattleground(); if (!bg) return false; @@ -4965,8 +4318,12 @@ bool BGTactics::useBuff() if (closeObjects.empty()) return false; - bool needRegen = bot->GetHealthPct() < sPlayerbotAIConfig->mediumHealth || (AI_VALUE2(bool, "has mana", "self target") && AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->mediumMana); - bool needSpeed = (bgType != BATTLEGROUND_WS || bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL)) || !(teamFlagTaken() || flagTaken()); + bool needRegen = bot->GetHealthPct() < sPlayerbotAIConfig->mediumHealth || + (AI_VALUE2(bool, "has mana", "self target") && + AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->mediumMana); + bool needSpeed = (bgType != BATTLEGROUND_WS || bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || + bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL)) || + !(teamFlagTaken() || flagTaken()); bool foundBuff = false; for (ObjectGuid const guid : closeObjects) @@ -4979,7 +4336,8 @@ bool BGTactics::useBuff() continue; // use speed buff only if close - if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, go), go->GetEntry() == Buff_Entries[0] ? 20.0f : 50.0f)) + if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, go), + go->GetEntry() == Buff_Entries[0] ? 20.0f : 50.0f)) continue; if (needSpeed && go->GetEntry() == Buff_Entries[0]) @@ -4989,15 +4347,16 @@ bool BGTactics::useBuff() foundBuff = true; // do not move to Berserk buff if bot is healer or has flag - if (!(bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL)) && + if (!(bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || + bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL)) && !botAI->IsHeal(bot) && go->GetEntry() == Buff_Entries[2]) foundBuff = true; if (foundBuff) { - //std::ostringstream out; - //out << "Moving to buff..."; - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; + // out << "Moving to buff..."; + // bot->Say(out.str(), LANG_UNIVERSAL); return MoveTo(go->GetMapId(), go->GetPositionX(), go->GetPositionY(), go->GetPositionZ()); } @@ -5051,9 +4410,11 @@ bool BGTactics::IsLockedInsideKeep() return false; bool isInside = false; - if (bot->GetTeamId() == TEAM_ALLIANCE && bot->GetPositionX() < 410.0f && bot->GetPositionY() > -900.0f && bot->GetPositionY() < -765.0f) + if (bot->GetTeamId() == TEAM_ALLIANCE && bot->GetPositionX() < 410.0f && bot->GetPositionY() > -900.0f && + bot->GetPositionY() < -765.0f) isInside = true; - if (bot->GetTeamId() == TEAM_HORDE && bot->GetPositionX() > 1153.0f && bot->GetPositionY() > -849.0f && bot->GetPositionY() < -679.0f) + if (bot->GetTeamId() == TEAM_HORDE && bot->GetPositionX() > 1153.0f && bot->GetPositionY() > -849.0f && + bot->GetPositionY() < -679.0f) isInside = true; if (!isInside) @@ -5158,7 +4519,8 @@ bool BGTactics::IsLockedInsideKeep() } else { - return MoveTo(bot->GetMapId(), closestPortal->GetPositionX(), closestPortal->GetPositionY(), closestPortal->GetPositionZ()); + return MoveTo(bot->GetMapId(), closestPortal->GetPositionX(), closestPortal->GetPositionY(), + closestPortal->GetPositionZ()); } } @@ -5203,12 +4565,12 @@ bool ArenaTactics::Execute(Event event) if (botAI->HasStrategy("buff", BOT_STATE_NON_COMBAT)) botAI->ChangeStrategy("-buff", BOT_STATE_NON_COMBAT); -// this causes bot to reset constantly in arena -// if (sBattlegroundMgr->IsArenaType(bg->GetBgTypeID())) -// { -// botAI->ResetStrategies(false); -// botAI->SetMaster(nullptr); -// } + // this causes bot to reset constantly in arena + // if (sBattlegroundMgr->IsArenaType(bg->GetBgTypeID())) + // { + // botAI->ResetStrategies(false); + // botAI->SetMaster(nullptr); + // } if (!bot->IsInCombat()) return moveToCenter(bg); @@ -5308,7 +4670,8 @@ bool ArenaTactics::moveToCenter(Battleground* bg) } break; case BATTLEGROUND_DS: - if (!MoveTo(bg->GetMapId(), 1291.58f + frand(-5, +5), 790.87f + frand(-5, +5), 7.8f, false, true)) { + if (!MoveTo(bg->GetMapId(), 1291.58f + frand(-5, +5), 790.87f + frand(-5, +5), 7.8f, false, true)) + { // they like to hang around at the tip of the pipes doing nothing, so we just teleport them down if (bot->GetDistance(1333.07f, 817.18f, 13.35f) < 4) bot->TeleportTo(bg->GetMapId(), 1330.96f, 816.75f, 3.2f, bot->GetOrientation()); diff --git a/src/strategy/actions/BattleGroundTactics.h b/src/strategy/actions/BattleGroundTactics.h index 7fba2076..2b8e04dc 100644 --- a/src/strategy/actions/BattleGroundTactics.h +++ b/src/strategy/actions/BattleGroundTactics.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_BATTLEGROUNDTACTICSACTION_H @@ -14,11 +15,11 @@ struct Position; #define SPELL_CAPTURE_BANNER 21651 -typedef void(*BattleBotWaypointFunc)(); +typedef void (*BattleBotWaypointFunc)(); struct BattleBotWaypoint { - BattleBotWaypoint(float x_, float y_, float z_, BattleBotWaypointFunc func) : x(x_), y(y_), z(z_), pFunc(func) { }; + BattleBotWaypoint(float x_, float y_, float z_, BattleBotWaypointFunc func) : x(x_), y(y_), z(z_), pFunc(func){}; float x = 0.0f; float y = 0.0f; @@ -36,43 +37,43 @@ extern std::vector const vPaths_IC; class BGTactics : public MovementAction { - public: - static bool HandleConsoleCommand(ChatHandler* handler, char const* args); +public: + static bool HandleConsoleCommand(ChatHandler* handler, char const* args); - BGTactics(PlayerbotAI* botAI, std::string const name = "bg tactics") : MovementAction(botAI, name) { } + BGTactics(PlayerbotAI* botAI, std::string const name = "bg tactics") : MovementAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - static std::string const HandleConsoleCommandPrivate(WorldSession* session, char const* args); - bool moveToStart(bool force = false); - bool selectObjective(bool reset = false); - bool moveToObjective(); - bool selectObjectiveWp(std::vector const& vPaths); - bool moveToObjectiveWp(BattleBotPath* const& currentPath, uint32 currentPoint, bool reverse = false); - bool startNewPathBegin(std::vector const& vPaths); - bool startNewPathFree(std::vector const& vPaths); - bool resetObjective(); - bool wsgPaths(); - bool eyJumpDown(); - bool atFlag(std::vector const& vPaths, std::vector const& vFlagIds); - bool flagTaken(); - bool teamFlagTaken(); - bool protectFC(); - bool useBuff(); - uint32 getPlayersInArea(TeamId teamId, Position point, float range, bool combat = true); - bool IsLockedInsideKeep(); +private: + static std::string const HandleConsoleCommandPrivate(WorldSession* session, char const* args); + bool moveToStart(bool force = false); + bool selectObjective(bool reset = false); + bool moveToObjective(); + bool selectObjectiveWp(std::vector const& vPaths); + bool moveToObjectiveWp(BattleBotPath* const& currentPath, uint32 currentPoint, bool reverse = false); + bool startNewPathBegin(std::vector const& vPaths); + bool startNewPathFree(std::vector const& vPaths); + bool resetObjective(); + bool wsgPaths(); + bool eyJumpDown(); + bool atFlag(std::vector const& vPaths, std::vector const& vFlagIds); + bool flagTaken(); + bool teamFlagTaken(); + bool protectFC(); + bool useBuff(); + uint32 getPlayersInArea(TeamId teamId, Position point, float range, bool combat = true); + bool IsLockedInsideKeep(); }; class ArenaTactics : public MovementAction { - public: - ArenaTactics(PlayerbotAI* botAI, std::string const name = "arena tactics") : MovementAction(botAI, name) { } +public: + ArenaTactics(PlayerbotAI* botAI, std::string const name = "arena tactics") : MovementAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - bool moveToCenter(Battleground *bg); +private: + bool moveToCenter(Battleground* bg); }; #endif diff --git a/src/strategy/actions/BuffAction.cpp b/src/strategy/actions/BuffAction.cpp index 3def115c..103f8b99 100644 --- a/src/strategy/actions/BuffAction.cpp +++ b/src/strategy/actions/BuffAction.cpp @@ -1,60 +1,62 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "BuffAction.h" + #include "Event.h" #include "ItemCountValue.h" #include "Playerbots.h" class FindBuffVisitor : public IterateItemsVisitor { - public: - FindBuffVisitor(Player* bot) : IterateItemsVisitor(), bot(bot) - { - } - - bool Visit(Item* item) override - { - if (bot->CanUseItem(item->GetTemplate()) != EQUIP_ERR_OK) - return true; - - ItemTemplate const* proto = item->GetTemplate(); - - if (proto->Class != ITEM_CLASS_CONSUMABLE) - return true; - - if (proto->SubClass != ITEM_SUBCLASS_ELIXIR && proto->SubClass != ITEM_SUBCLASS_FLASK && proto->SubClass != ITEM_SUBCLASS_SCROLL && - proto->SubClass != ITEM_SUBCLASS_FOOD && proto->SubClass != ITEM_SUBCLASS_CONSUMABLE_OTHER && proto->SubClass != ITEM_SUBCLASS_ITEM_ENHANCEMENT) - return true; - - for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; i++) - { - uint32 spellId = proto->Spells[i].SpellId; - if (!spellId) - continue; - - if (bot->HasAura(spellId)) - return true; - - Item* itemForSpell = *GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue("item for spell", spellId); - if (itemForSpell && itemForSpell->IsInWorld() && itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) - return true; - - if (items.find(proto->SubClass) == items.end()) - items[proto->SubClass] = std::vector(); - - items[proto->SubClass].push_back(item); - break; - } +public: + FindBuffVisitor(Player* bot) : IterateItemsVisitor(), bot(bot) {} + bool Visit(Item* item) override + { + if (bot->CanUseItem(item->GetTemplate()) != EQUIP_ERR_OK) return true; + + ItemTemplate const* proto = item->GetTemplate(); + + if (proto->Class != ITEM_CLASS_CONSUMABLE) + return true; + + if (proto->SubClass != ITEM_SUBCLASS_ELIXIR && proto->SubClass != ITEM_SUBCLASS_FLASK && + proto->SubClass != ITEM_SUBCLASS_SCROLL && proto->SubClass != ITEM_SUBCLASS_FOOD && + proto->SubClass != ITEM_SUBCLASS_CONSUMABLE_OTHER && proto->SubClass != ITEM_SUBCLASS_ITEM_ENHANCEMENT) + return true; + + for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; i++) + { + uint32 spellId = proto->Spells[i].SpellId; + if (!spellId) + continue; + + if (bot->HasAura(spellId)) + return true; + + Item* itemForSpell = + *GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue("item for spell", spellId); + if (itemForSpell && itemForSpell->IsInWorld() && itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) + return true; + + if (items.find(proto->SubClass) == items.end()) + items[proto->SubClass] = std::vector(); + + items[proto->SubClass].push_back(item); + break; } - std::map > items; + return true; + } - private: - Player* bot; + std::map > items; + +private: + Player* bot; }; void BuffAction::TellHeader(uint32 subClass) diff --git a/src/strategy/actions/BuffAction.h b/src/strategy/actions/BuffAction.h index 755524ef..9978b293 100644 --- a/src/strategy/actions/BuffAction.h +++ b/src/strategy/actions/BuffAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_BUFFACTION_H @@ -11,13 +12,13 @@ class PlayerbotAI; class BuffAction : public InventoryAction { - public: - BuffAction(PlayerbotAI* botAI) : InventoryAction(botAI, "buff") { } +public: + BuffAction(PlayerbotAI* botAI) : InventoryAction(botAI, "buff") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - void TellHeader(uint32 subClass); +private: + void TellHeader(uint32 subClass); }; #endif diff --git a/src/strategy/actions/BuyAction.cpp b/src/strategy/actions/BuyAction.cpp index 4346ba1c..18587346 100644 --- a/src/strategy/actions/BuyAction.cpp +++ b/src/strategy/actions/BuyAction.cpp @@ -1,13 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "BuyAction.h" + #include "BudgetValues.h" #include "Event.h" -#include "ItemVisitors.h" #include "ItemCountValue.h" #include "ItemUsageValue.h" +#include "ItemVisitors.h" #include "Playerbots.h" bool BuyAction::Execute(Event event) @@ -48,20 +50,26 @@ bool BuyAction::Execute(Event event) VendorItemList m_items_sorted = tItems->m_items; - m_items_sorted.erase(std::remove_if(m_items_sorted.begin(), m_items_sorted.end(), [](VendorItem* i) - { - ItemTemplate const* proto = sObjectMgr->GetItemTemplate(i->item); - return !proto; - }), m_items_sorted.end()); + m_items_sorted.erase(std::remove_if(m_items_sorted.begin(), m_items_sorted.end(), + [](VendorItem* i) + { + ItemTemplate const* proto = sObjectMgr->GetItemTemplate(i->item); + return !proto; + }), + m_items_sorted.end()); if (m_items_sorted.empty()) continue; - std::sort(m_items_sorted.begin(), m_items_sorted.end(), [](VendorItem* i, VendorItem* j) { return sObjectMgr->GetItemTemplate(i->item)->ItemLevel > sObjectMgr->GetItemTemplate(j->item)->ItemLevel; }); + std::sort(m_items_sorted.begin(), m_items_sorted.end(), + [](VendorItem* i, VendorItem* j) { + return sObjectMgr->GetItemTemplate(i->item)->ItemLevel > + sObjectMgr->GetItemTemplate(j->item)->ItemLevel; + }); for (auto& tItem : m_items_sorted) { - for (uint32 i = 0; i < 10; i++) // Buy 10 times or until no longer usefull/possible + for (uint32 i = 0; i < 10; i++) // Buy 10 times or until no longer usefull/possible { ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", tItem->item); ItemTemplate const* proto = sObjectMgr->GetItemTemplate(tItem->item); @@ -104,7 +112,8 @@ bool BuyAction::Execute(Event event) if (!BuyItem(tItems, vendorguid, proto)) break; - if (usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_EQUIP) // Equip upgrades and stop buying this time. + if (usage == ITEM_USAGE_REPLACE || + usage == ITEM_USAGE_EQUIP) // Equip upgrades and stop buying this time. { botAI->DoSpecificAction("equip upgrades"); break; @@ -120,7 +129,7 @@ bool BuyAction::Execute(Event event) for (ItemIds::iterator i = itemIds.begin(); i != itemIds.end(); i++) { uint32 itemId = *i; - ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId); + ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId); if (!proto) continue; @@ -170,7 +179,10 @@ bool BuyAction::BuyItem(VendorItemData const* tItems, ObjectGuid vendorguid, Ite bot->SetMoney(botMoney); } - if (oldCount < AI_VALUE2(uint32, "item count", proto->Name1)) // BuyItem Always returns false (unless unique) so we have to check the item counts. + if (oldCount < + AI_VALUE2( + uint32, "item count", + proto->Name1)) // BuyItem Always returns false (unless unique) so we have to check the item counts. { std::ostringstream out; out << "Buying " << ChatHelper::FormatItem(proto); diff --git a/src/strategy/actions/BuyAction.h b/src/strategy/actions/BuyAction.h index d1910324..3cbb546b 100644 --- a/src/strategy/actions/BuyAction.h +++ b/src/strategy/actions/BuyAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_BUYACTION_H @@ -18,16 +19,15 @@ struct VendorItemData; class BuyAction : public InventoryAction { - public: - BuyAction(PlayerbotAI* botAI) : InventoryAction(botAI, "buy") { } +public: + BuyAction(PlayerbotAI* botAI) : InventoryAction(botAI, "buy") {} - bool Execute(Event event) override; - - private: - bool BuyItem(VendorItemData const* tItems, ObjectGuid vendorguid, ItemTemplate const* proto); - bool TradeItem(FindItemVisitor* visitor, int8 slot); - bool TradeItem(Item const* item, int8 slot); + bool Execute(Event event) override; +private: + bool BuyItem(VendorItemData const* tItems, ObjectGuid vendorguid, ItemTemplate const* proto); + bool TradeItem(FindItemVisitor* visitor, int8 slot); + bool TradeItem(Item const* item, int8 slot); }; #endif diff --git a/src/strategy/actions/CastCustomSpellAction.cpp b/src/strategy/actions/CastCustomSpellAction.cpp index a4ca32ee..9e8254a2 100644 --- a/src/strategy/actions/CastCustomSpellAction.cpp +++ b/src/strategy/actions/CastCustomSpellAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CastCustomSpellAction.h" + #include "ChatHelper.h" #include "Event.h" #include "ItemUsageValue.h" @@ -56,10 +58,10 @@ bool CastCustomSpellAction::Execute(Event event) if (master && master->GetTarget()) target = botAI->GetUnit(master->GetTarget()); - if (!target) + if (!target) target = bot; - if (!master) // Use self as master for permissions. + if (!master) // Use self as master for permissions. master = bot; Item* itemTarget = nullptr; @@ -136,7 +138,7 @@ bool CastCustomSpellAction::Execute(Event event) std::ostringstream cmd; cmd << castString(target) << " " << text << " " << (castCount - 1); botAI->HandleCommand(CHAT_MSG_WHISPER, cmd.str(), master); - msg << "|cffffff00(x" << (castCount-1) << " left)|r"; + msg << "|cffffff00(x" << (castCount - 1) << " left)|r"; } botAI->TellMasterNoFacing(msg.str()); @@ -150,10 +152,7 @@ bool CastCustomSpellAction::Execute(Event event) return result; } -bool CastCustomNcSpellAction::isUseful() -{ - return !bot->IsInCombat(); -} +bool CastCustomNcSpellAction::isUseful() { return !bot->IsInCombat(); } std::string const CastCustomNcSpellAction::castString(WorldObject* target) { @@ -162,7 +161,8 @@ std::string const CastCustomNcSpellAction::castString(WorldObject* target) bool CastRandomSpellAction::AcceptSpell(SpellInfo const* spellInfo) { - bool isTradeSkill = spellInfo->Effects[EFFECT_0].Effect == SPELL_EFFECT_CREATE_ITEM && spellInfo->ReagentCount[EFFECT_0] > 0 && spellInfo->SchoolMask == 1; + bool isTradeSkill = spellInfo->Effects[EFFECT_0].Effect == SPELL_EFFECT_CREATE_ITEM && + spellInfo->ReagentCount[EFFECT_0] > 0 && spellInfo->SchoolMask == 1; return !isTradeSkill && spellInfo->GetRecoveryTime() < MINUTE * IN_MILLISECONDS; } @@ -220,7 +220,8 @@ bool CastRandomSpellAction::Execute(Event event) if (target && botAI->CanCastSpell(spellId, target, true)) spellList.push_back(std::make_pair(spellId, std::make_pair(spellPriority, target))); - if (got && botAI->CanCastSpell(spellId, got->GetPositionX(), got->GetPositionY(), got->GetPositionZ(), true)) + if (got && + botAI->CanCastSpell(spellId, got->GetPositionX(), got->GetPositionY(), got->GetPositionZ(), true)) spellList.push_back(std::make_pair(spellId, std::make_pair(spellPriority, got))); if (botAI->CanCastSpell(spellId, bot, true)) spellList.push_back(std::make_pair(spellId, std::make_pair(spellPriority, bot))); @@ -232,10 +233,9 @@ bool CastRandomSpellAction::Execute(Event event) bool isCast = false; - std::sort(spellList.begin(), spellList.end(), [](std::pair> i, std::pair> j) - { - return i.first > j.first; - }); + std::sort(spellList.begin(), spellList.end(), + [](std::pair> i, + std::pair> j) { return i.first > j.first; }); uint32 rndBound = spellList.size() / 4; @@ -270,7 +270,8 @@ bool CastRandomSpellAction::Execute(Event event) bool CraftRandomItemAction::AcceptSpell(SpellInfo const* spellInfo) { - return spellInfo->Effects[EFFECT_0].Effect == SPELL_EFFECT_CREATE_ITEM && spellInfo->ReagentCount[EFFECT_0] > 0 && spellInfo->SchoolMask == 0; + return spellInfo->Effects[EFFECT_0].Effect == SPELL_EFFECT_CREATE_ITEM && spellInfo->ReagentCount[EFFECT_0] > 0 && + spellInfo->SchoolMask == 0; } uint32 CraftRandomItemAction::GetSpellPriority(SpellInfo const* spellInfo) @@ -282,7 +283,8 @@ uint32 CraftRandomItemAction::GetSpellPriority(SpellInfo const* spellInfo) { ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", newItemId); - if (usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_AMMO || usage == ITEM_USAGE_QUEST || usage == ITEM_USAGE_SKILL || usage == ITEM_USAGE_USE) + if (usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_AMMO || + usage == ITEM_USAGE_QUEST || usage == ITEM_USAGE_SKILL || usage == ITEM_USAGE_USE) return 10; } @@ -295,7 +297,6 @@ uint32 CraftRandomItemAction::GetSpellPriority(SpellInfo const* spellInfo) bool CastRandomSpellAction::castSpell(uint32 spellId, WorldObject* wo) { - if (wo->GetGUID().IsUnit()) return botAI->CastSpell(spellId, (Unit*)(wo)); else @@ -304,16 +305,19 @@ bool CastRandomSpellAction::castSpell(uint32 spellId, WorldObject* wo) bool DisEnchantRandomItemAction::Execute(Event event) { - std::vector items = AI_VALUE2(std::vector, "inventory items", "usage " + std::to_string(ITEM_USAGE_DISENCHANT)); + std::vector items = + AI_VALUE2(std::vector, "inventory items", "usage " + std::to_string(ITEM_USAGE_DISENCHANT)); std::reverse(items.begin(), items.end()); - for (auto& item: items) + for (auto& item : items) { // don't touch rare+ items if with real player/guild - if ((botAI->HasRealPlayerMaster() || botAI->IsInRealGuild()) && item->GetTemplate()->Quality > ITEM_QUALITY_UNCOMMON) + if ((botAI->HasRealPlayerMaster() || botAI->IsInRealGuild()) && + item->GetTemplate()->Quality > ITEM_QUALITY_UNCOMMON) return false; - if(CastCustomSpellAction::Execute(Event("disenchant random item", "13262 "+ chat->FormatQItem(item->GetEntry())))) + if (CastCustomSpellAction::Execute( + Event("disenchant random item", "13262 " + chat->FormatQItem(item->GetEntry())))) return true; } @@ -322,13 +326,11 @@ bool DisEnchantRandomItemAction::Execute(Event event) bool DisEnchantRandomItemAction::isUseful() { - return botAI->HasSkill(SKILL_ENCHANTING) && !bot->IsInCombat() && AI_VALUE2(uint32, "item count", "usage " + std::to_string(ITEM_USAGE_DISENCHANT)) > 0; + return botAI->HasSkill(SKILL_ENCHANTING) && !bot->IsInCombat() && + AI_VALUE2(uint32, "item count", "usage " + std::to_string(ITEM_USAGE_DISENCHANT)) > 0; } -bool EnchantRandomItemAction::isUseful() -{ - return botAI->HasSkill(SKILL_ENCHANTING) && !bot->IsInCombat(); -} +bool EnchantRandomItemAction::isUseful() { return botAI->HasSkill(SKILL_ENCHANTING) && !bot->IsInCombat(); } bool EnchantRandomItemAction::AcceptSpell(SpellInfo const* spellInfo) { diff --git a/src/strategy/actions/CastCustomSpellAction.h b/src/strategy/actions/CastCustomSpellAction.h index 4ab62fcd..e598154d 100644 --- a/src/strategy/actions/CastCustomSpellAction.h +++ b/src/strategy/actions/CastCustomSpellAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CASTCUSTOMSPELLACTION_H @@ -13,11 +14,14 @@ class WorldObject; class CastCustomSpellAction : public InventoryAction { - public: - CastCustomSpellAction(PlayerbotAI* botAI, std::string const name = "cast custom spell") : InventoryAction(botAI, name) { } +public: + CastCustomSpellAction(PlayerbotAI* botAI, std::string const name = "cast custom spell") + : InventoryAction(botAI, name) + { + } - bool Execute(Event event) override; - virtual std::string const castString(WorldObject* target) { return "cast"; } + bool Execute(Event event) override; + virtual std::string const castString(WorldObject* target) { return "cast"; } protected: bool ncCast = false; @@ -25,57 +29,60 @@ protected: class CastCustomNcSpellAction : public CastCustomSpellAction { - public: - CastCustomNcSpellAction(PlayerbotAI* botAI, std::string const name = "cast custom nc spell") : CastCustomSpellAction(botAI, name) { } +public: + CastCustomNcSpellAction(PlayerbotAI* botAI, std::string const name = "cast custom nc spell") + : CastCustomSpellAction(botAI, name) + { + } - bool isUseful() override; - std::string const castString(WorldObject* target) override; + bool isUseful() override; + std::string const castString(WorldObject* target) override; }; class CastRandomSpellAction : public ListSpellsAction { - public: - CastRandomSpellAction(PlayerbotAI* botAI, std::string const name = "cast random spell") : ListSpellsAction(botAI, name) { } +public: + CastRandomSpellAction(PlayerbotAI* botAI, std::string const name = "cast random spell") + : ListSpellsAction(botAI, name) + { + } - bool isUseful() override { return false; } - virtual bool AcceptSpell(SpellInfo const* spellInfo); - virtual uint32 GetSpellPriority(SpellInfo const* spellInfo) { return 1; } - virtual bool castSpell(uint32 spellId, WorldObject* wo); - bool Execute(Event event) override; + bool isUseful() override { return false; } + virtual bool AcceptSpell(SpellInfo const* spellInfo); + virtual uint32 GetSpellPriority(SpellInfo const* spellInfo) { return 1; } + virtual bool castSpell(uint32 spellId, WorldObject* wo); + bool Execute(Event event) override; - protected: - bool MultiCast = false; +protected: + bool MultiCast = false; }; class CraftRandomItemAction : public CastRandomSpellAction { - public: - CraftRandomItemAction(PlayerbotAI* botAI) : CastRandomSpellAction(botAI, "craft random item") - { - MultiCast = true; - } +public: + CraftRandomItemAction(PlayerbotAI* botAI) : CastRandomSpellAction(botAI, "craft random item") { MultiCast = true; } - bool AcceptSpell(SpellInfo const* spellInfo) override; - uint32 GetSpellPriority(SpellInfo const* spellInfo) override; + bool AcceptSpell(SpellInfo const* spellInfo) override; + uint32 GetSpellPriority(SpellInfo const* spellInfo) override; }; class DisEnchantRandomItemAction : public CastCustomSpellAction { - public: - DisEnchantRandomItemAction(PlayerbotAI* botAI) : CastCustomSpellAction(botAI, "disenchant random item") {} +public: + DisEnchantRandomItemAction(PlayerbotAI* botAI) : CastCustomSpellAction(botAI, "disenchant random item") {} - bool isUseful() override; - bool Execute(Event event) override; + bool isUseful() override; + bool Execute(Event event) override; }; class EnchantRandomItemAction : public CastRandomSpellAction { - public: - EnchantRandomItemAction(PlayerbotAI* botAI) : CastRandomSpellAction(botAI, "enchant random item") { } +public: + EnchantRandomItemAction(PlayerbotAI* botAI) : CastRandomSpellAction(botAI, "enchant random item") {} - bool isUseful() override; - bool AcceptSpell(SpellInfo const* spellInfo) override; - uint32 GetSpellPriority(SpellInfo const* spellInfo) override; + bool isUseful() override; + bool AcceptSpell(SpellInfo const* spellInfo) override; + uint32 GetSpellPriority(SpellInfo const* spellInfo) override; }; #endif diff --git a/src/strategy/actions/ChangeChatAction.cpp b/src/strategy/actions/ChangeChatAction.cpp index 388224d6..4caee907 100644 --- a/src/strategy/actions/ChangeChatAction.cpp +++ b/src/strategy/actions/ChangeChatAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ChangeChatAction.h" + #include "Event.h" #include "Playerbots.h" diff --git a/src/strategy/actions/ChangeChatAction.h b/src/strategy/actions/ChangeChatAction.h index d72cf8bb..12c4d9d4 100644 --- a/src/strategy/actions/ChangeChatAction.h +++ b/src/strategy/actions/ChangeChatAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHANGECHATACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class ChangeChatAction : public Action { - public: - ChangeChatAction(PlayerbotAI* botAI) : Action(botAI, "chat") { } +public: + ChangeChatAction(PlayerbotAI* botAI) : Action(botAI, "chat") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ChangeStrategyAction.cpp b/src/strategy/actions/ChangeStrategyAction.cpp index 6addf8e5..1690774d 100644 --- a/src/strategy/actions/ChangeStrategyAction.cpp +++ b/src/strategy/actions/ChangeStrategyAction.cpp @@ -1,11 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ChangeStrategyAction.h" + #include "Event.h" -#include "Playerbots.h" #include "PlayerbotDbStore.h" +#include "Playerbots.h" bool ChangeCombatStrategyAction::Execute(Event event) { @@ -38,7 +40,8 @@ bool ChangeNonCombatStrategyAction::Execute(Event event) std::string const text = event.getParam(); uint32 account = bot->GetSession()->GetAccountId(); - if (sPlayerbotAIConfig->IsInRandomAccountList(account) && botAI->GetMaster() && botAI->GetMaster()->GetSession()->GetSecurity() < SEC_GAMEMASTER) + if (sPlayerbotAIConfig->IsInRandomAccountList(account) && botAI->GetMaster() && + botAI->GetMaster()->GetSession()->GetSecurity() < SEC_GAMEMASTER) { if (text.find("loot") != std::string::npos || text.find("gather") != std::string::npos) { diff --git a/src/strategy/actions/ChangeStrategyAction.h b/src/strategy/actions/ChangeStrategyAction.h index ae84ec7f..b50b7131 100644 --- a/src/strategy/actions/ChangeStrategyAction.h +++ b/src/strategy/actions/ChangeStrategyAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHANGESTRATEGYACTION_H @@ -11,26 +12,26 @@ class PlayerbotAI; class ChangeCombatStrategyAction : public Action { - public: - ChangeCombatStrategyAction(PlayerbotAI* botAI, std::string const name = "co") : Action(botAI, name) { } +public: + ChangeCombatStrategyAction(PlayerbotAI* botAI, std::string const name = "co") : Action(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class ChangeNonCombatStrategyAction : public Action { - public: - ChangeNonCombatStrategyAction(PlayerbotAI* botAI) : Action(botAI, "nc") { } +public: + ChangeNonCombatStrategyAction(PlayerbotAI* botAI) : Action(botAI, "nc") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class ChangeDeadStrategyAction : public Action { - public: - ChangeDeadStrategyAction(PlayerbotAI* botAI) : Action(botAI, "de") { } +public: + ChangeDeadStrategyAction(PlayerbotAI* botAI) : Action(botAI, "de") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ChangeTalentsAction.cpp b/src/strategy/actions/ChangeTalentsAction.cpp index c6b546a1..cbaa8965 100644 --- a/src/strategy/actions/ChangeTalentsAction.cpp +++ b/src/strategy/actions/ChangeTalentsAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ChangeTalentsAction.h" + #include "AiFactory.h" #include "ChatHelper.h" #include "Event.h" @@ -17,16 +19,22 @@ bool ChangeTalentsAction::Execute(Event event) std::ostringstream out; TalentSpec botSpec(bot); - + if (!param.empty()) { - if (param.find("help") != std::string::npos) { + if (param.find("help") != std::string::npos) + { out << TalentsHelp(); - } else if (param.find("switch") != std::string::npos) { - if (param.find("switch 1") != std::string::npos) { + } + else if (param.find("switch") != std::string::npos) + { + if (param.find("switch 1") != std::string::npos) + { bot->ActivateSpec(0); out << "Active first talent"; - } else if (param.find("switch 2") != std::string::npos) { + } + else if (param.find("switch 2") != std::string::npos) + { if (bot->GetSpecsCount() == 1 && bot->GetLevel() >= sWorld->getIntConfig(CONFIG_MIN_DUALSPEC_LEVEL)) { bot->CastSpell(bot, 63680, true, nullptr, nullptr, bot->GetGUID()); @@ -35,28 +43,39 @@ bool ChangeTalentsAction::Execute(Event event) bot->ActivateSpec(1); out << "Active second talent"; } - } else if (param.find("autopick") != std::string::npos) { + } + else if (param.find("autopick") != std::string::npos) + { PlayerbotFactory factory(bot, bot->GetLevel()); factory.InitTalentsTree(true); out << "Auto pick talents"; - } else if (param.find("spec list") != std::string::npos) { + } + else if (param.find("spec list") != std::string::npos) + { out << SpecList(); - } else if (param.find("spec ") != std::string::npos) { + } + else if (param.find("spec ") != std::string::npos) + { param = param.substr(5); out << SpecPick(param); botAI->ResetStrategies(); - } else if (param.find("apply ") != std::string::npos) { + } + else if (param.find("apply ") != std::string::npos) + { param = param.substr(6); out << SpecApply(param); botAI->ResetStrategies(); - } else { + } + else + { out << "Unknown command."; } } else { uint32 tab = AiFactory::GetPlayerSpecTab(bot); - out << "My current talent spec is: " << "|h|cffffffff"; + out << "My current talent spec is: " + << "|h|cffffffff"; out << chat->FormatClass(bot, tab) << "\n"; out << TalentsHelp(); } @@ -70,7 +89,7 @@ std::string ChangeTalentsAction::TalentsHelp() { std::ostringstream out; out << "Talents usage: talents switch <1/2>, talents autopick, talents spec list, " - "talents spec , talents apply ."; + "talents spec , talents apply ."; return out.str(); } @@ -79,8 +98,10 @@ std::string ChangeTalentsAction::SpecList() int cls = bot->getClass(); int specFound = 0; std::ostringstream out; - for (int specNo = 0; specNo < MAX_SPECNO; ++specNo) { - if (sPlayerbotAIConfig->premadeSpecName[cls][specNo].size() == 0) { + for (int specNo = 0; specNo < MAX_SPECNO; ++specNo) + { + if (sPlayerbotAIConfig->premadeSpecName[cls][specNo].size() == 0) + { break; } specFound++; @@ -88,7 +109,8 @@ std::string ChangeTalentsAction::SpecList() std::vector> parsed = sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specNo][80]; std::unordered_map tabCount; tabCount[0] = tabCount[1] = tabCount[2] = 0; - for (auto &item : parsed) { + for (auto& item : parsed) + { tabCount[item[0]] += item[3]; } out << specFound << ". " << sPlayerbotAIConfig->premadeSpecName[cls][specNo] << " ("; @@ -103,11 +125,14 @@ std::string ChangeTalentsAction::SpecPick(std::string param) { int cls = bot->getClass(); int specFound = 0; - for (int specNo = 0; specNo < MAX_SPECNO; ++specNo) { - if (sPlayerbotAIConfig->premadeSpecName[cls][specNo].size() == 0) { + for (int specNo = 0; specNo < MAX_SPECNO; ++specNo) + { + if (sPlayerbotAIConfig->premadeSpecName[cls][specNo].size() == 0) + { break; } - if (sPlayerbotAIConfig->premadeSpecName[cls][specNo] == param) { + if (sPlayerbotAIConfig->premadeSpecName[cls][specNo] == param) + { PlayerbotFactory::InitTalentsBySpecNo(bot, specNo, true); std::ostringstream out; out << "Picking " << sPlayerbotAIConfig->premadeSpecName[cls][specNo]; @@ -119,13 +144,13 @@ std::string ChangeTalentsAction::SpecPick(std::string param) return out.str(); } - std::string ChangeTalentsAction::SpecApply(std::string param) { int cls = bot->getClass(); std::ostringstream out; std::vector> parsedSpecLink = PlayerbotAIConfig::ParseTempTalentsOrder(cls, param); - if (parsedSpecLink.size() == 0) { + if (parsedSpecLink.size() == 0) + { out << "Invalid link " << param; return out.str(); } @@ -243,7 +268,8 @@ std::string ChangeTalentsAction::SpecApply(std::string param) // newSpec.ApplyTalents(bot, out); // if (newSpec.GetTalentPoints() > 0) // { -// *out << "Upgrading spec " << "|h|cffffffff" << getPremadePath(specId)->name << "" << newSpec.FormatSpec(bot); +// *out << "Upgrading spec " << "|h|cffffffff" << getPremadePath(specId)->name << "" << +// newSpec.FormatSpec(bot); // } // } // else if (!specLink.empty()) @@ -254,7 +280,8 @@ std::string ChangeTalentsAction::SpecApply(std::string param) // if (newSpec.GetTalentPoints() > 0) // { // *out << "Upgrading saved spec " -// << "|h|cffffffff" << chat->FormatClass(bot, newSpec.highestTree()) << " (" << newSpec.FormatSpec(bot) << ")"; +// << "|h|cffffffff" << chat->FormatClass(bot, newSpec.highestTree()) << " (" << +// newSpec.FormatSpec(bot) << ")"; // } // } @@ -278,7 +305,8 @@ std::string ChangeTalentsAction::SpecApply(std::string param) // specId = -1; // // specLink = ""; // } -// else if (paths.size() > 1 && false/*!sPlayerbotAIConfig->autoPickTalents*/ && !sRandomPlayerbotMgr->IsRandomBot(bot)) +// else if (paths.size() > 1 && false/*!sPlayerbotAIConfig->autoPickTalents*/ && +// !sRandomPlayerbotMgr->IsRandomBot(bot)) // { // *out << "Found multiple specs: "; // listPremadePaths(paths, out); @@ -294,7 +322,8 @@ std::string ChangeTalentsAction::SpecApply(std::string param) // if (paths.size() > 1) // *out << "Found " << paths.size() << " possible specs to choose from. "; -// *out << "Apply spec " << "|h|cffffffff" << getPremadePath(specId)->name << " " << newSpec.FormatSpec(bot); +// *out << "Apply spec " << "|h|cffffffff" << getPremadePath(specId)->name << " " << +// newSpec.FormatSpec(bot); // } // } diff --git a/src/strategy/actions/ChangeTalentsAction.h b/src/strategy/actions/ChangeTalentsAction.h index 4ccb9e1b..d241987c 100644 --- a/src/strategy/actions/ChangeTalentsAction.h +++ b/src/strategy/actions/ChangeTalentsAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHANGETALENTSACTION_H @@ -12,31 +13,31 @@ class PlayerbotAI; class ChangeTalentsAction : public Action { - public: - ChangeTalentsAction(PlayerbotAI* botAI, std::string const name = "talents") : Action(botAI, name) { } +public: + ChangeTalentsAction(PlayerbotAI* botAI, std::string const name = "talents") : Action(botAI, name) {} - bool Execute(Event event); - // bool AutoSelectTalents(std::ostringstream* out); + bool Execute(Event event); + // bool AutoSelectTalents(std::ostringstream* out); - private: - // std::vector getPremadePaths(std::string const findName); - // std::vector getPremadePaths(TalentSpec* oldSpec); - // TalentPath* getPremadePath(uint32 id); - // void listPremadePaths(std::vector paths, std::ostringstream* out); - // TalentPath* PickPremadePath(std::vector paths, bool useProbability); - // TalentSpec* GetBestPremadeSpec(uint32 spec); - std::string TalentsHelp(); - std::string SpecList(); - std::string SpecPick(std::string param); - std::string SpecApply(std::string param); +private: + // std::vector getPremadePaths(std::string const findName); + // std::vector getPremadePaths(TalentSpec* oldSpec); + // TalentPath* getPremadePath(uint32 id); + // void listPremadePaths(std::vector paths, std::ostringstream* out); + // TalentPath* PickPremadePath(std::vector paths, bool useProbability); + // TalentSpec* GetBestPremadeSpec(uint32 spec); + std::string TalentsHelp(); + std::string SpecList(); + std::string SpecPick(std::string param); + std::string SpecApply(std::string param); }; class AutoSetTalentsAction : public ChangeTalentsAction { - public: - AutoSetTalentsAction(PlayerbotAI* botAI) : ChangeTalentsAction(botAI, "auto talents") { } +public: + AutoSetTalentsAction(PlayerbotAI* botAI) : ChangeTalentsAction(botAI, "auto talents") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ChatActionContext.h b/src/strategy/actions/ChatActionContext.h index 8fb48c64..56597747 100644 --- a/src/strategy/actions/ChatActionContext.h +++ b/src/strategy/actions/ChatActionContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHATACTIONCONTEXTACTION_H @@ -12,8 +13,8 @@ #include "BuyAction.h" #include "CastCustomSpellAction.h" #include "ChangeChatAction.h" -#include "ChangeTalentsAction.h" #include "ChangeStrategyAction.h" +#include "ChangeTalentsAction.h" #include "ChatShortcutActions.h" #include "CheatAction.h" #include "CustomStrategyEditAction.h" @@ -22,6 +23,7 @@ #include "DropQuestAction.h" #include "EquipAction.h" #include "FlagAction.h" +#include "Formations.h" #include "GoAction.h" #include "GossipHelloAction.h" #include "GuildBankAction.h" @@ -35,10 +37,11 @@ #include "LogLevelAction.h" #include "LootStrategyAction.h" #include "MailAction.h" -#include "QueryItemUsageAction.h" -#include "QueryQuestAction.h" +#include "NamedObjectContext.h" #include "PassLeadershipToMasterAction.h" #include "PositionAction.h" +#include "QueryItemUsageAction.h" +#include "QueryQuestAction.h" #include "RangeAction.h" #include "ReleaseSpiritAction.h" #include "RepairAllAction.h" @@ -49,11 +52,12 @@ #include "RtscAction.h" #include "SaveManaAction.h" #include "SellAction.h" -#include "SetCraftAction.h" #include "SendMailAction.h" +#include "SetCraftAction.h" #include "SetHomeAction.h" #include "ShareQuestAction.h" #include "SkipSpellsListAction.h" +#include "Stances.h" #include "StatsAction.h" #include "TaxiAction.h" #include "TeleportAction.h" @@ -69,205 +73,201 @@ #include "UseMeetingStoneAction.h" #include "WhoAction.h" #include "WtsAction.h" -#include "NamedObjectContext.h" -#include "Formations.h" -#include "Stances.h" class ChatActionContext : public NamedObjectContext { - public: - ChatActionContext() - { - creators["range"] = &ChatActionContext::range; - creators["stats"] = &ChatActionContext::stats; - creators["quests"] = &ChatActionContext::quests; - creators["leave"] = &ChatActionContext::leave; - creators["reputation"] = &ChatActionContext::reputation; - creators["log"] = &ChatActionContext::log; - creators["los"] = &ChatActionContext::los; - creators["aura"] = &ChatActionContext::aura; - creators["drop"] = &ChatActionContext::drop; - creators["clean quest log"] = &ChatActionContext::clean_quest_log; - creators["share"] = &ChatActionContext::share; - creators["query quest"] = &ChatActionContext::query_quest; - creators["query item usage"] = &ChatActionContext::query_item_usage; - creators["ll"] = &ChatActionContext::ll; - creators["ss"] = &ChatActionContext::ss; - creators["add all loot"] = &ChatActionContext::add_all_loot; - creators["release"] = &ChatActionContext::release; - creators["repop"] = &ChatActionContext::repop; - creators["teleport"] = &ChatActionContext::teleport; - creators["taxi"] = &ChatActionContext::taxi; - creators["repair"] = &ChatActionContext::repair; - creators["use"] = &ChatActionContext::use; - creators["item count"] = &ChatActionContext::item_count; - creators["equip"] = &ChatActionContext::equip; - creators["equip upgrades"] = &ChatActionContext::equip_upgrades; - creators["unequip"] = &ChatActionContext::unequip; - creators["sell"] = &ChatActionContext::sell; - creators["buy"] = &ChatActionContext::buy; - creators["reward"] = &ChatActionContext::reward; - creators["trade"] = &ChatActionContext::trade; - creators["talents"] = &ChatActionContext::talents; - creators["spells"] = &ChatActionContext::spells; - creators["co"] = &ChatActionContext::co; - creators["nc"] = &ChatActionContext::nc; - creators["de"] = &ChatActionContext::dead; - creators["trainer"] = &ChatActionContext::trainer; - creators["maintenance"] = &ChatActionContext::maintenance; - creators["remove glyph"] = &ChatActionContext::remove_glyph; - creators["autogear"] = &ChatActionContext::autogear; - creators["equip upgrade"] = &ChatActionContext::equip_upgrade; - creators["attack my target"] = &ChatActionContext::attack_my_target; - creators["chat"] = &ChatActionContext::chat; - creators["home"] = &ChatActionContext::home; - creators["destroy"] = &ChatActionContext::destroy; - creators["reset botAI"] = &ChatActionContext::reset_ai; - creators["buff"] = &ChatActionContext::buff; - creators["help"] = &ChatActionContext::help; - creators["gb"] = &ChatActionContext::gb; - creators["bank"] = &ChatActionContext::bank; - creators["follow chat shortcut"] = &ChatActionContext::follow_chat_shortcut; - creators["stay chat shortcut"] = &ChatActionContext::stay_chat_shortcut; - creators["flee chat shortcut"] = &ChatActionContext::flee_chat_shortcut; - creators["runaway chat shortcut"] = &ChatActionContext::runaway_chat_shortcut; - creators["grind chat shortcut"] = &ChatActionContext::grind_chat_shortcut; - creators["tank attack chat shortcut"] = &ChatActionContext::tank_attack_chat_shortcut; - creators["gossip hello"] = &ChatActionContext::gossip_hello; - creators["cast custom spell"] = &ChatActionContext::cast_custom_spell; - creators["cast custom nc spell"] = &ChatActionContext::cast_custom_nc_spell; - creators["invite"] = &ChatActionContext::invite; - creators["spell"] = &ChatActionContext::spell; - creators["rti"] = &ChatActionContext::rti; - creators["spirit healer"] = &ChatActionContext::spirit_healer; - creators["position"] = &ChatActionContext::position; - creators["tell target"] = &ChatActionContext::tell_target; - creators["summon"] = &ChatActionContext::summon; - creators["who"] = &ChatActionContext::who; - creators["save mana"] = &ChatActionContext::save_mana; - creators["max dps chat shortcut"] = &ChatActionContext::max_dps_chat_shortcut; - creators["tell attackers"] = &ChatActionContext::tell_attackers; - creators["tell target"] = &ChatActionContext::tell_target; - creators["formation"] = &ChatActionContext::formation; - creators["stance"] = &ChatActionContext::stance; - creators["sendmail"] = &ChatActionContext::sendmail; - creators["mail"] = &ChatActionContext::mail; - creators["go"] = &ChatActionContext::go; - creators["debug"] = &ChatActionContext::debug; - creators["cdebug"] = &ChatActionContext::debug; - creators["cs"] = &ChatActionContext::cs; - creators["wts"] = &ChatActionContext::wts; - creators["hire"] = &ChatActionContext::hire; - creators["craft"] = &ChatActionContext::craft; - creators["flag"] = &ChatActionContext::flag; - creators["give leader"] = &ChatActionContext::give_leader; - creators["cheat"] = &ChatActionContext::cheat; - creators["ginvite"] = &ChatActionContext::ginvite; - creators["guild promote"] = &ChatActionContext::guild_promote; - creators["guild demote"] = &ChatActionContext::guild_demote; - creators["guild remove"] = &ChatActionContext::guild_remove; - creators["guild leave"] = &ChatActionContext::guild_leave; - creators["rtsc"] = &ChatActionContext::rtsc; - creators["naxx chat shortcut"] = &ChatActionContext::naxx_chat_shortcut; - creators["bwl chat shortcut"] = &ChatActionContext::bwl_chat_shortcut; - creators["tell expected dps"] = &ChatActionContext::tell_expected_dps; - - } +public: + ChatActionContext() + { + creators["range"] = &ChatActionContext::range; + creators["stats"] = &ChatActionContext::stats; + creators["quests"] = &ChatActionContext::quests; + creators["leave"] = &ChatActionContext::leave; + creators["reputation"] = &ChatActionContext::reputation; + creators["log"] = &ChatActionContext::log; + creators["los"] = &ChatActionContext::los; + creators["aura"] = &ChatActionContext::aura; + creators["drop"] = &ChatActionContext::drop; + creators["clean quest log"] = &ChatActionContext::clean_quest_log; + creators["share"] = &ChatActionContext::share; + creators["query quest"] = &ChatActionContext::query_quest; + creators["query item usage"] = &ChatActionContext::query_item_usage; + creators["ll"] = &ChatActionContext::ll; + creators["ss"] = &ChatActionContext::ss; + creators["add all loot"] = &ChatActionContext::add_all_loot; + creators["release"] = &ChatActionContext::release; + creators["repop"] = &ChatActionContext::repop; + creators["teleport"] = &ChatActionContext::teleport; + creators["taxi"] = &ChatActionContext::taxi; + creators["repair"] = &ChatActionContext::repair; + creators["use"] = &ChatActionContext::use; + creators["item count"] = &ChatActionContext::item_count; + creators["equip"] = &ChatActionContext::equip; + creators["equip upgrades"] = &ChatActionContext::equip_upgrades; + creators["unequip"] = &ChatActionContext::unequip; + creators["sell"] = &ChatActionContext::sell; + creators["buy"] = &ChatActionContext::buy; + creators["reward"] = &ChatActionContext::reward; + creators["trade"] = &ChatActionContext::trade; + creators["talents"] = &ChatActionContext::talents; + creators["spells"] = &ChatActionContext::spells; + creators["co"] = &ChatActionContext::co; + creators["nc"] = &ChatActionContext::nc; + creators["de"] = &ChatActionContext::dead; + creators["trainer"] = &ChatActionContext::trainer; + creators["maintenance"] = &ChatActionContext::maintenance; + creators["remove glyph"] = &ChatActionContext::remove_glyph; + creators["autogear"] = &ChatActionContext::autogear; + creators["equip upgrade"] = &ChatActionContext::equip_upgrade; + creators["attack my target"] = &ChatActionContext::attack_my_target; + creators["chat"] = &ChatActionContext::chat; + creators["home"] = &ChatActionContext::home; + creators["destroy"] = &ChatActionContext::destroy; + creators["reset botAI"] = &ChatActionContext::reset_ai; + creators["buff"] = &ChatActionContext::buff; + creators["help"] = &ChatActionContext::help; + creators["gb"] = &ChatActionContext::gb; + creators["bank"] = &ChatActionContext::bank; + creators["follow chat shortcut"] = &ChatActionContext::follow_chat_shortcut; + creators["stay chat shortcut"] = &ChatActionContext::stay_chat_shortcut; + creators["flee chat shortcut"] = &ChatActionContext::flee_chat_shortcut; + creators["runaway chat shortcut"] = &ChatActionContext::runaway_chat_shortcut; + creators["grind chat shortcut"] = &ChatActionContext::grind_chat_shortcut; + creators["tank attack chat shortcut"] = &ChatActionContext::tank_attack_chat_shortcut; + creators["gossip hello"] = &ChatActionContext::gossip_hello; + creators["cast custom spell"] = &ChatActionContext::cast_custom_spell; + creators["cast custom nc spell"] = &ChatActionContext::cast_custom_nc_spell; + creators["invite"] = &ChatActionContext::invite; + creators["spell"] = &ChatActionContext::spell; + creators["rti"] = &ChatActionContext::rti; + creators["spirit healer"] = &ChatActionContext::spirit_healer; + creators["position"] = &ChatActionContext::position; + creators["tell target"] = &ChatActionContext::tell_target; + creators["summon"] = &ChatActionContext::summon; + creators["who"] = &ChatActionContext::who; + creators["save mana"] = &ChatActionContext::save_mana; + creators["max dps chat shortcut"] = &ChatActionContext::max_dps_chat_shortcut; + creators["tell attackers"] = &ChatActionContext::tell_attackers; + creators["tell target"] = &ChatActionContext::tell_target; + creators["formation"] = &ChatActionContext::formation; + creators["stance"] = &ChatActionContext::stance; + creators["sendmail"] = &ChatActionContext::sendmail; + creators["mail"] = &ChatActionContext::mail; + creators["go"] = &ChatActionContext::go; + creators["debug"] = &ChatActionContext::debug; + creators["cdebug"] = &ChatActionContext::debug; + creators["cs"] = &ChatActionContext::cs; + creators["wts"] = &ChatActionContext::wts; + creators["hire"] = &ChatActionContext::hire; + creators["craft"] = &ChatActionContext::craft; + creators["flag"] = &ChatActionContext::flag; + creators["give leader"] = &ChatActionContext::give_leader; + creators["cheat"] = &ChatActionContext::cheat; + creators["ginvite"] = &ChatActionContext::ginvite; + creators["guild promote"] = &ChatActionContext::guild_promote; + creators["guild demote"] = &ChatActionContext::guild_demote; + creators["guild remove"] = &ChatActionContext::guild_remove; + creators["guild leave"] = &ChatActionContext::guild_leave; + creators["rtsc"] = &ChatActionContext::rtsc; + creators["naxx chat shortcut"] = &ChatActionContext::naxx_chat_shortcut; + creators["bwl chat shortcut"] = &ChatActionContext::bwl_chat_shortcut; + creators["tell expected dps"] = &ChatActionContext::tell_expected_dps; + } - private: - static Action* range(PlayerbotAI* botAI) { return new RangeAction(botAI); } - static Action* flag(PlayerbotAI* botAI) { return new FlagAction(botAI); } - static Action* craft(PlayerbotAI* botAI) { return new SetCraftAction(botAI); } - static Action* hire(PlayerbotAI* botAI) { return new HireAction(botAI); } - static Action* wts(PlayerbotAI* botAI) { return new WtsAction(botAI); } - static Action* cs(PlayerbotAI* botAI) { return new CustomStrategyEditAction(botAI); } - static Action* debug(PlayerbotAI* botAI) { return new DebugAction(botAI); } - static Action* mail(PlayerbotAI* botAI) { return new MailAction(botAI); } - static Action* go(PlayerbotAI* botAI) { return new GoAction(botAI); } - static Action* sendmail(PlayerbotAI* botAI) { return new SendMailAction(botAI); } - static Action* formation(PlayerbotAI* botAI) { return new SetFormationAction(botAI); } - static Action* stance(PlayerbotAI* botAI) { return new SetStanceAction(botAI); } - static Action* tell_attackers(PlayerbotAI* botAI) { return new TellAttackersAction(botAI); } - static Action* max_dps_chat_shortcut(PlayerbotAI* botAI) { return new MaxDpsChatShortcutAction(botAI); } - static Action* save_mana(PlayerbotAI* botAI) { return new SaveManaAction(botAI); } - static Action* who(PlayerbotAI* botAI) { return new WhoAction(botAI); } - static Action* summon(PlayerbotAI* botAI) { return new SummonAction(botAI); } - static Action* tell_target(PlayerbotAI* botAI) { return new TellTargetAction(botAI); } - static Action* position(PlayerbotAI* botAI) { return new PositionAction(botAI); } - static Action* spirit_healer(PlayerbotAI* botAI) { return new SpiritHealerAction(botAI); } - static Action* rti(PlayerbotAI* botAI) { return new RtiAction(botAI); } - static Action* invite(PlayerbotAI* botAI) { return new InviteToGroupAction(botAI); } - static Action* spell(PlayerbotAI* botAI) { return new TellSpellAction(botAI); } - static Action* cast_custom_spell(PlayerbotAI* botAI) { return new CastCustomSpellAction(botAI); } - static Action* cast_custom_nc_spell(PlayerbotAI* botAI) { return new CastCustomNcSpellAction(botAI); } - static Action* tank_attack_chat_shortcut(PlayerbotAI* botAI) { return new TankAttackChatShortcutAction(botAI); } - static Action* grind_chat_shortcut(PlayerbotAI* botAI) { return new GrindChatShortcutAction(botAI); } - static Action* flee_chat_shortcut(PlayerbotAI* botAI) { return new FleeChatShortcutAction(botAI); } - static Action* runaway_chat_shortcut(PlayerbotAI* botAI) { return new GoawayChatShortcutAction(botAI); } - static Action* stay_chat_shortcut(PlayerbotAI* botAI) { return new StayChatShortcutAction(botAI); } - static Action* follow_chat_shortcut(PlayerbotAI* botAI) { return new FollowChatShortcutAction(botAI); } - static Action* gb(PlayerbotAI* botAI) { return new GuildBankAction(botAI); } - static Action* bank(PlayerbotAI* botAI) { return new BankAction(botAI); } - static Action* help(PlayerbotAI* botAI) { return new HelpAction(botAI); } - static Action* buff(PlayerbotAI* botAI) { return new BuffAction(botAI); } - static Action* destroy(PlayerbotAI* botAI) { return new DestroyItemAction(botAI); } - static Action* home(PlayerbotAI* botAI) { return new SetHomeAction(botAI); } - static Action* chat(PlayerbotAI* botAI) { return new ChangeChatAction(botAI); } - static Action* attack_my_target(PlayerbotAI* botAI) { return new AttackMyTargetAction(botAI); } - static Action* trainer(PlayerbotAI* botAI) { return new TrainerAction(botAI); } - static Action* maintenance(PlayerbotAI* botAI) { return new MaintenanceAction(botAI); } - static Action* remove_glyph(PlayerbotAI* botAI) { return new RemoveGlyphAction(botAI); } - static Action* autogear(PlayerbotAI* botAI) { return new AutoGearAction(botAI); } - static Action* equip_upgrade(PlayerbotAI* botAI) { return new EquipUpgradeAction(botAI); } - static Action* co(PlayerbotAI* botAI) { return new ChangeCombatStrategyAction(botAI); } - static Action* nc(PlayerbotAI* botAI) { return new ChangeNonCombatStrategyAction(botAI); } - static Action* dead(PlayerbotAI* botAI) { return new ChangeDeadStrategyAction(botAI); } - static Action* spells(PlayerbotAI* botAI) { return new ListSpellsAction(botAI); } - static Action* talents(PlayerbotAI* botAI) { return new ChangeTalentsAction(botAI); } +private: + static Action* range(PlayerbotAI* botAI) { return new RangeAction(botAI); } + static Action* flag(PlayerbotAI* botAI) { return new FlagAction(botAI); } + static Action* craft(PlayerbotAI* botAI) { return new SetCraftAction(botAI); } + static Action* hire(PlayerbotAI* botAI) { return new HireAction(botAI); } + static Action* wts(PlayerbotAI* botAI) { return new WtsAction(botAI); } + static Action* cs(PlayerbotAI* botAI) { return new CustomStrategyEditAction(botAI); } + static Action* debug(PlayerbotAI* botAI) { return new DebugAction(botAI); } + static Action* mail(PlayerbotAI* botAI) { return new MailAction(botAI); } + static Action* go(PlayerbotAI* botAI) { return new GoAction(botAI); } + static Action* sendmail(PlayerbotAI* botAI) { return new SendMailAction(botAI); } + static Action* formation(PlayerbotAI* botAI) { return new SetFormationAction(botAI); } + static Action* stance(PlayerbotAI* botAI) { return new SetStanceAction(botAI); } + static Action* tell_attackers(PlayerbotAI* botAI) { return new TellAttackersAction(botAI); } + static Action* max_dps_chat_shortcut(PlayerbotAI* botAI) { return new MaxDpsChatShortcutAction(botAI); } + static Action* save_mana(PlayerbotAI* botAI) { return new SaveManaAction(botAI); } + static Action* who(PlayerbotAI* botAI) { return new WhoAction(botAI); } + static Action* summon(PlayerbotAI* botAI) { return new SummonAction(botAI); } + static Action* tell_target(PlayerbotAI* botAI) { return new TellTargetAction(botAI); } + static Action* position(PlayerbotAI* botAI) { return new PositionAction(botAI); } + static Action* spirit_healer(PlayerbotAI* botAI) { return new SpiritHealerAction(botAI); } + static Action* rti(PlayerbotAI* botAI) { return new RtiAction(botAI); } + static Action* invite(PlayerbotAI* botAI) { return new InviteToGroupAction(botAI); } + static Action* spell(PlayerbotAI* botAI) { return new TellSpellAction(botAI); } + static Action* cast_custom_spell(PlayerbotAI* botAI) { return new CastCustomSpellAction(botAI); } + static Action* cast_custom_nc_spell(PlayerbotAI* botAI) { return new CastCustomNcSpellAction(botAI); } + static Action* tank_attack_chat_shortcut(PlayerbotAI* botAI) { return new TankAttackChatShortcutAction(botAI); } + static Action* grind_chat_shortcut(PlayerbotAI* botAI) { return new GrindChatShortcutAction(botAI); } + static Action* flee_chat_shortcut(PlayerbotAI* botAI) { return new FleeChatShortcutAction(botAI); } + static Action* runaway_chat_shortcut(PlayerbotAI* botAI) { return new GoawayChatShortcutAction(botAI); } + static Action* stay_chat_shortcut(PlayerbotAI* botAI) { return new StayChatShortcutAction(botAI); } + static Action* follow_chat_shortcut(PlayerbotAI* botAI) { return new FollowChatShortcutAction(botAI); } + static Action* gb(PlayerbotAI* botAI) { return new GuildBankAction(botAI); } + static Action* bank(PlayerbotAI* botAI) { return new BankAction(botAI); } + static Action* help(PlayerbotAI* botAI) { return new HelpAction(botAI); } + static Action* buff(PlayerbotAI* botAI) { return new BuffAction(botAI); } + static Action* destroy(PlayerbotAI* botAI) { return new DestroyItemAction(botAI); } + static Action* home(PlayerbotAI* botAI) { return new SetHomeAction(botAI); } + static Action* chat(PlayerbotAI* botAI) { return new ChangeChatAction(botAI); } + static Action* attack_my_target(PlayerbotAI* botAI) { return new AttackMyTargetAction(botAI); } + static Action* trainer(PlayerbotAI* botAI) { return new TrainerAction(botAI); } + static Action* maintenance(PlayerbotAI* botAI) { return new MaintenanceAction(botAI); } + static Action* remove_glyph(PlayerbotAI* botAI) { return new RemoveGlyphAction(botAI); } + static Action* autogear(PlayerbotAI* botAI) { return new AutoGearAction(botAI); } + static Action* equip_upgrade(PlayerbotAI* botAI) { return new EquipUpgradeAction(botAI); } + static Action* co(PlayerbotAI* botAI) { return new ChangeCombatStrategyAction(botAI); } + static Action* nc(PlayerbotAI* botAI) { return new ChangeNonCombatStrategyAction(botAI); } + static Action* dead(PlayerbotAI* botAI) { return new ChangeDeadStrategyAction(botAI); } + static Action* spells(PlayerbotAI* botAI) { return new ListSpellsAction(botAI); } + static Action* talents(PlayerbotAI* botAI) { return new ChangeTalentsAction(botAI); } - static Action* equip(PlayerbotAI* botAI) { return new EquipAction(botAI); } - static Action* equip_upgrades(PlayerbotAI* botAI) { return new EquipUpgradesAction(botAI); } - static Action* unequip(PlayerbotAI* botAI) { return new UnequipAction(botAI); } - static Action* sell(PlayerbotAI* botAI) { return new SellAction(botAI); } - static Action* buy(PlayerbotAI* botAI) { return new BuyAction(botAI); } - static Action* reward(PlayerbotAI* botAI) { return new RewardAction(botAI); } - static Action* trade(PlayerbotAI* botAI) { return new TradeAction(botAI); } + static Action* equip(PlayerbotAI* botAI) { return new EquipAction(botAI); } + static Action* equip_upgrades(PlayerbotAI* botAI) { return new EquipUpgradesAction(botAI); } + static Action* unequip(PlayerbotAI* botAI) { return new UnequipAction(botAI); } + static Action* sell(PlayerbotAI* botAI) { return new SellAction(botAI); } + static Action* buy(PlayerbotAI* botAI) { return new BuyAction(botAI); } + static Action* reward(PlayerbotAI* botAI) { return new RewardAction(botAI); } + static Action* trade(PlayerbotAI* botAI) { return new TradeAction(botAI); } - static Action* item_count(PlayerbotAI* botAI) { return new TellItemCountAction(botAI); } - static Action* use(PlayerbotAI* botAI) { return new UseItemAction(botAI); } - static Action* repair(PlayerbotAI* botAI) { return new RepairAllAction(botAI); } - static Action* taxi(PlayerbotAI* botAI) { return new TaxiAction(botAI); } - static Action* teleport(PlayerbotAI* botAI) { return new TeleportAction(botAI); } - static Action* release(PlayerbotAI* botAI) { return new ReleaseSpiritAction(botAI); } - static Action* repop(PlayerbotAI* botAI) { return new RepopAction(botAI); } - static Action* query_item_usage(PlayerbotAI* botAI) { return new QueryItemUsageAction(botAI); } - static Action* query_quest(PlayerbotAI* botAI) { return new QueryQuestAction(botAI); } - static Action* drop(PlayerbotAI* botAI) { return new DropQuestAction(botAI); } - static Action* clean_quest_log(PlayerbotAI* botAI) { return new CleanQuestLogAction(botAI); } - static Action* share(PlayerbotAI* botAI) { return new ShareQuestAction(botAI); } - static Action* stats(PlayerbotAI* botAI) { return new StatsAction(botAI); } - static Action* quests(PlayerbotAI* botAI) { return new ListQuestsAction(botAI); } - static Action* leave(PlayerbotAI* botAI) { return new LeaveGroupAction(botAI); } - static Action* reputation(PlayerbotAI* botAI) { return new TellReputationAction(botAI); } - static Action* log(PlayerbotAI* botAI) { return new LogLevelAction(botAI); } - static Action* los(PlayerbotAI* botAI) { return new TellLosAction(botAI); } - static Action* aura(PlayerbotAI* ai) { return new TellAuraAction(ai); } - static Action* ll(PlayerbotAI* botAI) { return new LootStrategyAction(botAI); } - static Action* ss(PlayerbotAI* botAI) { return new SkipSpellsListAction(botAI); } - static Action* add_all_loot(PlayerbotAI* botAI) { return new AddAllLootAction(botAI); } - static Action* reset_ai(PlayerbotAI* botAI) { return new ResetAiAction(botAI); } - static Action* gossip_hello(PlayerbotAI* botAI) { return new GossipHelloAction(botAI); } - static Action* give_leader(PlayerbotAI* botAI) { return new GiveLeaderAction(botAI); } - static Action* cheat(PlayerbotAI* botAI) { return new CheatAction(botAI); } - static Action* ginvite(PlayerbotAI* botAI) { return new GuildInviteAction(botAI); } - static Action* guild_promote(PlayerbotAI* botAI) { return new GuildPromoteAction(botAI); } - static Action* guild_demote(PlayerbotAI* botAI) { return new GuildDemoteAction(botAI); } - static Action* guild_remove(PlayerbotAI* botAI) { return new GuildRemoveAction(botAI); } - static Action* guild_leave(PlayerbotAI* botAI) { return new GuildLeaveAction(botAI); } - static Action* rtsc(PlayerbotAI* botAI) { return new RTSCAction(botAI); } - static Action* naxx_chat_shortcut(PlayerbotAI* ai) { return new NaxxChatShortcutAction(ai); } - static Action* bwl_chat_shortcut(PlayerbotAI* ai) { return new BwlChatShortcutAction(ai); } - static Action* tell_expected_dps(PlayerbotAI* ai) { return new TellExpectedDpsAction(ai); } + static Action* item_count(PlayerbotAI* botAI) { return new TellItemCountAction(botAI); } + static Action* use(PlayerbotAI* botAI) { return new UseItemAction(botAI); } + static Action* repair(PlayerbotAI* botAI) { return new RepairAllAction(botAI); } + static Action* taxi(PlayerbotAI* botAI) { return new TaxiAction(botAI); } + static Action* teleport(PlayerbotAI* botAI) { return new TeleportAction(botAI); } + static Action* release(PlayerbotAI* botAI) { return new ReleaseSpiritAction(botAI); } + static Action* repop(PlayerbotAI* botAI) { return new RepopAction(botAI); } + static Action* query_item_usage(PlayerbotAI* botAI) { return new QueryItemUsageAction(botAI); } + static Action* query_quest(PlayerbotAI* botAI) { return new QueryQuestAction(botAI); } + static Action* drop(PlayerbotAI* botAI) { return new DropQuestAction(botAI); } + static Action* clean_quest_log(PlayerbotAI* botAI) { return new CleanQuestLogAction(botAI); } + static Action* share(PlayerbotAI* botAI) { return new ShareQuestAction(botAI); } + static Action* stats(PlayerbotAI* botAI) { return new StatsAction(botAI); } + static Action* quests(PlayerbotAI* botAI) { return new ListQuestsAction(botAI); } + static Action* leave(PlayerbotAI* botAI) { return new LeaveGroupAction(botAI); } + static Action* reputation(PlayerbotAI* botAI) { return new TellReputationAction(botAI); } + static Action* log(PlayerbotAI* botAI) { return new LogLevelAction(botAI); } + static Action* los(PlayerbotAI* botAI) { return new TellLosAction(botAI); } + static Action* aura(PlayerbotAI* ai) { return new TellAuraAction(ai); } + static Action* ll(PlayerbotAI* botAI) { return new LootStrategyAction(botAI); } + static Action* ss(PlayerbotAI* botAI) { return new SkipSpellsListAction(botAI); } + static Action* add_all_loot(PlayerbotAI* botAI) { return new AddAllLootAction(botAI); } + static Action* reset_ai(PlayerbotAI* botAI) { return new ResetAiAction(botAI); } + static Action* gossip_hello(PlayerbotAI* botAI) { return new GossipHelloAction(botAI); } + static Action* give_leader(PlayerbotAI* botAI) { return new GiveLeaderAction(botAI); } + static Action* cheat(PlayerbotAI* botAI) { return new CheatAction(botAI); } + static Action* ginvite(PlayerbotAI* botAI) { return new GuildInviteAction(botAI); } + static Action* guild_promote(PlayerbotAI* botAI) { return new GuildPromoteAction(botAI); } + static Action* guild_demote(PlayerbotAI* botAI) { return new GuildDemoteAction(botAI); } + static Action* guild_remove(PlayerbotAI* botAI) { return new GuildRemoveAction(botAI); } + static Action* guild_leave(PlayerbotAI* botAI) { return new GuildLeaveAction(botAI); } + static Action* rtsc(PlayerbotAI* botAI) { return new RTSCAction(botAI); } + static Action* naxx_chat_shortcut(PlayerbotAI* ai) { return new NaxxChatShortcutAction(ai); } + static Action* bwl_chat_shortcut(PlayerbotAI* ai) { return new BwlChatShortcutAction(ai); } + static Action* tell_expected_dps(PlayerbotAI* ai) { return new TellExpectedDpsAction(ai); } }; #endif diff --git a/src/strategy/actions/ChatShortcutActions.cpp b/src/strategy/actions/ChatShortcutActions.cpp index be1c4496..85304a87 100644 --- a/src/strategy/actions/ChatShortcutActions.cpp +++ b/src/strategy/actions/ChatShortcutActions.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ChatShortcutActions.h" + #include "Event.h" #include "Formations.h" -#include "PositionValue.h" #include "Playerbots.h" +#include "PositionValue.h" void ReturnPositionResetAction::ResetReturnPosition() { @@ -66,7 +68,8 @@ bool FollowChatShortcutAction::Execute(Event event) } /* Default mechanics takes care of this now. - if (bot->GetMapId() != master->GetMapId() || (master && bot->GetDistance(master) > sPlayerbotAIConfig->sightDistance)) + if (bot->GetMapId() != master->GetMapId() || (master && bot->GetDistance(master) > + sPlayerbotAIConfig->sightDistance)) { if (bot->isDead()) { @@ -76,8 +79,8 @@ bool FollowChatShortcutAction::Execute(Event event) else botAI->TellMaster("You are too far away from me! I will there soon."); - bot->TeleportTo(master->GetMapId(), master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), master->GetOrientation()); - return true; + bot->TeleportTo(master->GetMapId(), master->GetPositionX(), master->GetPositionY(), master->GetPositionZ(), + master->GetOrientation()); return true; } */ diff --git a/src/strategy/actions/ChatShortcutActions.h b/src/strategy/actions/ChatShortcutActions.h index 916ecc1e..b1348341 100644 --- a/src/strategy/actions/ChatShortcutActions.h +++ b/src/strategy/actions/ChatShortcutActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHATSHORTCUTACTION_H @@ -11,80 +12,80 @@ class PlayerbotAI; class ReturnPositionResetAction : public Action { - public: - ReturnPositionResetAction(PlayerbotAI* botAI, std::string const name) : Action(botAI, name) { } +public: + ReturnPositionResetAction(PlayerbotAI* botAI, std::string const name) : Action(botAI, name) {} - void ResetReturnPosition(); - void SetReturnPosition(float x, float y, float z); + void ResetReturnPosition(); + void SetReturnPosition(float x, float y, float z); }; class FollowChatShortcutAction : public MovementAction { - public: - FollowChatShortcutAction(PlayerbotAI* botAI) : MovementAction(botAI, "follow chat shortcut") { } +public: + FollowChatShortcutAction(PlayerbotAI* botAI) : MovementAction(botAI, "follow chat shortcut") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class StayChatShortcutAction : public ReturnPositionResetAction { - public: - StayChatShortcutAction(PlayerbotAI* botAI) : ReturnPositionResetAction(botAI, "stay chat shortcut") { } +public: + StayChatShortcutAction(PlayerbotAI* botAI) : ReturnPositionResetAction(botAI, "stay chat shortcut") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class FleeChatShortcutAction : public ReturnPositionResetAction { - public: - FleeChatShortcutAction(PlayerbotAI* botAI) : ReturnPositionResetAction(botAI, "flee chat shortcut") { } +public: + FleeChatShortcutAction(PlayerbotAI* botAI) : ReturnPositionResetAction(botAI, "flee chat shortcut") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class GoawayChatShortcutAction : public ReturnPositionResetAction { - public: - GoawayChatShortcutAction(PlayerbotAI* botAI) : ReturnPositionResetAction(botAI, "runaway chat shortcut") { } +public: + GoawayChatShortcutAction(PlayerbotAI* botAI) : ReturnPositionResetAction(botAI, "runaway chat shortcut") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class GrindChatShortcutAction : public ReturnPositionResetAction { - public: - GrindChatShortcutAction(PlayerbotAI* botAI) : ReturnPositionResetAction(botAI, "grind chat shortcut") { } +public: + GrindChatShortcutAction(PlayerbotAI* botAI) : ReturnPositionResetAction(botAI, "grind chat shortcut") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class TankAttackChatShortcutAction : public ReturnPositionResetAction { - public: - TankAttackChatShortcutAction(PlayerbotAI* botAI) : ReturnPositionResetAction(botAI, "tank attack chat shortcut") { } +public: + TankAttackChatShortcutAction(PlayerbotAI* botAI) : ReturnPositionResetAction(botAI, "tank attack chat shortcut") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class MaxDpsChatShortcutAction : public Action { - public: - MaxDpsChatShortcutAction(PlayerbotAI* botAI) : Action(botAI, "max dps chat shortcut") { } +public: + MaxDpsChatShortcutAction(PlayerbotAI* botAI) : Action(botAI, "max dps chat shortcut") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class NaxxChatShortcutAction : public Action { - public: - NaxxChatShortcutAction(PlayerbotAI* ai) : Action(ai, "naxx chat shortcut") {} - virtual bool Execute(Event event); +public: + NaxxChatShortcutAction(PlayerbotAI* ai) : Action(ai, "naxx chat shortcut") {} + virtual bool Execute(Event event); }; class BwlChatShortcutAction : public Action { - public: - BwlChatShortcutAction(PlayerbotAI* ai) : Action(ai, "bwl chat shortcut") {} - virtual bool Execute(Event event); +public: + BwlChatShortcutAction(PlayerbotAI* ai) : Action(ai, "bwl chat shortcut") {} + virtual bool Execute(Event event); }; #endif diff --git a/src/strategy/actions/CheatAction.cpp b/src/strategy/actions/CheatAction.cpp index 8d9f6598..1092ca34 100644 --- a/src/strategy/actions/CheatAction.cpp +++ b/src/strategy/actions/CheatAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CheatAction.h" + #include "Playerbots.h" bool CheatAction::Execute(Event event) @@ -36,7 +38,7 @@ bool CheatAction::Execute(Event event) BotCheatMask CheatAction::GetCheatMask(std::string const cheat) { - if (cheat=="taxi") + if (cheat == "taxi") return BotCheatMask::taxi; if (cheat == "gold") @@ -59,7 +61,7 @@ std::string const CheatAction::GetCheatName(BotCheatMask cheatMask) switch (cheatMask) { case BotCheatMask::taxi: - return "taxi"; + return "taxi"; case BotCheatMask::gold: return "gold"; case BotCheatMask::health: @@ -80,9 +82,9 @@ void CheatAction::ListCheats() { BotCheatMask cheatMask = BotCheatMask(1 << i); if ((uint32)cheatMask & (uint32)sPlayerbotAIConfig->botCheatMask) - out << "[conf:" << GetCheatName(BotCheatMask(cheatMask)) << "]"; + out << "[conf:" << GetCheatName(BotCheatMask(cheatMask)) << "]"; else if (botAI->HasCheat(cheatMask)) - out << "[" << GetCheatName(BotCheatMask(cheatMask)) << "]"; + out << "[" << GetCheatName(BotCheatMask(cheatMask)) << "]"; } botAI->TellMasterNoFacing(out); diff --git a/src/strategy/actions/CheatAction.h b/src/strategy/actions/CheatAction.h index 29b5f816..8c2061a0 100644 --- a/src/strategy/actions/CheatAction.h +++ b/src/strategy/actions/CheatAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "Action.h" @@ -10,13 +11,13 @@ enum class BotCheatMask : uint32; class CheatAction : public Action { - public: - CheatAction(PlayerbotAI* botAI) : Action(botAI, "cheat") { } +public: + CheatAction(PlayerbotAI* botAI) : Action(botAI, "cheat") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - static BotCheatMask GetCheatMask(std::string const cheat); - static std::string const GetCheatName(BotCheatMask cheatMask); - void ListCheats(); +private: + static BotCheatMask GetCheatMask(std::string const cheat); + static std::string const GetCheatName(BotCheatMask cheatMask); + void ListCheats(); }; diff --git a/src/strategy/actions/CheckMailAction.cpp b/src/strategy/actions/CheckMailAction.cpp index e7d27f49..96c1ba95 100644 --- a/src/strategy/actions/CheckMailAction.cpp +++ b/src/strategy/actions/CheckMailAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CheckMailAction.h" + #include "Event.h" #include "GuildTaskMgr.h" #include "Playerbots.h" @@ -74,7 +76,7 @@ void CheckMailAction::ProcessMail(Mail* mail, Player* owner, CharacterDatabaseTr for (MailItemInfoVec::iterator i = mail->items.begin(); i != mail->items.end(); ++i) { - Item *item = bot->GetMItem(i->item_guid); + Item* item = bot->GetMItem(i->item_guid); if (!item) continue; diff --git a/src/strategy/actions/CheckMailAction.h b/src/strategy/actions/CheckMailAction.h index 27587f57..2089c111 100644 --- a/src/strategy/actions/CheckMailAction.h +++ b/src/strategy/actions/CheckMailAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHECKMAILACTION_H @@ -14,14 +15,14 @@ struct Mail; class CheckMailAction : public Action { - public: - CheckMailAction(PlayerbotAI* botAI) : Action(botAI, "check mail") { } +public: + CheckMailAction(PlayerbotAI* botAI) : Action(botAI, "check mail") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; - private: - void ProcessMail(Mail* mail, Player* owner, CharacterDatabaseTransaction trans); +private: + void ProcessMail(Mail* mail, Player* owner, CharacterDatabaseTransaction trans); }; #endif diff --git a/src/strategy/actions/CheckMountStateAction.cpp b/src/strategy/actions/CheckMountStateAction.cpp index 09a4e208..17660836 100644 --- a/src/strategy/actions/CheckMountStateAction.cpp +++ b/src/strategy/actions/CheckMountStateAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CheckMountStateAction.h" + #include "BattlegroundWS.h" #include "Event.h" #include "PlayerbotAI.h" @@ -12,18 +14,23 @@ bool CheckMountStateAction::Execute(Event event) { - bool noattackers = AI_VALUE2(bool, "combat", "self target") ? (AI_VALUE(uint8, "attacker count") > 0 ? false : true) : true; + bool noattackers = + AI_VALUE2(bool, "combat", "self target") ? (AI_VALUE(uint8, "attacker count") > 0 ? false : true) : true; bool enemy = AI_VALUE(Unit*, "enemy player target"); // ignore grind target in BG or bots will dismount near any creature (eg: the rams in AV) bool dps = (AI_VALUE(Unit*, "dps target") || (!bot->InBattleground() && AI_VALUE(Unit*, "grind target"))); - bool fartarget = (enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 40.0f)) || + bool fartarget = + (enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 40.0f)) || (dps && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "dps target"), 50.0f)); bool attackdistance = false; bool chasedistance = false; float attack_distance = 35.0f; - if (PlayerbotAI::IsMelee(bot)) { + if (PlayerbotAI::IsMelee(bot)) + { attack_distance = 10.0f; - } else { + } + else + { attack_distance = 40.0f; } if (enemy) @@ -31,11 +38,15 @@ bool CheckMountStateAction::Execute(Event event) if (dps || enemy) { - attackdistance = (enemy || dps) && sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "current target"), attack_distance); - chasedistance = enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 45.0f) && AI_VALUE2(bool, "moving", "enemy player target"); + attackdistance = (enemy || dps) && sServerFacade->IsDistanceLessThan( + AI_VALUE2(float, "distance", "current target"), attack_distance); + chasedistance = + enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 45.0f) && + AI_VALUE2(bool, "moving", "enemy player target"); } - if (bot->IsMounted() && attackdistance) { + if (bot->IsMounted() && attackdistance) + { WorldPacket emptyPacket; bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket); return true; @@ -48,7 +59,8 @@ bool CheckMountStateAction::Execute(Event event) return false; // bool farFromMaster = sServerFacade->GetDistance2d(bot, master) > sPlayerbotAIConfig->sightDistance; - if (master->IsMounted() && !bot->IsMounted() && noattackers && !attackdistance && !bot->IsInCombat() && botAI->GetState() != BOT_STATE_COMBAT) + if (master->IsMounted() && !bot->IsMounted() && noattackers && !attackdistance && !bot->IsInCombat() && + botAI->GetState() != BOT_STATE_COMBAT) { return Mount(); } @@ -59,7 +71,8 @@ bool CheckMountStateAction::Execute(Event event) bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket); return true; } - // if (!bot->IsMounted() && (chasedistance || (farFromMaster && botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT))) && !bot->IsInCombat() && !dps) + // if (!bot->IsMounted() && (chasedistance || (farFromMaster && botAI->HasStrategy("follow", + // BOT_STATE_NON_COMBAT))) && !bot->IsInCombat() && !dps) // return Mount(); // if (!bot->IsFlying() && ((!farFromMaster && !master->IsMounted()) || attackdistance) && bot->IsMounted()) @@ -73,17 +86,20 @@ bool CheckMountStateAction::Execute(Event event) } // For random bots - if (!bot->InBattleground() && !master) { - if (!bot->IsMounted() && noattackers && !attackdistance && !bot->IsInCombat()) { + if (!bot->InBattleground() && !master) + { + if (!bot->IsMounted() && noattackers && !attackdistance && !bot->IsInCombat()) + { return Mount(); } } - if (bot->InBattleground() && !attackdistance && (noattackers || fartarget) && !bot->IsInCombat() && !bot->IsMounted()) + if (bot->InBattleground() && !attackdistance && (noattackers || fartarget) && !bot->IsInCombat() && + !bot->IsMounted()) { if (bot->GetBattlegroundTypeId() == BATTLEGROUND_WS) { - BattlegroundWS *bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); + BattlegroundWS* bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); if (bot->HasAura(23333) || bot->HasAura(23335)) { return false; @@ -97,11 +113,13 @@ bool CheckMountStateAction::Execute(Event event) // { // if (AI_VALUE(GuidPosition, "rpg target")) // { - // if (sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "rpg target"), sPlayerbotAIConfig->farDistance) && noattackers && !dps && !enemy) + // if (sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "rpg target"), + // sPlayerbotAIConfig->farDistance) && noattackers && !dps && !enemy) // return Mount(); // } - // if (((!AI_VALUE(GuidVector, "possible rpg targets").empty()) && noattackers && !dps && !enemy) && urand(0, 100) > 50) + // if (((!AI_VALUE(GuidVector, "possible rpg targets").empty()) && noattackers && !dps && !enemy) && urand(0, + // 100) > 50) // return Mount(); // } @@ -175,8 +193,8 @@ bool CheckMountStateAction::Mount() // bot->GetMotionMaster()->MoveIdle(); } - Player* master = GetMaster(); - botAI->RemoveShapeshift(); + Player* master = GetMaster(); + botAI->RemoveShapeshift(); botAI->RemoveAura("tree of life"); int32 masterSpeed = 59; SpellInfo const* masterSpell = nullptr; @@ -213,7 +231,7 @@ bool CheckMountStateAction::Mount() bool hasSwiftMount = false; - //std::map > spells; + // std::map > spells; std::map>> allSpells; for (PlayerSpellMap::iterator itr = bot->GetSpellMap().begin(); itr != bot->GetSpellMap().end(); ++itr) { @@ -226,16 +244,20 @@ bool CheckMountStateAction::Mount() continue; int32 effect = std::max(spellInfo->Effects[1].BasePoints, spellInfo->Effects[2].BasePoints); - //if (effect < masterSpeed) - //continue; + // if (effect < masterSpeed) + // continue; uint32 index = (spellInfo->Effects[1].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED || - spellInfo->Effects[2].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) ? 1 : 0; + spellInfo->Effects[2].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) + ? 1 + : 0; - if (index == 0 && std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) > 59) + if (index == 0 && + std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) > 59) hasSwiftMount = true; - if (index == 1 && std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) > 149) + if (index == 1 && + std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) > 149) hasSwiftMount = true; allSpells[index][effect].push_back(spellId); @@ -245,7 +267,9 @@ bool CheckMountStateAction::Mount() if (masterSpell) { masterMountType = (masterSpell->Effects[1].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED || - masterSpell->Effects[2].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) ? 1 : 0; + masterSpell->Effects[2].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) + ? 1 + : 0; } std::map>& spells = allSpells[masterMountType]; @@ -260,10 +284,12 @@ bool CheckMountStateAction::Mount() if (!spellInfo) continue; - if (masterMountType == 0 && masterSpeed > 59 && std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) < 99) + if (masterMountType == 0 && masterSpeed > 59 && + std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) < 99) spells[59].clear(); - if (masterMountType == 1 && masterSpeed > 149 && std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) < 279) + if (masterMountType == 1 && masterSpeed > 149 && + std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) < 279) spells[149].clear(); } } @@ -276,8 +302,8 @@ bool CheckMountStateAction::Mount() if (index >= ids.size()) continue; - - return botAI->CastSpell(ids[index], bot);; + return botAI->CastSpell(ids[index], bot); + ; } std::vector items = AI_VALUE2(std::vector, "inventory items", "mount"); diff --git a/src/strategy/actions/CheckMountStateAction.h b/src/strategy/actions/CheckMountStateAction.h index 7c350400..9acb3bd7 100644 --- a/src/strategy/actions/CheckMountStateAction.h +++ b/src/strategy/actions/CheckMountStateAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHECKMOUNTSTATEACTION_H @@ -11,13 +12,13 @@ class PlayerbotAI; class CheckMountStateAction : public UseItemAction { - public: - CheckMountStateAction(PlayerbotAI* botAI) : UseItemAction(botAI, "check mount state", true) { } +public: + CheckMountStateAction(PlayerbotAI* botAI) : UseItemAction(botAI, "check mount state", true) {} - bool Execute(Event event) override; - bool isUseful() override; - bool isPossible() override { return true; } - bool Mount(); + bool Execute(Event event) override; + bool isUseful() override; + bool isPossible() override { return true; } + bool Mount(); }; #endif diff --git a/src/strategy/actions/CheckValuesAction.cpp b/src/strategy/actions/CheckValuesAction.cpp index 6a9ee8e8..89ad4b15 100644 --- a/src/strategy/actions/CheckValuesAction.cpp +++ b/src/strategy/actions/CheckValuesAction.cpp @@ -1,15 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CheckValuesAction.h" + #include "Event.h" #include "Playerbots.h" #include "ServerFacade.h" -CheckValuesAction::CheckValuesAction(PlayerbotAI* botAI) : Action(botAI, "check values") -{ -} +CheckValuesAction::CheckValuesAction(PlayerbotAI* botAI) : Action(botAI, "check values") {} bool CheckValuesAction::Execute(Event event) { diff --git a/src/strategy/actions/CheckValuesAction.h b/src/strategy/actions/CheckValuesAction.h index 0bec8c05..c884828e 100644 --- a/src/strategy/actions/CheckValuesAction.h +++ b/src/strategy/actions/CheckValuesAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHECKVALUESACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class CheckValuesAction : public Action { - public: - CheckValuesAction(PlayerbotAI* botAI); +public: + CheckValuesAction(PlayerbotAI* botAI); - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ChooseRpgTargetAction.cpp b/src/strategy/actions/ChooseRpgTargetAction.cpp index 14b8e865..e0890c98 100644 --- a/src/strategy/actions/ChooseRpgTargetAction.cpp +++ b/src/strategy/actions/ChooseRpgTargetAction.cpp @@ -1,18 +1,20 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ChooseRpgTargetAction.h" + +#include + #include "BattlegroundMgr.h" #include "BudgetValues.h" #include "ChatHelper.h" #include "Event.h" #include "Formations.h" #include "GuildCreateActions.h" -#include "PossibleRpgTargetsValue.h" #include "Playerbots.h" - -#include +#include "PossibleRpgTargetsValue.h" bool ChooseRpgTargetAction::HasSameTarget(ObjectGuid guid, uint32 max, GuidVector const& nearGuids) { @@ -117,7 +119,7 @@ bool ChooseRpgTargetAction::Execute(Event event) if (urand(0, 9)) { - for (auto target : ignoreList) + for (auto target : ignoreList) targets.erase(target); } @@ -188,7 +190,8 @@ bool ChooseRpgTargetAction::Execute(Event event) if (targets.empty()) { - LOG_DEBUG("playerbots", "{} can't choose RPG target: all {} are not available", bot->GetName().c_str(), possibleTargets.size()); + LOG_DEBUG("playerbots", "{} can't choose RPG target: all {} are not available", bot->GetName().c_str(), + possibleTargets.size()); RESET_AI_VALUE(GuidSet&, "ignore rpg target"); RESET_AI_VALUE(GuidPosition, "rpg target"); return false; @@ -280,7 +283,8 @@ bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldPosition pos) if (realMaster->IsInWorld() && realMaster->GetMap()->IsDungeon() && bot->GetMapId() == realMaster->GetMapId()) inDungeon = true; - if (realMaster && realMaster->IsInWorld() && realMaster->GetMap()->IsDungeon() && (realMaster->GetMapId() != pos.getMapId())) + if (realMaster && realMaster->IsInWorld() && realMaster->GetMap()->IsDungeon() && + (realMaster->GetMapId() != pos.getMapId())) return false; } @@ -299,7 +303,8 @@ bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldPosition pos) if (!botAI->HasActivePlayerMaster() && distance < 50.0f) { Player* player = master; - if (!master->isMoving() || PAI_VALUE(WorldPosition, "last long move").distance(pos) < sPlayerbotAIConfig->reactDistance) + if (!master->isMoving() || + PAI_VALUE(WorldPosition, "last long move").distance(pos) < sPlayerbotAIConfig->reactDistance) return true; } @@ -310,7 +315,7 @@ bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldPosition pos) return true; if (distance < formation->GetMaxDistance()) - return true; + return true; return false; } diff --git a/src/strategy/actions/ChooseRpgTargetAction.h b/src/strategy/actions/ChooseRpgTargetAction.h index a50462c8..d46b5f7e 100644 --- a/src/strategy/actions/ChooseRpgTargetAction.h +++ b/src/strategy/actions/ChooseRpgTargetAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHOOSERPGTARGETACTION_H @@ -16,27 +17,27 @@ class WorldPosition; class ChooseRpgTargetAction : public Action { - public: - ChooseRpgTargetAction(PlayerbotAI* botAI, std::string const name = "choose rpg target") : Action(botAI, name) { } +public: + ChooseRpgTargetAction(PlayerbotAI* botAI, std::string const name = "choose rpg target") : Action(botAI, name) {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; - static bool isFollowValid(Player* bot, WorldObject* target); - static bool isFollowValid(Player* bot, WorldPosition pos); + static bool isFollowValid(Player* bot, WorldObject* target); + static bool isFollowValid(Player* bot, WorldPosition pos); - private: - float getMaxRelevance(GuidPosition guidP); - bool HasSameTarget(ObjectGuid guid, uint32 max, GuidVector const& nearGuids); +private: + float getMaxRelevance(GuidPosition guidP); + bool HasSameTarget(ObjectGuid guid, uint32 max, GuidVector const& nearGuids); }; class ClearRpgTargetAction : public ChooseRpgTargetAction { - public: - ClearRpgTargetAction(PlayerbotAI* botAI) : ChooseRpgTargetAction(botAI, "clear rpg target") { } +public: + ClearRpgTargetAction(PlayerbotAI* botAI) : ChooseRpgTargetAction(botAI, "clear rpg target") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/ChooseTargetActions.cpp b/src/strategy/actions/ChooseTargetActions.cpp index d4a9f237..54bf0b1c 100644 --- a/src/strategy/actions/ChooseTargetActions.cpp +++ b/src/strategy/actions/ChooseTargetActions.cpp @@ -1,13 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ChooseTargetActions.h" + #include "ChooseRpgTargetAction.h" #include "Event.h" #include "LootObjectStack.h" -#include "PossibleRpgTargetsValue.h" #include "Playerbots.h" +#include "PossibleRpgTargetsValue.h" #include "ServerFacade.h" bool AttackEnemyPlayerAction::isUseful() @@ -22,19 +24,21 @@ bool AttackEnemyPlayerAction::isUseful() bool AttackEnemyFlagCarrierAction::isUseful() { Unit* target = context->GetValue("enemy flag carrier")->Get(); - return target && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target), 75.0f) && (bot->HasAura(23333) || bot->HasAura(23335) || bot->HasAura(34976)); + return target && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target), 75.0f) && + (bot->HasAura(23333) || bot->HasAura(23335) || bot->HasAura(34976)); } bool AttackAnythingAction::isUseful() { - if (!botAI->AllowActivity(GRIND_ACTIVITY)) //Bot not allowed to be active + if (!botAI->AllowActivity(GRIND_ACTIVITY)) // Bot not allowed to be active return false; if (!AI_VALUE(bool, "can move around")) return false; - if (context->GetValue("travel target")->Get()->isTraveling() && - ChooseRpgTargetAction::isFollowValid(bot, *context->GetValue("travel target")->Get()->getPosition())) //Bot is traveling + if (context->GetValue("travel target")->Get()->isTraveling() && + ChooseRpgTargetAction::isFollowValid( + bot, *context->GetValue("travel target")->Get()->getPosition())) // Bot is traveling return false; // if (bot->IsInCombat()) { // return false; @@ -45,10 +49,11 @@ bool AttackAnythingAction::isUseful() return false; std::string const name = std::string(target->GetName()); - if (!name.empty() && name.find("Dummy") != std::string::npos) // Target is not a targetdummy + if (!name.empty() && name.find("Dummy") != std::string::npos) // Target is not a targetdummy return false; - // if (!ChooseRpgTargetAction::isFollowValid(bot, target)) //Do not grind mobs far away from master. + // if (!ChooseRpgTargetAction::isFollowValid(bot, target)) //Do not grind mobs far + // away from master. // return false; return true; @@ -115,10 +120,7 @@ bool AttackAnythingAction::Execute(Event event) return result; } -bool AttackAnythingAction::isPossible() -{ - return AttackAction::isPossible() && GetTarget(); -} +bool AttackAnythingAction::isPossible() { return AttackAction::isPossible() && GetTarget(); } bool DpsAssistAction::isUseful() { diff --git a/src/strategy/actions/ChooseTargetActions.h b/src/strategy/actions/ChooseTargetActions.h index 41362d31..6b801a72 100644 --- a/src/strategy/actions/ChooseTargetActions.h +++ b/src/strategy/actions/ChooseTargetActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHOOSETARGETACTIONS_H @@ -11,80 +12,80 @@ class PlayerbotAI; class DpsAoeAction : public AttackAction { - public: - DpsAoeAction(PlayerbotAI* botAI) : AttackAction(botAI, "dps aoe") { } +public: + DpsAoeAction(PlayerbotAI* botAI) : AttackAction(botAI, "dps aoe") {} - std::string const GetTargetName() override { return "dps aoe target"; } + std::string const GetTargetName() override { return "dps aoe target"; } }; class DpsAssistAction : public AttackAction { - public: - DpsAssistAction(PlayerbotAI* botAI) : AttackAction(botAI, "dps assist") { } +public: + DpsAssistAction(PlayerbotAI* botAI) : AttackAction(botAI, "dps assist") {} - std::string const GetTargetName() override { return "dps target"; } - bool isUseful() override; + std::string const GetTargetName() override { return "dps target"; } + bool isUseful() override; }; class TankAssistAction : public AttackAction { - public: - TankAssistAction(PlayerbotAI* botAI) : AttackAction(botAI, "tank assist") { } +public: + TankAssistAction(PlayerbotAI* botAI) : AttackAction(botAI, "tank assist") {} - std::string const GetTargetName() override { return "tank target"; } + std::string const GetTargetName() override { return "tank target"; } }; class AttackAnythingAction : public AttackAction { - public: - AttackAnythingAction(PlayerbotAI* botAI) : AttackAction(botAI, "attack anything") { } +public: + AttackAnythingAction(PlayerbotAI* botAI) : AttackAction(botAI, "attack anything") {} - std::string const GetTargetName() override { return "grind target"; } - bool Execute(Event event) override; - bool isUseful() override; - bool isPossible() override; + std::string const GetTargetName() override { return "grind target"; } + bool Execute(Event event) override; + bool isUseful() override; + bool isPossible() override; }; class AttackLeastHpTargetAction : public AttackAction { - public: - AttackLeastHpTargetAction(PlayerbotAI* botAI) : AttackAction(botAI, "attack least hp target") { } +public: + AttackLeastHpTargetAction(PlayerbotAI* botAI) : AttackAction(botAI, "attack least hp target") {} - std::string const GetTargetName() override { return "least hp target"; } + std::string const GetTargetName() override { return "least hp target"; } }; class AttackEnemyPlayerAction : public AttackAction { - public: - AttackEnemyPlayerAction(PlayerbotAI* botAI) : AttackAction(botAI, "attack enemy player") { } +public: + AttackEnemyPlayerAction(PlayerbotAI* botAI) : AttackAction(botAI, "attack enemy player") {} - std::string const GetTargetName() override { return "enemy player target"; } - bool isUseful() override; + std::string const GetTargetName() override { return "enemy player target"; } + bool isUseful() override; }; class AttackRtiTargetAction : public AttackAction { - public: - AttackRtiTargetAction(PlayerbotAI* botAI) : AttackAction(botAI, "attack rti target") { } +public: + AttackRtiTargetAction(PlayerbotAI* botAI) : AttackAction(botAI, "attack rti target") {} - std::string const GetTargetName() override { return "rti target"; } + std::string const GetTargetName() override { return "rti target"; } }; class AttackEnemyFlagCarrierAction : public AttackAction { - public: - AttackEnemyFlagCarrierAction(PlayerbotAI* botAI) : AttackAction(botAI, "attack enemy flag carrier") { } +public: + AttackEnemyFlagCarrierAction(PlayerbotAI* botAI) : AttackAction(botAI, "attack enemy flag carrier") {} - std::string const GetTargetName() override { return "enemy flag carrier"; } - bool isUseful() override; + std::string const GetTargetName() override { return "enemy flag carrier"; } + bool isUseful() override; }; class DropTargetAction : public Action { - public: - DropTargetAction(PlayerbotAI* botAI) : Action(botAI, "drop target") { } +public: + DropTargetAction(PlayerbotAI* botAI) : Action(botAI, "drop target") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ChooseTravelTargetAction.cpp b/src/strategy/actions/ChooseTravelTargetAction.cpp index 8ef35bf4..ec188f82 100644 --- a/src/strategy/actions/ChooseTravelTargetAction.cpp +++ b/src/strategy/actions/ChooseTravelTargetAction.cpp @@ -1,97 +1,106 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ChooseTravelTargetAction.h" + #include "ChatHelper.h" #include "LootObjectStack.h" #include "Playerbots.h" bool ChooseTravelTargetAction::Execute(Event event) { - //Get the current travel target. This target is no longer active. + // Get the current travel target. This target is no longer active. TravelTarget* oldTarget = context->GetValue("travel target")->Get(); - //Select a new target to travel to. + // Select a new target to travel to. TravelTarget newTarget = TravelTarget(botAI); getNewTarget(&newTarget, oldTarget); - //If the new target is not active we failed. + // If the new target is not active we failed. if (!newTarget.isActive()) - return false; + return false; setNewTarget(&newTarget, oldTarget); return true; } -//Select a new travel target. -//Currently this selectes mostly based on priority (current quest > new quest). -//This works fine because destinations can be full (max 15 bots per quest giver, max 1 bot per quest mob). +// Select a new travel target. +// Currently this selectes mostly based on priority (current quest > new quest). +// This works fine because destinations can be full (max 15 bots per quest giver, max 1 bot per quest mob). // -//Eventually we want to rewrite this to be more intelligent. +// Eventually we want to rewrite this to be more intelligent. void ChooseTravelTargetAction::getNewTarget(TravelTarget* newTarget, TravelTarget* oldTarget) { bool foundTarget = false; - foundTarget = SetGroupTarget(newTarget); //Join groups members + foundTarget = SetGroupTarget(newTarget); // Join groups members - //Enpty bags/repair - if (!foundTarget && urand(1, 100) > 10) //90% chance - if (AI_VALUE2(bool, "group or", "should sell,can sell,following party,near leader") || AI_VALUE2(bool, "group or", "should repair,can repair,following party,near leader")) - foundTarget = SetRpgTarget(newTarget); //Go to town to sell items or repair + // Enpty bags/repair + if (!foundTarget && urand(1, 100) > 10) // 90% chance + if (AI_VALUE2(bool, "group or", "should sell,can sell,following party,near leader") || + AI_VALUE2(bool, "group or", "should repair,can repair,following party,near leader")) + foundTarget = SetRpgTarget(newTarget); // Go to town to sell items or repair - //Rpg in city - if (!foundTarget && urand(1, 100) > 90) //10% chance - foundTarget = SetNpcFlagTarget(newTarget, { UNIT_NPC_FLAG_BANKER,UNIT_NPC_FLAG_BATTLEMASTER,UNIT_NPC_FLAG_AUCTIONEER }); + // Rpg in city + if (!foundTarget && urand(1, 100) > 90) // 10% chance + foundTarget = + SetNpcFlagTarget(newTarget, {UNIT_NPC_FLAG_BANKER, UNIT_NPC_FLAG_BATTLEMASTER, UNIT_NPC_FLAG_AUCTIONEER}); - //Grind for money - if (!foundTarget && AI_VALUE(bool, "should get money")) { + // Grind for money + if (!foundTarget && AI_VALUE(bool, "should get money")) + { if (urand(1, 100) > 66) { - foundTarget = SetQuestTarget(newTarget, true); //Turn in quests for money. + foundTarget = SetQuestTarget(newTarget, true); // Turn in quests for money. if (!foundTarget) - foundTarget = SetQuestTarget(newTarget); //Do low level quests - } else if (urand(1, 100) > 50) { - foundTarget = SetGrindTarget(newTarget); //Go grind mobs for money - } else { - foundTarget = SetNewQuestTarget(newTarget); //Find a low level quest to do + foundTarget = SetQuestTarget(newTarget); // Do low level quests + } + else if (urand(1, 100) > 50) + { + foundTarget = SetGrindTarget(newTarget); // Go grind mobs for money + } + else + { + foundTarget = SetNewQuestTarget(newTarget); // Find a low level quest to do } } - //Continue - if (!foundTarget && urand(1, 100) > 10) //90% chance - foundTarget = SetCurrentTarget(newTarget, oldTarget); //Extend current target. + // Continue + if (!foundTarget && urand(1, 100) > 10) // 90% chance + foundTarget = SetCurrentTarget(newTarget, oldTarget); // Extend current target. - //Dungeon in group - if (!foundTarget && urand(1, 100) > 50) //50% chance + // Dungeon in group + if (!foundTarget && urand(1, 100) > 50) // 50% chance if (AI_VALUE(bool, "can fight boss")) - foundTarget = SetBossTarget(newTarget); //Go fight a (dungeon boss) + foundTarget = SetBossTarget(newTarget); // Go fight a (dungeon boss) - if (!foundTarget && urand(1, 100) > 5) //95% chance - foundTarget = SetQuestTarget(newTarget); //Do a target of an active quest. + if (!foundTarget && urand(1, 100) > 5) // 95% chance + foundTarget = SetQuestTarget(newTarget); // Do a target of an active quest. if (!foundTarget && urand(1, 100) > 5) - foundTarget = SetNewQuestTarget(newTarget); //Find a new quest to do. + foundTarget = SetNewQuestTarget(newTarget); // Find a new quest to do. - if (!foundTarget && botAI->HasStrategy("explore", BOT_STATE_NON_COMBAT)) //Explore a unexplored sub-zone. + if (!foundTarget && botAI->HasStrategy("explore", BOT_STATE_NON_COMBAT)) // Explore a unexplored sub-zone. foundTarget = SetExploreTarget(newTarget); // if (!foundTarget) - //foundTarget = SetRpgTarget(target); + // foundTarget = SetRpgTarget(target); if (!foundTarget) - SetNullTarget(newTarget); //Idle a bit. + SetNullTarget(newTarget); // Idle a bit. } void ChooseTravelTargetAction::setNewTarget(TravelTarget* newTarget, TravelTarget* oldTarget) { - //Tell the master where we are going. + // Tell the master where we are going. if (!bot->GetGroup() || (botAI->GetGroupMaster() == bot)) ReportTravelTarget(newTarget, oldTarget); - //If we are heading to a creature/npc clear it from the ignore list. + // If we are heading to a creature/npc clear it from the ignore list. if (oldTarget && oldTarget == newTarget && newTarget->getEntry()) { GuidSet& ignoreList = context->GetValue("ignore rpg target")->Get(); @@ -107,22 +116,23 @@ void ChooseTravelTargetAction::setNewTarget(TravelTarget* newTarget, TravelTarge context->GetValue("ignore rpg target")->Set(ignoreList); } - //Actually apply the new target to the travel target used by the bot. + // Actually apply the new target to the travel target used by the bot. oldTarget->copyTarget(newTarget); - //If we are idling but have a master. Idle only 10 seconds. - if (botAI->GetMaster() && oldTarget->isActive() && oldTarget->getDestination()->getName() == "NullTravelDestination") + // If we are idling but have a master. Idle only 10 seconds. + if (botAI->GetMaster() && oldTarget->isActive() && + oldTarget->getDestination()->getName() == "NullTravelDestination") oldTarget->setExpireIn(10 * IN_MILLISECONDS); - else if (oldTarget->isForced()) // Make sure travel goes into cooldown after getting to the destination. + else if (oldTarget->isForced()) // Make sure travel goes into cooldown after getting to the destination. oldTarget->setExpireIn(HOUR * IN_MILLISECONDS); - //Clear rpg and pull/grind target. We want to travel, not hang around some more. + // Clear rpg and pull/grind target. We want to travel, not hang around some more. RESET_AI_VALUE(GuidPosition, "rpg target"); RESET_AI_VALUE(ObjectGuid, "pull target"); } -//Tell the master what travel target we are moving towards. -//This should at some point be rewritten to be denser or perhaps logic moved to ->getTitle() +// Tell the master what travel target we are moving towards. +// This should at some point be rewritten to be denser or perhaps logic moved to ->getTitle() void ChooseTravelTargetAction::ReportTravelTarget(TravelTarget* newTarget, TravelTarget* oldTarget) { TravelDestination* destination = newTarget->getDestination(); @@ -133,7 +143,8 @@ void ChooseTravelTargetAction::ReportTravelTarget(TravelTarget* newTarget, Trave if (newTarget->isForced()) out << "(Forced) "; - if (destination->getName() == "QuestRelationTravelDestination" || destination->getName() == "QuestObjectiveTravelDestination") + if (destination->getName() == "QuestRelationTravelDestination" || + destination->getName() == "QuestObjectiveTravelDestination") { QuestTravelDestination* QuestDestination = (QuestTravelDestination*)destination; Quest const* quest = QuestDestination->GetQuestTemplate(); @@ -179,7 +190,7 @@ void ChooseTravelTargetAction::ReportTravelTarget(TravelTarget* newTarget, Trave out << round(newTarget->getDestination()->distanceTo(&botLocation)) << "y"; - out << " for "; + out << " for "; if (AI_VALUE2(bool, "group or", "should sell,can sell")) out << "selling items"; @@ -264,20 +275,22 @@ void ChooseTravelTargetAction::ReportTravelTarget(TravelTarget* newTarget, Trave } } -bool ChooseTravelTargetAction::getBestDestination(std::vector* activeDestinations, std::vector* activePoints) +bool ChooseTravelTargetAction::getBestDestination(std::vector* activeDestinations, + std::vector* activePoints) { - if (activeDestinations->empty() || activePoints->empty()) //No targets or no points. + if (activeDestinations->empty() || activePoints->empty()) // No targets or no points. return false; WorldPosition botLocation(bot); - std::vector availablePoints = sTravelMgr->getNextPoint(&botLocation, *activePoints); //Pick a good point. + std::vector availablePoints = + sTravelMgr->getNextPoint(&botLocation, *activePoints); // Pick a good point. - if (availablePoints.empty()) //No points available. + if (availablePoints.empty()) // No points available. return false; TravelDestination* targetDestination; - for (auto activeTarget : *activeDestinations) //Pick the destination that has this point. + for (auto activeTarget : *activeDestinations) // Pick the destination that has this point. if (activeTarget->distanceTo(availablePoints.front()) == 0) targetDestination = activeTarget; @@ -319,7 +332,7 @@ bool ChooseTravelTargetAction::SetGroupTarget(TravelTarget* target) } } - //Find targets of the group. + // Find targets of the group. for (auto& member : groupPlayers) { Player* player = ObjectAccessor::FindPlayer(member); @@ -341,7 +354,8 @@ bool ChooseTravelTargetAction::SetGroupTarget(TravelTarget* target) if (!groupTarget->isActive()) continue; - if (!groupTarget->getDestination()->isActive(bot) || groupTarget->getDestination()->getName() == "RpgTravelDestination") + if (!groupTarget->getDestination()->isActive(bot) || + groupTarget->getDestination()->getName() == "RpgTravelDestination") continue; activeDestinations.push_back(groupTarget->getDestination()); @@ -363,10 +377,10 @@ bool ChooseTravelTargetAction::SetCurrentTarget(TravelTarget* target, TravelTarg if (oldTarget->isMaxRetry(false)) return false; - if (!oldDestination) //Does this target have a destination? + if (!oldDestination) // Does this target have a destination? return false; - if (!oldDestination->isActive(bot)) //Is the destination still valid? + if (!oldDestination->isActive(bot)) // Is the destination still valid? return false; WorldPosition botLocation(bot); @@ -390,7 +404,7 @@ bool ChooseTravelTargetAction::SetQuestTarget(TravelTarget* target, bool onlyCom WorldPosition botLocation(bot); - //Find destinations related to the active quests. + // Find destinations related to the active quests. for (auto& quest : questMap) { if (bot->IsQuestRewarded(quest.first)) @@ -399,10 +413,12 @@ bool ChooseTravelTargetAction::SetQuestTarget(TravelTarget* target, bool onlyCom uint32 questId = quest.first; QuestStatusData* questStatus = &quest.second; - if (onlyCompleted && sObjectMgr->GetQuestTemplate(questId) && !bot->CanRewardQuest(sObjectMgr->GetQuestTemplate(questId), false)) + if (onlyCompleted && sObjectMgr->GetQuestTemplate(questId) && + !bot->CanRewardQuest(sObjectMgr->GetQuestTemplate(questId), false)) continue; - std::vector questDestinations = sTravelMgr->getQuestTravelDestinations(bot, questId, botAI->HasRealPlayerMaster(), false, 5000); + std::vector questDestinations = + sTravelMgr->getQuestTravelDestinations(bot, questId, botAI->HasRealPlayerMaster(), false, 5000); std::vector questPoints; for (auto& questDestination : questDestinations) @@ -417,7 +433,6 @@ bool ChooseTravelTargetAction::SetQuestTarget(TravelTarget* target, bool onlyCom activeDestinations.push_back(questDestinations.front()); activePoints.push_back(questPoints.front()); } - } if (!getBestDestination(&activeDestinations, &activePoints)) @@ -435,12 +450,13 @@ bool ChooseTravelTargetAction::SetNewQuestTarget(TravelTarget* target) WorldPosition botLocation(bot); - //Find quest givers. - std::vector TravelDestinations = sTravelMgr->getQuestTravelDestinations(bot, -1, botAI->HasRealPlayerMaster()); + // Find quest givers. + std::vector TravelDestinations = + sTravelMgr->getQuestTravelDestinations(bot, -1, botAI->HasRealPlayerMaster()); activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end()); - //Pick one good point per destination. + // Pick one good point per destination. for (auto& activeTarget : activeDestinations) { std::vector points = activeTarget->nextPoint(&botLocation); @@ -463,12 +479,13 @@ bool ChooseTravelTargetAction::SetRpgTarget(TravelTarget* target) WorldPosition botLocation(bot); - //Find rpg npcs - std::vector TravelDestinations = sTravelMgr->getRpgTravelDestinations(bot, botAI->HasRealPlayerMaster()); + // Find rpg npcs + std::vector TravelDestinations = + sTravelMgr->getRpgTravelDestinations(bot, botAI->HasRealPlayerMaster()); activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end()); - //Pick one good point per destination. + // Pick one good point per destination. for (auto& activeTarget : activeDestinations) { std::vector points = activeTarget->nextPoint(&botLocation); @@ -491,12 +508,13 @@ bool ChooseTravelTargetAction::SetGrindTarget(TravelTarget* target) WorldPosition botLocation(bot); - //Find grind mobs. - std::vector TravelDestinations = sTravelMgr->getGrindTravelDestinations(bot, botAI->HasRealPlayerMaster()); + // Find grind mobs. + std::vector TravelDestinations = + sTravelMgr->getGrindTravelDestinations(bot, botAI->HasRealPlayerMaster()); activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end()); - //Pick one good point per destination. + // Pick one good point per destination. for (auto& activeTarget : activeDestinations) { std::vector points = activeTarget->nextPoint(&botLocation); @@ -519,12 +537,13 @@ bool ChooseTravelTargetAction::SetBossTarget(TravelTarget* target) WorldPosition botLocation(bot); - //Find boss mobs. - std::vector TravelDestinations = sTravelMgr->getBossTravelDestinations(bot, botAI->HasRealPlayerMaster()); + // Find boss mobs. + std::vector TravelDestinations = + sTravelMgr->getBossTravelDestinations(bot, botAI->HasRealPlayerMaster()); activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end()); - //Pick one good point per destination. + // Pick one good point per destination. for (auto& activeTarget : activeDestinations) { std::vector points = activeTarget->nextPoint(&botLocation); @@ -547,7 +566,7 @@ bool ChooseTravelTargetAction::SetExploreTarget(TravelTarget* target) WorldPosition botLocation(bot); - //Find quest givers. + // Find quest givers. std::vector TravelDestinations = sTravelMgr->getExploreTravelDestinations(bot, true, true); activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end()); @@ -589,7 +608,8 @@ bool ChooseTravelTargetAction::SetExploreTarget(TravelTarget* target) char* strstri(char const* haystack, char const* needle); -bool ChooseTravelTargetAction::SetNpcFlagTarget(TravelTarget* target, std::vector flags, std::string const name, std::vector items) +bool ChooseTravelTargetAction::SetNpcFlagTarget(TravelTarget* target, std::vector flags, + std::string const name, std::vector items) { WorldPosition botPos(bot); @@ -615,7 +635,8 @@ bool ChooseTravelTargetAction::SetNpcFlagTarget(TravelTarget* target, std::vecto if (!foundFlag) continue; - if (!name.empty() && !strstri(cInfo->Name.c_str(), name.c_str()) && !strstri(cInfo->SubName.c_str(), name.c_str())) + if (!name.empty() && !strstri(cInfo->Name.c_str(), name.c_str()) && + !strstri(cInfo->SubName.c_str(), name.c_str())) continue; if (!items.empty()) @@ -652,10 +673,11 @@ bool ChooseTravelTargetAction::SetNpcFlagTarget(TravelTarget* target, std::vecto if (!dests.empty()) { - TravelDestination* dest = *std::min_element(dests.begin(), dests.end(), [botPos](TravelDestination* i, TravelDestination* j) - { - return i->distanceTo(const_cast(&botPos)) < j->distanceTo(const_cast(&botPos)); - }); + TravelDestination* dest = *std::min_element(dests.begin(), dests.end(), + [botPos](TravelDestination* i, TravelDestination* j) { + return i->distanceTo(const_cast(&botPos)) < + j->distanceTo(const_cast(&botPos)); + }); std::vector points = dest->nextPoint(const_cast(&botPos), true); if (points.empty()) @@ -670,7 +692,8 @@ bool ChooseTravelTargetAction::SetNpcFlagTarget(TravelTarget* target, std::vecto return false; } -std::vector TravelMgr::getBossTravelDestinations(Player* bot, bool ignoreFull, bool ignoreInactive, float maxDistance) +std::vector TravelMgr::getBossTravelDestinations(Player* bot, bool ignoreFull, bool ignoreInactive, + float maxDistance) { WorldPosition botLocation(bot); @@ -711,28 +734,28 @@ TravelDestination* ChooseTravelTargetAction::FindDestination(Player* bot, std::s std::vector dests; - //Zones + // Zones for (auto& d : sTravelMgr->getExploreTravelDestinations(bot, true, true)) { if (strstri(d->getTitle().c_str(), name.c_str())) dests.push_back(d); } - //Npcs + // Npcs for (auto& d : sTravelMgr->getRpgTravelDestinations(bot, true, true)) { if (strstri(d->getTitle().c_str(), name.c_str())) dests.push_back(d); } - //Mobs + // Mobs for (auto& d : sTravelMgr->getGrindTravelDestinations(bot, true, true)) { if (strstri(d->getTitle().c_str(), name.c_str())) dests.push_back(d); } - //Bosses + // Bosses for (auto& d : sTravelMgr->getBossTravelDestinations(bot, true, true)) { if (strstri(d->getTitle().c_str(), name.c_str())) @@ -744,10 +767,11 @@ TravelDestination* ChooseTravelTargetAction::FindDestination(Player* bot, std::s if (dests.empty()) return nullptr; - TravelDestination* dest = *std::min_element(dests.begin(), dests.end(), [botPos](TravelDestination* i, TravelDestination* j) - { - return i->distanceTo(const_cast(&botPos)) < j->distanceTo(const_cast(&botPos)); - }); + TravelDestination* dest = *std::min_element(dests.begin(), dests.end(), + [botPos](TravelDestination* i, TravelDestination* j) { + return i->distanceTo(const_cast(&botPos)) < + j->distanceTo(const_cast(&botPos)); + }); return dest; }; @@ -757,7 +781,8 @@ bool ChooseTravelTargetAction::isUseful() if (!botAI->AllowActivity(TRAVEL_ACTIVITY)) return false; - return !context->GetValue("travel target")->Get()->isActive() && !context->GetValue("loot target")->Get().IsLootPossible(bot) && !bot->IsInCombat(); + return !context->GetValue("travel target")->Get()->isActive() && + !context->GetValue("loot target")->Get().IsLootPossible(bot) && !bot->IsInCombat(); } bool ChooseTravelTargetAction::needForQuest(Unit* target) @@ -801,7 +826,7 @@ bool ChooseTravelTargetAction::needForQuest(Unit* target) int required = questTemplate->RequiredNpcOrGoCount[j]; int available = questStatus.CreatureOrGOCount[j]; - if(required && available < required && (target->GetEntry() == entry || justCheck)) + if (required && available < required && (target->GetEntry() == entry || justCheck)) return true; } @@ -832,12 +857,12 @@ bool ChooseTravelTargetAction::needForQuest(Unit* target) } } } - } return false; } -bool ChooseTravelTargetAction::needItemForQuest(uint32 itemId, const Quest* questTemplate, const QuestStatusData* questStatus) +bool ChooseTravelTargetAction::needItemForQuest(uint32 itemId, const Quest* questTemplate, + const QuestStatusData* questStatus) { for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; i++) { diff --git a/src/strategy/actions/ChooseTravelTargetAction.h b/src/strategy/actions/ChooseTravelTargetAction.h index 1fdba5f4..1c7c2e28 100644 --- a/src/strategy/actions/ChooseTravelTargetAction.h +++ b/src/strategy/actions/ChooseTravelTargetAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHOOSETRAVELTARGETACTION_H @@ -16,35 +17,40 @@ struct QuestStatusData; class ChooseTravelTargetAction : public MovementAction { - public: - ChooseTravelTargetAction(PlayerbotAI* botAI, std::string const name = "choose travel target") : MovementAction(botAI, name) { } +public: + ChooseTravelTargetAction(PlayerbotAI* botAI, std::string const name = "choose travel target") + : MovementAction(botAI, name) + { + } - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; - static TravelDestination* FindDestination(Player* bot, std::string const name); + static TravelDestination* FindDestination(Player* bot, std::string const name); - protected: - void getNewTarget(TravelTarget* newTarget, TravelTarget* oldTarget); - void setNewTarget(TravelTarget* newTarget, TravelTarget* oldTarget); - void ReportTravelTarget(TravelTarget* newTarget, TravelTarget* oldTarget); +protected: + void getNewTarget(TravelTarget* newTarget, TravelTarget* oldTarget); + void setNewTarget(TravelTarget* newTarget, TravelTarget* oldTarget); + void ReportTravelTarget(TravelTarget* newTarget, TravelTarget* oldTarget); - bool getBestDestination(std::vector* activeDestinations, std::vector* activePoints); + bool getBestDestination(std::vector* activeDestinations, + std::vector* activePoints); - bool SetGroupTarget(TravelTarget* target); - bool SetCurrentTarget(TravelTarget* target, TravelTarget* oldTarget); - bool SetQuestTarget(TravelTarget* target, bool onlyCompleted = false); - bool SetNewQuestTarget(TravelTarget* target); - bool SetRpgTarget(TravelTarget* target); - bool SetGrindTarget(TravelTarget* target); - bool SetBossTarget(TravelTarget* target); - bool SetExploreTarget(TravelTarget* target); - bool SetNpcFlagTarget(TravelTarget* target, std::vector flags, std::string const name = "", std::vector items = { }); - bool SetNullTarget(TravelTarget* target); + bool SetGroupTarget(TravelTarget* target); + bool SetCurrentTarget(TravelTarget* target, TravelTarget* oldTarget); + bool SetQuestTarget(TravelTarget* target, bool onlyCompleted = false); + bool SetNewQuestTarget(TravelTarget* target); + bool SetRpgTarget(TravelTarget* target); + bool SetGrindTarget(TravelTarget* target); + bool SetBossTarget(TravelTarget* target); + bool SetExploreTarget(TravelTarget* target); + bool SetNpcFlagTarget(TravelTarget* target, std::vector flags, std::string const name = "", + std::vector items = {}); + bool SetNullTarget(TravelTarget* target); - private: - virtual bool needForQuest(Unit* target); - virtual bool needItemForQuest(uint32 itemId, Quest const* questTemplate, QuestStatusData const* questStatus); +private: + virtual bool needForQuest(Unit* target); + virtual bool needItemForQuest(uint32 itemId, Quest const* questTemplate, QuestStatusData const* questStatus); }; #endif diff --git a/src/strategy/actions/CombatActions.cpp b/src/strategy/actions/CombatActions.cpp index 5ac5d072..52b809cd 100644 --- a/src/strategy/actions/CombatActions.cpp +++ b/src/strategy/actions/CombatActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CombatActions.h" + #include "Event.h" #include "LastMovementValue.h" #include "Playerbots.h" @@ -10,7 +12,7 @@ bool SwitchToMeleeAction::Execute(Event event) { - //botAI->TellMasterNoFacing("Switching to melee!"); + // botAI->TellMasterNoFacing("Switching to melee!"); return ChangeCombatStrategyAction::Execute(event); } @@ -20,8 +22,11 @@ bool SwitchToMeleeAction::isUseful() { Unit* target = AI_VALUE(Unit*, "current target"); time_t lastFlee = AI_VALUE(LastMovement&, "last movement").lastFlee; - return botAI->HasStrategy("ranged", BOT_STATE_COMBAT) && ((bot->IsInCombat() && target && (target->GetVictim() == bot && (!bot->GetGroup() || lastFlee) && - sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "current target"), 8.0f))) || (!bot->IsInCombat())); + return botAI->HasStrategy("ranged", BOT_STATE_COMBAT) && + ((bot->IsInCombat() && target && + (target->GetVictim() == bot && (!bot->GetGroup() || lastFlee) && + sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "current target"), 8.0f))) || + (!bot->IsInCombat())); } return botAI->HasStrategy("ranged", BOT_STATE_COMBAT); @@ -29,7 +34,7 @@ bool SwitchToMeleeAction::isUseful() bool SwitchToRangedAction::Execute(Event event) { - //botAI->TellMasterNoFacing("Switching to ranged!"); + // botAI->TellMasterNoFacing("Switching to ranged!"); return ChangeCombatStrategyAction::Execute(event); } @@ -39,8 +44,11 @@ bool SwitchToRangedAction::isUseful() { Unit* target = AI_VALUE(Unit*, "current target"); bool hasAmmo = AI_VALUE2(uint32, "item count", "ammo"); - return botAI->HasStrategy("close", BOT_STATE_COMBAT) && hasAmmo && ((bot->IsInCombat() && target && ((target->GetVictim() != bot || target->GetTarget() != bot->GetGUID()) || - sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "current target"), 8.0f))) || (!bot->IsInCombat())); + return botAI->HasStrategy("close", BOT_STATE_COMBAT) && hasAmmo && + ((bot->IsInCombat() && target && + ((target->GetVictim() != bot || target->GetTarget() != bot->GetGUID()) || + sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "current target"), 8.0f))) || + (!bot->IsInCombat())); } return botAI->HasStrategy("close", BOT_STATE_COMBAT); diff --git a/src/strategy/actions/CombatActions.h b/src/strategy/actions/CombatActions.h index 9c3b18c0..5ce6df49 100644 --- a/src/strategy/actions/CombatActions.h +++ b/src/strategy/actions/CombatActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_COMBATACTIONS_H @@ -11,20 +12,20 @@ class PlayerbotAI; class SwitchToMeleeAction : public ChangeCombatStrategyAction { - public: - SwitchToMeleeAction(PlayerbotAI* botAI) : ChangeCombatStrategyAction(botAI, "-ranged,+close") { } +public: + SwitchToMeleeAction(PlayerbotAI* botAI) : ChangeCombatStrategyAction(botAI, "-ranged,+close") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class SwitchToRangedAction : public ChangeCombatStrategyAction { - public: - SwitchToRangedAction(PlayerbotAI* botAI) : ChangeCombatStrategyAction(botAI, "-close,+ranged") { } +public: + SwitchToRangedAction(PlayerbotAI* botAI) : ChangeCombatStrategyAction(botAI, "-close,+ranged") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/CustomStrategyEditAction.cpp b/src/strategy/actions/CustomStrategyEditAction.cpp index e1f5c572..8f043fd5 100644 --- a/src/strategy/actions/CustomStrategyEditAction.cpp +++ b/src/strategy/actions/CustomStrategyEditAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CustomStrategyEditAction.h" + #include "CustomStrategy.h" #include "Event.h" #include "Playerbots.h" @@ -33,7 +35,8 @@ bool CustomStrategyEditAction::PrintHelp() uint32 owner = botAI->GetBot()->GetGUID().GetCounter(); - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_CUSTOM_STRATEGY_BY_OWNER); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_CUSTOM_STRATEGY_BY_OWNER); stmt->SetData(0, owner); if (PreparedQueryResult result = PlayerbotsDatabase.Query(stmt)) { @@ -42,8 +45,7 @@ bool CustomStrategyEditAction::PrintHelp() Field* fields = result->Fetch(); std::string const name = fields[0].Get(); botAI->TellMaster(name); - } - while (result->NextRow()); + } while (result->NextRow()); } botAI->TellMaster("Usage: cs "); @@ -58,7 +60,8 @@ bool CustomStrategyEditAction::Print(std::string const name) uint32 owner = botAI->GetBot()->GetGUID().GetCounter(); - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_CUSTOM_STRATEGY_BY_OWNER_AND_NAME); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_CUSTOM_STRATEGY_BY_OWNER_AND_NAME); stmt->SetData(0, owner); stmt->SetData(1, name); if (PreparedQueryResult result = PlayerbotsDatabase.Query(stmt)) @@ -70,8 +73,7 @@ bool CustomStrategyEditAction::Print(std::string const name) std::string const action = fields[1].Get(); PrintActionLine(idx, action); - } - while (result->NextRow()); + } while (result->NextRow()); } return true; @@ -81,7 +83,8 @@ bool CustomStrategyEditAction::Edit(std::string const name, uint32 idx, std::str { uint32 owner = botAI->GetBot()->GetGUID().GetCounter(); - PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_CUSTOM_STRATEGY_BY_OWNER_AND_NAME_AND_IDX); + PlayerbotsDatabasePreparedStatement* stmt = + PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_SEL_CUSTOM_STRATEGY_BY_OWNER_AND_NAME_AND_IDX); stmt->SetData(0, owner); stmt->SetData(1, name); stmt->SetData(2, idx); diff --git a/src/strategy/actions/CustomStrategyEditAction.h b/src/strategy/actions/CustomStrategyEditAction.h index f27f1678..f019a88d 100644 --- a/src/strategy/actions/CustomStrategyEditAction.h +++ b/src/strategy/actions/CustomStrategyEditAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CUSTOMSTRATEGYEDITACTION_H @@ -11,16 +12,16 @@ class PlayerbotAI; class CustomStrategyEditAction : public Action { - public: - CustomStrategyEditAction(PlayerbotAI* botAI) : Action(botAI, "cs") { } +public: + CustomStrategyEditAction(PlayerbotAI* botAI) : Action(botAI, "cs") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - bool PrintHelp(); - bool PrintActionLine(uint32 idx, std::string const command); - bool Print(std::string const name); - bool Edit(std::string const name, uint32 idx, std::string const command); +private: + bool PrintHelp(); + bool PrintActionLine(uint32 idx, std::string const command); + bool Print(std::string const name); + bool Edit(std::string const name, uint32 idx, std::string const command); }; #endif diff --git a/src/strategy/actions/DebugAction.cpp b/src/strategy/actions/DebugAction.cpp index 5f536c53..6e3791a8 100644 --- a/src/strategy/actions/DebugAction.cpp +++ b/src/strategy/actions/DebugAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DebugAction.h" + #include "ChooseTravelTargetAction.h" #include "MapMgr.h" #include "Playerbots.h" @@ -26,7 +28,8 @@ bool DebugAction::Execute(Event event) uint32 areaId = 0; uint32 zoneId = 0; - sMapMgr->GetZoneAndAreaId(PHASEMASK_NORMAL, zoneId, areaId, pos.getMapId(), pos.getX(), pos.getY(), pos.getZ()); + sMapMgr->GetZoneAndAreaId(PHASEMASK_NORMAL, zoneId, areaId, pos.getMapId(), pos.getX(), pos.getY(), + pos.getZ()); std::ostringstream out; out << zoneId << "," << areaId << "," << (pos.getAreaName().empty() ? "none" : pos.getAreaName()) << ","; @@ -71,7 +74,8 @@ bool DebugAction::Execute(Event event) std::vector beginPath, endPath; TravelNodeRoute route = sTravelNodeMap->getRoute(botPos, *points.front(), beginPath, bot); - std::ostringstream out; out << "Traveling to " << dest->getTitle() << ": "; + std::ostringstream out; + out << "Traveling to " << dest->getTitle() << ": "; for (auto node : route.getNodes()) { @@ -228,18 +232,19 @@ bool DebugAction::Execute(Event event) } else if (text.find("reset node") != std::string::npos) { - for (auto& node : sTravelNodeMap->getNodes()) node->setLinked(false); + for (auto& node : sTravelNodeMap->getNodes()) + node->setLinked(false); return true; } else if (text.find("reset path") != std::string::npos) { for (auto& node : sTravelNodeMap->getNodes()) - for (auto& path : *node->getLinks()) node->removeLinkTo(path.first, true); + for (auto& path : *node->getLinks()) + node->removeLinkTo(path.first, true); return true; } else if (text.find("gen node") != std::string::npos) { - // Pathfinder sTravelNodeMap->generateNodes(); return true; @@ -262,11 +267,12 @@ bool DebugAction::Execute(Event event) } else if (text.find("load node") != std::string::npos) { - std::thread t([] - { - sTravelNodeMap->removeNodes(); - sTravelNodeMap->loadNodeStore(); - }); + std::thread t( + [] + { + sTravelNodeMap->removeNodes(); + sTravelNodeMap->loadNodeStore(); + }); t.detach(); @@ -282,7 +288,7 @@ bool DebugAction::Execute(Event event) { for (auto& l : *node->getLinks()) { - Unit* start = nullptr; + Unit* start = nullptr; GuidVector units; uint32 time = 60 * IN_MILLISECONDS; @@ -291,15 +297,16 @@ bool DebugAction::Execute(Event event) for (auto p : ppath) { - Creature* wpCreature = bot->SummonCreature(1, p.getX(), p.getY(), p.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 20000.0f); - //addAura(246, wpCreature); + Creature* wpCreature = + bot->SummonCreature(1, p.getX(), p.getY(), p.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 20000.0f); + // addAura(246, wpCreature); units.push_back(wpCreature->GetGUID()); if (!start) start = wpCreature; } - //FakeSpell(1064, bot, start, units.front(), units, {}, pos, pos); + // FakeSpell(1064, bot, start, units.front(), units, {}, pos, pos); } } return true; @@ -312,7 +319,7 @@ bool DebugAction::Execute(Event event) for (float i = 0; i < 60; i++) { - float ang = i / 60 * static_cast(M_PI) * 4; + float ang = i / 60 * static_cast(M_PI) * 4; float dist = i / 60 * 30; WorldPosition botPos(bot); @@ -322,7 +329,8 @@ bool DebugAction::Execute(Event event) botPos.setY(botPos.getY() + sin(ang) * dist); botPos.setZ(botPos.getHeight() + 2); - Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); + Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, + TEMPSUMMON_TIMED_DESPAWN, 10000.0f); FakeSpell(spellEffect, wpCreature, wpCreature, prev->GetGUID(), {}, {}, botPos, botPos); @@ -338,7 +346,7 @@ bool DebugAction::Execute(Event event) for (float i = 0; i < 60; i++) { - float ang = i / 60 * static_cast(M_PI) * 4; + float ang = i / 60 * static_cast(M_PI) * 4; float dist = i / 60 * 30; WorldPosition botPos(bot); @@ -348,13 +356,14 @@ bool DebugAction::Execute(Event event) botPos.setY(botPos.getY() + sin(ang) * dist); botPos.setZ(botPos.getHeight() + 2); - Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); + Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, + TEMPSUMMON_TIMED_DESPAWN, 10000.0f); if (wpCreature) { - WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 8 + 4); // visual effect on guid + WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 8 + 4); // visual effect on guid data << wpCreature->GetGUID(); - data << uint32(spellEffect); // index from SpellVisualKit.dbc + data << uint32(spellEffect); // index from SpellVisualKit.dbc wpCreature->SendMessageToSet(&data, true); } } @@ -368,7 +377,7 @@ bool DebugAction::Execute(Event event) for (float i = 0; i < 60; i++) { - float ang = i / 60 * static_cast(M_PI) * 4; + float ang = i / 60 * static_cast(M_PI) * 4; float dist = i / 60 * 30; WorldPosition botPos(bot); @@ -378,7 +387,8 @@ bool DebugAction::Execute(Event event) botPos.setY(botPos.getY() + sin(ang) * dist); botPos.setZ(botPos.getHeight() + 2); - Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 5000.0f + i * 100.0f); + Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, + TEMPSUMMON_TIMED_DESPAWN, 5000.0f + i * 100.0f); wpCreature->SetObjectScale(0.5f); if (wpCreature) @@ -396,7 +406,7 @@ bool DebugAction::Execute(Event event) for (float i = 0; i < 60; i++) { - float ang = i / 60 * static_cast(M_PI) * 4; + float ang = i / 60 * static_cast(M_PI) * 4; float dist = i / 60 * 30; WorldPosition botPos(bot); @@ -405,7 +415,8 @@ bool DebugAction::Execute(Event event) botPos.setY(botPos.getY() + sin(ang) * dist); botPos.setZ(botPos.getHeight() + 2); - Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); + Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, + TEMPSUMMON_TIMED_DESPAWN, 10000.0f); units.push_back(wpCreature->GetGUID()); } @@ -438,12 +449,12 @@ bool DebugAction::Execute(Event event) } { - WorldPacket data(SMSG_SPELL_GO, 53); // guess size + WorldPacket data(SMSG_SPELL_GO, 53); // guess size data << bot->GetPackGUID(); data << bot->GetPackGUID(); - data << uint32(spellEffect); // spellID - data << uint8(0) << uint8(1); // flags - data << uint8(1); // amount of targets + data << uint32(spellEffect); // spellID + data << uint8(0) << uint8(1); // flags + data << uint8(1); // amount of targets data << master->GetGUID(); data << uint8(0); data << uint16(2); @@ -465,15 +476,17 @@ bool DebugAction::Execute(Event event) { for (int32 dy = 0; dy < 10; dy++) { - uint32 spellEffect = stoi(text.substr(10)); - uint32 effect = dx + dy * 10 + spellEffect * 100; + uint32 spellEffect = stoi(text.substr(10)); + uint32 effect = dx + dy * 10 + spellEffect * 100; WorldPosition botPos(bot); botPos.setX(botPos.getX() + (dx - 5) * 5); botPos.setY(botPos.getY() + (dy - 5) * 5); botPos.setZ(botPos.getHeight()); - Creature* wpCreature = bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); + Creature* wpCreature = + bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), botPos.getY(), + botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); if (wpCreature) { @@ -495,15 +508,16 @@ bool DebugAction::Execute(Event event) { for (int32 dy = 0; dy < 10; dy++) { - uint32 spellEffect = stoi(text.substr(10)); - uint32 effect = dx + dy * 10 + spellEffect * 100; + uint32 spellEffect = stoi(text.substr(10)); + uint32 effect = dx + dy * 10 + spellEffect * 100; WorldPosition botPos(bot); botPos.setX(botPos.getX() + (dx - 5) * 5); botPos.setY(botPos.getY() + (dy - 5) * 5); botPos.setZ(botPos.getHeight()); - Creature* wpCreature = bot->SummonCreature(effect, botPos.getX(), botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); + Creature* wpCreature = bot->SummonCreature(effect, botPos.getX(), botPos.getY(), botPos.getZ(), 0, + TEMPSUMMON_TIMED_DESPAWN, 10000.0f); } } return true; @@ -514,8 +528,8 @@ bool DebugAction::Execute(Event event) { for (int32 dy = 0; dy < 10; dy++) { - uint32 spellEffect = stoi(text.substr(10)); - uint32 effect = dx + dy * 10 + spellEffect * 100; + uint32 spellEffect = stoi(text.substr(10)); + uint32 effect = dx + dy * 10 + spellEffect * 100; WorldPosition botPos(bot); botPos.setX(botPos.getX() + (dx - 5) * 5); @@ -534,26 +548,28 @@ bool DebugAction::Execute(Event event) { for (int32 dy = 0; dy < 10; dy++) { - uint32 spellEffect = stoi(text.substr(10)); - uint32 effect = dx + dy * 10 + spellEffect * 100; + uint32 spellEffect = stoi(text.substr(10)); + uint32 effect = dx + dy * 10 + spellEffect * 100; WorldPosition botPos(bot); botPos.setX(botPos.getX() + (dx - 5) * 5); botPos.setY(botPos.getY() + (dy - 5) * 5); botPos.setZ(botPos.getHeight()); - Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); + Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, + TEMPSUMMON_TIMED_DESPAWN, 10000.0f); if (wpCreature) { - WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 8 + 4); // visual effect on guid + WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 8 + 4); // visual effect on guid data << wpCreature->GetGUID(); data << uint32(effect); - ; // index from SpellVisualKit.dbc + ; // index from SpellVisualKit.dbc // wpCreature->SendMessageToSet(&data, true); datMap.push_back(data); - //wpCreature->MonsterMoveWithSpeed(botPos.getX(), botPos.getY() + 80, botPos.getZ(), 8.0f, true, true); + // wpCreature->MonsterMoveWithSpeed(botPos.getX(), botPos.getY() + 80, botPos.getZ(), 8.0f, true, + // true); } } } @@ -580,21 +596,23 @@ bool DebugAction::Execute(Event event) { for (int32 dy = 0; dy < 10; dy++) { - uint32 spellEffect = stoi(text.substr(10)); - uint32 effect = dx + dy * 10 + spellEffect * 100; + uint32 spellEffect = stoi(text.substr(10)); + uint32 effect = dx + dy * 10 + spellEffect * 100; WorldPosition botPos(bot); botPos.setX(botPos.getX() + (dx - 5) * 5); botPos.setY(botPos.getY() + (dy - 5) * 5); botPos.setZ(botPos.getHeight()); - Creature* wpCreature = bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); + Creature* wpCreature = + bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), botPos.getY(), + botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); if (wpCreature) { - WorldPacket data(SMSG_PLAY_SPELL_IMPACT, 8 + 4); // visual effect on player + WorldPacket data(SMSG_PLAY_SPELL_IMPACT, 8 + 4); // visual effect on player data << wpCreature->GetGUID(); - data << uint32(effect); // index from SpellVisualKit.dbc + data << uint32(effect); // index from SpellVisualKit.dbc // wpCreature->SendMessageToSet(&data, true); datMap.push_back(data); } @@ -619,20 +637,21 @@ bool DebugAction::Execute(Event event) else if (text.find("cspellmap") != std::string::npos) { Creature* wpCreature = nullptr; - Creature* lCreature = nullptr; + Creature* lCreature = nullptr; for (int32 dx = 0; dx < 10; dx++) { for (int32 dy = 0; dy < 10; dy++) { - uint32 spellEffect = stoi(text.substr(10)); - uint32 effect = dx + dy * 10 + spellEffect * 100; + uint32 spellEffect = stoi(text.substr(10)); + uint32 effect = dx + dy * 10 + spellEffect * 100; WorldPosition botPos(bot); botPos.setX(botPos.getX() + (dx - 5) * 5); botPos.setY(botPos.getY() + (dy - 5) * 5); botPos.setZ(botPos.getHeight()); - wpCreature = bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); + wpCreature = bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), + botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); if (wpCreature && lCreature) { @@ -652,15 +671,16 @@ bool DebugAction::Execute(Event event) { for (int32 dy = 0; dy < 10; dy++) { - uint32 spellEffect = stoi(text.substr(10)); - uint32 effect = dx + dy * 10 + spellEffect * 100; + uint32 spellEffect = stoi(text.substr(10)); + uint32 effect = dx + dy * 10 + spellEffect * 100; WorldPosition botPos(bot); botPos.setX(botPos.getX() + (dx - 5) * 5); botPos.setY(botPos.getY() + (dy - 5) * 5); botPos.setZ(botPos.getHeight()); - wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); + wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, + TEMPSUMMON_TIMED_DESPAWN, 10000.0f); if (wpCreature) { @@ -672,7 +692,7 @@ bool DebugAction::Execute(Event event) } else if (text.find("gspellmap") != std::string::npos) { - GuidVector all_targets; // = { bot->GetGUID(), master->GetGUID() }; + GuidVector all_targets; // = { bot->GetGUID(), master->GetGUID() }; // std::GuidVector all_dummies = { bot->GetGUID(), master->GetGUID() }; /*GuidVector a_targets = *context->GetValue("all targets"); @@ -692,7 +712,8 @@ bool DebugAction::Execute(Event event) botPos.setY(botPos.getY() + (dy - 5) * 5); botPos.setZ(botPos.getHeight()); - Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); + Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, + TEMPSUMMON_TIMED_DESPAWN, 10000.0f); all_targets.push_back(wpCreature->GetGUID()); } @@ -709,9 +730,9 @@ bool DebugAction::Execute(Event event) for (int32 dy = 0; dy < 10; dy++) { uint32 spellEffect = stoi(text.substr(10)); - uint32 effect = dx + dy * 10 + spellEffect * 100; + uint32 effect = dx + dy * 10 + spellEffect * 100; - uint32 i = dx + dy * 10; + uint32 i = dx + dy * 10; GuidVector hits, miss; SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(effect); @@ -722,21 +743,23 @@ bool DebugAction::Execute(Event event) switch (urand(0, 10)) { - case 0: - hits.push_back(tar); - break; - case 1: - miss.push_back(tar); - break; - case 2: - case 3: - break; + case 0: + hits.push_back(tar); + break; + case 1: + miss.push_back(tar); + break; + case 2: + case 3: + break; } } - Unit* realCaster = botAI->GetUnit(all_targets[i]); // botAI->GetUnit(all_targets[urand(0, all_targets.size() - 1)]); - Unit* caster = botAI->GetUnit(all_targets[i]); // botAI->GetUnit(all_targets[urand(0, all_targets.size() - 1)]); - Unit* target = botAI->GetUnit(all_targets[i + 1]); + Unit* realCaster = botAI->GetUnit( + all_targets[i]); // botAI->GetUnit(all_targets[urand(0, all_targets.size() - 1)]); + Unit* caster = botAI->GetUnit( + all_targets[i]); // botAI->GetUnit(all_targets[urand(0, all_targets.size() - 1)]); + Unit* target = botAI->GetUnit(all_targets[i + 1]); if (!realCaster) realCaster = bot; @@ -747,7 +770,8 @@ bool DebugAction::Execute(Event event) if (!target) target = master; - FakeSpell(effect, realCaster, caster, target->GetGUID(), hits, miss, WorldPosition(caster), WorldPosition(target)); + FakeSpell(effect, realCaster, caster, target->GetGUID(), hits, miss, WorldPosition(caster), + WorldPosition(target)); std::this_thread::sleep_for(std::chrono::milliseconds(20)); } @@ -768,7 +792,8 @@ bool DebugAction::Execute(Event event) botPos.setY(botPos.getY() + (dy - 5) * 5); botPos.setZ(botPos.getHeight()); - Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); + Creature* wpCreature = bot->SummonCreature(2334, botPos.getX(), botPos.getY(), botPos.getZ(), 0, + TEMPSUMMON_TIMED_DESPAWN, 10000.0f); all_targets.push_back(wpCreature->GetGUID()); } @@ -808,8 +833,10 @@ bool DebugAction::Execute(Event event) } } - Unit* realCaster = botAI->GetUnit(all_targets[i]);//botAI->GetUnit(all_targets[urand(0, all_targets.size() - 1)]); - Unit* caster = botAI->GetUnit(all_targets[i]);//botAI->GetUnit(all_targets[urand(0, all_targets.size() - 1)]); + Unit* realCaster = botAI->GetUnit( + all_targets[i]); // botAI->GetUnit(all_targets[urand(0, all_targets.size() - 1)]); + Unit* caster = botAI->GetUnit( + all_targets[i]); // botAI->GetUnit(all_targets[urand(0, all_targets.size() - 1)]); Unit* target = botAI->GetUnit(all_targets[i + 1]); if (!realCaster) @@ -822,13 +849,14 @@ bool DebugAction::Execute(Event event) target = master; master->SendPlaySpellVisual(caster->GetGUID(), 5036); - FakeSpell(effect, realCaster, caster, target->GetGUID(), hits, miss, WorldPosition(caster), WorldPosition(target)); + FakeSpell(effect, realCaster, caster, target->GetGUID(), hits, miss, WorldPosition(caster), + WorldPosition(target)); std::this_thread::sleep_for(std::chrono::milliseconds(20)); } } - return true; + return true; } else if (text.find("soundmap") != std::string::npos) { @@ -844,7 +872,9 @@ bool DebugAction::Execute(Event event) botPos.setY(botPos.getY() + (dy - 5) * 5); botPos.setZ(botPos.getHeight()); - Creature* wpCreature = bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), botPos.getY(), botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); + Creature* wpCreature = + bot->SummonCreature((dy == 0 && (dx == 0 || dx == 2)) ? 6 : 2, botPos.getX(), botPos.getY(), + botPos.getZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 10000.0f); wpCreature->PlayDistanceSound(effect); } @@ -886,33 +916,35 @@ bool DebugAction::Execute(Event event) return true; } -void DebugAction::FakeSpell(uint32 spellId, Unit* truecaster, Unit* caster, ObjectGuid target, GuidVector otherTargets, GuidVector missTargets, WorldPosition source, WorldPosition dest, bool forceDest) +void DebugAction::FakeSpell(uint32 spellId, Unit* truecaster, Unit* caster, ObjectGuid target, GuidVector otherTargets, + GuidVector missTargets, WorldPosition source, WorldPosition dest, bool forceDest) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); { uint32 castFlags = CAST_FLAG_HAS_TRAJECTORY; - if (spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) || spellInfo->HasAttribute(SPELL_ATTR0_CU_NEEDS_AMMO_DATA)) + if (spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) || + spellInfo->HasAttribute(SPELL_ATTR0_CU_NEEDS_AMMO_DATA)) castFlags |= CAST_FLAG_PROJECTILE; WorldPacket data(SMSG_SPELL_START, (8 + 8 + 4 + 2 + 4)); - data << truecaster->GetPackGUID(); //truecaster + data << truecaster->GetPackGUID(); // truecaster if (caster) - data << caster->GetPackGUID(); //m_caster->GetPackGUID(); + data << caster->GetPackGUID(); // m_caster->GetPackGUID(); else data << ObjectGuid::Empty; - data << uint32(spellId); // spellId - data << uint16(castFlags); // cast flags - data << uint32(1000.0f); // delay? + data << uint32(spellId); // spellId + data << uint16(castFlags); // cast flags + data << uint32(1000.0f); // delay? SpellCastTargets m_targets; m_targets.Write(data); - //projectile info + // projectile info if (castFlags & CAST_FLAG_PROJECTILE) { data << uint32(5996); @@ -935,16 +967,18 @@ void DebugAction::FakeSpell(uint32 spellId, Unit* truecaster, Unit* caster, Obje m_targets.SetSrc(source.getX(), source.getY(), source.getZ()); if (!forceDest && target) - if (!spellInfo || !(spellInfo->Targets & TARGET_FLAG_DEST_LOCATION && spellInfo->Targets & TARGET_FLAG_SOURCE_LOCATION)) + if (!spellInfo || + !(spellInfo->Targets & TARGET_FLAG_DEST_LOCATION && spellInfo->Targets & TARGET_FLAG_SOURCE_LOCATION)) m_targets.SetUnitTarget(botAI->GetUnit(target)); uint32 castFlags = CAST_FLAG_UNKNOWN_9; - if (spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) || spellInfo->HasAttribute(SPELL_ATTR0_CU_NEEDS_AMMO_DATA)) - castFlags |= CAST_FLAG_PROJECTILE; // arrows/bullets visual + if (spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) || + spellInfo->HasAttribute(SPELL_ATTR0_CU_NEEDS_AMMO_DATA)) + castFlags |= CAST_FLAG_PROJECTILE; // arrows/bullets visual if (spellInfo->HasEffect(SPELL_EFFECT_ACTIVATE_RUNE)) - castFlags |= CAST_FLAG_RUNE_LIST; // rune cooldowns list + castFlags |= CAST_FLAG_RUNE_LIST; // rune cooldowns list if (m_targets.HasTraj()) castFlags |= CAST_FLAG_ADJUST_MISSILE; @@ -952,43 +986,43 @@ void DebugAction::FakeSpell(uint32 spellId, Unit* truecaster, Unit* caster, Obje if (!spellInfo->StartRecoveryTime) castFlags |= CAST_FLAG_NO_GCD; - WorldPacket data(SMSG_SPELL_GO, 53); // guess size + WorldPacket data(SMSG_SPELL_GO, 53); // guess size - data << truecaster->GetPackGUID(); //truecaster + data << truecaster->GetPackGUID(); // truecaster if (caster) - data << caster->GetPackGUID(); //m_caster->GetPackGUID(); + data << caster->GetPackGUID(); // m_caster->GetPackGUID(); else data << ObjectGuid::Empty; - data << uint32(spellId); // spellId - data << uint16(castFlags); // cast flags + data << uint32(spellId); // spellId + data << uint16(castFlags); // cast flags - //WriteSpellGoTargets + // WriteSpellGoTargets uint32 hits = otherTargets.size() + (target ? 1 : 0); - data << uint8(hits); // Hits + data << uint8(hits); // Hits if (target) data << target; - //Hit targets here. + // Hit targets here. for (auto otherTarget : otherTargets) data << otherTarget; - data << (uint8)missTargets.size(); //miss + data << (uint8)missTargets.size(); // miss for (auto missTarget : missTargets) { data << missTarget; - data << uint8(SPELL_MISS_RESIST); //Miss condition - data << uint8(SPELL_MISS_NONE); //Miss condition + data << uint8(SPELL_MISS_RESIST); // Miss condition + data << uint8(SPELL_MISS_NONE); // Miss condition } m_targets.Write(data); - //projectile info + // projectile info if (castFlags & CAST_FLAG_PROJECTILE) { data << uint32(5996); @@ -1011,7 +1045,8 @@ void DebugAction::addAura(uint32 spellId, Unit* target) if (!spellInfo) return; - if (!target->IsAlive() && !spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) && !spellInfo->HasAttribute(SPELL_ATTR2_ALLOW_DEAD_TARGET)) + if (!target->IsAlive() && !spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) && + !spellInfo->HasAttribute(SPELL_ATTR2_ALLOW_DEAD_TARGET)) return; target->AddAura(spellInfo, MAX_EFFECT_MASK, target); diff --git a/src/strategy/actions/DebugAction.h b/src/strategy/actions/DebugAction.h index de7100f1..df4a28bc 100644 --- a/src/strategy/actions/DebugAction.h +++ b/src/strategy/actions/DebugAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DEBUGACTION_H @@ -14,13 +15,15 @@ class Unit; class DebugAction : public Action { - public: - DebugAction(PlayerbotAI* botAI) : Action(botAI, "Debug") { } +public: + DebugAction(PlayerbotAI* botAI) : Action(botAI, "Debug") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - void FakeSpell(uint32 spellId, Unit* truecaster, Unit* caster, ObjectGuid target = ObjectGuid::Empty, GuidVector otherTargets = {}, GuidVector missTargets = {}, WorldPosition source = WorldPosition(), WorldPosition dest = WorldPosition(), bool forceDest = false); - void addAura(uint32 spellId, Unit* target); + void FakeSpell(uint32 spellId, Unit* truecaster, Unit* caster, ObjectGuid target = ObjectGuid::Empty, + GuidVector otherTargets = {}, GuidVector missTargets = {}, WorldPosition source = WorldPosition(), + WorldPosition dest = WorldPosition(), bool forceDest = false); + void addAura(uint32 spellId, Unit* target); }; #endif diff --git a/src/strategy/actions/DelayAction.cpp b/src/strategy/actions/DelayAction.cpp index 7547a911..a393bd90 100644 --- a/src/strategy/actions/DelayAction.cpp +++ b/src/strategy/actions/DelayAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DelayAction.h" + #include "Event.h" #include "Playerbots.h" @@ -15,7 +17,4 @@ bool DelayAction::Execute(Event event) return true; } -bool DelayAction::isUseful() -{ - return !botAI->AllowActivity(ALL_ACTIVITY); -} +bool DelayAction::isUseful() { return !botAI->AllowActivity(ALL_ACTIVITY); } diff --git a/src/strategy/actions/DelayAction.h b/src/strategy/actions/DelayAction.h index 659b890c..4d341d8d 100644 --- a/src/strategy/actions/DelayAction.h +++ b/src/strategy/actions/DelayAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DELAYACTION_H @@ -11,11 +12,11 @@ class PlayerbotAI; class DelayAction : public Action { - public: - DelayAction(PlayerbotAI* botAI) : Action(botAI, "delay") { } +public: + DelayAction(PlayerbotAI* botAI) : Action(botAI, "delay") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/DestroyItemAction.cpp b/src/strategy/actions/DestroyItemAction.cpp index 12b08b2e..153606a0 100644 --- a/src/strategy/actions/DestroyItemAction.cpp +++ b/src/strategy/actions/DestroyItemAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DestroyItemAction.h" + #include "Event.h" #include "ItemCountValue.h" #include "Playerbots.h" @@ -25,20 +27,17 @@ void DestroyItemAction::DestroyItem(FindItemVisitor* visitor) { IterateItems(visitor); std::vector items = visitor->GetResult(); - for (Item* item : items) + for (Item* item : items) { std::ostringstream out; out << chat->FormatItem(item->GetTemplate()) << " destroyed"; botAI->TellMaster(out); - bot->DestroyItem(item->GetBagSlot(),item->GetSlot(), true); + bot->DestroyItem(item->GetBagSlot(), item->GetSlot(), true); } } -bool SmartDestroyItemAction::isUseful() -{ - return !botAI->HasActivePlayerMaster(); -} +bool SmartDestroyItemAction::isUseful() { return !botAI->HasActivePlayerMaster(); } bool SmartDestroyItemAction::Execute(Event event) { @@ -68,19 +67,23 @@ bool SmartDestroyItemAction::Execute(Event event) return true; } - std::vector bestToDestroy = { ITEM_USAGE_NONE }; //First destroy anything useless. + std::vector bestToDestroy = {ITEM_USAGE_NONE}; // First destroy anything useless. - if (!AI_VALUE(bool, "can sell") && AI_VALUE(bool, "should get money")) // We need money so quest items are less important since they can't directly be sold. + if (!AI_VALUE(bool, "can sell") && + AI_VALUE( + bool, + "should get money")) // We need money so quest items are less important since they can't directly be sold. bestToDestroy.push_back(ITEM_USAGE_QUEST); - else // We don't need money so destroy the cheapest stuff. + else // We don't need money so destroy the cheapest stuff. { bestToDestroy.push_back(ITEM_USAGE_VENDOR); bestToDestroy.push_back(ITEM_USAGE_AH); } // If we still need room - bestToDestroy.push_back(ITEM_USAGE_SKILL); // Items that might help tradeskill are more important than above but still expenable. - bestToDestroy.push_back(ITEM_USAGE_USE); // These are more likely to be usefull 'soon' but still expenable. + bestToDestroy.push_back( + ITEM_USAGE_SKILL); // Items that might help tradeskill are more important than above but still expenable. + bestToDestroy.push_back(ITEM_USAGE_USE); // These are more likely to be usefull 'soon' but still expenable. for (auto& usage : bestToDestroy) { diff --git a/src/strategy/actions/DestroyItemAction.h b/src/strategy/actions/DestroyItemAction.h index f10c387a..a0d4f5ef 100644 --- a/src/strategy/actions/DestroyItemAction.h +++ b/src/strategy/actions/DestroyItemAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DESTROYITEMACTION_H @@ -12,22 +13,22 @@ class PlayerbotAI; class DestroyItemAction : public InventoryAction { - public: - DestroyItemAction(PlayerbotAI* botAI, std::string const name = "destroy") : InventoryAction(botAI, name) { } +public: + DestroyItemAction(PlayerbotAI* botAI, std::string const name = "destroy") : InventoryAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; - protected: - void DestroyItem(FindItemVisitor* visitor); +protected: + void DestroyItem(FindItemVisitor* visitor); }; class SmartDestroyItemAction : public DestroyItemAction { - public: - SmartDestroyItemAction(PlayerbotAI* botAI) : DestroyItemAction(botAI, "smart destroy") { } +public: + SmartDestroyItemAction(PlayerbotAI* botAI) : DestroyItemAction(botAI, "smart destroy") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/DropQuestAction.cpp b/src/strategy/actions/DropQuestAction.cpp index 6c34001c..a6079d7f 100644 --- a/src/strategy/actions/DropQuestAction.cpp +++ b/src/strategy/actions/DropQuestAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DropQuestAction.h" + #include "ChatHelper.h" #include "Event.h" #include "Playerbots.h" @@ -56,32 +58,32 @@ bool CleanQuestLogAction::Execute(Event event) uint8 totalQuests = 0; - DropQuestType(totalQuests); //Count the total quests + DropQuestType(totalQuests); // Count the total quests if (MAX_QUEST_LOG_SIZE - totalQuests > 6) return true; - if (AI_VALUE(bool, "can fight equal")) // Only drop gray quests when able to fight proper lvl quests. + if (AI_VALUE(bool, "can fight equal")) // Only drop gray quests when able to fight proper lvl quests. { - DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 6); // Drop gray/red quests. - DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 6, false, true); // Drop gray/red quests with progress. - DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 6, false, true, true); // Drop gray/red completed quests. + DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 6); // Drop gray/red quests. + DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 6, false, true); // Drop gray/red quests with progress. + DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 6, false, true, true); // Drop gray/red completed quests. } if (MAX_QUEST_LOG_SIZE - totalQuests > 4) return true; - DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 4, true); //Drop quests without progress. + DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 4, true); // Drop quests without progress. if (MAX_QUEST_LOG_SIZE - totalQuests > 2) return true; - DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 2, true, true); //Drop quests with progress. + DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 2, true, true); // Drop quests with progress. if (MAX_QUEST_LOG_SIZE - totalQuests > 0) return true; - DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 1, true, true, true); //Drop completed quests. + DropQuestType(totalQuests, MAX_QUEST_LOG_SIZE - 1, true, true, true); // Drop completed quests. if (MAX_QUEST_LOG_SIZE - totalQuests > 0) return true; @@ -101,23 +103,26 @@ void CleanQuestLogAction::DropQuestType(uint8& numQuest, uint8 wantNum, bool isG if (!quest) continue; - if (quest->GetRequiredClasses() && (quest->GetRewSpellCast() || quest->GetRewSpell())) //Do not drop class specific quests that learn spells. + if (quest->GetRequiredClasses() && + (quest->GetRewSpellCast() || quest->GetRewSpell())) // Do not drop class specific quests that learn spells. continue; - if (quest->GetRequiredClasses() && (quest->GetRewSpellCast() || quest->GetRewSpell())) // Do not drop class specific quests that learn spells. + if (quest->GetRequiredClasses() && + (quest->GetRewSpellCast() || quest->GetRewSpell())) // Do not drop class specific quests that learn spells. continue; if (wantNum == 100) numQuest++; int32 lowLevelDiff = sWorld->getIntConfig(CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF); - if (lowLevelDiff < 0 || bot->GetLevel() <= bot->GetQuestLevel(quest) + uint32(lowLevelDiff)) // Quest is not gray + if (lowLevelDiff < 0 || + bot->GetLevel() <= bot->GetQuestLevel(quest) + uint32(lowLevelDiff)) // Quest is not gray { - if (bot->GetLevel() + 5 > bot->GetQuestLevel(quest)) // Quest is not red + if (bot->GetLevel() + 5 > bot->GetQuestLevel(quest)) // Quest is not red if (!isGreen) continue; } - else // Quest is gray + else // Quest is gray { if (isGreen) continue; @@ -129,13 +134,13 @@ void CleanQuestLogAction::DropQuestType(uint8& numQuest, uint8 wantNum, bool isG if (bot->GetQuestStatus(questId) == QUEST_STATUS_COMPLETE && !isComplete) continue; - if (numQuest <= wantNum && bot->GetQuestStatus(questId) != QUEST_STATUS_FAILED) // Always drop failed quests + if (numQuest <= wantNum && bot->GetQuestStatus(questId) != QUEST_STATUS_FAILED) // Always drop failed quests continue; - //Drop quest. + // Drop quest. bot->SetQuestSlot(slot, 0); - //We ignore unequippable quest items in this case, its' still be equipped + // We ignore unequippable quest items in this case, its' still be equipped bot->TakeQuestSourceItem(questId, false); bot->SetQuestStatus(questId, QUEST_STATUS_NONE); @@ -163,7 +168,7 @@ bool CleanQuestLogAction::HasProgress(Player* bot, Quest const* quest) if (quest->RequiredItemId[i]) { - int required = quest->RequiredItemCount[i]; + int required = quest->RequiredItemCount[i]; int available = questStatus.ItemCount[i]; if (available > 0 && required > 0) return true; @@ -171,7 +176,7 @@ bool CleanQuestLogAction::HasProgress(Player* bot, Quest const* quest) if (quest->RequiredNpcOrGo[i]) { - int required = quest->RequiredNpcOrGoCount[i]; + int required = quest->RequiredNpcOrGoCount[i]; int available = questStatus.CreatureOrGOCount[i]; if (available > 0 && required > 0) diff --git a/src/strategy/actions/DropQuestAction.h b/src/strategy/actions/DropQuestAction.h index c5ed44a4..b20cccde 100644 --- a/src/strategy/actions/DropQuestAction.h +++ b/src/strategy/actions/DropQuestAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DROPQUESTACTION_H @@ -13,22 +14,22 @@ class Quest; class DropQuestAction : public Action { - public: - DropQuestAction(PlayerbotAI* botAI) : Action(botAI, "drop quest") { } +public: + DropQuestAction(PlayerbotAI* botAI) : Action(botAI, "drop quest") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class CleanQuestLogAction : public Action { - public: - CleanQuestLogAction(PlayerbotAI* botAI) : Action(botAI, "clean quest log") { } +public: + CleanQuestLogAction(PlayerbotAI* botAI) : Action(botAI, "clean quest log") {} - bool Execute(Event event) override; - void DropQuestType(uint8& numQuest, uint8 wantNum = 100, bool isGreen = false, bool hasProgress = false, bool isComplete = false); + bool Execute(Event event) override; + void DropQuestType(uint8& numQuest, uint8 wantNum = 100, bool isGreen = false, bool hasProgress = false, + bool isComplete = false); - static bool HasProgress(Player* bot, Quest const* quest); + static bool HasProgress(Player* bot, Quest const* quest); }; - #endif diff --git a/src/strategy/actions/EmoteAction.cpp b/src/strategy/actions/EmoteAction.cpp index 8fe57374..57e7ffb6 100644 --- a/src/strategy/actions/EmoteAction.cpp +++ b/src/strategy/actions/EmoteAction.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "EmoteAction.h" + #include "Event.h" +#include "PlayerbotTextMgr.h" #include "Playerbots.h" #include "ServerFacade.h" -#include "PlayerbotTextMgr.h" std::map EmoteActionBase::emotes; std::map EmoteActionBase::textEmotes; @@ -18,9 +20,7 @@ EmoteActionBase::EmoteActionBase(PlayerbotAI* botAI, std::string const name) : A InitEmotes(); } -EmoteAction::EmoteAction(PlayerbotAI* botAI) : EmoteActionBase(botAI, "emote"), Qualified() -{ -} +EmoteAction::EmoteAction(PlayerbotAI* botAI) : EmoteActionBase(botAI, "emote"), Qualified() {} void EmoteActionBase::InitEmotes() { @@ -67,10 +67,10 @@ void EmoteActionBase::InitEmotes() textEmotes["congratulate"] = TEXT_EMOTE_CONGRATULATE; textEmotes["hello"] = TEXT_EMOTE_HELLO; textEmotes["no"] = TEXT_EMOTE_NO; - textEmotes["nod"] = TEXT_EMOTE_NOD; // yes + textEmotes["nod"] = TEXT_EMOTE_NOD; // yes textEmotes["sigh"] = TEXT_EMOTE_SIGH; textEmotes["thank"] = TEXT_EMOTE_THANK; - textEmotes["welcome"] = TEXT_EMOTE_WELCOME; // you are welcome + textEmotes["welcome"] = TEXT_EMOTE_WELCOME; // you are welcome textEmotes["whistle"] = TEXT_EMOTE_WHISTLE; textEmotes["yawn"] = TEXT_EMOTE_YAWN; textEmotes["oom"] = 323; @@ -196,7 +196,7 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) case TEXT_EMOTE_BLUSH: case TEXT_EMOTE_SMILE: case TEXT_EMOTE_LOVE: - //case TEXT_EMOTE_HOLDHAND: + // case TEXT_EMOTE_HOLDHAND: emoteText = "Awwwww..."; emoteId = EMOTE_ONESHOT_SHY; textEmote = TEXT_EMOTE_SHY; @@ -207,13 +207,13 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) textEmote = TEXT_EMOTE_APPLAUD; break; case TEXT_EMOTE_ANGRY: - //case TEXT_EMOTE_FACEPALM: + // case TEXT_EMOTE_FACEPALM: case TEXT_EMOTE_GLARE: case TEXT_EMOTE_BLAME: - //case TEXT_EMOTE_FAIL: - //case TEXT_EMOTE_REGRET: - //case TEXT_EMOTE_SCOLD: - //case TEXT_EMOTE_CROSSARMS: + // case TEXT_EMOTE_FAIL: + // case TEXT_EMOTE_REGRET: + // case TEXT_EMOTE_SCOLD: + // case TEXT_EMOTE_CROSSARMS: emoteText = "Did I do thaaaaat?"; emoteId = EMOTE_ONESHOT_QUESTION; textEmote = TEXT_EMOTE_SHRUG; @@ -247,7 +247,7 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) case TEXT_EMOTE_CLAP: case TEXT_EMOTE_CONGRATULATE: case TEXT_EMOTE_HAPPY: - //case TEXT_EMOTE_GOLFCLAP: + // case TEXT_EMOTE_GOLFCLAP: emoteId = EMOTE_ONESHOT_BOW; textEmote = TEXT_EMOTE_BOW; emoteText = "Thank you.. Thank you.. I'm here all week."; @@ -262,8 +262,8 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) case TEXT_EMOTE_BITE: case TEXT_EMOTE_POKE: case TEXT_EMOTE_SCRATCH: - //case TEXT_EMOTE_PINCH: - //case TEXT_EMOTE_PUNCH: + // case TEXT_EMOTE_PINCH: + // case TEXT_EMOTE_PUNCH: emoteId = EMOTE_ONESHOT_ROAR; textEmote = TEXT_EMOTE_ROAR; emoteYell = "OUCH! Dammit, that hurt!"; @@ -300,9 +300,9 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) case TEXT_EMOTE_PRAISE: case TEXT_EMOTE_SCARED: case TEXT_EMOTE_COMMEND: - //case TEXT_EMOTE_AWE: - //case TEXT_EMOTE_JEALOUS: - //case TEXT_EMOTE_PROUD: + // case TEXT_EMOTE_AWE: + // case TEXT_EMOTE_JEALOUS: + // case TEXT_EMOTE_PROUD: emoteId = EMOTE_ONESHOT_FLEX; textEmote = TEXT_EMOTE_FLEX; emoteText = "Yes, Yes. I know I'm amazing.."; @@ -310,8 +310,8 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) case TEXT_EMOTE_BLEED: case TEXT_EMOTE_MOURN: case TEXT_EMOTE_FLOP: - //case TEXT_EMOTE_FAINT: - //case TEXT_EMOTE_PULSE: + // case TEXT_EMOTE_FAINT: + // case TEXT_EMOTE_PULSE: emoteId = EMOTE_ONESHOT_KNEEL; textEmote = TEXT_EMOTE_KNEEL; emoteText = "MEDIC! Stat!"; @@ -338,7 +338,7 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) case TEXT_EMOTE_GUFFAW: case TEXT_EMOTE_ROFL: case TEXT_EMOTE_SNICKER: - //case TEXT_EMOTE_SNORT: + // case TEXT_EMOTE_SNORT: emoteId = EMOTE_ONESHOT_LAUGH; textEmote = TEXT_EMOTE_LAUGH; emoteText = "Wait... what are we laughing at again?"; @@ -368,8 +368,8 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) case TEXT_EMOTE_SPIT: case TEXT_EMOTE_LICK: case TEXT_EMOTE_BREATH: - //case TEXT_EMOTE_SNEEZE: - //case TEXT_EMOTE_SWEAT: + // case TEXT_EMOTE_SNEEZE: + // case TEXT_EMOTE_SWEAT: emoteId = EMOTE_ONESHOT_POINT; textEmote = TEXT_EMOTE_POINT; emoteText = "Ewww! Keep your nasty germs over there!"; @@ -420,7 +420,7 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) case TEXT_EMOTE_SHIMMY: case TEXT_EMOTE_SMIRK: case TEXT_EMOTE_WINK: - //case TEXT_EMOTE_CHARM: + // case TEXT_EMOTE_CHARM: emoteId = EMOTE_ONESHOT_NO; textEmote = TEXT_EMOTE_NO; emoteText = "Keep it in your pants, boss.."; @@ -447,7 +447,7 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) case TEXT_EMOTE_RASP: emoteId = EMOTE_ONESHOT_RUDE; textEmote = TEXT_EMOTE_RASP; - emoteText = "Right back at you, bub!"; // , LANG_UNIVERSAL; + emoteText = "Right back at you, bub!"; // , LANG_UNIVERSAL; break; case TEXT_EMOTE_ROAR: case TEXT_EMOTE_THREATEN: @@ -456,17 +456,17 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) case TEXT_EMOTE_TAUNT: case TEXT_EMOTE_PITY: case TEXT_EMOTE_GROWL: - //case TEXT_EMOTE_TRAIN: - //case TEXT_EMOTE_INCOMING: - //case TEXT_EMOTE_CHARGE: - //case TEXT_EMOTE_FLEE: - //case TEXT_EMOTE_ATTACKMYTARGET: + // case TEXT_EMOTE_TRAIN: + // case TEXT_EMOTE_INCOMING: + // case TEXT_EMOTE_CHARGE: + // case TEXT_EMOTE_FLEE: + // case TEXT_EMOTE_ATTACKMYTARGET: case TEXT_EMOTE_OPENFIRE: case TEXT_EMOTE_ENCOURAGE: case TEXT_EMOTE_ENEMY: - //case TEXT_EMOTE_CHALLENGE: - //case TEXT_EMOTE_REVENGE: - //case TEXT_EMOTE_SHAKEFIST: + // case TEXT_EMOTE_CHALLENGE: + // case TEXT_EMOTE_REVENGE: + // case TEXT_EMOTE_SHAKEFIST: emoteId = EMOTE_ONESHOT_ROAR; textEmote = TEXT_EMOTE_ROAR; emoteYell = "RAWR!"; @@ -493,8 +493,8 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) case TEXT_EMOTE_VICTORY: case TEXT_EMOTE_CHEER: case TEXT_EMOTE_TOAST: - //case TEXT_EMOTE_HIGHFIVE: - //case TEXT_EMOTE_DING: + // case TEXT_EMOTE_HIGHFIVE: + // case TEXT_EMOTE_DING: emoteId = EMOTE_ONESHOT_CHEER; textEmote = TEXT_EMOTE_CHEER; emoteText = "Yay!"; @@ -502,9 +502,9 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) case TEXT_EMOTE_COLD: case TEXT_EMOTE_SHIVER: case TEXT_EMOTE_THIRSTY: - //case TEXT_EMOTE_OOM: - //case TEXT_EMOTE_HEALME: - //case TEXT_EMOTE_POUT: + // case TEXT_EMOTE_OOM: + // case TEXT_EMOTE_HEALME: + // case TEXT_EMOTE_POUT: emoteId = EMOTE_ONESHOT_QUESTION; textEmote = TEXT_EMOTE_PUZZLE; emoteText = "And what exactly am I supposed to do about that?"; @@ -542,7 +542,7 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) emoteText = "Shoo yourself!"; break; case TEXT_EMOTE_SLAP: - //case TEXT_EMOTE_SMACK: + // case TEXT_EMOTE_SMACK: emoteId = EMOTE_ONESHOT_CRY; textEmote = TEXT_EMOTE_CRY; emoteText = "What did I do to deserve that?"; @@ -562,18 +562,18 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) textEmote = TEXT_EMOTE_SIGH; emoteText = "Har Har.. very funny.."; break; - //case TEXT_EMOTE_HELPME: - // bot->HandleEmoteCommand(EMOTE_ONESHOT_POINT); - // bot->Yell("Quick! Someone HELP!", LANG_UNIVERSAL); - // break; + // case TEXT_EMOTE_HELPME: + // bot->HandleEmoteCommand(EMOTE_ONESHOT_POINT); + // bot->Yell("Quick! Someone HELP!", LANG_UNIVERSAL); + // break; case TEXT_EMOTE_GOODLUCK: - //case TEXT_EMOTE_LUCK: + // case TEXT_EMOTE_LUCK: emoteId = EMOTE_ONESHOT_TALK; textEmote = TEXT_EMOTE_THANK; emoteText = "Thanks... I'll need it.."; break; case TEXT_EMOTE_BRANDISH: - //case TEXT_EMOTE_MERCY: + // case TEXT_EMOTE_MERCY: emoteId = EMOTE_ONESHOT_BEG; textEmote = TEXT_EMOTE_BEG; emoteText = "Please don't kill me!"; @@ -612,9 +612,9 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal) bot->Yell("You think that's going to help you?!", LANG_UNIVERSAL); break;*/ default: - //return false; - //bot->HandleEmoteCommand(EMOTE_ONESHOT_QUESTION); - //bot->Say("Mmmmmkaaaaaay...", LANG_UNIVERSAL); + // return false; + // bot->HandleEmoteCommand(EMOTE_ONESHOT_QUESTION); + // bot->Say("Mmmmmkaaaaaay...", LANG_UNIVERSAL); break; } @@ -668,8 +668,9 @@ bool EmoteAction::Execute(Event event) p >> nam; pSource = ObjectAccessor::FindPlayer(source); - if (pSource && (pSource->GetGUID() != bot->GetGUID()) && ((urand(0, 1) && bot->HasInArc(static_cast(M_PI), pSource, 10.0f)) || - (namlen > 1 && strstri(bot->GetName().c_str(), nam.c_str())))) + if (pSource && (pSource->GetGUID() != bot->GetGUID()) && + ((urand(0, 1) && bot->HasInArc(static_cast(M_PI), pSource, 10.0f)) || + (namlen > 1 && strstri(bot->GetName().c_str(), nam.c_str())))) { /*LOG_INFO("playerbots", "Bot {} {}:{} <{}> received SMSG_TEXT_EMOTE {} from player {} <{}>", bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), @@ -688,14 +689,16 @@ bool EmoteAction::Execute(Event event) p >> emoteId >> source; pSource = ObjectAccessor::FindPlayer(source); - if (pSource && pSource != bot && sServerFacade->GetDistance2d(bot, pSource) < sPlayerbotAIConfig->farDistance && emoteId != EMOTE_ONESHOT_NONE) + if (pSource && pSource != bot && sServerFacade->GetDistance2d(bot, pSource) < sPlayerbotAIConfig->farDistance && + emoteId != EMOTE_ONESHOT_NONE) { - if ((pSource->GetGUID() != bot->GetGUID()) && (pSource->GetTarget() == bot->GetGUID() || - (urand(0, 1) && bot->HasInArc(static_cast(M_PI), pSource, 10.0f)))) + if ((pSource->GetGUID() != bot->GetGUID()) && + (pSource->GetTarget() == bot->GetGUID() || + (urand(0, 1) && bot->HasInArc(static_cast(M_PI), pSource, 10.0f)))) { /*LOG_INFO("playerbots", "Bot {} {}:{} <{}> received SMSG_EMOTE {} from player {} <{}>", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), - emoteId, pSource->GetGUID().ToString().c_str(), pSource->GetName());*/ + bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + bot->GetName(), emoteId, pSource->GetGUID().ToString().c_str(), pSource->GetName());*/ std::vector types; for (int32 i = sEmotesTextStore.GetNumRows(); i >= 0; --i) @@ -732,7 +735,9 @@ bool EmoteAction::Execute(Event event) if ((!isReact && param.empty()) || emote) { time_t lastEmote = AI_VALUE2(time_t, "last emote", qualifier); - botAI->GetAiObjectContext()->GetValue("last emote", qualifier)->Set(time(nullptr) + urand(1000, sPlayerbotAIConfig->repeatDelay) / 1000); + botAI->GetAiObjectContext() + ->GetValue("last emote", qualifier) + ->Set(time(nullptr) + urand(1000, sPlayerbotAIConfig->repeatDelay) / 1000); param = qualifier; } @@ -832,7 +837,8 @@ uint32 TalkAction::GetRandomEmote(Unit* unit, bool textEmote) types.push_back(TEXT_EMOTE_TALKEX); types.push_back(TEXT_EMOTE_TALKQ); - if (unit && (unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER) || unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))) + if (unit && (unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER) || + unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))) { types.push_back(TEXT_EMOTE_SALUTE); } @@ -858,7 +864,8 @@ uint32 TalkAction::GetRandomEmote(Unit* unit, bool textEmote) types.push_back(EMOTE_ONESHOT_EXCLAMATION); types.push_back(EMOTE_ONESHOT_QUESTION); - if (unit && (unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER) || unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))) + if (unit && (unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER) || + unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))) { types.push_back(EMOTE_ONESHOT_SALUTE); } @@ -1272,24 +1279,24 @@ uint32 EmoteActionBase::GetNumberOfEmoteVariants(TextEmotes emote, uint8 Race, u { switch (Race) { - case RACE_HUMAN: - case RACE_DWARF: - case RACE_NIGHTELF: - case RACE_GNOME: - case RACE_ORC: - case RACE_TAUREN: - case RACE_TROLL: - { - if (Gender == GENDER_MALE) + case RACE_HUMAN: + case RACE_DWARF: + case RACE_NIGHTELF: + case RACE_GNOME: + case RACE_ORC: + case RACE_TAUREN: + case RACE_TROLL: + { + if (Gender == GENDER_MALE) + return 3; return 3; - return 3; - } - case RACE_UNDEAD_PLAYER: - { - if (Gender == GENDER_MALE) - return 2; - return 3; - } + } + case RACE_UNDEAD_PLAYER: + { + if (Gender == GENDER_MALE) + return 2; + return 3; + } } } else if (emote == TEXT_EMOTE_CONGRATULATE) diff --git a/src/strategy/actions/EmoteAction.h b/src/strategy/actions/EmoteAction.h index 34816805..b1836cb3 100644 --- a/src/strategy/actions/EmoteAction.h +++ b/src/strategy/actions/EmoteAction.h @@ -1,15 +1,16 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_EMOTEACTION_H #define _PLAYERBOT_EMOTEACTION_H +#include + #include "Action.h" #include "NamedObjectContext.h" -#include - class Player; class PlayerbotAI; class Unit; @@ -18,36 +19,36 @@ enum TextEmotes : uint32; class EmoteActionBase : public Action { - public: - EmoteActionBase(PlayerbotAI* botAI, std::string const name); +public: + EmoteActionBase(PlayerbotAI* botAI, std::string const name); - static uint32 GetNumberOfEmoteVariants(TextEmotes emote, uint8 race, uint8 gender); + static uint32 GetNumberOfEmoteVariants(TextEmotes emote, uint8 race, uint8 gender); - protected: - bool Emote(Unit* target, uint32 type, bool textEmote = false); - bool ReceiveEmote(Player* source, uint32 emote, bool verbal = false); - Unit* GetTarget(); - void InitEmotes(); - static std::map emotes; - static std::map textEmotes; +protected: + bool Emote(Unit* target, uint32 type, bool textEmote = false); + bool ReceiveEmote(Player* source, uint32 emote, bool verbal = false); + Unit* GetTarget(); + void InitEmotes(); + static std::map emotes; + static std::map textEmotes; }; class EmoteAction : public EmoteActionBase, public Qualified { - public: - EmoteAction(PlayerbotAI* botAI); +public: + EmoteAction(PlayerbotAI* botAI); - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class TalkAction : public EmoteActionBase { - public: - TalkAction(PlayerbotAI* botAI) : EmoteActionBase(botAI, "talk") { } +public: + TalkAction(PlayerbotAI* botAI) : EmoteActionBase(botAI, "talk") {} - bool Execute(Event event) override; - static uint32 GetRandomEmote(Unit* unit, bool textEmote = false); + bool Execute(Event event) override; + static uint32 GetRandomEmote(Unit* unit, bool textEmote = false); }; #endif diff --git a/src/strategy/actions/EquipAction.cpp b/src/strategy/actions/EquipAction.cpp index c542ac89..85591cf8 100644 --- a/src/strategy/actions/EquipAction.cpp +++ b/src/strategy/actions/EquipAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "EquipAction.h" + #include "Event.h" #include "ItemCountValue.h" #include "ItemUsageValue.h" @@ -18,14 +20,14 @@ bool EquipAction::Execute(Event event) void EquipAction::EquipItems(ItemIds ids) { - for (ItemIds::iterator i =ids.begin(); i != ids.end(); i++) + for (ItemIds::iterator i = ids.begin(); i != ids.end(); i++) { FindItemByIdVisitor visitor(*i); EquipItem(&visitor); } } -//Return bagslot with smalest bag. +// Return bagslot with smalest bag. uint8 EquipAction::GetSmallestBagSlot() { int8 curBag = 0; @@ -52,7 +54,7 @@ void EquipAction::EquipItem(FindItemVisitor* visitor) { IterateItems(visitor); std::vector items = visitor->GetResult(); - if (!items.empty()) + if (!items.empty()) EquipItem(*items.begin()); } @@ -120,7 +122,9 @@ bool EquipUpgradesAction::Execute(Event event) ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", i->first); if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_BAD_EQUIP) { - // LOG_INFO("playerbots", "Bot {} <{}> auto equips item {} ({})", bot->GetGUID().ToString().c_str(), bot->GetName().c_str(), i->first, usage == 1 ? "no item in slot" : usage == 2 ? "replace" : usage == 3 ? "wrong item but empty slot" : ""); + // LOG_INFO("playerbots", "Bot {} <{}> auto equips item {} ({})", bot->GetGUID().ToString().c_str(), + // bot->GetName().c_str(), i->first, usage == 1 ? "no item in slot" : usage == 2 ? "replace" : usage == 3 ? + // "wrong item but empty slot" : ""); items.insert(i->first); } } diff --git a/src/strategy/actions/EquipAction.h b/src/strategy/actions/EquipAction.h index 816cd0af..64ef5aa3 100644 --- a/src/strategy/actions/EquipAction.h +++ b/src/strategy/actions/EquipAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_EQUIPACTION_H @@ -14,33 +15,32 @@ class PlayerbotAI; class EquipAction : public InventoryAction { - public: - EquipAction(PlayerbotAI* botAI, std::string const name = "equip") : InventoryAction(botAI, name) { } +public: + EquipAction(PlayerbotAI* botAI, std::string const name = "equip") : InventoryAction(botAI, name) {} - bool Execute(Event event) override; - void EquipItems(ItemIds ids); + bool Execute(Event event) override; + void EquipItems(ItemIds ids); - private: - void EquipItem(FindItemVisitor* visitor); - uint8 GetSmallestBagSlot(); - void EquipItem(Item* item); +private: + void EquipItem(FindItemVisitor* visitor); + uint8 GetSmallestBagSlot(); + void EquipItem(Item* item); }; class EquipUpgradesAction : public EquipAction { - public: - EquipUpgradesAction(PlayerbotAI* botAI, std::string const name = "equip upgrades") : EquipAction(botAI, name) { } +public: + EquipUpgradesAction(PlayerbotAI* botAI, std::string const name = "equip upgrades") : EquipAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class EquipUpgradeAction : public EquipAction { - public: - EquipUpgradeAction(PlayerbotAI* botAI, std::string const name = "equip upgrade") : EquipAction(botAI, name) { } +public: + EquipUpgradeAction(PlayerbotAI* botAI, std::string const name = "equip upgrade") : EquipAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; - #endif diff --git a/src/strategy/actions/FlagAction.cpp b/src/strategy/actions/FlagAction.cpp index bf8f0b51..566f2df0 100644 --- a/src/strategy/actions/FlagAction.cpp +++ b/src/strategy/actions/FlagAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "FlagAction.h" + #include "Event.h" #include "Playerbots.h" @@ -58,4 +60,3 @@ bool FlagAction::Execute(Event event) botAI->TellMaster(out.str()); return true; } - diff --git a/src/strategy/actions/FlagAction.h b/src/strategy/actions/FlagAction.h index 65439344..3e64db8e 100644 --- a/src/strategy/actions/FlagAction.h +++ b/src/strategy/actions/FlagAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_FLAGACTION_H @@ -11,13 +12,13 @@ class PlayerbotAI; class FlagAction : public Action { - public: - FlagAction(PlayerbotAI* botAI) : Action(botAI, "flag") { } +public: + FlagAction(PlayerbotAI* botAI) : Action(botAI, "flag") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - bool TellUsage(); +private: + bool TellUsage(); }; #endif diff --git a/src/strategy/actions/FollowActions.cpp b/src/strategy/actions/FollowActions.cpp index 28fee92a..7a4a4bdb 100644 --- a/src/strategy/actions/FollowActions.cpp +++ b/src/strategy/actions/FollowActions.cpp @@ -1,14 +1,17 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "FollowActions.h" + +#include + #include "Event.h" #include "Formations.h" #include "Playerbots.h" #include "ServerFacade.h" #include "SharedDefines.h" -#include bool FollowAction::Execute(Event event) { @@ -44,19 +47,21 @@ bool FollowAction::Execute(Event event) // pet->GetMotionMaster()->MoveFollow(bot, PET_FOLLOW_DIST, pet->GetFollowAngle()); } } - //if (moved) - //botAI->SetNextCheckDelay(sPlayerbotAIConfig->reactDelay); + // if (moved) + // botAI->SetNextCheckDelay(sPlayerbotAIConfig->reactDelay); return moved; } bool FollowAction::isUseful() { - if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL) != nullptr) { + if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL) != nullptr) + { return false; } Formation* formation = AI_VALUE(Formation*, "formation"); - if (!formation) { + if (!formation) + { return false; } std::string const target = formation->GetTargetName(); @@ -111,7 +116,7 @@ bool FleeToMasterAction::Execute(Event event) bool canFollow = Follow(fTarget); if (!canFollow) { - //botAI->SetNextCheckDelay(5000); + // botAI->SetNextCheckDelay(5000); return false; } @@ -129,9 +134,8 @@ bool FleeToMasterAction::Execute(Event event) if (!urand(0, 10)) botAI->TellMaster("I heading to your position."); } - else - if (!urand(0,20)) - botAI->TellMaster("I am traveling to your position."); + else if (!urand(0, 20)) + botAI->TellMaster("I am traveling to your position."); botAI->SetNextCheckDelay(3000); diff --git a/src/strategy/actions/FollowActions.h b/src/strategy/actions/FollowActions.h index 3c5b65d5..d9819744 100644 --- a/src/strategy/actions/FollowActions.h +++ b/src/strategy/actions/FollowActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_FOLLOWACTIONS_H @@ -11,21 +12,21 @@ class PlayerbotAI; class FollowAction : public MovementAction { - public: - FollowAction(PlayerbotAI* botAI, std::string const name = "follow") : MovementAction(botAI, name) { } +public: + FollowAction(PlayerbotAI* botAI, std::string const name = "follow") : MovementAction(botAI, name) {} - bool Execute(Event event) override; - bool isUseful() override; - bool CanDeadFollow(Unit* target); + bool Execute(Event event) override; + bool isUseful() override; + bool CanDeadFollow(Unit* target); }; class FleeToMasterAction : public FollowAction { - public: - FleeToMasterAction(PlayerbotAI* botAI) : FollowAction(botAI, "flee to master") { } +public: + FleeToMasterAction(PlayerbotAI* botAI) : FollowAction(botAI, "flee to master") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/GenericActions.cpp b/src/strategy/actions/GenericActions.cpp index 9b16ee7a..be75370a 100644 --- a/src/strategy/actions/GenericActions.cpp +++ b/src/strategy/actions/GenericActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericActions.h" + #include "CreatureAI.h" #include "Playerbots.h" @@ -15,54 +17,59 @@ bool MeleeAction::isUseful() return true; } -bool TogglePetSpellAutoCastAction::Execute(Event event) { +bool TogglePetSpellAutoCastAction::Execute(Event event) +{ Pet* pet = bot->GetPet(); - if (!pet) { + if (!pet) + { return false; } bool toggled = false; for (PetSpellMap::const_iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr) { - if(itr->second.state == PETSPELL_REMOVED) + if (itr->second.state == PETSPELL_REMOVED) continue; uint32 spellId = itr->first; const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (spellInfo->IsPassive()) continue; - + bool shouldApply = true; // imp's spell, felhunte's intelligence, ghoul's leap, cat stealth - if (spellId == 4511 || spellId == 1742 || - spellId == 54424 || spellId == 57564 || spellId == 57565 || spellId == 57566 || spellId == 57567 || - spellId == 47482 || spellId == 24450) { + if (spellId == 4511 || spellId == 1742 || spellId == 54424 || spellId == 57564 || spellId == 57565 || + spellId == 57566 || spellId == 57567 || spellId == 47482 || spellId == 24450) + { shouldApply = false; } bool isAutoCast = false; - for (unsigned int &m_autospell : pet->m_autospells) - { - if (m_autospell == spellId) - { - isAutoCast = true; - break; - } - } - if (shouldApply != isAutoCast) { + for (unsigned int& m_autospell : pet->m_autospells) + { + if (m_autospell == spellId) + { + isAutoCast = true; + break; + } + } + if (shouldApply != isAutoCast) + { pet->ToggleAutocast(spellInfo, shouldApply); toggled = true; } } - return toggled; + return toggled; } bool PetAttackAction::Execute(Event event) { Guardian* pet = bot->GetGuardianPet(); - if (!pet) { + if (!pet) + { return false; } Unit* target = AI_VALUE(Unit*, "current target"); - if (!target) { + if (!target) + { return false; } // pet->SetReactState(REACT_DEFENSIVE); diff --git a/src/strategy/actions/GenericActions.h b/src/strategy/actions/GenericActions.h index 1b34c82c..d3347df5 100644 --- a/src/strategy/actions/GenericActions.h +++ b/src/strategy/actions/GenericActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICACTIONS_H @@ -11,26 +12,25 @@ class PlayerbotAI; class MeleeAction : public AttackAction { - public: - MeleeAction(PlayerbotAI* botAI) : AttackAction(botAI, "melee") { } +public: + MeleeAction(PlayerbotAI* botAI) : AttackAction(botAI, "melee") {} - std::string const GetTargetName() override { return "current target"; } - bool isUseful() override; + std::string const GetTargetName() override { return "current target"; } + bool isUseful() override; }; -class TogglePetSpellAutoCastAction: public Action +class TogglePetSpellAutoCastAction : public Action { public: - TogglePetSpellAutoCastAction(PlayerbotAI* ai): Action(ai, "toggle pet spell") {} + TogglePetSpellAutoCastAction(PlayerbotAI* ai) : Action(ai, "toggle pet spell") {} virtual bool Execute(Event event) override; }; -class PetAttackAction: public Action +class PetAttackAction : public Action { public: - PetAttackAction(PlayerbotAI* ai): Action(ai, "pet attack") {} + PetAttackAction(PlayerbotAI* ai) : Action(ai, "pet attack") {} virtual bool Execute(Event event) override; }; - #endif diff --git a/src/strategy/actions/GenericSpellActions.cpp b/src/strategy/actions/GenericSpellActions.cpp index 24700d5e..3e4b2147 100644 --- a/src/strategy/actions/GenericSpellActions.cpp +++ b/src/strategy/actions/GenericSpellActions.cpp @@ -1,13 +1,16 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericSpellActions.h" + #include "Event.h" #include "Playerbots.h" #include "ServerFacade.h" -CastSpellAction::CastSpellAction(PlayerbotAI* botAI, std::string const spell) : Action(botAI, spell), range(botAI->GetRange("spell")), spell(spell) +CastSpellAction::CastSpellAction(PlayerbotAI* botAI, std::string const spell) + : Action(botAI, spell), range(botAI->GetRange("spell")), spell(spell) { } @@ -15,9 +18,9 @@ bool CastSpellAction::Execute(Event event) { if (spell == "conjure food" || spell == "conjure water") { - //uint32 id = AI_VALUE2(uint32, "spell id", spell); - //if (!id) - // return false; + // uint32 id = AI_VALUE2(uint32, "spell id", spell); + // if (!id) + // return false; uint32 castId = 0; @@ -62,10 +65,11 @@ bool CastSpellAction::Execute(Event event) bool CastSpellAction::isPossible() { - if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true)) { - if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && botAI->HasRealPlayerMaster())) { - LOG_DEBUG("playerbots", "Can cast spell failed. Vehicle. - bot name: {}", - bot->GetName()); + if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true)) + { + if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && botAI->HasRealPlayerMaster())) + { + LOG_DEBUG("playerbots", "Can cast spell failed. Vehicle. - bot name: {}", bot->GetName()); } return false; } @@ -75,9 +79,9 @@ bool CastSpellAction::isPossible() if (spell == "mount" && bot->IsInCombat()) { - if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && botAI->HasRealPlayerMaster())) { - LOG_DEBUG("playerbots", "Can cast spell failed. Mount. - bot name: {}", - bot->GetName()); + if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && botAI->HasRealPlayerMaster())) + { + LOG_DEBUG("playerbots", "Can cast spell failed. Mount. - bot name: {}", bot->GetName()); } bot->Dismount(); return false; @@ -112,7 +116,9 @@ bool CastSpellAction::isUseful() // if (!botAI->IsRanged(bot)) // combatReach += 4.0f / 3.0f; - return spellTarget && AI_VALUE2(bool, "spell cast useful", spell); // && sServerFacade->GetDistance2d(bot, spellTarget) <= (range + combatReach); + return spellTarget && + AI_VALUE2(bool, "spell cast useful", + spell); // && sServerFacade->GetDistance2d(bot, spellTarget) <= (range + combatReach); } CastMeleeSpellAction::CastMeleeSpellAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell) @@ -127,10 +133,12 @@ CastMeleeSpellAction::CastMeleeSpellAction(PlayerbotAI* botAI, std::string const bool CastAuraSpellAction::isUseful() { - return GetTarget() && (GetTarget() != nullptr) && CastSpellAction::isUseful() && !botAI->HasAura(spell, GetTarget(), false, isOwner); + return GetTarget() && (GetTarget() != nullptr) && CastSpellAction::isUseful() && + !botAI->HasAura(spell, GetTarget(), false, isOwner); } -CastEnchantItemAction::CastEnchantItemAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell) +CastEnchantItemAction::CastEnchantItemAction(PlayerbotAI* botAI, std::string const spell) + : CastSpellAction(botAI, spell) { range = botAI->GetRange("spell"); } @@ -138,34 +146,30 @@ CastEnchantItemAction::CastEnchantItemAction(PlayerbotAI* botAI, std::string con bool CastEnchantItemAction::isPossible() { // if (!CastSpellAction::isPossible()) { - + // botAI->TellMasterNoFacing("Impossible: " + spell); // return false; // } uint32 spellId = AI_VALUE2(uint32, "spell id", spell); - + // bool ok = AI_VALUE2(Item*, "item for spell", spellId); // Item* item = AI_VALUE2(Item*, "item for spell", spellId); - // botAI->TellMasterNoFacing("spell: " + spell + ", spell id: " + std::to_string(spellId) + " item for spell: " + std::to_string(ok)); + // botAI->TellMasterNoFacing("spell: " + spell + ", spell id: " + std::to_string(spellId) + " item for spell: " + + // std::to_string(ok)); return spellId && AI_VALUE2(Item*, "item for spell", spellId); } -CastHealingSpellAction::CastHealingSpellAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount, HealingManaEfficiency manaEfficiency) +CastHealingSpellAction::CastHealingSpellAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount, + HealingManaEfficiency manaEfficiency) : CastAuraSpellAction(botAI, spell, true), estAmount(estAmount), manaEfficiency(manaEfficiency) { range = botAI->GetRange("heal"); } -bool CastHealingSpellAction::isUseful() -{ - return CastAuraSpellAction::isUseful(); -} +bool CastHealingSpellAction::isUseful() { return CastAuraSpellAction::isUseful(); } -bool CastAoeHealSpellAction::isUseful() -{ - return CastSpellAction::isUseful(); -} +bool CastAoeHealSpellAction::isUseful() { return CastSpellAction::isUseful(); } CastCureSpellAction::CastCureSpellAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell) { @@ -211,9 +215,11 @@ NextAction** CastSpellAction::getPrerequisites() if (range > botAI->GetRange("spell")) return nullptr; else if (range > ATTACK_DISTANCE) - return NextAction::merge(NextAction::array(0, new NextAction("reach spell"), nullptr), Action::getPrerequisites()); + return NextAction::merge(NextAction::array(0, new NextAction("reach spell"), nullptr), + Action::getPrerequisites()); else - return NextAction::merge(NextAction::array(0, new NextAction("reach melee"), nullptr), Action::getPrerequisites()); + return NextAction::merge(NextAction::array(0, new NextAction("reach melee"), nullptr), + Action::getPrerequisites()); } Value* CastDebuffSpellOnAttackerAction::GetTargetValue() @@ -226,7 +232,8 @@ Value* CastDebuffSpellOnMeleeAttackerAction::GetTargetValue() return context->GetValue("melee attacker without aura", spell); } -CastBuffSpellAction::CastBuffSpellAction(PlayerbotAI* botAI, std::string const spell, bool checkIsOwner) : CastAuraSpellAction(botAI, spell, checkIsOwner) +CastBuffSpellAction::CastBuffSpellAction(PlayerbotAI* botAI, std::string const spell, bool checkIsOwner) + : CastAuraSpellAction(botAI, spell, checkIsOwner) { range = botAI->GetRange("spell"); } @@ -236,40 +243,19 @@ Value* CastSpellOnEnemyHealerAction::GetTargetValue() return context->GetValue("enemy healer target", spell); } -Value* CastSnareSpellAction::GetTargetValue() -{ - return context->GetValue("snare target", spell); -} +Value* CastSnareSpellAction::GetTargetValue() { return context->GetValue("snare target", spell); } -Value* CastCrowdControlSpellAction::GetTargetValue() -{ - return context->GetValue("cc target", getName()); -} +Value* CastCrowdControlSpellAction::GetTargetValue() { return context->GetValue("cc target", getName()); } -bool CastCrowdControlSpellAction::Execute(Event event) -{ - return botAI->CastSpell(getName(), GetTarget()); -} +bool CastCrowdControlSpellAction::Execute(Event event) { return botAI->CastSpell(getName(), GetTarget()); } -bool CastCrowdControlSpellAction::isPossible() -{ - return botAI->CanCastSpell(getName(), GetTarget()); -} +bool CastCrowdControlSpellAction::isPossible() { return botAI->CanCastSpell(getName(), GetTarget()); } -bool CastCrowdControlSpellAction::isUseful() -{ - return true; -} +bool CastCrowdControlSpellAction::isUseful() { return true; } -std::string const CastProtectSpellAction::GetTargetName() -{ - return "party member to protect"; -} +std::string const CastProtectSpellAction::GetTargetName() { return "party member to protect"; } -bool CastProtectSpellAction::isUseful() -{ - return GetTarget() && !botAI->HasAura(spell, GetTarget()); -} +bool CastProtectSpellAction::isUseful() { return GetTarget() && !botAI->HasAura(spell, GetTarget()); } bool CastVehicleSpellAction::isPossible() { @@ -277,10 +263,7 @@ bool CastVehicleSpellAction::isPossible() return botAI->CanCastVehicleSpell(spellId, GetTarget()); } -bool CastVehicleSpellAction::isUseful() -{ - return botAI->IsInVehicle(false, true); -} +bool CastVehicleSpellAction::isUseful() { return botAI->IsInVehicle(false, true); } bool CastVehicleSpellAction::Execute(Event event) { @@ -288,16 +271,15 @@ bool CastVehicleSpellAction::Execute(Event event) return botAI->CastVehicleSpell(spellId, GetTarget()); } -Value* BuffOnMainTankAction::GetTargetValue() -{ - return context->GetValue("main tank", spell); -} +Value* BuffOnMainTankAction::GetTargetValue() { return context->GetValue("main tank", spell); } bool CastDebuffSpellAction::isUseful() { Unit* target = GetTarget(); - if (!target || !target->IsAlive() || !target->IsInWorld()) { + if (!target || !target->IsAlive() || !target->IsInWorld()) + { return false; } - return CastAuraSpellAction::isUseful() && (target->GetHealth() / AI_VALUE(float, "expected group dps")) >= needLifeTime; + return CastAuraSpellAction::isUseful() && + (target->GetHealth() / AI_VALUE(float, "expected group dps")) >= needLifeTime; } \ No newline at end of file diff --git a/src/strategy/actions/GenericSpellActions.h b/src/strategy/actions/GenericSpellActions.h index e0389e51..773f3ac0 100644 --- a/src/strategy/actions/GenericSpellActions.h +++ b/src/strategy/actions/GenericSpellActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICSPELLACTIONS_H @@ -16,341 +17,363 @@ class WorldObject; class CastSpellAction : public Action { - public: - CastSpellAction(PlayerbotAI* botAI, std::string const spell); +public: + CastSpellAction(PlayerbotAI* botAI, std::string const spell); - std::string const GetTargetName() override { return "current target"; }; - bool Execute(Event event) override; - bool isPossible() override; - bool isUseful() override; - ActionThreatType getThreatType() override { return ActionThreatType::Single; } + std::string const GetTargetName() override { return "current target"; }; + bool Execute(Event event) override; + bool isPossible() override; + bool isUseful() override; + ActionThreatType getThreatType() override { return ActionThreatType::Single; } - NextAction** getPrerequisites() override; + NextAction** getPrerequisites() override; - protected: - std::string spell; - float range; +protected: + std::string spell; + float range; }; class CastAuraSpellAction : public CastSpellAction { - public: - CastAuraSpellAction(PlayerbotAI* botAI, std::string const spell, bool isOwner = false) : CastSpellAction(botAI, spell) { this->isOwner = isOwner; } +public: + CastAuraSpellAction(PlayerbotAI* botAI, std::string const spell, bool isOwner = false) + : CastSpellAction(botAI, spell) + { + this->isOwner = isOwner; + } - bool isUseful() override; + bool isUseful() override; - protected: - bool isOwner; +protected: + bool isOwner; }; class CastMeleeSpellAction : public CastSpellAction { - public: - CastMeleeSpellAction(PlayerbotAI* botAI, std::string const spell); +public: + CastMeleeSpellAction(PlayerbotAI* botAI, std::string const spell); }; class CastDebuffSpellAction : public CastAuraSpellAction { - public: - CastDebuffSpellAction(PlayerbotAI* botAI, std::string const spell, bool isOwner = false, float needLifeTime = 8.0f) : CastAuraSpellAction(botAI, spell, isOwner), needLifeTime(needLifeTime) { } - bool isUseful() override; - private: - float needLifeTime; +public: + CastDebuffSpellAction(PlayerbotAI* botAI, std::string const spell, bool isOwner = false, float needLifeTime = 8.0f) + : CastAuraSpellAction(botAI, spell, isOwner), needLifeTime(needLifeTime) + { + } + bool isUseful() override; + +private: + float needLifeTime; }; class CastDebuffSpellOnAttackerAction : public CastDebuffSpellAction { - public: - CastDebuffSpellOnAttackerAction(PlayerbotAI* botAI, std::string const spell, bool isOwner = true, float needLifeTime = 8.0f) : CastDebuffSpellAction(botAI, spell, isOwner, needLifeTime) { } +public: + CastDebuffSpellOnAttackerAction(PlayerbotAI* botAI, std::string const spell, bool isOwner = true, + float needLifeTime = 8.0f) + : CastDebuffSpellAction(botAI, spell, isOwner, needLifeTime) + { + } - Value* GetTargetValue() override; - std::string const getName() override { return spell + " on attacker"; } - // ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } + Value* GetTargetValue() override; + std::string const getName() override { return spell + " on attacker"; } + // ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } }; class CastDebuffSpellOnMeleeAttackerAction : public CastDebuffSpellAction { - public: - CastDebuffSpellOnMeleeAttackerAction(PlayerbotAI* botAI, std::string const spell, bool isOwner = true, float needLifeTime = 8.0f) : CastDebuffSpellAction(botAI, spell, isOwner, needLifeTime) { } +public: + CastDebuffSpellOnMeleeAttackerAction(PlayerbotAI* botAI, std::string const spell, bool isOwner = true, + float needLifeTime = 8.0f) + : CastDebuffSpellAction(botAI, spell, isOwner, needLifeTime) + { + } - Value* GetTargetValue() override; - std::string const getName() override { return spell + " on attacker"; } - // ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } + Value* GetTargetValue() override; + std::string const getName() override { return spell + " on attacker"; } + // ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } }; class CastBuffSpellAction : public CastAuraSpellAction { - public: - CastBuffSpellAction(PlayerbotAI* botAI, std::string const spell, bool checkIsOwner = false); +public: + CastBuffSpellAction(PlayerbotAI* botAI, std::string const spell, bool checkIsOwner = false); - std::string const GetTargetName() override { return "self target"; } + std::string const GetTargetName() override { return "self target"; } }; class CastEnchantItemAction : public CastSpellAction { - public: - CastEnchantItemAction(PlayerbotAI* botAI, std::string const spell); +public: + CastEnchantItemAction(PlayerbotAI* botAI, std::string const spell); - bool isPossible() override; - std::string const GetTargetName() override { return "self target"; } + bool isPossible() override; + std::string const GetTargetName() override { return "self target"; } }; class CastHealingSpellAction : public CastAuraSpellAction { - public: - CastHealingSpellAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount = 15.0f, HealingManaEfficiency manaEfficiency = HealingManaEfficiency::MEDIUM); +public: + CastHealingSpellAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount = 15.0f, + HealingManaEfficiency manaEfficiency = HealingManaEfficiency::MEDIUM); - std::string const GetTargetName() override { return "self target"; } - bool isUseful() override; - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } - // Yunfan: Mana efficiency tell the bot how to save mana. The higher the better. - HealingManaEfficiency manaEfficiency; - uint8 estAmount; + std::string const GetTargetName() override { return "self target"; } + bool isUseful() override; + ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } + // Yunfan: Mana efficiency tell the bot how to save mana. The higher the better. + HealingManaEfficiency manaEfficiency; + uint8 estAmount; // protected: }; class CastAoeHealSpellAction : public CastHealingSpellAction { - public: - CastAoeHealSpellAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount = 15.0f, HealingManaEfficiency manaEfficiency = HealingManaEfficiency::MEDIUM) - : CastHealingSpellAction(botAI, spell, estAmount, manaEfficiency) { } +public: + CastAoeHealSpellAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount = 15.0f, + HealingManaEfficiency manaEfficiency = HealingManaEfficiency::MEDIUM) + : CastHealingSpellAction(botAI, spell, estAmount, manaEfficiency) + { + } - std::string const GetTargetName() override { return "party member to heal"; } - bool isUseful() override; + std::string const GetTargetName() override { return "party member to heal"; } + bool isUseful() override; }; class CastCureSpellAction : public CastSpellAction { - public: - CastCureSpellAction(PlayerbotAI* botAI, std::string const spell); +public: + CastCureSpellAction(PlayerbotAI* botAI, std::string const spell); - std::string const GetTargetName() override { return "self target"; } + std::string const GetTargetName() override { return "self target"; } }; class PartyMemberActionNameSupport { - public: - PartyMemberActionNameSupport(std::string const spell) - { - name = std::string(spell + " on party"); - } +public: + PartyMemberActionNameSupport(std::string const spell) { name = std::string(spell + " on party"); } - std::string const getName() { return name; } + std::string const getName() { return name; } - private: - std::string name; +private: + std::string name; }; class HealPartyMemberAction : public CastHealingSpellAction, public PartyMemberActionNameSupport { - public: - HealPartyMemberAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount = 15.0f, HealingManaEfficiency manaEfficiency = HealingManaEfficiency::MEDIUM) : - CastHealingSpellAction(botAI, spell, estAmount, manaEfficiency), PartyMemberActionNameSupport(spell) { } +public: + HealPartyMemberAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount = 15.0f, + HealingManaEfficiency manaEfficiency = HealingManaEfficiency::MEDIUM) + : CastHealingSpellAction(botAI, spell, estAmount, manaEfficiency), PartyMemberActionNameSupport(spell) + { + } - std::string const GetTargetName() override { return "party member to heal"; } - std::string const getName() override { return PartyMemberActionNameSupport::getName(); } + std::string const GetTargetName() override { return "party member to heal"; } + std::string const getName() override { return PartyMemberActionNameSupport::getName(); } }; class ResurrectPartyMemberAction : public CastSpellAction { - public: - ResurrectPartyMemberAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell) { - } +public: + ResurrectPartyMemberAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell) {} - std::string const GetTargetName() override { return "party member to resurrect"; } - NextAction** getPrerequisites() override - { - return NextAction::merge( NextAction::array(0, new NextAction("reach party member to resurrect"), NULL), Action::getPrerequisites()); - } + std::string const GetTargetName() override { return "party member to resurrect"; } + NextAction** getPrerequisites() override + { + return NextAction::merge(NextAction::array(0, new NextAction("reach party member to resurrect"), NULL), + Action::getPrerequisites()); + } }; class CurePartyMemberAction : public CastSpellAction, public PartyMemberActionNameSupport { - public: - CurePartyMemberAction(PlayerbotAI* botAI, std::string const spell, uint32 dispelType) : - CastSpellAction(botAI, spell), PartyMemberActionNameSupport(spell), dispelType(dispelType) { } +public: + CurePartyMemberAction(PlayerbotAI* botAI, std::string const spell, uint32 dispelType) + : CastSpellAction(botAI, spell), PartyMemberActionNameSupport(spell), dispelType(dispelType) + { + } - Value* GetTargetValue() override; - std::string const getName() override { return PartyMemberActionNameSupport::getName(); } + Value* GetTargetValue() override; + std::string const getName() override { return PartyMemberActionNameSupport::getName(); } - protected: - uint32 dispelType; +protected: + uint32 dispelType; }; class BuffOnPartyAction : public CastBuffSpellAction, public PartyMemberActionNameSupport { - public: - BuffOnPartyAction(PlayerbotAI* botAI, std::string const spell) : - CastBuffSpellAction(botAI, spell), PartyMemberActionNameSupport(spell) { } +public: + BuffOnPartyAction(PlayerbotAI* botAI, std::string const spell) + : CastBuffSpellAction(botAI, spell), PartyMemberActionNameSupport(spell) + { + } - Value* GetTargetValue() override; - std::string const getName() override { return PartyMemberActionNameSupport::getName(); } + Value* GetTargetValue() override; + std::string const getName() override { return PartyMemberActionNameSupport::getName(); } }; class CastShootAction : public CastSpellAction { - public: - CastShootAction(PlayerbotAI* botAI); +public: + CastShootAction(PlayerbotAI* botAI); - ActionThreatType getThreatType() override { return ActionThreatType::None; } + ActionThreatType getThreatType() override { return ActionThreatType::None; } }; class CastLifeBloodAction : public CastHealingSpellAction { - public: - CastLifeBloodAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "lifeblood") { } +public: + CastLifeBloodAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "lifeblood") {} }; class CastGiftOfTheNaaruAction : public CastHealingSpellAction { - public: - CastGiftOfTheNaaruAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "gift of the naaru") { } +public: + CastGiftOfTheNaaruAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "gift of the naaru") {} }; class CastArcaneTorrentAction : public CastBuffSpellAction { - public: - CastArcaneTorrentAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "arcane torrent") { } +public: + CastArcaneTorrentAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "arcane torrent") {} }; class CastManaTapAction : public CastBuffSpellAction { - public: - CastManaTapAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "mana tap") { } +public: + CastManaTapAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "mana tap") {} }; class CastWarStompAction : public CastSpellAction { - public: - CastWarStompAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "war stomp") { } +public: + CastWarStompAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "war stomp") {} }; class CastSpellOnEnemyHealerAction : public CastSpellAction { - public: - CastSpellOnEnemyHealerAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell) { } +public: + CastSpellOnEnemyHealerAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell) {} - Value* GetTargetValue() override; - std::string const getName() override { return spell + " on enemy healer"; } + Value* GetTargetValue() override; + std::string const getName() override { return spell + " on enemy healer"; } }; class CastSnareSpellAction : public CastDebuffSpellAction { - public: - CastSnareSpellAction(PlayerbotAI* botAI, std::string const spell) : CastDebuffSpellAction(botAI, spell) { } +public: + CastSnareSpellAction(PlayerbotAI* botAI, std::string const spell) : CastDebuffSpellAction(botAI, spell) {} - Value* GetTargetValue() override; - std::string const getName() override { return spell + " on snare target"; } - ActionThreatType getThreatType() override { return ActionThreatType::None; } + Value* GetTargetValue() override; + std::string const getName() override { return spell + " on snare target"; } + ActionThreatType getThreatType() override { return ActionThreatType::None; } }; class CastCrowdControlSpellAction : public CastBuffSpellAction { - public: - CastCrowdControlSpellAction(PlayerbotAI* botAI, std::string const spell) : CastBuffSpellAction(botAI, spell) { } +public: + CastCrowdControlSpellAction(PlayerbotAI* botAI, std::string const spell) : CastBuffSpellAction(botAI, spell) {} - Value* GetTargetValue() override; - bool Execute(Event event) override; - bool isPossible() override; - bool isUseful() override; - ActionThreatType getThreatType() override { return ActionThreatType::None; } + Value* GetTargetValue() override; + bool Execute(Event event) override; + bool isPossible() override; + bool isUseful() override; + ActionThreatType getThreatType() override { return ActionThreatType::None; } }; class CastProtectSpellAction : public CastSpellAction { - public: - CastProtectSpellAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell) { } +public: + CastProtectSpellAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell) {} - std::string const GetTargetName() override; - bool isUseful() override; - ActionThreatType getThreatType() override { return ActionThreatType::None; } + std::string const GetTargetName() override; + bool isUseful() override; + ActionThreatType getThreatType() override { return ActionThreatType::None; } }; class CastVehicleSpellAction : public CastSpellAction { - public: - CastVehicleSpellAction(PlayerbotAI* botAI, std::string const& spell) : CastSpellAction(botAI, spell) - { - range = 120.0f; - } +public: + CastVehicleSpellAction(PlayerbotAI* botAI, std::string const& spell) : CastSpellAction(botAI, spell) + { + range = 120.0f; + } - std::string const GetTargetName() override { return "current target"; } - bool Execute(Event event) override; - bool isUseful() override; - bool isPossible() override; - ActionThreatType getThreatType() override { return ActionThreatType::None; } + std::string const GetTargetName() override { return "current target"; } + bool Execute(Event event) override; + bool isUseful() override; + bool isPossible() override; + ActionThreatType getThreatType() override { return ActionThreatType::None; } - protected: - WorldObject* spellTarget; +protected: + WorldObject* spellTarget; }; class CastHurlBoulderAction : public CastVehicleSpellAction { - public: - CastHurlBoulderAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "hurl boulder") { } +public: + CastHurlBoulderAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "hurl boulder") {} }; class CastSteamRushAction : public CastVehicleSpellAction { - public: - CastSteamRushAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "steam rush") { } +public: + CastSteamRushAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "steam rush") {} }; class CastRamAction : public CastVehicleSpellAction { - public: - CastRamAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "ram") { } +public: + CastRamAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "ram") {} }; class CastNapalmAction : public CastVehicleSpellAction { - public: - CastNapalmAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "napalm") { } +public: + CastNapalmAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "napalm") {} }; class CastFireCannonAction : public CastVehicleSpellAction { - public: - CastFireCannonAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "fire cannon") { } +public: + CastFireCannonAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "fire cannon") {} }; class CastSteamBlastAction : public CastVehicleSpellAction { - public: - CastSteamBlastAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "steam blast") { } +public: + CastSteamBlastAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "steam blast") {} }; class CastIncendiaryRocketAction : public CastVehicleSpellAction { - public: - CastIncendiaryRocketAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "incendiary rocket") { } +public: + CastIncendiaryRocketAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "incendiary rocket") {} }; class CastRocketBlastAction : public CastVehicleSpellAction { - public: - CastRocketBlastAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "rocket blast") { } +public: + CastRocketBlastAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "rocket blast") {} }; class CastGlaiveThrowAction : public CastVehicleSpellAction { - public: - CastGlaiveThrowAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "glaive throw") { } +public: + CastGlaiveThrowAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "glaive throw") {} }; class CastBladeSalvoAction : public CastVehicleSpellAction { - public: - CastBladeSalvoAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "blade salvo") { } +public: + CastBladeSalvoAction(PlayerbotAI* botAI) : CastVehicleSpellAction(botAI, "blade salvo") {} }; -class MainTankActionNameSupport { +class MainTankActionNameSupport +{ public: - MainTankActionNameSupport(std::string spell) - { - name = std::string(spell) + " on main tank"; - } + MainTankActionNameSupport(std::string spell) { name = std::string(spell) + " on main tank"; } virtual std::string const getName() { return name; } @@ -361,8 +384,11 @@ private: class BuffOnMainTankAction : public CastBuffSpellAction, public MainTankActionNameSupport { public: - BuffOnMainTankAction(PlayerbotAI* ai, std::string spell, bool checkIsOwner = false) : - CastBuffSpellAction(ai, spell, checkIsOwner), MainTankActionNameSupport(spell) {} + BuffOnMainTankAction(PlayerbotAI* ai, std::string spell, bool checkIsOwner = false) + : CastBuffSpellAction(ai, spell, checkIsOwner), MainTankActionNameSupport(spell) + { + } + public: virtual Value* GetTargetValue(); virtual std::string const getName() { return MainTankActionNameSupport::getName(); } diff --git a/src/strategy/actions/GiveItemAction.cpp b/src/strategy/actions/GiveItemAction.cpp index cf3a0717..a68482c0 100644 --- a/src/strategy/actions/GiveItemAction.cpp +++ b/src/strategy/actions/GiveItemAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GiveItemAction.h" + #include "Event.h" #include "ItemCountValue.h" #include "Playerbots.h" @@ -49,7 +51,8 @@ bool GiveItemAction::Execute(Event event) else { std::ostringstream out; - out << "Cannot get " << chat->FormatItem(item->GetTemplate(), item->GetCount()) << " from " << bot->GetName() << "- my bags are full"; + out << "Cannot get " << chat->FormatItem(item->GetTemplate(), item->GetCount()) << " from " + << bot->GetName() << "- my bags are full"; receiverAi->TellError(out.str()); } } @@ -57,36 +60,26 @@ bool GiveItemAction::Execute(Event event) return true; } -Unit* GiveItemAction::GetTarget() -{ - return AI_VALUE2(Unit*, "party member without item", item); -} +Unit* GiveItemAction::GetTarget() { return AI_VALUE2(Unit*, "party member without item", item); } bool GiveItemAction::isUseful() { return GetTarget() && AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig->lowMana; } -Unit* GiveFoodAction::GetTarget() -{ - return AI_VALUE(Unit*, "party member without food"); -} +Unit* GiveFoodAction::GetTarget() { return AI_VALUE(Unit*, "party member without food"); } bool GiveFoodAction::isUseful() { if (!GetTarget()) return false; - bool isRandomBot = GetTarget()->IsPlayer() && sRandomPlayerbotMgr->IsRandomBot((Player*) GetTarget()); + bool isRandomBot = GetTarget()->IsPlayer() && sRandomPlayerbotMgr->IsRandomBot((Player*)GetTarget()); return !isRandomBot || (isRandomBot && !sPlayerbotAIConfig->freeFood); } -Unit* GiveWaterAction::GetTarget() -{ - return AI_VALUE(Unit*, "party member without water"); -} - +Unit* GiveWaterAction::GetTarget() { return AI_VALUE(Unit*, "party member without water"); } bool GiveWaterAction::isUseful() { diff --git a/src/strategy/actions/GiveItemAction.h b/src/strategy/actions/GiveItemAction.h index b4aeeea5..169be1e9 100644 --- a/src/strategy/actions/GiveItemAction.h +++ b/src/strategy/actions/GiveItemAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GIVEITEMACTION_H @@ -11,21 +12,24 @@ class PlayerbotAI; class GiveItemAction : public InventoryAction { - public: - GiveItemAction(PlayerbotAI* botAI, std::string const name, std::string const item) : InventoryAction(botAI, name), item(item) { } +public: + GiveItemAction(PlayerbotAI* botAI, std::string const name, std::string const item) + : InventoryAction(botAI, name), item(item) + { + } - bool Execute(Event event) override; - bool isUseful() override; - Unit* GetTarget() override; + bool Execute(Event event) override; + bool isUseful() override; + Unit* GetTarget() override; - protected: - std::string const item; +protected: + std::string const item; }; class GiveFoodAction : public GiveItemAction { - public: - GiveFoodAction(PlayerbotAI* botAI) : GiveItemAction(botAI, "give food", "conjured food") { } +public: + GiveFoodAction(PlayerbotAI* botAI) : GiveItemAction(botAI, "give food", "conjured food") {} bool isUseful() override; Unit* GetTarget() override; @@ -33,8 +37,8 @@ class GiveFoodAction : public GiveItemAction class GiveWaterAction : public GiveItemAction { - public: - GiveWaterAction(PlayerbotAI* botAI) : GiveItemAction(botAI, "give water", "conjured water") { } +public: + GiveWaterAction(PlayerbotAI* botAI) : GiveItemAction(botAI, "give water", "conjured water") {} bool isUseful() override; Unit* GetTarget() override; diff --git a/src/strategy/actions/GoAction.cpp b/src/strategy/actions/GoAction.cpp index 273217e2..bb1076d6 100644 --- a/src/strategy/actions/GoAction.cpp +++ b/src/strategy/actions/GoAction.cpp @@ -1,14 +1,16 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GoAction.h" + #include "ChooseTravelTargetAction.h" #include "Event.h" #include "Formations.h" #include "PathGenerator.h" -#include "PositionValue.h" #include "Playerbots.h" +#include "PositionValue.h" #include "ServerFacade.h" std::vector split(std::string const s, char delim); @@ -73,7 +75,8 @@ bool GoAction::Execute(Event event) if (GameObject* go = botAI->GetGameObject(guid)) if (go->isSpawned()) { - if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, go), sPlayerbotAIConfig->reactDistance)) + if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, go), + sPlayerbotAIConfig->reactDistance)) { botAI->TellError("It is too far away"); return false; @@ -82,7 +85,8 @@ bool GoAction::Execute(Event event) std::ostringstream out; out << "Moving to " << ChatHelper::FormatGameobject(go); botAI->TellMasterNoFacing(out.str()); - return MoveNear(bot->GetMapId(), go->GetPositionX(), go->GetPositionY(), go->GetPositionZ() + 0.5f, sPlayerbotAIConfig->followDistance); + return MoveNear(bot->GetMapId(), go->GetPositionX(), go->GetPositionY(), go->GetPositionZ() + 0.5f, + sPlayerbotAIConfig->followDistance); } } return false; @@ -101,7 +105,8 @@ bool GoAction::Execute(Event event) std::ostringstream out; out << "Moving to " << unit->GetName(); botAI->TellMasterNoFacing(out.str()); - return MoveNear(bot->GetMapId(), unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ() + 0.5f, sPlayerbotAIConfig->followDistance); + return MoveNear(bot->GetMapId(), unit->GetPositionX(), unit->GetPositionY(), + unit->GetPositionZ() + 0.5f, sPlayerbotAIConfig->followDistance); } } @@ -144,7 +149,6 @@ bool GoAction::Execute(Event event) out << (end - aend).length(); - for (auto i : points) { CreateWp(bot, i.x, i.y, i.z, 0.f, 11144); @@ -172,7 +176,8 @@ bool GoAction::Execute(Event event) float z = bot->GetPositionZ(); bot->UpdateAllowedPositionZ(x, y, z); - if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, x, y), sPlayerbotAIConfig->reactDistance)) + if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, x, y), + sPlayerbotAIConfig->reactDistance)) { botAI->TellMaster("It is too far away"); return false; @@ -204,7 +209,8 @@ bool GoAction::Execute(Event event) PositionInfo pos = context->GetValue("position")->Get()[param]; if (pos.isSet()) { - if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, pos.x, pos.y), sPlayerbotAIConfig->reactDistance)) + if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, pos.x, pos.y), + sPlayerbotAIConfig->reactDistance)) { botAI->TellError("It is too far away"); return false; diff --git a/src/strategy/actions/GoAction.h b/src/strategy/actions/GoAction.h index 3ca6b7c1..068f15f7 100644 --- a/src/strategy/actions/GoAction.h +++ b/src/strategy/actions/GoAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GOACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class GoAction : public MovementAction { - public: - GoAction(PlayerbotAI* botAI) : MovementAction(botAI, "Go") { } +public: + GoAction(PlayerbotAI* botAI) : MovementAction(botAI, "Go") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/GossipHelloAction.cpp b/src/strategy/actions/GossipHelloAction.cpp index 851bf881..0a10541d 100644 --- a/src/strategy/actions/GossipHelloAction.cpp +++ b/src/strategy/actions/GossipHelloAction.cpp @@ -1,47 +1,53 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GossipHelloAction.h" -#include "GossipDef.h" + #include "Event.h" +#include "GossipDef.h" #include "Playerbots.h" bool GossipHelloAction::Execute(Event event) { - ObjectGuid guid; + ObjectGuid guid; - WorldPacket &p = event.getPacket(); - if (p.empty()) - { - Player* master = GetMaster(); - if (master) - guid = master->GetTarget(); - } - else - { - p.rpos(0); - p >> guid; - } + WorldPacket& p = event.getPacket(); + if (p.empty()) + { + Player* master = GetMaster(); + if (master) + guid = master->GetTarget(); + } + else + { + p.rpos(0); + p >> guid; + } - if (!guid) - return false; + if (!guid) + return false; - Creature* pCreature = bot->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); - if (!pCreature) - { - LOG_DEBUG("playerbots", "[PlayerbotMgr]: HandleMasterIncomingPacket - Received CMSG_GOSSIP_HELLO {} not found or you can't interact with him.", guid.ToString().c_str()); - return false; - } + Creature* pCreature = bot->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); + if (!pCreature) + { + LOG_DEBUG("playerbots", + "[PlayerbotMgr]: HandleMasterIncomingPacket - Received CMSG_GOSSIP_HELLO {} not found or you can't " + "interact with him.", + guid.ToString().c_str()); + return false; + } - GossipMenuItemsMapBounds pMenuItemBounds = sObjectMgr->GetGossipMenuItemsMapBounds(pCreature->GetCreatureTemplate()->GossipMenuId); - if (pMenuItemBounds.first == pMenuItemBounds.second) - return false; + GossipMenuItemsMapBounds pMenuItemBounds = + sObjectMgr->GetGossipMenuItemsMapBounds(pCreature->GetCreatureTemplate()->GossipMenuId); + if (pMenuItemBounds.first == pMenuItemBounds.second) + return false; - std::string const text = event.getParam(); - int32 menuToSelect = -1; - if (text.empty()) - { + std::string const text = event.getParam(); + int32 menuToSelect = -1; + if (text.empty()) + { WorldPacket p1; p1 << guid; bot->GetSession()->HandleGossipHelloOpcode(p1); @@ -52,23 +58,23 @@ bool GossipHelloAction::Execute(Event event) botAI->TellMasterNoFacing(out.str()); TellGossipMenus(); - } - else if (!bot->PlayerTalkClass) - { - botAI->TellError("I need to talk first"); - return false; - } - else - { - menuToSelect = atoi(text.c_str()); - // if (menuToSelect > 0) + } + else if (!bot->PlayerTalkClass) + { + botAI->TellError("I need to talk first"); + return false; + } + else + { + menuToSelect = atoi(text.c_str()); + // if (menuToSelect > 0) // menuToSelect--; ProcessGossip(menuToSelect); - } + } - bot->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID()); - return true; + bot->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID()); + return true; } void GossipHelloAction::TellGossipText(uint32 textId) @@ -104,8 +110,9 @@ void GossipHelloAction::TellGossipMenus() TellGossipText(textId); } - GossipMenuItemContainer const &items = menu.GetMenuItems(); - for (auto iter = items.begin(); iter != items.end(); iter++) { + GossipMenuItemContainer const& items = menu.GetMenuItems(); + for (auto iter = items.begin(); iter != items.end(); iter++) + { GossipMenuItem const* item = &(iter->second); std::ostringstream out; out << "[" << iter->first << "] " << item->Message; @@ -113,7 +120,6 @@ void GossipHelloAction::TellGossipMenus() } } - bool GossipHelloAction::ProcessGossip(int32 menuToSelect) { GossipMenu& menu = bot->PlayerTalkClass->GetGossipMenu(); diff --git a/src/strategy/actions/GossipHelloAction.h b/src/strategy/actions/GossipHelloAction.h index bd038d90..8643766c 100644 --- a/src/strategy/actions/GossipHelloAction.h +++ b/src/strategy/actions/GossipHelloAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GOSSIPHELLOACTION_H @@ -11,15 +12,15 @@ class PlayerbotAI; class GossipHelloAction : public Action { - public: - GossipHelloAction(PlayerbotAI* botAI) : Action(botAI, "gossip hello") { } +public: + GossipHelloAction(PlayerbotAI* botAI) : Action(botAI, "gossip hello") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - void TellGossipMenus(); - bool ProcessGossip(int32 menuToSelect); - void TellGossipText(uint32 textId); +private: + void TellGossipMenus(); + bool ProcessGossip(int32 menuToSelect); + void TellGossipText(uint32 textId); }; #endif diff --git a/src/strategy/actions/GreetAction.cpp b/src/strategy/actions/GreetAction.cpp index 31c597bb..ff7118f3 100644 --- a/src/strategy/actions/GreetAction.cpp +++ b/src/strategy/actions/GreetAction.cpp @@ -1,14 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GreetAction.h" + #include "Event.h" #include "Playerbots.h" -GreetAction::GreetAction(PlayerbotAI* botAI) : Action(botAI, "greet") -{ -} +GreetAction::GreetAction(PlayerbotAI* botAI) : Action(botAI, "greet") {} bool GreetAction::Execute(Event event) { @@ -25,7 +25,7 @@ bool GreetAction::Execute(Event event) ObjectGuid oldSel = bot->GetTarget(); bot->SetTarget(guid); - //bot->HandleEmote(EMOTE_ONESHOT_WAVE); + // bot->HandleEmote(EMOTE_ONESHOT_WAVE); botAI->PlayEmote(TEXT_EMOTE_HELLO); bot->SetTarget(oldSel); diff --git a/src/strategy/actions/GreetAction.h b/src/strategy/actions/GreetAction.h index 4a2080db..aef11098 100644 --- a/src/strategy/actions/GreetAction.h +++ b/src/strategy/actions/GreetAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GREETACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class GreetAction : public Action { - public: - GreetAction(PlayerbotAI* botAI); +public: + GreetAction(PlayerbotAI* botAI); - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/GuildAcceptAction.cpp b/src/strategy/actions/GuildAcceptAction.cpp index 2678aaa3..f926a68e 100644 --- a/src/strategy/actions/GuildAcceptAction.cpp +++ b/src/strategy/actions/GuildAcceptAction.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GuildAcceptAction.h" + #include "Event.h" #include "GuildPackets.h" -#include "Playerbots.h" #include "PlayerbotSecurity.h" +#include "Playerbots.h" bool GuildAcceptAction::Execute(Event event) { diff --git a/src/strategy/actions/GuildAcceptAction.h b/src/strategy/actions/GuildAcceptAction.h index 39aa86ea..50284dff 100644 --- a/src/strategy/actions/GuildAcceptAction.h +++ b/src/strategy/actions/GuildAcceptAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GUILDACCEPTACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class GuildAcceptAction : public Action { - public: - GuildAcceptAction(PlayerbotAI* botAI) : Action(botAI, "guild accept") { } +public: + GuildAcceptAction(PlayerbotAI* botAI) : Action(botAI, "guild accept") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/GuildBankAction.cpp b/src/strategy/actions/GuildBankAction.cpp index 328ab762..a7d50a99 100644 --- a/src/strategy/actions/GuildBankAction.cpp +++ b/src/strategy/actions/GuildBankAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GuildBankAction.h" + #include "GuildMgr.h" #include "Playerbots.h" @@ -18,7 +20,7 @@ bool GuildBankAction::Execute(Event event) return false; } - GuidVector gos = *botAI->GetAiObjectContext()->GetValue("nearest game objects"); + GuidVector gos = *botAI->GetAiObjectContext()->GetValue("nearest game objects"); for (GuidVector::iterator i = gos.begin(); i != gos.end(); ++i) { GameObject* go = botAI->GetGameObject(*i); @@ -58,11 +60,12 @@ bool GuildBankAction::MoveFromCharToBank(Item* item, GameObject* bank) std::ostringstream out; Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId()); - //guild->SwapItems(bot, 0, playerSlot, 0, INVENTORY_SLOT_BAG_0, 0); + // guild->SwapItems(bot, 0, playerSlot, 0, INVENTORY_SLOT_BAG_0, 0); // check source pos rights (item moved to bank) if (!guild->MemberHasTabRights(bot->GetGUID(), 0, GUILD_BANK_RIGHT_DEPOSIT_ITEM)) - out << "I can't put " << chat->FormatItem(item->GetTemplate()) << " to guild bank. I have no rights to put items in the first guild bank tab"; + out << "I can't put " << chat->FormatItem(item->GetTemplate()) + << " to guild bank. I have no rights to put items in the first guild bank tab"; else { out << chat->FormatItem(item->GetTemplate()) << " put to guild bank"; diff --git a/src/strategy/actions/GuildBankAction.h b/src/strategy/actions/GuildBankAction.h index 4f472540..5aac99b8 100644 --- a/src/strategy/actions/GuildBankAction.h +++ b/src/strategy/actions/GuildBankAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GUILDBANKACTION_H @@ -13,14 +14,14 @@ class PlayerbotAI; class GuildBankAction : public InventoryAction { - public: - GuildBankAction(PlayerbotAI* botAI) : InventoryAction(botAI, "guild bank") { } +public: + GuildBankAction(PlayerbotAI* botAI) : InventoryAction(botAI, "guild bank") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - bool Execute(std::string const text, GameObject* bank); - bool MoveFromCharToBank(Item* item, GameObject* bank); +private: + bool Execute(std::string const text, GameObject* bank); + bool MoveFromCharToBank(Item* item, GameObject* bank); }; #endif diff --git a/src/strategy/actions/GuildCreateActions.cpp b/src/strategy/actions/GuildCreateActions.cpp index 6bf04ba2..57d22fc2 100644 --- a/src/strategy/actions/GuildCreateActions.cpp +++ b/src/strategy/actions/GuildCreateActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GuildCreateActions.h" + #include "ArenaTeam.h" #include "BudgetValues.h" #include "Event.h" @@ -13,7 +15,7 @@ bool BuyPetitionAction::Execute(Event event) { - GuidVector vendors = botAI->GetAiObjectContext()->GetValue("nearest npcs")->Get(); + GuidVector vendors = botAI->GetAiObjectContext()->GetValue("nearest npcs")->Get(); bool vendored = false, result = false; for (GuidVector::iterator i = vendors.begin(); i != vendors.end(); ++i) { @@ -48,7 +50,7 @@ bool BuyPetitionAction::Execute(Event event) for (uint8 i = 0; i < 10; ++i) data << std::string(""); - data << uint32(0); // index + data << uint32(0); // index data << uint32(0); bot->GetSession()->HandlePetitionBuyOpcode(data); @@ -59,10 +61,7 @@ bool BuyPetitionAction::Execute(Event event) return false; } -bool BuyPetitionAction::isUseful() -{ - return canBuyPetition(bot); -}; +bool BuyPetitionAction::isUseful() { return canBuyPetition(bot); }; bool BuyPetitionAction::canBuyPetition(Player* bot) { @@ -87,7 +86,7 @@ bool BuyPetitionAction::canBuyPetition(Player* bot) if (!botAI->HasStrategy("guild", BOT_STATE_NON_COMBAT)) return false; - uint32 cost = 1000; //GUILD_CHARTER_COST; + uint32 cost = 1000; // GUILD_CHARTER_COST; if (AI_VALUE2(uint32, "free money for", uint32(NeedMoneyFor::guild)) < cost) return false; @@ -97,10 +96,10 @@ bool BuyPetitionAction::canBuyPetition(Player* bot) bool PetitionOfferAction::Execute(Event event) { - uint32 petitionEntry = 5863; //GUILD_CHARTER + uint32 petitionEntry = 5863; // GUILD_CHARTER std::vector petitions = AI_VALUE2(std::vector, "inventory items", chat->FormatQItem(5863)); - if (petitions.empty()) + if (petitions.empty()) return false; ObjectGuid guid = event.getObject(); @@ -131,8 +130,9 @@ bool PetitionOfferAction::Execute(Event event) data << petitions.front()->GetGUID(); data << guid; - QueryResult result = CharacterDatabase.Query("SELECT playerguid FROM petition_sign WHERE player_account = {} AND petitionguid = {}", - player->GetSession()->GetAccountId(), petitions.front()->GetGUID().GetCounter()); + QueryResult result = + CharacterDatabase.Query("SELECT playerguid FROM petition_sign WHERE player_account = {} AND petitionguid = {}", + player->GetSession()->GetAccountId(), petitions.front()->GetGUID().GetCounter()); if (result) { return false; @@ -140,7 +140,8 @@ bool PetitionOfferAction::Execute(Event event) bot->GetSession()->HandleOfferPetitionOpcode(data); - result = CharacterDatabase.Query("SELECT playerguid FROM petition_sign WHERE petitionguid = {}", petitions.front()->GetGUID().GetCounter()); + result = CharacterDatabase.Query("SELECT playerguid FROM petition_sign WHERE petitionguid = {}", + petitions.front()->GetGUID().GetCounter()); uint8 signs = result ? (uint8)result->GetRowCount() : 0; context->GetValue("petition signs")->Set(signs); @@ -148,16 +149,13 @@ bool PetitionOfferAction::Execute(Event event) return true; } -bool PetitionOfferAction::isUseful() -{ - return !bot->GetGuildId(); -} +bool PetitionOfferAction::isUseful() { return !bot->GetGuildId(); } bool PetitionOfferNearbyAction::Execute(Event event) { uint32 found = 0; - GuidVector nearGuids = botAI->GetAiObjectContext()->GetValue("nearest friendly players")->Get(); + GuidVector nearGuids = botAI->GetAiObjectContext()->GetValue("nearest friendly players")->Get(); for (auto& i : nearGuids) { Player* player = ObjectAccessor::FindPlayer(i); @@ -180,7 +178,7 @@ bool PetitionOfferNearbyAction::Execute(Event event) continue; */ - if (botAI->HasActivePlayerMaster()) //Do not invite alts of active players. + if (botAI->HasActivePlayerMaster()) // Do not invite alts of active players. continue; } else @@ -192,7 +190,7 @@ bool PetitionOfferNearbyAction::Execute(Event event) if (sServerFacade->GetDistance2d(bot, player) > sPlayerbotAIConfig->sightDistance) continue; - //Parse rpg target to quest action. + // Parse rpg target to quest action. WorldPacket p(CMSG_QUESTGIVER_ACCEPT_QUEST); p << i; p.rpos(0); @@ -206,12 +204,13 @@ bool PetitionOfferNearbyAction::Execute(Event event) bool PetitionOfferNearbyAction::isUseful() { - return !bot->GetGuildId() && AI_VALUE2(uint32, "item count", chat->FormatQItem(5863)) && AI_VALUE(uint8, "petition signs") < sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS); + return !bot->GetGuildId() && AI_VALUE2(uint32, "item count", chat->FormatQItem(5863)) && + AI_VALUE(uint8, "petition signs") < sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS); } bool PetitionTurnInAction::Execute(Event event) { - GuidVector vendors = botAI->GetAiObjectContext()->GetValue("nearest npcs")->Get(); + GuidVector vendors = botAI->GetAiObjectContext()->GetValue("nearest npcs")->Get(); bool vendored = false, result = false; std::vector petitions = AI_VALUE2(std::vector, "inventory items", chat->FormatQItem(5863)); @@ -250,7 +249,7 @@ bool PetitionTurnInAction::Execute(Event event) guild->HandleSetEmblem(emblemInfo); - //LANG_GUILD_VETERAN -> can invite + // LANG_GUILD_VETERAN -> can invite guild->HandleSetRankInfo(2, GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK | GR_RIGHT_INVITE); } @@ -259,10 +258,10 @@ bool PetitionTurnInAction::Execute(Event event) TravelTarget* oldTarget = context->GetValue("travel target")->Get(); - //Select a new target to travel to. + // Select a new target to travel to. TravelTarget newTarget = TravelTarget(botAI); - bool foundTarget = SetNpcFlagTarget(&newTarget, { UNIT_NPC_FLAG_PETITIONER }); + bool foundTarget = SetNpcFlagTarget(&newTarget, {UNIT_NPC_FLAG_PETITIONER}); if (!foundTarget || !newTarget.isActive()) return false; @@ -284,7 +283,8 @@ bool PetitionTurnInAction::isUseful() } return inCity && !bot->GetGuildId() && AI_VALUE2(uint32, "item count", chat->FormatQItem(5863)) && - AI_VALUE(uint8, "petition signs") >= sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS) && !context->GetValue("travel target")->Get()->isTraveling(); + AI_VALUE(uint8, "petition signs") >= sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS) && + !context->GetValue("travel target")->Get()->isTraveling(); } bool BuyTabardAction::Execute(Event event) @@ -295,10 +295,10 @@ bool BuyTabardAction::Execute(Event event) TravelTarget* oldTarget = context->GetValue("travel target")->Get(); - //Select a new target to travel to. + // Select a new target to travel to. TravelTarget newTarget = TravelTarget(botAI); - bool foundTarget = SetNpcFlagTarget(&newTarget, { UNIT_NPC_FLAG_TABARDDESIGNER }, "Tabard Vendor", { 5976 }); + bool foundTarget = SetNpcFlagTarget(&newTarget, {UNIT_NPC_FLAG_TABARDDESIGNER}, "Tabard Vendor", {5976}); if (!foundTarget || !newTarget.isActive()) return false; @@ -320,5 +320,6 @@ bool BuyTabardAction::isUseful() } return inCity && bot->GetGuildId() && !AI_VALUE2(uint32, "item count", chat->FormatQItem(5976)) && - AI_VALUE2(uint32, "free money for", uint32(NeedMoneyFor::guild)) >= 10000 && !context->GetValue("travel target")->Get()->isTraveling(); + AI_VALUE2(uint32, "free money for", uint32(NeedMoneyFor::guild)) >= 10000 && + !context->GetValue("travel target")->Get()->isTraveling(); } diff --git a/src/strategy/actions/GuildCreateActions.h b/src/strategy/actions/GuildCreateActions.h index ef0ba9ae..a4e7ba9b 100644 --- a/src/strategy/actions/GuildCreateActions.h +++ b/src/strategy/actions/GuildCreateActions.h @@ -1,60 +1,61 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GUILDCREATEACTION_H #define _PLAYERBOT_GUILDCREATEACTION_H -#include "InventoryAction.h" #include "ChooseTravelTargetAction.h" +#include "InventoryAction.h" class PlayerbotAI; class BuyPetitionAction : public InventoryAction { - public: - BuyPetitionAction(PlayerbotAI* botAI) : InventoryAction(botAI, "buy petition") { } +public: + BuyPetitionAction(PlayerbotAI* botAI) : InventoryAction(botAI, "buy petition") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; - static bool canBuyPetition(Player* bot); + static bool canBuyPetition(Player* bot); }; class PetitionOfferAction : public Action { - public: - PetitionOfferAction(PlayerbotAI* botAI, std::string const name = "petition offer") : Action(botAI, name) { } +public: + PetitionOfferAction(PlayerbotAI* botAI, std::string const name = "petition offer") : Action(botAI, name) {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class PetitionOfferNearbyAction : public PetitionOfferAction { - public: - PetitionOfferNearbyAction(PlayerbotAI* botAI) : PetitionOfferAction(botAI, "petition offer nearby") { } +public: + PetitionOfferNearbyAction(PlayerbotAI* botAI) : PetitionOfferAction(botAI, "petition offer nearby") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class PetitionTurnInAction : public ChooseTravelTargetAction { - public: - PetitionTurnInAction(PlayerbotAI* botAI) : ChooseTravelTargetAction(botAI, "turn in petitn") { } +public: + PetitionTurnInAction(PlayerbotAI* botAI) : ChooseTravelTargetAction(botAI, "turn in petitn") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class BuyTabardAction : public ChooseTravelTargetAction { - public: - BuyTabardAction(PlayerbotAI* botAI) : ChooseTravelTargetAction(botAI, "buy tabard") { } +public: + BuyTabardAction(PlayerbotAI* botAI) : ChooseTravelTargetAction(botAI, "buy tabard") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/GuildManagementActions.cpp b/src/strategy/actions/GuildManagementActions.cpp index 18138145..c1666fb1 100644 --- a/src/strategy/actions/GuildManagementActions.cpp +++ b/src/strategy/actions/GuildManagementActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GuildManagementActions.h" + #include "GuildMgr.h" #include "GuildPackets.h" #include "Playerbots.h" @@ -38,9 +40,9 @@ Player* GuidManageAction::GetPlayer(Event event) Player* master = GetMaster(); if (!master) - guid = bot->GetTarget(); + guid = bot->GetTarget(); else - guid = master->GetTarget(); + guid = master->GetTarget(); player = ObjectAccessor::FindPlayer(guid); @@ -50,7 +52,7 @@ Player* GuidManageAction::GetPlayer(Event event) player = event.getOwner(); if (player) - return player; + return player; return nullptr; } @@ -69,10 +71,7 @@ bool GuidManageAction::Execute(Event event) return true; } -bool GuidManageAction::PlayerIsValid(Player* member) -{ - return !member->GetGuildId(); -} +bool GuidManageAction::PlayerIsValid(Player* member) { return !member->GetGuildId(); } uint8 GuidManageAction::GetRankId(Player* member) { @@ -90,10 +89,7 @@ void GuildInviteAction::SendPacket(WorldPacket packet) bot->GetSession()->HandleGuildInviteOpcode(data); } -bool GuildInviteAction::PlayerIsValid(Player* member) -{ - return !member->GetGuildId(); -} +bool GuildInviteAction::PlayerIsValid(Player* member) { return !member->GetGuildId(); } bool GuildPromoteAction::isUseful() { @@ -158,7 +154,7 @@ bool GuildManageNearbyAction::Execute(Event event) if (!player || bot == player) continue; - if (player->GetGuildId()) //Promote or demote nearby members based on chance. + if (player->GetGuildId()) // Promote or demote nearby members based on chance. { Guild::Member* member = guild->GetMember(player->GetGUID()); uint32 dCount = AI_VALUE(uint32, "death count"); @@ -196,12 +192,11 @@ bool GuildManageNearbyAction::Execute(Event event) if (botAI) { - - if (botAI->GetGuilderType() == GuilderType::SOLO && !botAI->HasRealPlayerMaster()) //Do not invite solo players. + if (botAI->GetGuilderType() == GuilderType::SOLO && + !botAI->HasRealPlayerMaster()) // Do not invite solo players. continue; - - if (botAI->HasActivePlayerMaster()) //Do not invite alts of active players. + if (botAI->HasActivePlayerMaster()) // Do not invite alts of active players. continue; } else @@ -245,7 +240,4 @@ bool GuildLeaveAction::Execute(Event event) return true; } -bool GuildLeaveAction::isUseful() -{ - return bot->GetGuildId(); -} +bool GuildLeaveAction::isUseful() { return bot->GetGuildId(); } diff --git a/src/strategy/actions/GuildManagementActions.h b/src/strategy/actions/GuildManagementActions.h index a3d7e286..99186351 100644 --- a/src/strategy/actions/GuildManagementActions.h +++ b/src/strategy/actions/GuildManagementActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GUILDMAMANEGEMENTACTION_H @@ -14,85 +15,100 @@ class WorldPacket; class GuidManageAction : public Action { - public: - GuidManageAction(PlayerbotAI* botAI, std::string const name = "guild manage", uint16 opcode = CMSG_GUILD_INVITE) : Action(botAI, name), opcode(opcode) { } +public: + GuidManageAction(PlayerbotAI* botAI, std::string const name = "guild manage", uint16 opcode = CMSG_GUILD_INVITE) + : Action(botAI, name), opcode(opcode) + { + } - bool Execute(Event event) override; - bool isUseful() override { return false; } + bool Execute(Event event) override; + bool isUseful() override { return false; } - protected: - virtual void SendPacket(WorldPacket data) { }; - virtual Player* GetPlayer(Event event); - virtual bool PlayerIsValid(Player* member); - virtual uint8 GetRankId(Player* member); +protected: + virtual void SendPacket(WorldPacket data){}; + virtual Player* GetPlayer(Event event); + virtual bool PlayerIsValid(Player* member); + virtual uint8 GetRankId(Player* member); - uint16 opcode; + uint16 opcode; }; class GuildInviteAction : public GuidManageAction { - public: - GuildInviteAction(PlayerbotAI* botAI, std::string const name = "guild invite", uint16 opcode = CMSG_GUILD_INVITE) : GuidManageAction(botAI, name, opcode) { } +public: + GuildInviteAction(PlayerbotAI* botAI, std::string const name = "guild invite", uint16 opcode = CMSG_GUILD_INVITE) + : GuidManageAction(botAI, name, opcode) + { + } - bool isUseful() override; + bool isUseful() override; - protected: - void SendPacket(WorldPacket data) override; - bool PlayerIsValid(Player* member) override; +protected: + void SendPacket(WorldPacket data) override; + bool PlayerIsValid(Player* member) override; }; class GuildPromoteAction : public GuidManageAction { - public: - GuildPromoteAction(PlayerbotAI* botAI, std::string const name = "guild promote", uint16 opcode = CMSG_GUILD_PROMOTE) : GuidManageAction(botAI, name, opcode) { } +public: + GuildPromoteAction(PlayerbotAI* botAI, std::string const name = "guild promote", uint16 opcode = CMSG_GUILD_PROMOTE) + : GuidManageAction(botAI, name, opcode) + { + } - bool isUseful() override; + bool isUseful() override; - protected: - void SendPacket(WorldPacket data) override; - bool PlayerIsValid(Player* member) override; +protected: + void SendPacket(WorldPacket data) override; + bool PlayerIsValid(Player* member) override; }; class GuildDemoteAction : public GuidManageAction { - public: - GuildDemoteAction(PlayerbotAI* botAI, std::string const name = "guild demote", uint16 opcode = CMSG_GUILD_DEMOTE) : GuidManageAction(botAI, name, opcode) { } +public: + GuildDemoteAction(PlayerbotAI* botAI, std::string const name = "guild demote", uint16 opcode = CMSG_GUILD_DEMOTE) + : GuidManageAction(botAI, name, opcode) + { + } - bool isUseful() override; + bool isUseful() override; - protected: - void SendPacket(WorldPacket data) override; - bool PlayerIsValid(Player* member) override; +protected: + void SendPacket(WorldPacket data) override; + bool PlayerIsValid(Player* member) override; }; class GuildRemoveAction : public GuidManageAction { - public: - GuildRemoveAction(PlayerbotAI* botAI, std::string const name = "guild remove", uint16 opcode = CMSG_GUILD_REMOVE) : GuidManageAction(botAI, name, opcode) { } +public: + GuildRemoveAction(PlayerbotAI* botAI, std::string const name = "guild remove", uint16 opcode = CMSG_GUILD_REMOVE) + : GuidManageAction(botAI, name, opcode) + { + } - bool isUseful() override; + bool isUseful() override; - protected: - void SendPacket(WorldPacket data) override; - bool PlayerIsValid(Player* member) override; +protected: + void SendPacket(WorldPacket data) override; + bool PlayerIsValid(Player* member) override; }; class GuildManageNearbyAction : public Action { - public: - GuildManageNearbyAction(PlayerbotAI* botAI) : Action(botAI, "guild manage nearby") { } +public: + GuildManageNearbyAction(PlayerbotAI* botAI) : Action(botAI, "guild manage nearby") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class GuildLeaveAction : public Action { - public: - GuildLeaveAction(PlayerbotAI* botAI) : Action(botAI, "guild leave") { } +public: + GuildLeaveAction(PlayerbotAI* botAI) : Action(botAI, "guild leave") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/HelpAction.cpp b/src/strategy/actions/HelpAction.cpp index d452b996..6f0ef2ce 100644 --- a/src/strategy/actions/HelpAction.cpp +++ b/src/strategy/actions/HelpAction.cpp @@ -1,21 +1,17 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HelpAction.h" + #include "ChatActionContext.h" #include "Event.h" #include "Playerbots.h" -HelpAction::HelpAction(PlayerbotAI* botAI) : Action(botAI, "help") -{ - chatContext = new ChatActionContext(); -} +HelpAction::HelpAction(PlayerbotAI* botAI) : Action(botAI, "help") { chatContext = new ChatActionContext(); } -HelpAction::~HelpAction() -{ - delete chatContext; -} +HelpAction::~HelpAction() { delete chatContext; } bool HelpAction::Execute(Event event) { @@ -45,12 +41,12 @@ std::string const HelpAction::CombineSupported(std::set commands) { std::ostringstream out; - for (std::set::iterator i = commands.begin(); i != commands.end(); ) - { + for (std::set::iterator i = commands.begin(); i != commands.end();) + { out << *i; - if (++i != commands.end()) - out << ", "; - } + if (++i != commands.end()) + out << ", "; + } return out.str(); } diff --git a/src/strategy/actions/HelpAction.h b/src/strategy/actions/HelpAction.h index 9baa84ff..0481bb0d 100644 --- a/src/strategy/actions/HelpAction.h +++ b/src/strategy/actions/HelpAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HELPACTION_H @@ -12,18 +13,18 @@ class PlayerbotAI; class HelpAction : public Action { - public: - HelpAction(PlayerbotAI* botAI); +public: + HelpAction(PlayerbotAI* botAI); - virtual ~HelpAction(); - bool Execute(Event event) override; + virtual ~HelpAction(); + bool Execute(Event event) override; - private: - void TellChatCommands(); - void TellStrategies(); - std::string const CombineSupported(std::set commands); +private: + void TellChatCommands(); + void TellStrategies(); + std::string const CombineSupported(std::set commands); - NamedObjectContext* chatContext; + NamedObjectContext* chatContext; }; #endif diff --git a/src/strategy/actions/HireAction.cpp b/src/strategy/actions/HireAction.cpp index f910843d..6ad575fc 100644 --- a/src/strategy/actions/HireAction.cpp +++ b/src/strategy/actions/HireAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HireAction.h" + #include "Event.h" #include "Playerbots.h" @@ -43,7 +45,8 @@ bool HireAction::Execute(Event event) if (discount < moneyReq) { std::ostringstream out; - out << "You cannot hire me - I barely know you. Make sure you have at least " << chat->formatMoney(moneyReq) << " as a trade discount"; + out << "You cannot hire me - I barely know you. Make sure you have at least " << chat->formatMoney(moneyReq) + << " as a trade discount"; botAI->TellMaster(out.str()); return false; } @@ -52,7 +55,8 @@ bool HireAction::Execute(Event event) bot->SetMoney(moneyReq); sRandomPlayerbotMgr->Remove(bot); - CharacterDatabase.Execute("UPDATE characters SET account = {} WHERE guid = {}", account, bot->GetGUID().GetCounter()); + CharacterDatabase.Execute("UPDATE characters SET account = {} WHERE guid = {}", account, + bot->GetGUID().GetCounter()); return true; } diff --git a/src/strategy/actions/HireAction.h b/src/strategy/actions/HireAction.h index cb423dd5..96f38527 100644 --- a/src/strategy/actions/HireAction.h +++ b/src/strategy/actions/HireAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HIREACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class HireAction : public Action { - public: - HireAction(PlayerbotAI* botAI) : Action(botAI, "hire") { } +public: + HireAction(PlayerbotAI* botAI) : Action(botAI, "hire") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ImbueAction.cpp b/src/strategy/actions/ImbueAction.cpp index 60f3de32..158bd099 100644 --- a/src/strategy/actions/ImbueAction.cpp +++ b/src/strategy/actions/ImbueAction.cpp @@ -1,14 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ImbueAction.h" + #include "Event.h" #include "Playerbots.h" -ImbueWithPoisonAction::ImbueWithPoisonAction(PlayerbotAI* botAI) : Action(botAI, "apply poison") -{ -} +ImbueWithPoisonAction::ImbueWithPoisonAction(PlayerbotAI* botAI) : Action(botAI, "apply poison") {} bool ImbueWithPoisonAction::Execute(Event event) { @@ -65,9 +65,7 @@ bool ImbueWithPoisonAction::Execute(Event event) } // Search and apply stone to weapons -ImbueWithStoneAction::ImbueWithStoneAction(PlayerbotAI* botAI) : Action(botAI, "apply stone") -{ -} +ImbueWithStoneAction::ImbueWithStoneAction(PlayerbotAI* botAI) : Action(botAI, "apply stone") {} bool ImbueWithStoneAction::Execute(Event event) { @@ -112,9 +110,7 @@ bool ImbueWithStoneAction::Execute(Event event) } // Search and apply oil to weapons -ImbueWithOilAction::ImbueWithOilAction(PlayerbotAI* botAI) : Action(botAI, "apply oil") -{ -} +ImbueWithOilAction::ImbueWithOilAction(PlayerbotAI* botAI) : Action(botAI, "apply oil") {} bool ImbueWithOilAction::Execute(Event event) { @@ -145,16 +141,29 @@ bool ImbueWithOilAction::Execute(Event event) return true; } -static const uint32 uPriorizedHealingItemIds[19] = -{ - HEALTHSTONE_DISPLAYID, FEL_REGENERATION_POTION, SUPER_HEALING_POTION, CRYSTAL_HEALING_POTION, MAJOR_DREAMLESS_SLEEP_POTION, VOLATILE_HEALING_POTION, - MAJOR_HEALING_POTION, WHIPPER_ROOT_TUBER, NIGHT_DRAGON_BREATH, LIMITED_INVULNERABILITY_POTION, GREATER_DREAMLESS_SLEEP_POTION, - SUPERIOR_HEALING_POTION, CRYSTAL_RESTORE, DREAMLESS_SLEEP_POTION, GREATER_HEALING_POTION, HEALING_POTION, LESSER_HEALING_POTION, DISCOLORED_HEALING_POTION, MINOR_HEALING_POTION, +static const uint32 uPriorizedHealingItemIds[19] = { + HEALTHSTONE_DISPLAYID, + FEL_REGENERATION_POTION, + SUPER_HEALING_POTION, + CRYSTAL_HEALING_POTION, + MAJOR_DREAMLESS_SLEEP_POTION, + VOLATILE_HEALING_POTION, + MAJOR_HEALING_POTION, + WHIPPER_ROOT_TUBER, + NIGHT_DRAGON_BREATH, + LIMITED_INVULNERABILITY_POTION, + GREATER_DREAMLESS_SLEEP_POTION, + SUPERIOR_HEALING_POTION, + CRYSTAL_RESTORE, + DREAMLESS_SLEEP_POTION, + GREATER_HEALING_POTION, + HEALING_POTION, + LESSER_HEALING_POTION, + DISCOLORED_HEALING_POTION, + MINOR_HEALING_POTION, }; -TryEmergencyAction::TryEmergencyAction(PlayerbotAI* botAI) : Action(botAI, "try emergency") -{ -} +TryEmergencyAction::TryEmergencyAction(PlayerbotAI* botAI) : Action(botAI, "try emergency") {} bool TryEmergencyAction::Execute(Event event) { @@ -163,7 +172,7 @@ bool TryEmergencyAction::Execute(Event event) return false; // If bot does not have aggro: use bandage instead of potion/stone/crystal - if ((!AI_VALUE(uint8, "my attacker count")) && !bot->HasAura(11196)) // Recently bandaged + if ((!AI_VALUE(uint8, "my attacker count")) && !bot->HasAura(11196)) // Recently bandaged { if (Item* bandage = botAI->FindBandage()) { @@ -183,4 +192,3 @@ bool TryEmergencyAction::Execute(Event event) return true; } - diff --git a/src/strategy/actions/ImbueAction.h b/src/strategy/actions/ImbueAction.h index 14f26277..ca317c7d 100644 --- a/src/strategy/actions/ImbueAction.h +++ b/src/strategy/actions/ImbueAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_IMBUEACTION_H @@ -19,26 +20,26 @@ public: class ImbueWithStoneAction : public Action { - public: - ImbueWithStoneAction(PlayerbotAI* botAI); +public: + ImbueWithStoneAction(PlayerbotAI* botAI); - bool Execute(Event event) override; + bool Execute(Event event) override; }; class ImbueWithOilAction : public Action { - public: - ImbueWithOilAction(PlayerbotAI* botAI); +public: + ImbueWithOilAction(PlayerbotAI* botAI); - bool Execute(Event event) override; + bool Execute(Event event) override; }; class TryEmergencyAction : public Action { - public: - TryEmergencyAction(PlayerbotAI* botAI); +public: + TryEmergencyAction(PlayerbotAI* botAI); - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/InventoryAction.cpp b/src/strategy/actions/InventoryAction.cpp index d9753574..d2d54da1 100644 --- a/src/strategy/actions/InventoryAction.cpp +++ b/src/strategy/actions/InventoryAction.cpp @@ -1,11 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "InventoryAction.h" + #include "Event.h" -#include "ItemVisitors.h" #include "ItemCountValue.h" +#include "ItemVisitors.h" #include "Playerbots.h" void InventoryAction::IterateItems(IterateItemsVisitor* visitor, IterateItemsMask mask) @@ -23,18 +25,18 @@ void InventoryAction::IterateItems(IterateItemsVisitor* visitor, IterateItemsMas void InventoryAction::IterateItemsInBags(IterateItemsVisitor* visitor) { for (uint32 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) - if (Item *pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + if (Item* pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (!visitor->Visit(pItem)) return; for (uint32 i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; ++i) - if (Item *pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + if (Item* pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (!visitor->Visit(pItem)) return; for (uint32 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - if (Bag *pBag = (Bag*)bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - for(uint32 j = 0; j < pBag->GetBagSize(); ++j) + if (Bag* pBag = (Bag*)bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) + for (uint32 j = 0; j < pBag->GetBagSize(); ++j) if (Item* pItem = pBag->GetItemByPos(j)) if (!visitor->Visit(pItem)) return; @@ -58,7 +60,7 @@ void InventoryAction::IterateItemsInBank(IterateItemsVisitor* visitor) for (uint8 slot = BANK_SLOT_ITEM_START; slot < BANK_SLOT_ITEM_END; slot++) { Item* const pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); - if(!pItem) + if (!pItem) continue; if (!visitor->Visit(pItem)) @@ -75,7 +77,7 @@ void InventoryAction::IterateItemsInBank(IterateItemsVisitor* visitor) { if (Item* pItem = pBag->GetItemByPos(j)) { - if(!pItem) + if (!pItem) continue; if (!visitor->Visit(pItem)) @@ -223,7 +225,8 @@ std::vector InventoryAction::parseItems(std::string const text, IterateIt IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS); found.insert(visitor.GetResult().begin(), visitor.GetResult().end()); - if (found.empty()) { + if (found.empty()) + { FindFoodVisitor visitor(bot, 11); IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS); found.insert(visitor.GetResult().begin(), visitor.GetResult().end()); @@ -355,7 +358,6 @@ uint32 InventoryAction::GetItemCount(FindItemVisitor* visitor, IterateItemsMask return count; } - ItemIds InventoryAction::FindOutfitItems(std::string const name) { std::vector& outfits = AI_VALUE(std::vector&, "outfit list"); diff --git a/src/strategy/actions/InventoryAction.h b/src/strategy/actions/InventoryAction.h index f8a3bdf7..f7fd6cd2 100644 --- a/src/strategy/actions/InventoryAction.h +++ b/src/strategy/actions/InventoryAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_INVENTORYACTION_H @@ -14,23 +15,23 @@ struct ItemTemplate; class InventoryAction : public Action { - public: - InventoryAction(PlayerbotAI* botAI, std::string const name) : Action(botAI, name) { } +public: + InventoryAction(PlayerbotAI* botAI, std::string const name) : Action(botAI, name) {} - protected: - void IterateItems(IterateItemsVisitor* visitor, IterateItemsMask mask = ITERATE_ITEMS_IN_BAGS); - void TellItems(std::map items, std::map soulbound); - void TellItem(ItemTemplate const* proto, uint32 count, bool soulbound); - std::vector parseItems(std::string const text, IterateItemsMask mask = ITERATE_ALL_ITEMS); - uint32 GetItemCount(FindItemVisitor* visitor, IterateItemsMask mask = ITERATE_ITEMS_IN_BAGS); - std::string const parseOutfitName(std::string const outfit); - ItemIds parseOutfitItems(std::string const outfit); - ItemIds FindOutfitItems(std::string const name); +protected: + void IterateItems(IterateItemsVisitor* visitor, IterateItemsMask mask = ITERATE_ITEMS_IN_BAGS); + void TellItems(std::map items, std::map soulbound); + void TellItem(ItemTemplate const* proto, uint32 count, bool soulbound); + std::vector parseItems(std::string const text, IterateItemsMask mask = ITERATE_ALL_ITEMS); + uint32 GetItemCount(FindItemVisitor* visitor, IterateItemsMask mask = ITERATE_ITEMS_IN_BAGS); + std::string const parseOutfitName(std::string const outfit); + ItemIds parseOutfitItems(std::string const outfit); + ItemIds FindOutfitItems(std::string const name); - private: - void IterateItemsInBags(IterateItemsVisitor* visitor); - void IterateItemsInEquip(IterateItemsVisitor* visitor); - void IterateItemsInBank(IterateItemsVisitor* visitor); +private: + void IterateItemsInBags(IterateItemsVisitor* visitor); + void IterateItemsInEquip(IterateItemsVisitor* visitor); + void IterateItemsInBank(IterateItemsVisitor* visitor); }; #endif diff --git a/src/strategy/actions/InventoryChangeFailureAction.cpp b/src/strategy/actions/InventoryChangeFailureAction.cpp index 6184b643..238fa945 100644 --- a/src/strategy/actions/InventoryChangeFailureAction.cpp +++ b/src/strategy/actions/InventoryChangeFailureAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "InventoryChangeFailureAction.h" + #include "Event.h" #include "Playerbots.h" diff --git a/src/strategy/actions/InventoryChangeFailureAction.h b/src/strategy/actions/InventoryChangeFailureAction.h index beddf20c..a8596adb 100644 --- a/src/strategy/actions/InventoryChangeFailureAction.h +++ b/src/strategy/actions/InventoryChangeFailureAction.h @@ -1,24 +1,25 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_INVENTORYCHANGEFAILUREACTION_H #define _PLAYERBOT_INVENTORYCHANGEFAILUREACTION_H -#include "Item.h" #include "Action.h" +#include "Item.h" class PlayerbotAI; class InventoryChangeFailureAction : public Action { - public: - InventoryChangeFailureAction(PlayerbotAI* botAI) : Action(botAI, "inventory change failure") { } +public: + InventoryChangeFailureAction(PlayerbotAI* botAI) : Action(botAI, "inventory change failure") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - static std::map messages; +private: + static std::map messages; }; #endif diff --git a/src/strategy/actions/InviteToGroupAction.cpp b/src/strategy/actions/InviteToGroupAction.cpp index 58094fc6..d56fdf3b 100644 --- a/src/strategy/actions/InviteToGroupAction.cpp +++ b/src/strategy/actions/InviteToGroupAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "InviteToGroupAction.h" + #include "Event.h" #include "GuildMgr.h" #include "Playerbots.h" @@ -48,10 +50,11 @@ bool InviteNearbyToGroupAction::Execute(Event event) if (botAI) { - if (botAI->GetGrouperType() == GrouperType::SOLO && !botAI->HasRealPlayerMaster()) // Do not invite solo players. + if (botAI->GetGrouperType() == GrouperType::SOLO && + !botAI->HasRealPlayerMaster()) // Do not invite solo players. continue; - if (botAI->HasActivePlayerMaster()) // Do not invite alts of active players. + if (botAI->HasActivePlayerMaster()) // Do not invite alts of active players. continue; } else @@ -97,7 +100,7 @@ bool InviteNearbyToGroupAction::isUseful() return false; } - if (botAI->HasActivePlayerMaster()) // Alts do not invite randomly + if (botAI->HasActivePlayerMaster()) // Alts do not invite randomly return false; return true; @@ -129,13 +132,15 @@ bool InviteGuildToGroupAction::Execute(Event event) if (botAI) { - if (botAI->GetGrouperType() == GrouperType::SOLO && !botAI->HasRealPlayerMaster()) //Do not invite solo players. + if (botAI->GetGrouperType() == GrouperType::SOLO && + !botAI->HasRealPlayerMaster()) // Do not invite solo players. continue; - if (botAI->HasActivePlayerMaster()) //Do not invite alts of active players. + if (botAI->HasActivePlayerMaster()) // Do not invite alts of active players. continue; - if (player->GetLevel() > bot->GetLevel() + 5) // Only invite higher levels that need money so they can grind money and help out. + if (player->GetLevel() > + bot->GetLevel() + 5) // Only invite higher levels that need money so they can grind money and help out. { AiObjectContext* botContext = botAI->GetAiObjectContext(); @@ -161,7 +166,4 @@ bool InviteGuildToGroupAction::Execute(Event event) return false; } -bool InviteGuildToGroupAction::isUseful() -{ - return bot->GetGuildId() && InviteNearbyToGroupAction::isUseful(); -}; +bool InviteGuildToGroupAction::isUseful() { return bot->GetGuildId() && InviteNearbyToGroupAction::isUseful(); }; diff --git a/src/strategy/actions/InviteToGroupAction.h b/src/strategy/actions/InviteToGroupAction.h index 8b8fa7f7..3564ebb0 100644 --- a/src/strategy/actions/InviteToGroupAction.h +++ b/src/strategy/actions/InviteToGroupAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_INVITETOGROUPACTION_H @@ -12,53 +13,53 @@ class PlayerbotAI; class InviteToGroupAction : public Action { - public: - InviteToGroupAction(PlayerbotAI* botAI, std::string const name = "invite") : Action(botAI, name) { } +public: + InviteToGroupAction(PlayerbotAI* botAI, std::string const name = "invite") : Action(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; - virtual bool Invite(Player* player); + virtual bool Invite(Player* player); }; class InviteNearbyToGroupAction : public InviteToGroupAction { - public: - InviteNearbyToGroupAction(PlayerbotAI* botAI, std::string const name = "invite nearby") : InviteToGroupAction(botAI, name) { } +public: + InviteNearbyToGroupAction(PlayerbotAI* botAI, std::string const name = "invite nearby") + : InviteToGroupAction(botAI, name) + { + } - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; -//Generic guid member finder +// Generic guid member finder class FindGuildMembers { - public: - FindGuildMembers() { }; +public: + FindGuildMembers(){}; - void operator()(Player* player) - { - data.push_back(player); - }; + void operator()(Player* player) { data.push_back(player); }; - std::vector const GetResult() - { - return data; - }; + std::vector const GetResult() { return data; }; - private: - std::vector data; +private: + std::vector data; }; class InviteGuildToGroupAction : public InviteNearbyToGroupAction { - public: - InviteGuildToGroupAction(PlayerbotAI* botAI, std::string const name = "invite guild") : InviteNearbyToGroupAction(botAI, name) { } +public: + InviteGuildToGroupAction(PlayerbotAI* botAI, std::string const name = "invite guild") + : InviteNearbyToGroupAction(botAI, name) + { + } - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; - private: - std::vector getGuildMembers(); +private: + std::vector getGuildMembers(); }; #endif diff --git a/src/strategy/actions/LeaveGroupAction.cpp b/src/strategy/actions/LeaveGroupAction.cpp index 433d45e7..8acbe2d0 100644 --- a/src/strategy/actions/LeaveGroupAction.cpp +++ b/src/strategy/actions/LeaveGroupAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LeaveGroupAction.h" + #include "Event.h" #include "PlayerbotAIConfig.h" #include "Playerbots.h" @@ -66,7 +68,8 @@ bool UninviteAction::Execute(Event event) bool LeaveGroupAction::Leave(Player* player) { - if (player && !GET_PLAYERBOT_AI(player) && !botAI->GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_INVITE, false, player)) + if (player && !GET_PLAYERBOT_AI(player) && + !botAI->GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_INVITE, false, player)) return false; bool aiMaster = GET_PLAYERBOT_AI(botAI->GetMaster()) != nullptr; @@ -95,10 +98,7 @@ bool LeaveGroupAction::Leave(Player* player) return true; } -bool LeaveFarAwayAction::Execute(Event event) -{ - return Leave(nullptr); -} +bool LeaveFarAwayAction::Execute(Event event) { return Leave(nullptr); } bool LeaveFarAwayAction::isUseful() { @@ -128,7 +128,8 @@ bool LeaveFarAwayAction::isUseful() if (trueMaster && !GET_PLAYERBOT_AI(trueMaster)) return false; - if (botAI->IsAlt() && (!masterBotAI || masterBotAI->IsRealPlayer())) // Don't leave group when alt grouped with player master. + if (botAI->IsAlt() && + (!masterBotAI || masterBotAI->IsRealPlayer())) // Don't leave group when alt grouped with player master. return false; if (botAI->GetGrouperType() == GrouperType::SOLO) @@ -154,9 +155,10 @@ bool LeaveFarAwayAction::isUseful() if (abs(int32(master->GetLevel() - bot->GetLevel())) > 4) return true; - if (bot->GetMapId() != master->GetMapId() || bot->GetDistance2d(master) >= 2 * sPlayerbotAIConfig->rpgDistance) { + if (bot->GetMapId() != master->GetMapId() || bot->GetDistance2d(master) >= 2 * sPlayerbotAIConfig->rpgDistance) + { return true; } - + return false; } diff --git a/src/strategy/actions/LeaveGroupAction.h b/src/strategy/actions/LeaveGroupAction.h index b9703f3c..824b9055 100644 --- a/src/strategy/actions/LeaveGroupAction.h +++ b/src/strategy/actions/LeaveGroupAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LEAVEGROUPACTION_H @@ -12,37 +13,37 @@ class PlayerbotAI; class LeaveGroupAction : public Action { - public: - LeaveGroupAction(PlayerbotAI* botAI, std::string const name = "leave") : Action(botAI, name) { } +public: + LeaveGroupAction(PlayerbotAI* botAI, std::string const name = "leave") : Action(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; - virtual bool Leave(Player* player); + virtual bool Leave(Player* player); }; class PartyCommandAction : public LeaveGroupAction { - public: - PartyCommandAction(PlayerbotAI* botAI) : LeaveGroupAction(botAI, "party command") { } +public: + PartyCommandAction(PlayerbotAI* botAI) : LeaveGroupAction(botAI, "party command") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class UninviteAction : public LeaveGroupAction { - public: - UninviteAction(PlayerbotAI* botAI) : LeaveGroupAction(botAI, "uninvite") { } +public: + UninviteAction(PlayerbotAI* botAI) : LeaveGroupAction(botAI, "uninvite") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class LeaveFarAwayAction : public LeaveGroupAction { - public: - LeaveFarAwayAction(PlayerbotAI* botAI) : LeaveGroupAction(botAI, "leave far away") { } +public: + LeaveFarAwayAction(PlayerbotAI* botAI) : LeaveGroupAction(botAI, "leave far away") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/LfgActions.cpp b/src/strategy/actions/LfgActions.cpp index d7e7b865..cac31678 100644 --- a/src/strategy/actions/LfgActions.cpp +++ b/src/strategy/actions/LfgActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LfgActions.h" + #include "AiFactory.h" #include "ItemVisitors.h" #include "LFGMgr.h" @@ -10,10 +12,7 @@ using namespace lfg; -bool LfgJoinAction::Execute(Event event) -{ - return JoinLFG(); -} +bool LfgJoinAction::Execute(Event event) { return JoinLFG(); } uint32 LfgJoinAction::GetRoles() { @@ -87,8 +86,11 @@ bool LfgJoinAction::JoinLFG() ItemCountByQuality visitor; IterateItems(&visitor, ITERATE_ITEMS_IN_EQUIP); bool random = urand(0, 100) < 20; - bool heroic = urand(0, 100) < 50 && (visitor.count[ITEM_QUALITY_EPIC] >= 3 || visitor.count[ITEM_QUALITY_RARE] >= 10) && bot->GetLevel() >= 70; - bool rbotAId = !heroic && (urand(0, 100) < 50 && visitor.count[ITEM_QUALITY_EPIC] >= 5 && (bot->GetLevel() == 60 || bot->GetLevel() == 70 || bot->GetLevel() == 80)); + bool heroic = urand(0, 100) < 50 && + (visitor.count[ITEM_QUALITY_EPIC] >= 3 || visitor.count[ITEM_QUALITY_RARE] >= 10) && + bot->GetLevel() >= 70; + bool rbotAId = !heroic && (urand(0, 100) < 50 && visitor.count[ITEM_QUALITY_EPIC] >= 5 && + (bot->GetLevel() == 60 || bot->GetLevel() == 70 || bot->GetLevel() == 80)); LfgDungeonSet list; std::vector selected; @@ -100,16 +102,15 @@ bool LfgJoinAction::JoinLFG() for (std::vector::iterator i = dungeons.begin(); i != dungeons.end(); ++i) { LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(*i); - if (!dungeon || (dungeon->TypeID != LFG_TYPE_RANDOM && dungeon->TypeID != LFG_TYPE_DUNGEON && dungeon->TypeID != LFG_TYPE_HEROIC && dungeon->TypeID != LFG_TYPE_RAID)) + if (!dungeon || (dungeon->TypeID != LFG_TYPE_RANDOM && dungeon->TypeID != LFG_TYPE_DUNGEON && + dungeon->TypeID != LFG_TYPE_HEROIC && dungeon->TypeID != LFG_TYPE_RAID)) continue; const auto& botLevel = bot->GetLevel(); - /*LFG_TYPE_RANDOM on classic is 15-58 so bot over level 25 will never queue*/ - if (dungeon->MinLevel && (botLevel < dungeon->MinLevel || botLevel > dungeon->MaxLevel) - || - (botLevel > dungeon->MinLevel + 10 && dungeon->TypeID == LFG_TYPE_DUNGEON) - ) + /*LFG_TYPE_RANDOM on classic is 15-58 so bot over level 25 will never queue*/ + if (dungeon->MinLevel && (botLevel < dungeon->MinLevel || botLevel > dungeon->MaxLevel) || + (botLevel > dungeon->MinLevel + 10 && dungeon->TypeID == LFG_TYPE_DUNGEON)) continue; selected.push_back(dungeon->ID); @@ -137,9 +138,9 @@ bool LfgJoinAction::JoinLFG() if (roleMask & PLAYER_ROLE_DAMAGE) _roles = "DPS"; - LOG_INFO("playerbots", "Bot {} {}:{} <{}>: queues LFG, Dungeon as {} ({})", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", - bot->GetLevel(), bot->GetName().c_str(), _roles, many ? "several dungeons" : dungeon->Name[0]); + LOG_INFO("playerbots", "Bot {} {}:{} <{}>: queues LFG, Dungeon as {} ({})", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str(), _roles, + many ? "several dungeons" : dungeon->Name[0]); // Set RbotAId Browser comment std::string const _gs = std::to_string(botAI->GetEquipGearScore(bot, false, false)); @@ -161,8 +162,8 @@ bool LfgRoleCheckAction::Execute(Event event) sLFGMgr->UpdateRoleCheck(group->GetGUID(), bot->GetGUID(), newRoles); - LOG_INFO("playerbots", "Bot {} {}:{} <{}>: LFG roles checked", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); + LOG_INFO("playerbots", "Bot {} {}:{} <{}>: LFG roles checked", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); return true; } @@ -179,19 +180,20 @@ bool LfgAcceptAction::Execute(Event event) uint32 id = AI_VALUE(uint32, "lfg proposal"); if (id) { - //if (urand(0, 1 + 10 / sPlayerbotAIConfig->randomChangeMultiplier)) - // return false; + // if (urand(0, 1 + 10 / sPlayerbotAIConfig->randomChangeMultiplier)) + // return false; if (bot->IsInCombat() || bot->isDead()) { LOG_INFO("playerbots", "Bot {} {}:{} <{}> is in combat and refuses LFG proposal {}", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str(), id); + bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + bot->GetName().c_str(), id); sLFGMgr->UpdateProposal(id, bot->GetGUID(), false); return true; } - LOG_INFO("playerbots", "Bot {} {}:{} <{}> accepts LFG proposal {}", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str(), id); + LOG_INFO("playerbots", "Bot {} {}:{} <{}> accepts LFG proposal {}", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str(), id); botAI->GetAiObjectContext()->GetValue("lfg proposal")->Set(0); @@ -203,7 +205,7 @@ bool LfgAcceptAction::Execute(Event event) { sRandomPlayerbotMgr->Refresh(bot); botAI->ResetStrategies(); - //bot->TeleportToHomebind(); + // bot->TeleportToHomebind(); } botAI->Reset(); @@ -225,7 +227,7 @@ bool LfgAcceptAction::Execute(Event event) bool LfgLeaveAction::Execute(Event event) { // Don't leave if lfg strategy enabled - //if (botAI->HasStrategy("lfg", BOT_STATE_NON_COMBAT)) + // if (botAI->HasStrategy("lfg", BOT_STATE_NON_COMBAT)) // return false; // Don't leave if already invited / in dungeon @@ -236,10 +238,7 @@ bool LfgLeaveAction::Execute(Event event) return true; } -bool LfgLeaveAction::isUseful() -{ - return true; -} +bool LfgLeaveAction::isUseful() { return true; } bool LfgTeleportAction::Execute(Event event) { @@ -263,16 +262,17 @@ bool LfgJoinAction::isUseful() { if (!sPlayerbotAIConfig->randomBotJoinLfg) { - //botAI->ChangeStrategy("-lfg", BOT_STATE_NON_COMBAT); + // botAI->ChangeStrategy("-lfg", BOT_STATE_NON_COMBAT); return false; } if (bot->GetLevel() < 15) return false; - if ((botAI->GetMaster() && !GET_PLAYERBOT_AI(botAI->GetMaster())) || bot->GetGroup() && bot->GetGroup()->GetLeaderGUID() != bot->GetGUID()) + if ((botAI->GetMaster() && !GET_PLAYERBOT_AI(botAI->GetMaster())) || + bot->GetGroup() && bot->GetGroup()->GetLeaderGUID() != bot->GetGUID()) { - //botAI->ChangeStrategy("-lfg", BOT_STATE_NON_COMBAT); + // botAI->ChangeStrategy("-lfg", BOT_STATE_NON_COMBAT); return false; } diff --git a/src/strategy/actions/LfgActions.h b/src/strategy/actions/LfgActions.h index 60e5596c..9f23389b 100644 --- a/src/strategy/actions/LfgActions.h +++ b/src/strategy/actions/LfgActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LFGACTIONS_H @@ -11,50 +12,50 @@ class PlayerbotAI; class LfgJoinAction : public InventoryAction { - public: - LfgJoinAction(PlayerbotAI* botAI, std::string const name = "lfg join") : InventoryAction(botAI, name) { } +public: + LfgJoinAction(PlayerbotAI* botAI, std::string const name = "lfg join") : InventoryAction(botAI, name) {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; - protected: - bool JoinLFG(); - uint32 GetRoles(); +protected: + bool JoinLFG(); + uint32 GetRoles(); }; class LfgAcceptAction : public LfgJoinAction { - public: - LfgAcceptAction(PlayerbotAI* botAI) : LfgJoinAction(botAI, "lfg accept") { } +public: + LfgAcceptAction(PlayerbotAI* botAI) : LfgJoinAction(botAI, "lfg accept") {} - bool Execute(Event event) override; - bool isUseful() override { return true; } + bool Execute(Event event) override; + bool isUseful() override { return true; } }; class LfgRoleCheckAction : public LfgJoinAction { - public: - LfgRoleCheckAction(PlayerbotAI* botAI) : LfgJoinAction(botAI, "lfg role check") { } +public: + LfgRoleCheckAction(PlayerbotAI* botAI) : LfgJoinAction(botAI, "lfg role check") {} - bool Execute(Event event) override; - bool isUseful() override { return true; } + bool Execute(Event event) override; + bool isUseful() override { return true; } }; class LfgLeaveAction : public Action { - public: - LfgLeaveAction(PlayerbotAI* botAI) : Action(botAI, "lfg leave") { } +public: + LfgLeaveAction(PlayerbotAI* botAI) : Action(botAI, "lfg leave") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class LfgTeleportAction : public Action { - public: - LfgTeleportAction(PlayerbotAI* botAI) : Action(botAI, "lfg teleport") { } +public: + LfgTeleportAction(PlayerbotAI* botAI) : Action(botAI, "lfg teleport") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ListQuestsActions.cpp b/src/strategy/actions/ListQuestsActions.cpp index 569d0230..7f5d9878 100644 --- a/src/strategy/actions/ListQuestsActions.cpp +++ b/src/strategy/actions/ListQuestsActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ListQuestsActions.h" + #include "Event.h" #include "Playerbots.h" @@ -54,7 +56,8 @@ void ListQuestsAction::ListQuests(QuestListFilter filter, QuestTravelDetail trav botAI->TellMaster("--- Summary ---"); std::ostringstream out; - out << "Total: " << (completeCount + incompleteCount) << " / 25 (incompleted: " << incompleteCount << ", completed: " << completeCount << ")"; + out << "Total: " << (completeCount + incompleteCount) << " / 25 (incompleted: " << incompleteCount + << ", completed: " << completeCount << ")"; botAI->TellMaster(out); } @@ -86,7 +89,8 @@ uint32 ListQuestsAction::ListQuests(bool completed, bool silent, QuestTravelDeta if (travelDetail != QUEST_TRAVEL_DETAIL_NONE && target->getDestination()) { - if (target->getDestination()->getName() == "QuestRelationTravelDestination" || target->getDestination()->getName() == "QuestObjectiveTravelDestination") + if (target->getDestination()->getName() == "QuestRelationTravelDestination" || + target->getDestination()->getName() == "QuestObjectiveTravelDestination") { QuestTravelDestination* QuestDestination = (QuestTravelDestination*)target->getDestination(); @@ -102,8 +106,10 @@ uint32 ListQuestsAction::ListQuests(bool completed, bool silent, QuestTravelDeta if (travelDetail == QUEST_TRAVEL_DETAIL_SUMMARY) { - std::vector allDestinations = sTravelMgr->getQuestTravelDestinations(bot, questId, true, true, -1); - std::vector availDestinations = sTravelMgr->getQuestTravelDestinations(bot, questId, botAI->GetMaster(), false, -1); + std::vector allDestinations = + sTravelMgr->getQuestTravelDestinations(bot, questId, true, true, -1); + std::vector availDestinations = + sTravelMgr->getQuestTravelDestinations(bot, questId, botAI->GetMaster(), false, -1); uint32 desTot = allDestinations.size(); uint32 desAvail = availDestinations.size(); @@ -133,14 +139,17 @@ uint32 ListQuestsAction::ListQuests(bool completed, bool silent, QuestTravelDeta else if (travelDetail == QUEST_TRAVEL_DETAIL_FULL) { uint32 limit = 0; - std::vector allDestinations = sTravelMgr->getQuestTravelDestinations(bot, questId, true, true, -1); + std::vector allDestinations = + sTravelMgr->getQuestTravelDestinations(bot, questId, true, true, -1); - std::sort(allDestinations.begin(), allDestinations.end(), [botPos](TravelDestination* i, TravelDestination* j) + std::sort(allDestinations.begin(), allDestinations.end(), + [botPos](TravelDestination* i, TravelDestination* j) { + return i->distanceTo(const_cast(&botPos)) < + j->distanceTo(const_cast(&botPos)); + }); + + for (auto dest : allDestinations) { - return i->distanceTo(const_cast(&botPos)) < j->distanceTo(const_cast(&botPos)); - }); - - for (auto dest : allDestinations) { if (limit > 5) continue; diff --git a/src/strategy/actions/ListQuestsActions.h b/src/strategy/actions/ListQuestsActions.h index f08b7f55..aea5dbad 100644 --- a/src/strategy/actions/ListQuestsActions.h +++ b/src/strategy/actions/ListQuestsActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LISTQUESTSACTIONS_H @@ -11,29 +12,29 @@ class PlayerbotAI; enum QuestListFilter { - QUEST_LIST_FILTER_SUMMARY = 0, - QUEST_LIST_FILTER_COMPLETED = 1, - QUEST_LIST_FILTER_INCOMPLETED = 2, - QUEST_LIST_FILTER_ALL = QUEST_LIST_FILTER_COMPLETED | QUEST_LIST_FILTER_INCOMPLETED + QUEST_LIST_FILTER_SUMMARY = 0, + QUEST_LIST_FILTER_COMPLETED = 1, + QUEST_LIST_FILTER_INCOMPLETED = 2, + QUEST_LIST_FILTER_ALL = QUEST_LIST_FILTER_COMPLETED | QUEST_LIST_FILTER_INCOMPLETED }; enum QuestTravelDetail { - QUEST_TRAVEL_DETAIL_NONE = 0, - QUEST_TRAVEL_DETAIL_SUMMARY = 1, - QUEST_TRAVEL_DETAIL_FULL = 2 + QUEST_TRAVEL_DETAIL_NONE = 0, + QUEST_TRAVEL_DETAIL_SUMMARY = 1, + QUEST_TRAVEL_DETAIL_FULL = 2 }; class ListQuestsAction : public Action { - public: - ListQuestsAction(PlayerbotAI* botAI) : Action(botAI, "quests") { } +public: + ListQuestsAction(PlayerbotAI* botAI) : Action(botAI, "quests") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - void ListQuests(QuestListFilter filter, QuestTravelDetail travelDetail = QUEST_TRAVEL_DETAIL_NONE); - uint32 ListQuests(bool completed, bool silent, QuestTravelDetail travelDetail); +private: + void ListQuests(QuestListFilter filter, QuestTravelDetail travelDetail = QUEST_TRAVEL_DETAIL_NONE); + uint32 ListQuests(bool completed, bool silent, QuestTravelDetail travelDetail); }; #endif diff --git a/src/strategy/actions/ListSpellsAction.cpp b/src/strategy/actions/ListSpellsAction.cpp index 36f61997..82e786a0 100644 --- a/src/strategy/actions/ListSpellsAction.cpp +++ b/src/strategy/actions/ListSpellsAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ListSpellsAction.h" + #include "Event.h" #include "Playerbots.h" @@ -13,7 +15,8 @@ bool CompareSpells(std::pair& s1, std::pairGetSpellInfo(s1.first); SpellInfo const* si2 = sSpellMgr->GetSpellInfo(s2.first); - if (!si1 || !si2) { + if (!si1 || !si2) + { LOG_ERROR("playerbots", "SpellInfo missing."); return false; } @@ -81,8 +84,7 @@ std::vector> ListSpellsAction::GetSpellList(std:: continue; vendorItems.insert(entry); - } - while (results->NextRow()); + } while (results->NextRow()); } } @@ -107,8 +109,8 @@ std::vector> ListSpellsAction::GetSpellList(std:: } } - - std::string const ignoreList = ",Opening,Closing,Stuck,Remove Insignia,Opening - No Text,Grovel,Duel,Honorless Target,"; + std::string const ignoreList = + ",Opening,Closing,Stuck,Remove Insignia,Opening - No Text,Grovel,Duel,Honorless Target,"; std::string alreadySeenList = ","; uint32 minLevel = 0; @@ -132,7 +134,7 @@ std::vector> ListSpellsAction::GetSpellList(std:: if (slot != EQUIPMENT_SLOT_END) filter = ""; - std::vector > spells; + std::vector> spells; for (PlayerSpellMap::iterator itr = bot->GetSpellMap().begin(); itr != bot->GetSpellMap().end(); ++itr) { if (itr->second->State == PLAYERSPELL_REMOVED || !itr->second->Active) @@ -215,7 +217,8 @@ std::vector> ListSpellsAction::GetSpellList(std:: out << chat->FormatItem(proto); - if ((minLevel || maxLevel) && (!proto->RequiredLevel || proto->RequiredLevel < minLevel || proto->RequiredLevel > maxLevel)) + if ((minLevel || maxLevel) && (!proto->RequiredLevel || proto->RequiredLevel < minLevel || + proto->RequiredLevel > maxLevel)) { filtered = true; break; @@ -288,7 +291,7 @@ bool ListSpellsAction::Execute(Event event) std::sort(spells.begin(), spells.end(), CompareSpells); uint32 count = 0; - for (std::vector >::iterator i = spells.begin(); i != spells.end(); ++i) + for (std::vector>::iterator i = spells.begin(); i != spells.end(); ++i) { botAI->TellMasterNoFacing(i->second); @@ -303,4 +306,3 @@ bool ListSpellsAction::Execute(Event event) return true; } - diff --git a/src/strategy/actions/ListSpellsAction.h b/src/strategy/actions/ListSpellsAction.h index 1556d303..0290c523 100644 --- a/src/strategy/actions/ListSpellsAction.h +++ b/src/strategy/actions/ListSpellsAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LISTSPELLSACTION_H @@ -11,15 +12,15 @@ class PlayerbotAI; class ListSpellsAction : public InventoryAction { - public: - ListSpellsAction(PlayerbotAI* botAI, std::string const name = "spells") : InventoryAction(botAI, name) { } +public: + ListSpellsAction(PlayerbotAI* botAI, std::string const name = "spells") : InventoryAction(botAI, name) {} - bool Execute(Event event) override; - virtual std::vector> GetSpellList(std::string filter = ""); + bool Execute(Event event) override; + virtual std::vector> GetSpellList(std::string filter = ""); - private: - static std::map skillSpells; - static std::set vendorItems; +private: + static std::map skillSpells; + static std::set vendorItems; }; #endif diff --git a/src/strategy/actions/LogLevelAction.cpp b/src/strategy/actions/LogLevelAction.cpp index 80a14b4c..0b8ff485 100644 --- a/src/strategy/actions/LogLevelAction.cpp +++ b/src/strategy/actions/LogLevelAction.cpp @@ -1,15 +1,17 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LogLevelAction.h" + #include "Event.h" #include "Playerbots.h" bool LogLevelAction::Execute(Event event) { std::string const param = event.getParam(); - Value *value = botAI->GetAiObjectContext()->GetValue("log level"); + Value* value = botAI->GetAiObjectContext()->GetValue("log level"); std::ostringstream out; if (param != "?") diff --git a/src/strategy/actions/LogLevelAction.h b/src/strategy/actions/LogLevelAction.h index 1e7f761c..8bd6c739 100644 --- a/src/strategy/actions/LogLevelAction.h +++ b/src/strategy/actions/LogLevelAction.h @@ -1,25 +1,26 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LOGLEVELACTION_H #define _PLAYERBOT_LOGLEVELACTION_H -#include "LogCommon.h" #include "Action.h" +#include "LogCommon.h" class PlayerbotAI; class LogLevelAction : public Action { - public: - LogLevelAction(PlayerbotAI* botAI) : Action(botAI, "log") { } +public: + LogLevelAction(PlayerbotAI* botAI) : Action(botAI, "log") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - public: - static std::string const logLevel2string(LogLevel level); - static LogLevel string2logLevel(std::string const level); +public: + static std::string const logLevel2string(LogLevel level); + static LogLevel string2logLevel(std::string const level); }; #endif diff --git a/src/strategy/actions/LootAction.cpp b/src/strategy/actions/LootAction.cpp index 10ae1ccc..da5747bc 100644 --- a/src/strategy/actions/LootAction.cpp +++ b/src/strategy/actions/LootAction.cpp @@ -1,18 +1,20 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LootAction.h" + #include "ChatHelper.h" #include "Event.h" -#include "ItemUsageValue.h" -#include "LootStrategyValue.h" -#include "LootObjectStack.h" +#include "GuildMgr.h" #include "GuildTaskMgr.h" +#include "ItemUsageValue.h" +#include "LootObjectStack.h" +#include "LootStrategyValue.h" #include "PlayerbotAIConfig.h" #include "Playerbots.h" #include "ServerFacade.h" -#include "GuildMgr.h" bool LootAction::Execute(Event event) { @@ -20,7 +22,8 @@ bool LootAction::Execute(Event event) return false; LootObject prevLoot = AI_VALUE(LootObject, "loot target"); - LootObject const& lootObject = AI_VALUE(LootObjectStack*, "available loot")->GetLoot(sPlayerbotAIConfig->lootDistance); + LootObject const& lootObject = + AI_VALUE(LootObjectStack*, "available loot")->GetLoot(sPlayerbotAIConfig->lootDistance); if (!prevLoot.IsEmpty() && prevLoot.guid != lootObject.guid) { @@ -33,25 +36,26 @@ bool LootAction::Execute(Event event) return true; } -bool LootAction::isUseful() { +bool LootAction::isUseful() +{ return sPlayerbotAIConfig->freeMethodLoot || !bot->GetGroup() || bot->GetGroup()->GetLootMethod() != FREE_FOR_ALL; } enum ProfessionSpells { - ALCHEMY = 2259, - BLACKSMITHING = 2018, - COOKING = 2550, - ENCHANTING = 7411, - ENGINEERING = 49383, - FIRST_AID = 3273, - FISHING = 7620, - HERB_GATHERING = 2366, - INSCRIPTION = 45357, - JEWELCRAFTING = 25229, - MINING = 2575, - SKINNING = 8613, - TAILORING = 3908 + ALCHEMY = 2259, + BLACKSMITHING = 2018, + COOKING = 2550, + ENCHANTING = 7411, + ENGINEERING = 49383, + FIRST_AID = 3273, + FISHING = 7620, + HERB_GATHERING = 2366, + INSCRIPTION = 45357, + JEWELCRAFTING = 25229, + MINING = 2575, + SKINNING = 8613, + TAILORING = 3908 }; bool OpenLootAction::Execute(Event event) @@ -85,7 +89,7 @@ bool OpenLootAction::DoLoot(LootObject& lootObject) return true; } - if (bot->isMoving()) + if (bot->isMoving()) { bot->StopMoving(); } @@ -125,7 +129,7 @@ bool OpenLootAction::DoLoot(LootObject& lootObject) uint32 spellId = GetOpeningSpell(lootObject); if (!spellId) return false; - + return botAI->CastSpell(spellId, bot); } @@ -144,15 +148,15 @@ uint32 OpenLootAction::GetOpeningSpell(LootObject& lootObject, GameObject* go) { uint32 spellId = itr->first; - if (itr->second->State == PLAYERSPELL_REMOVED || !itr->second->Active) - continue; + if (itr->second->State == PLAYERSPELL_REMOVED || !itr->second->Active) + continue; - if (spellId == MINING || spellId == HERB_GATHERING) - continue; + if (spellId == MINING || spellId == HERB_GATHERING) + continue; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); - if (!spellInfo) - continue; + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); + if (!spellInfo) + continue; if (CanOpenLock(lootObject, spellInfo, go)) return spellId; @@ -178,7 +182,8 @@ bool OpenLootAction::CanOpenLock(LootObject& lootObject, SpellInfo const* spellI { for (uint8 effIndex = 0; effIndex <= EFFECT_2; effIndex++) { - if (spellInfo->Effects[effIndex].Effect != SPELL_EFFECT_OPEN_LOCK && spellInfo->Effects[effIndex].Effect != SPELL_EFFECT_SKINNING) + if (spellInfo->Effects[effIndex].Effect != SPELL_EFFECT_OPEN_LOCK && + spellInfo->Effects[effIndex].Effect != SPELL_EFFECT_SKINNING) return false; uint32 lockId = go->GetGOInfo()->GetLockId(); @@ -189,11 +194,11 @@ bool OpenLootAction::CanOpenLock(LootObject& lootObject, SpellInfo const* spellI if (!lockInfo) return false; - bool reqKey = false; // some locks not have reqs + bool reqKey = false; // some locks not have reqs for (uint8 j = 0; j < 8; ++j) { - switch(lockInfo->Type[j]) + switch (lockInfo->Type[j]) { /* case LOCK_KEY_ITEM: @@ -308,7 +313,8 @@ uint32 stackCount = urand(1, proto->GetMaxStackSize()); item->SaveToDB(); auctionEntry->SaveToDB(); - LOG_ERROR("playerbots", "AhBot {} added {} of {} to auction {} for {}..{}", bot->GetName().c_str(), stackCount, proto->Name1.c_str(), 1, bidPrice, buyoutPrice); + LOG_ERROR("playerbots", "AhBot {} added {} of {} to auction {} for {}..{}", bot->GetName().c_str(), stackCount, +proto->Name1.c_str(), 1, bidPrice, buyoutPrice); if (oldItem->GetCount() > stackCount) oldItem->SetCount(oldItem->GetCount() - stackCount); @@ -321,20 +327,20 @@ uint32 stackCount = urand(1, proto->GetMaxStackSize()); bool StoreLootAction::Execute(Event event) { - WorldPacket p(event.getPacket()); // (8+1+4+1+1+4+4+4+4+4+1) + WorldPacket p(event.getPacket()); // (8+1+4+1+1+4+4+4+4+4+1) ObjectGuid guid; uint8 loot_type; uint32 gold = 0; uint8 items = 0; p.rpos(0); - p >> guid; // 8 corpse guid - p >> loot_type; // 1 loot type + p >> guid; // 8 corpse guid + p >> loot_type; // 1 loot type if (p.size() > 10) { - p >> gold; // 4 money on corpse - p >> items; // 1 number of items on corpse + p >> gold; // 4 money on corpse + p >> items; // 1 number of items on corpse } bot->SetLootGUID(guid); @@ -361,8 +367,8 @@ bool StoreLootAction::Execute(Event event) p.read_skip(); // randomPropertyId p >> lootslot_type; // 0 = can get, 1 = look only, 2 = master get - if (lootslot_type != LOOT_SLOT_TYPE_ALLOW_LOOT && lootslot_type != LOOT_SLOT_TYPE_OWNER) - continue; + if (lootslot_type != LOOT_SLOT_TYPE_ALLOW_LOOT && lootslot_type != LOOT_SLOT_TYPE_OWNER) + continue; if (loot_type != LOOT_SKINNING && !IsLootAllowed(itemid, botAI)) continue; @@ -417,7 +423,8 @@ 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 && bot->GetGuildId() && urand(0, 10) && + proto->Quality >= ITEM_QUALITY_RARE) { Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId()); @@ -438,8 +445,9 @@ bool StoreLootAction::Execute(Event event) // out << "Looting " << chat->FormatItem(proto); // botAI->TellMasterNoFacing(out.str()); - //ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", proto->ItemId); - //LOG_ERROR("playerbots", "Bot {} is looting {} {} for usage {}.", bot->GetName().c_str(), itemcount, proto->Name1.c_str(), usage); + // ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", proto->ItemId); + // LOG_ERROR("playerbots", "Bot {} is looting {} {} for usage {}.", bot->GetName().c_str(), itemcount, + // proto->Name1.c_str(), usage); } AI_VALUE(LootObjectStack*, "available loot")->Remove(guid); @@ -495,14 +503,14 @@ bool StoreLootAction::IsLootAllowed(uint32 itemid, PlayerbotAI* botAI) } } - //if (proto->Bonding == BIND_QUEST_ITEM || //Still testing if it works ok without these lines. - // proto->Bonding == BIND_QUEST_ITEM1 || //Eventually this has to be removed. - // proto->Class == ITEM_CLASS_QUEST) + // if (proto->Bonding == BIND_QUEST_ITEM || //Still testing if it works ok without these lines. + // proto->Bonding == BIND_QUEST_ITEM1 || //Eventually this has to be removed. + // proto->Class == ITEM_CLASS_QUEST) //{ bool canLoot = lootStrategy->CanLoot(proto, context); - //if (canLoot && proto->Bonding == BIND_WHEN_PICKED_UP && botAI->HasActivePlayerMaster()) - //canLoot = sPlayerbotAIConfig->IsInRandomAccountList(botAI->GetBot()->GetSession()->GetAccountId()); + // if (canLoot && proto->Bonding == BIND_WHEN_PICKED_UP && botAI->HasActivePlayerMaster()) + // canLoot = sPlayerbotAIConfig->IsInRandomAccountList(botAI->GetBot()->GetSession()->GetAccountId()); return canLoot; } diff --git a/src/strategy/actions/LootAction.h b/src/strategy/actions/LootAction.h index 847d8c9d..5607fc78 100644 --- a/src/strategy/actions/LootAction.h +++ b/src/strategy/actions/LootAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LOOTACTION_H @@ -15,43 +16,43 @@ class SpellInfo; class LootAction : public MovementAction { - public: - LootAction(PlayerbotAI* botAI) : MovementAction(botAI, "loot") { } +public: + LootAction(PlayerbotAI* botAI) : MovementAction(botAI, "loot") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class OpenLootAction : public MovementAction { - public: - OpenLootAction(PlayerbotAI* botAI) : MovementAction(botAI, "open loot") { } +public: + OpenLootAction(PlayerbotAI* botAI) : MovementAction(botAI, "open loot") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - bool DoLoot(LootObject& lootObject); - uint32 GetOpeningSpell(LootObject& lootObject); - uint32 GetOpeningSpell(LootObject& lootObject, GameObject* go); - bool CanOpenLock(LootObject& lootObject, SpellInfo const* spellInfo, GameObject* go); - bool CanOpenLock(uint32 skillId, uint32 reqSkillValue); +private: + bool DoLoot(LootObject& lootObject); + uint32 GetOpeningSpell(LootObject& lootObject); + uint32 GetOpeningSpell(LootObject& lootObject, GameObject* go); + bool CanOpenLock(LootObject& lootObject, SpellInfo const* spellInfo, GameObject* go); + bool CanOpenLock(uint32 skillId, uint32 reqSkillValue); }; class StoreLootAction : public InventoryAction { - public: - StoreLootAction(PlayerbotAI* botAI) : InventoryAction(botAI, "store loot") { } +public: + StoreLootAction(PlayerbotAI* botAI) : InventoryAction(botAI, "store loot") {} - bool Execute(Event event) override; - static bool IsLootAllowed(uint32 itemid, PlayerbotAI* botAI); + bool Execute(Event event) override; + static bool IsLootAllowed(uint32 itemid, PlayerbotAI* botAI); }; class ReleaseLootAction : public InventoryAction { - public: - ReleaseLootAction(PlayerbotAI* botAI) : InventoryAction(botAI, "release loot") { } +public: + ReleaseLootAction(PlayerbotAI* botAI) : InventoryAction(botAI, "release loot") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/LootRollAction.cpp b/src/strategy/actions/LootRollAction.cpp index 5b4835b4..4febe6ef 100644 --- a/src/strategy/actions/LootRollAction.cpp +++ b/src/strategy/actions/LootRollAction.cpp @@ -1,14 +1,16 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LootRollAction.h" + #include "Event.h" #include "Group.h" #include "ItemUsageValue.h" +#include "LootAction.h" #include "PlayerbotAIConfig.h" #include "Playerbots.h" -#include "LootAction.h" bool LootRollAction::Execute(Event event) { @@ -19,8 +21,10 @@ bool LootRollAction::Execute(Event event) return false; std::vector rolls = group->GetRolls(); - for (Roll* &roll : rolls) { - if (roll->playerVote.find(bot->GetGUID())->second != NOT_EMITED_YET) { + for (Roll*& roll : rolls) + { + if (roll->playerVote.find(bot->GetGUID())->second != NOT_EMITED_YET) + { continue; } ObjectGuid guid = roll->itemGUID; @@ -28,7 +32,7 @@ bool LootRollAction::Execute(Event event) uint32 itemId = roll->itemid; RollVote vote = PASS; - ItemTemplate const *proto = sObjectMgr->GetItemTemplate(itemId); + ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId); if (!proto) continue; ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", itemId); @@ -36,10 +40,12 @@ bool LootRollAction::Execute(Event event) { case ITEM_CLASS_WEAPON: case ITEM_CLASS_ARMOR: - if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_BAD_EQUIP) { + if (usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_BAD_EQUIP) + { vote = NEED; } - else if (usage != ITEM_USAGE_NONE) { + else if (usage != ITEM_USAGE_NONE) + { vote = GREED; } break; @@ -48,12 +54,18 @@ bool LootRollAction::Execute(Event event) vote = NEED; break; } - if (sPlayerbotAIConfig->lootRollLevel == 0) { + if (sPlayerbotAIConfig->lootRollLevel == 0) + { vote = PASS; - } else if (sPlayerbotAIConfig->lootRollLevel == 1) { - if (vote == NEED) { + } + else if (sPlayerbotAIConfig->lootRollLevel == 1) + { + if (vote == NEED) + { vote = GREED; - } else if (vote == GREED) { + } + else if (vote == GREED) + { vote = PASS; } } @@ -74,9 +86,8 @@ bool LootRollAction::Execute(Event event) // p >> slot; //number of players invited to roll // p >> rollType; //need,greed or pass on roll - // std::vector rolls = group->GetRolls(); - // bot->Say("guid:" + std::to_string(guid.GetCounter()) + + // bot->Say("guid:" + std::to_string(guid.GetCounter()) + // "item entry:" + std::to_string(guid.GetEntry()), LANG_UNIVERSAL); // for (std::vector::iterator i = rolls.begin(); i != rolls.end(); ++i) // { @@ -154,16 +165,13 @@ RollVote LootRollAction::CalculateRollVote(ItemTemplate const* proto) return StoreLootAction::IsLootAllowed(proto->ItemId, GET_PLAYERBOT_AI(bot)) ? needVote : PASS; } -bool MasterLootRollAction::isUseful() -{ - return !botAI->HasActivePlayerMaster(); -}; +bool MasterLootRollAction::isUseful() { return !botAI->HasActivePlayerMaster(); }; bool MasterLootRollAction::Execute(Event event) { Player* bot = QueryItemUsageAction::botAI->GetBot(); - WorldPacket p(event.getPacket()); //WorldPacket packet for CMSG_LOOT_ROLL, (8+4+1) + WorldPacket p(event.getPacket()); // WorldPacket packet for CMSG_LOOT_ROLL, (8+4+1) ObjectGuid creatureGuid; uint32 mapId; uint32 itemSlot; @@ -173,15 +181,15 @@ bool MasterLootRollAction::Execute(Event event) uint32 count; uint32 timeout; - p.rpos(0); //reset packet pointer - p >> creatureGuid; //creature guid what we're looting - p >> mapId; /// 3.3.3 mapid - p >> itemSlot; // the itemEntryId for the item that shall be rolled for - p >> itemId; // the itemEntryId for the item that shall be rolled for - p >> randomSuffix; // randomSuffix - p >> randomPropertyId; // item random property ID - p >> count; // items in stack - p >> timeout; // the countdown time to choose "need" or "greed" + p.rpos(0); // reset packet pointer + p >> creatureGuid; // creature guid what we're looting + p >> mapId; /// 3.3.3 mapid + p >> itemSlot; // the itemEntryId for the item that shall be rolled for + p >> itemId; // the itemEntryId for the item that shall be rolled for + p >> randomSuffix; // randomSuffix + p >> randomPropertyId; // item random property ID + p >> count; // items in stack + p >> timeout; // the countdown time to choose "need" or "greed" ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId); if (!proto) diff --git a/src/strategy/actions/LootRollAction.h b/src/strategy/actions/LootRollAction.h index af243e94..cc202c44 100644 --- a/src/strategy/actions/LootRollAction.h +++ b/src/strategy/actions/LootRollAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LOOTROLLACTION_H @@ -15,22 +16,22 @@ enum RollVote : uint8; class LootRollAction : public QueryItemUsageAction { - public: - LootRollAction(PlayerbotAI* botAI, std::string const name = "loot roll") : QueryItemUsageAction(botAI, name) { } +public: + LootRollAction(PlayerbotAI* botAI, std::string const name = "loot roll") : QueryItemUsageAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; - protected: - RollVote CalculateRollVote(ItemTemplate const* proto); +protected: + RollVote CalculateRollVote(ItemTemplate const* proto); }; class MasterLootRollAction : public LootRollAction { - public: - MasterLootRollAction(PlayerbotAI* botAI) : LootRollAction(botAI, "master loot roll") { } +public: + MasterLootRollAction(PlayerbotAI* botAI) : LootRollAction(botAI, "master loot roll") {} - bool isUseful() override; - bool Execute(Event event) override; + bool isUseful() override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/LootStrategyAction.cpp b/src/strategy/actions/LootStrategyAction.cpp index ff88ce2d..db09727f 100644 --- a/src/strategy/actions/LootStrategyAction.cpp +++ b/src/strategy/actions/LootStrategyAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LootStrategyAction.h" + #include "ChatHelper.h" #include "Event.h" #include "LootAction.h" @@ -66,7 +68,9 @@ bool LootStrategyAction::Execute(Event event) if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemid)) { std::ostringstream out; - out << (StoreLootAction::IsLootAllowed(itemid, botAI) ? "|cFF000000Will loot " : "|c00FF0000Won't loot ") << ChatHelper::FormatItem(proto); + out << (StoreLootAction::IsLootAllowed(itemid, botAI) ? "|cFF000000Will loot " + : "|c00FF0000Won't loot ") + << ChatHelper::FormatItem(proto); botAI->TellMaster(out.str()); } } @@ -88,4 +92,3 @@ bool LootStrategyAction::Execute(Event event) return true; } - diff --git a/src/strategy/actions/LootStrategyAction.h b/src/strategy/actions/LootStrategyAction.h index 16589612..6dcd5b40 100644 --- a/src/strategy/actions/LootStrategyAction.h +++ b/src/strategy/actions/LootStrategyAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LOOTSTRATEGYACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class LootStrategyAction : public Action { - public: - LootStrategyAction(PlayerbotAI* botAI) : Action(botAI, "ll") { } +public: + LootStrategyAction(PlayerbotAI* botAI) : Action(botAI, "ll") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/MailAction.cpp b/src/strategy/actions/MailAction.cpp index 0e084a36..f15034b2 100644 --- a/src/strategy/actions/MailAction.cpp +++ b/src/strategy/actions/MailAction.cpp @@ -1,186 +1,187 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "MailAction.h" -#include "Mail.h" -#include "Event.h" + #include "ChatHelper.h" +#include "Event.h" +#include "Mail.h" #include "Playerbots.h" std::map MailAction::processors; class TellMailProcessor : public MailProcessor { - public: - bool Before(PlayerbotAI* botAI) override +public: + bool Before(PlayerbotAI* botAI) override + { + botAI->TellMaster("=== Mailbox ==="); + tells.clear(); + return true; + } + + bool Process(uint32 index, Mail* mail, PlayerbotAI* botAI) override + { + Player* bot = botAI->GetBot(); + time_t cur_time = time(nullptr); + uint32 days = (cur_time - mail->deliver_time) / 3600 / 24; + + std::ostringstream out; + out << "#" << (index + 1) << " "; + if (!mail->money && !mail->HasItems()) + out << "|cffffffff" << mail->subject; + + if (mail->money) { - botAI->TellMaster("=== Mailbox ==="); - tells.clear(); - return true; + out << "|cffffff00" << ChatHelper::formatMoney(mail->money); + if (!mail->subject.empty()) + out << " |cffa0a0a0(" << mail->subject << ")"; } - bool Process(uint32 index, Mail* mail, PlayerbotAI* botAI) override + if (mail->HasItems()) { - Player* bot = botAI->GetBot(); - time_t cur_time = time(nullptr); - uint32 days = (cur_time - mail->deliver_time) / 3600 / 24; - - std::ostringstream out; - out << "#" << (index+1) << " "; - if (!mail->money && !mail->HasItems()) - out << "|cffffffff" << mail->subject; - - if (mail->money) + for (MailItemInfoVec::iterator i = mail->items.begin(); i != mail->items.end(); ++i) { - out << "|cffffff00" << ChatHelper::formatMoney(mail->money); - if (!mail->subject.empty()) - out << " |cffa0a0a0(" << mail->subject << ")"; - } + Item* item = bot->GetMItem(i->item_guid); + uint32 count = item ? item->GetCount() : 1; - if (mail->HasItems()) - { - for (MailItemInfoVec::iterator i = mail->items.begin(); i != mail->items.end(); ++i) + if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(i->item_template)) { - Item* item = bot->GetMItem(i->item_guid); - uint32 count = item ? item->GetCount() : 1; - - if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(i->item_template)) - { - out << ChatHelper::FormatItem(proto, count); - if (!mail->subject.empty()) - out << " |cffa0a0a0(" << mail->subject << ")"; - } + out << ChatHelper::FormatItem(proto, count); + if (!mail->subject.empty()) + out << " |cffa0a0a0(" << mail->subject << ")"; } } - - out << ", |cff00ff00" << days << " day(s)"; - tells.push_front(out.str()); - return true; } - bool After(PlayerbotAI* botAI) override - { - for (std::list::iterator i = tells.begin(); i != tells.end(); ++i) - botAI->TellMaster(*i); + out << ", |cff00ff00" << days << " day(s)"; + tells.push_front(out.str()); + return true; + } - return true; - } + bool After(PlayerbotAI* botAI) override + { + for (std::list::iterator i = tells.begin(); i != tells.end(); ++i) + botAI->TellMaster(*i); - static TellMailProcessor instance; + return true; + } - private: - std::list tells; + static TellMailProcessor instance; + +private: + std::list tells; }; class TakeMailProcessor : public MailProcessor { - public: - bool Process(uint32 index, Mail* mail, PlayerbotAI* botAI) override +public: + bool Process(uint32 index, Mail* mail, PlayerbotAI* botAI) override + { + Player* bot = botAI->GetBot(); + if (!CheckBagSpace(bot)) { - Player* bot = botAI->GetBot(); - if (!CheckBagSpace(bot)) - { - botAI->TellError("Not enough bag space"); - return false; - } + botAI->TellError("Not enough bag space"); + return false; + } - ObjectGuid mailbox = FindMailbox(botAI); - if (mail->money) - { - std::ostringstream out; - out << mail->subject << ", |cffffff00" << ChatHelper::formatMoney(mail->money) << "|cff00ff00 processed"; - botAI->TellMaster(out.str()); + ObjectGuid mailbox = FindMailbox(botAI); + if (mail->money) + { + std::ostringstream out; + out << mail->subject << ", |cffffff00" << ChatHelper::formatMoney(mail->money) << "|cff00ff00 processed"; + botAI->TellMaster(out.str()); + WorldPacket packet; + packet << mailbox; + packet << mail->messageID; + bot->GetSession()->HandleMailTakeMoney(packet); + RemoveMail(bot, mail->messageID, mailbox); + } + else if (!mail->items.empty()) + { + std::vector guids; + for (MailItemInfoVec::iterator i = mail->items.begin(); i != mail->items.end(); ++i) + if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(i->item_template)) + guids.push_back(i->item_guid); + + for (std::vector::iterator i = guids.begin(); i != guids.end(); ++i) + { WorldPacket packet; packet << mailbox; packet << mail->messageID; - bot->GetSession()->HandleMailTakeMoney(packet); - RemoveMail(bot, mail->messageID, mailbox); - } - else if (!mail->items.empty()) - { - std::vector guids; - for (MailItemInfoVec::iterator i = mail->items.begin(); i != mail->items.end(); ++i) - if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(i->item_template)) - guids.push_back(i->item_guid); + packet << *i; - for (std::vector::iterator i = guids.begin(); i != guids.end(); ++i) - { - WorldPacket packet; - packet << mailbox; - packet << mail->messageID; - packet << *i; + Item* item = bot->GetMItem(*i); - Item* item = bot->GetMItem(*i); + std::ostringstream out; + out << mail->subject << ", " << ChatHelper::FormatItem(item->GetTemplate()) << "|cff00ff00 processed"; - std::ostringstream out; - out << mail->subject << ", " << ChatHelper::FormatItem(item->GetTemplate()) << "|cff00ff00 processed"; - - bot->GetSession()->HandleMailTakeItem(packet); - botAI->TellMaster(out.str()); - } - - RemoveMail(bot, mail->messageID, mailbox); + bot->GetSession()->HandleMailTakeItem(packet); + botAI->TellMaster(out.str()); } - return true; + RemoveMail(bot, mail->messageID, mailbox); } - static TakeMailProcessor instance; + return true; + } - private: - bool CheckBagSpace(Player* bot) + static TakeMailProcessor instance; + +private: + bool CheckBagSpace(Player* bot) + { + uint32 totalused = 0, total = 16; + for (uint8 slot = INVENTORY_SLOT_ITEM_START; slot < INVENTORY_SLOT_ITEM_END; slot++) + if (bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) + ++totalused; + + uint32 totalfree = 16 - totalused; + for (uint8 bag = INVENTORY_SLOT_BAG_START; bag < INVENTORY_SLOT_BAG_END; ++bag) { - uint32 totalused = 0, total = 16; - for (uint8 slot = INVENTORY_SLOT_ITEM_START; slot < INVENTORY_SLOT_ITEM_END; slot++) - if (bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) - ++totalused; - - uint32 totalfree = 16 - totalused; - for (uint8 bag = INVENTORY_SLOT_BAG_START; bag < INVENTORY_SLOT_BAG_END; ++bag) + if (Bag const* pBag = (Bag*)bot->GetItemByPos(INVENTORY_SLOT_BAG_0, bag)) { - if (Bag const* pBag = (Bag*) bot->GetItemByPos(INVENTORY_SLOT_BAG_0, bag)) - { - ItemTemplate const* pBagProto = pBag->GetTemplate(); - if (pBagProto->Class == ITEM_CLASS_CONTAINER && pBagProto->SubClass == ITEM_SUBCLASS_CONTAINER) - totalfree += pBag->GetFreeSlots(); - } - + ItemTemplate const* pBagProto = pBag->GetTemplate(); + if (pBagProto->Class == ITEM_CLASS_CONTAINER && pBagProto->SubClass == ITEM_SUBCLASS_CONTAINER) + totalfree += pBag->GetFreeSlots(); } - - return totalfree >= 2; } + + return totalfree >= 2; + } }; class DeleteMailProcessor : public MailProcessor { - public: - bool Process(uint32 index, Mail* mail, PlayerbotAI* botAI) override - { - std::ostringstream out; - out << "|cffffffff" << mail->subject << "|cffff0000 deleted"; - RemoveMail(botAI->GetBot(), mail->messageID, FindMailbox(botAI)); - botAI->TellMaster(out.str()); - return true; - } +public: + bool Process(uint32 index, Mail* mail, PlayerbotAI* botAI) override + { + std::ostringstream out; + out << "|cffffffff" << mail->subject << "|cffff0000 deleted"; + RemoveMail(botAI->GetBot(), mail->messageID, FindMailbox(botAI)); + botAI->TellMaster(out.str()); + return true; + } - static DeleteMailProcessor instance; + static DeleteMailProcessor instance; }; class ReadMailProcessor : public MailProcessor { - public: - bool Process(uint32 index, Mail* mail, PlayerbotAI* botAI) override - { - std::ostringstream out, body; - out << "|cffffffff" << mail->subject; - botAI->TellMaster(out.str()); +public: + bool Process(uint32 index, Mail* mail, PlayerbotAI* botAI) override + { + std::ostringstream out, body; + out << "|cffffffff" << mail->subject; + botAI->TellMaster(out.str()); - return true; - } + return true; + } - static ReadMailProcessor instance; + static ReadMailProcessor instance; }; TellMailProcessor TellMailProcessor::instance; @@ -270,7 +271,8 @@ bool MailAction::Execute(Event event) std::string const text = event.getParam(); if (text.empty()) { - botAI->TellMaster("whisper 'mail ?' to query mailbox, 'mail take/delete/read filter' to take/delete/read mails by filter"); + botAI->TellMaster( + "whisper 'mail ?' to query mailbox, 'mail take/delete/read filter' to take/delete/read mails by filter"); return false; } @@ -281,7 +283,8 @@ bool MailAction::Execute(Event event) MailProcessor* processor = processors[action]; if (!processor) { - std::ostringstream out; out << action << ": I don't know how to do that"; + std::ostringstream out; + out << action << ": I don't know how to do that"; botAI->TellMaster(out.str()); return false; } @@ -315,7 +318,7 @@ void MailProcessor::RemoveMail(Player* bot, uint32 id, ObjectGuid mailbox) WorldPacket packet; packet << mailbox; packet << id; - packet << (uint32)0; //mailTemplateId + packet << (uint32)0; // mailTemplateId bot->GetSession()->HandleMailDelete(packet); } diff --git a/src/strategy/actions/MailAction.h b/src/strategy/actions/MailAction.h index 9bf864d9..c54cac3d 100644 --- a/src/strategy/actions/MailAction.h +++ b/src/strategy/actions/MailAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MAILACTION_H @@ -14,26 +15,26 @@ struct Mail; class MailProcessor { - public: - virtual bool Before([[maybe_unused]] PlayerbotAI* botAI) { return true; } - virtual bool Process(uint32 index, Mail* mail, PlayerbotAI* botAI) = 0; - virtual bool After([[maybe_unused]] PlayerbotAI* botAI) { return true; } +public: + virtual bool Before([[maybe_unused]] PlayerbotAI* botAI) { return true; } + virtual bool Process(uint32 index, Mail* mail, PlayerbotAI* botAI) = 0; + virtual bool After([[maybe_unused]] PlayerbotAI* botAI) { return true; } - static ObjectGuid FindMailbox(PlayerbotAI* botAI); + static ObjectGuid FindMailbox(PlayerbotAI* botAI); - protected: - void RemoveMail(Player* bot, uint32 id, ObjectGuid mailbox); +protected: + void RemoveMail(Player* bot, uint32 id, ObjectGuid mailbox); }; class MailAction : public InventoryAction { - public: - MailAction(PlayerbotAI* botAI) : InventoryAction(botAI, "mail") { } +public: + MailAction(PlayerbotAI* botAI) : InventoryAction(botAI, "mail") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - static std::map processors; +private: + static std::map processors; }; #endif diff --git a/src/strategy/actions/MoveToRpgTargetAction.cpp b/src/strategy/actions/MoveToRpgTargetAction.cpp index a45a25b6..d13b5669 100644 --- a/src/strategy/actions/MoveToRpgTargetAction.cpp +++ b/src/strategy/actions/MoveToRpgTargetAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "MoveToRpgTargetAction.h" + #include "ChatHelper.h" #include "ChooseRpgTargetAction.h" #include "Event.h" @@ -13,11 +15,13 @@ bool MoveToRpgTargetAction::Execute(Event event) { GuidPosition guidP = AI_VALUE(GuidPosition, "rpg target"); Unit* unit = botAI->GetUnit(guidP); - if (unit && !unit->IsInWorld()) { + if (unit && !unit->IsInWorld()) + { return false; } GameObject* go = botAI->GetGameObject(guidP); - if (go && !go->IsInWorld()) { + if (go && !go->IsInWorld()) + { return false; } Player* player = guidP.GetPlayer(); @@ -48,7 +52,7 @@ bool MoveToRpgTargetAction::Execute(Event event) if (guidPP.IsPlayer()) { - AI_VALUE(GuidSet&,"ignore rpg target").insert(AI_VALUE(GuidPosition, "rpg target")); + AI_VALUE(GuidSet&, "ignore rpg target").insert(AI_VALUE(GuidPosition, "rpg target")); RESET_AI_VALUE(GuidPosition, "rpg target"); return false; @@ -56,7 +60,8 @@ bool MoveToRpgTargetAction::Execute(Event event) } } - if ((unit && unit->isMoving() && !urand(0, 20)) || !ChooseRpgTargetAction::isFollowValid(bot, wo) || guidP.distance(bot) > sPlayerbotAIConfig->reactDistance * 2 || !urand(0, 50)) + if ((unit && unit->isMoving() && !urand(0, 20)) || !ChooseRpgTargetAction::isFollowValid(bot, wo) || + guidP.distance(bot) > sPlayerbotAIConfig->reactDistance * 2 || !urand(0, 50)) { AI_VALUE(GuidSet&, "ignore rpg target").insert(AI_VALUE(GuidPosition, "rpg target")); RESET_AI_VALUE(GuidPosition, "rpg target"); @@ -77,19 +82,20 @@ bool MoveToRpgTargetAction::Execute(Event event) if (bot->IsWithinLOS(x, y, z)) { if (!unit || !unit->isMoving()) - angle = wo->GetAngle(bot) + (M_PI * irand(-25, 25) / 100.0); //Closest 45 degrees towards the target + angle = wo->GetAngle(bot) + (M_PI * irand(-25, 25) / 100.0); // Closest 45 degrees towards the target else - angle = wo->GetOrientation() + (M_PI * irand(-25, 25) / 100.0); //45 degrees infront of target (leading it's movement) + angle = wo->GetOrientation() + + (M_PI * irand(-25, 25) / 100.0); // 45 degrees infront of target (leading it's movement) distance = frand(0.5f, 1.f); } else - angle = 2 * M_PI * urand(0, 100) / 100.0; //A circle around the target. + angle = 2 * M_PI * urand(0, 100) / 100.0; // A circle around the target. x += cos(angle) * INTERACTION_DISTANCE * distance; y += sin(angle) * INTERACTION_DISTANCE * distance; - //WaitForReach(distance); + // WaitForReach(distance); bool couldMove = false; diff --git a/src/strategy/actions/MoveToRpgTargetAction.h b/src/strategy/actions/MoveToRpgTargetAction.h index 3bd148a3..19ef1968 100644 --- a/src/strategy/actions/MoveToRpgTargetAction.h +++ b/src/strategy/actions/MoveToRpgTargetAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MOVETORPGTARGETACTION_H @@ -11,11 +12,11 @@ class PlayerbotAI; class MoveToRpgTargetAction : public MovementAction { - public: - MoveToRpgTargetAction(PlayerbotAI* botAI) : MovementAction(botAI, "move to rpg target") { } +public: + MoveToRpgTargetAction(PlayerbotAI* botAI) : MovementAction(botAI, "move to rpg target") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/MoveToTravelTargetAction.cpp b/src/strategy/actions/MoveToTravelTargetAction.cpp index 64676c2c..6782ea3f 100644 --- a/src/strategy/actions/MoveToTravelTargetAction.cpp +++ b/src/strategy/actions/MoveToTravelTargetAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "MoveToTravelTargetAction.h" + #include "ChooseRpgTargetAction.h" #include "LootObjectStack.h" #include "PathGenerator.h" @@ -44,10 +46,11 @@ bool MoveToTravelTargetAction::Execute(Event event) if (memberDistance > sPlayerbotAIConfig->reactDistance * 20) continue; - // float memberAngle = botLocation.getAngleBetween(targetPos, memberPos); + // float memberAngle = botLocation.getAngleBetween(targetPos, memberPos); - // if (botLocation.getMapId() == targetPos.getMapId() && botLocation.getMapId() == memberPos.getMapId() && memberAngle < static_cast(M_PI) / 2) //We are heading that direction anyway. - // continue; + // if (botLocation.getMapId() == targetPos.getMapId() && botLocation.getMapId() == memberPos.getMapId() && + // memberAngle < static_cast(M_PI) / 2) //We are heading that direction anyway. + // continue; if (!urand(0, 5)) { @@ -72,14 +75,14 @@ bool MoveToTravelTargetAction::Execute(Event event) float maxDistance = target->getDestination()->getRadiusMin(); - //Evenly distribute around the target. + // Evenly distribute around the target. float angle = 2 * M_PI * urand(0, 100) / 100.0; - if (target->getMaxTravelTime() > target->getTimeLeft()) //The bot is late. Speed it up. + if (target->getMaxTravelTime() > target->getTimeLeft()) // The bot is late. Speed it up. { - //distance = sPlayerbotAIConfig->fleeDistance; - //angle = bot->GetAngle(location.GetPositionX(), location.GetPositionY()); - //location = botLocation.getLocation(); + // distance = sPlayerbotAIConfig->fleeDistance; + // angle = bot->GetAngle(location.GetPositionX(), location.GetPositionY()); + // location = botLocation.getLocation(); } float x = location.GetPositionX(); @@ -87,7 +90,7 @@ bool MoveToTravelTargetAction::Execute(Event event) float z = location.GetPositionZ(); float mapId = location.GetMapId(); - //Move between 0.5 and 1.0 times the maxDistance. + // Move between 0.5 and 1.0 times the maxDistance. float mod = frand(50.f, 100.f) / 100.0f; x += cos(angle) * maxDistance * mod; @@ -137,9 +140,9 @@ bool MoveToTravelTargetAction::isUseful() if (loot.IsLootPossible(bot)) return false; - if (!ChooseRpgTargetAction::isFollowValid(bot, *context->GetValue("travel target")->Get()->getPosition())) + if (!ChooseRpgTargetAction::isFollowValid(bot, + *context->GetValue("travel target")->Get()->getPosition())) return false; return true; } - diff --git a/src/strategy/actions/MoveToTravelTargetAction.h b/src/strategy/actions/MoveToTravelTargetAction.h index 5db91a62..9f6400a9 100644 --- a/src/strategy/actions/MoveToTravelTargetAction.h +++ b/src/strategy/actions/MoveToTravelTargetAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MOVETOTRAVELTARGETACTION_H @@ -11,11 +12,11 @@ class PlayerbotAI; class MoveToTravelTargetAction : public MovementAction { - public: - MoveToTravelTargetAction(PlayerbotAI* botAI) : MovementAction(botAI, "move to travel target") { } +public: + MoveToTravelTargetAction(PlayerbotAI* botAI) : MovementAction(botAI, "move to travel target") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index 2ce77bf7..670735e4 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -1,10 +1,21 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "MovementActions.h" + +#include +#include +#include +#include + +#include "Event.h" +#include "FleeManager.h" #include "GameObject.h" #include "Geometry.h" +#include "LastMovementValue.h" +#include "LootObjectStack.h" #include "Map.h" #include "MotionMaster.h" #include "MoveSplineInitArgs.h" @@ -13,29 +24,21 @@ #include "ObjectGuid.h" #include "PathGenerator.h" #include "PlayerbotAIConfig.h" +#include "Playerbots.h" #include "Position.h" +#include "PositionValue.h" #include "Random.h" +#include "ServerFacade.h" #include "SharedDefines.h" #include "SpellAuraEffects.h" #include "SpellInfo.h" -#include "TargetedMovementGenerator.h" -#include "Event.h" -#include "LastMovementValue.h" -#include "PositionValue.h" #include "Stances.h" -#include "FleeManager.h" -#include "LootObjectStack.h" -#include "Playerbots.h" -#include "ServerFacade.h" +#include "TargetedMovementGenerator.h" #include "Timer.h" #include "Transport.h" #include "Unit.h" #include "Vehicle.h" #include "WaypointMovementGenerator.h" -#include -#include -#include -#include MovementAction::MovementAction(PlayerbotAI* botAI, std::string const name) : Action(botAI, name) { @@ -47,8 +50,8 @@ void MovementAction::CreateWp(Player* wpOwner, float x, float y, float z, float float dist = wpOwner->GetDistance(x, y, z); float delay = 1000.0f * dist / wpOwner->GetSpeed(MOVE_RUN) + sPlayerbotAIConfig->reactDelay; - //if (!important) - //delay *= 0.25; + // if (!important) + // delay *= 0.25; Creature* wpCreature = wpOwner->SummonCreature(entry, x, y, z - 1, o, TEMPSUMMON_TIMED_DESPAWN, delay); botAI->GetBot()->AddAura(246, wpCreature); @@ -57,7 +60,8 @@ void MovementAction::CreateWp(Player* wpOwner, float x, float y, float z, float wpCreature->SetObjectScale(0.5f); } -void MovementAction::JumpTo(uint32 mapId, float x, float y, float z) { +void MovementAction::JumpTo(uint32 mapId, float x, float y, float z) +{ float botZ = bot->GetPositionZ(); float speed = bot->GetSpeed(MOVE_RUN); MotionMaster& mm = *bot->GetMotionMaster(); @@ -85,7 +89,8 @@ bool MovementAction::MoveNear(WorldObject* target, float distance) float z = target->GetPositionZ(); float followAngle = GetFollowAngle(); - for (float angle = followAngle; angle <= followAngle + static_cast(2 * M_PI); angle += static_cast(M_PI / 4.f)) + for (float angle = followAngle; angle <= followAngle + static_cast(2 * M_PI); + angle += static_cast(M_PI / 4.f)) { float x = target->GetPositionX() + cos(angle) * distance; float y = target->GetPositionY() + sin(angle) * distance; @@ -99,7 +104,7 @@ bool MovementAction::MoveNear(WorldObject* target, float distance) return true; } - //botAI->TellError("All paths not in LOS"); + // botAI->TellError("All paths not in LOS"); return false; } @@ -108,14 +113,14 @@ bool MovementAction::MoveToLOS(WorldObject* target, bool ranged) if (!target) return false; - //std::ostringstream out; out << "Moving to LOS!"; - //bot->Say(out.str(), LANG_UNIVERSAL); + // std::ostringstream out; out << "Moving to LOS!"; + // bot->Say(out.str(), LANG_UNIVERSAL); float x = target->GetPositionX(); float y = target->GetPositionY(); float z = target->GetPositionZ(); - //Use standard PathGenerator to find a route. + // Use standard PathGenerator to find a route. PathGenerator path(bot); path.CalculatePath(x, y, z, false); PathType type = path.GetPathType(); @@ -158,7 +163,8 @@ bool MovementAction::MoveToLOS(WorldObject* target, bool ranged) bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, bool react, bool normal_only) { UpdateMovementState(); - if (!IsMovingAllowed(mapId, x, y, z)) { + if (!IsMovingAllowed(mapId, x, y, z)) + { return false; } // if (bot->Unit::IsFalling()) { @@ -171,11 +177,12 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // if (bot->Unit::IsFalling()) { // bot->Say("I'm falling", LANG_UNIVERSAL); // } - bool generatePath = !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && - !bot->IsFlying() && !bot->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING) && !bot->IsInWater(); + bool generatePath = !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !bot->IsFlying() && + !bot->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING) && !bot->IsInWater(); bool disableMoveSplinePath = sPlayerbotAIConfig->disableMoveSplinePath >= 2 || - (sPlayerbotAIConfig->disableMoveSplinePath == 1 && bot->InBattleground()); - if (disableMoveSplinePath || !generatePath) { + (sPlayerbotAIConfig->disableMoveSplinePath == 1 && bot->InBattleground()); + if (disableMoveSplinePath || !generatePath) + { float distance = bot->GetExactDist(x, y, z); if (distance > sPlayerbotAIConfig->contactDistance) { @@ -189,16 +196,20 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, bot->CastStop(); botAI->InterruptSpell(); } - MotionMaster &mm = *bot->GetMotionMaster(); + MotionMaster& mm = *bot->GetMotionMaster(); mm.Clear(); mm.MovePoint(mapId, x, y, z, generatePath); AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation()); return true; } - } else { + } + else + { float modifiedZ; - Movement::PointsArray path = SearchForBestPath(x, y, z, modifiedZ, sPlayerbotAIConfig->maxMovementSearchTime, normal_only); - if (modifiedZ == INVALID_HEIGHT) { + Movement::PointsArray path = + SearchForBestPath(x, y, z, modifiedZ, sPlayerbotAIConfig->maxMovementSearchTime, normal_only); + if (modifiedZ == INVALID_HEIGHT) + { return false; } float distance = bot->GetExactDist(x, y, modifiedZ); @@ -214,8 +225,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, bot->CastStop(); botAI->InterruptSpell(); } - MotionMaster &mm = *bot->GetMotionMaster(); - + MotionMaster& mm = *bot->GetMotionMaster(); + mm.Clear(); mm.MoveSplinePath(&path); AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation()); @@ -224,10 +235,9 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, } return false; - // + // // // LOG_DEBUG("playerbots", "IsMovingAllowed {}", IsMovingAllowed()); // bot->AddUnitMovementFlag() - // bool isVehicle = false; // Unit* mover = bot; @@ -255,11 +265,12 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // } // float minDist = sPlayerbotAIConfig->targetPosRecalcDistance; //Minium distance a bot should move. - // float maxDist = sPlayerbotAIConfig->reactDistance; //Maxium distance a bot can move in one single action. - // float originalZ = z; // save original destination height to check if bot needs to fly up + // float maxDist = sPlayerbotAIConfig->reactDistance; //Maxium distance a bot can move in one single + // action. float originalZ = z; // save original destination height to check + // if bot needs to fly up - // bool generatePath = !bot->IsFlying() && !bot->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING) && !bot->IsInWater() && !bot->IsUnderWater(); - // if (generatePath) + // bool generatePath = !bot->IsFlying() && !bot->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING) && !bot->IsInWater() && + // !bot->IsUnderWater(); if (generatePath) // { // z += CONTACT_DISTANCE; // mover->UpdateAllowedPositionZ(x, y, z); @@ -287,7 +298,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // WorldPosition movePosition; //The actual end location // float totalDistance = startPosition.distance(endPosition); //Total distance to where we want to go - // float maxDistChange = totalDistance * 0.1; //Maximum change between previous destination before needing a recalulation + // float maxDistChange = totalDistance * 0.1; //Maximum change between previous destination + // before needing a recalulation // if (totalDistance < minDist) // { @@ -301,9 +313,12 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // TravelPath movePath; - // if (lastMove.lastMoveShort.distance(endPosition) < maxDistChange && startPosition.distance(lastMove.lastMoveShort) < maxDist) //The last short movement was to the same place we want to move now. + // if (lastMove.lastMoveShort.distance(endPosition) < maxDistChange && + // startPosition.distance(lastMove.lastMoveShort) < maxDist) //The last short movement was to the same place we want + // to move now. // movePosition = endPosition; - // else if (!lastMove.lastPath.empty() && lastMove.lastPath.getBack().distance(endPosition) < maxDistChange) //The last long movement was to the same place we want to move now. + // else if (!lastMove.lastPath.empty() && lastMove.lastPath.getBack().distance(endPosition) < maxDistChange) //The + // last long movement was to the same place we want to move now. // { // movePath = lastMove.lastPath; // } @@ -324,8 +339,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // else // { // lastMove.future = std::async(&TravelNodeMap::getFullPath, startPosition, endPosition, bot); - // LOG_DEBUG("playerbots", "lastMove.future = std::async(&TravelNodeMap::getFullPath, startPosition, endPosition, bot);"); - // return true; + // LOG_DEBUG("playerbots", "lastMove.future = std::async(&TravelNodeMap::getFullPath, + // startPosition, endPosition, bot);"); return true; // } // } // else @@ -397,7 +412,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // if (entry) // { // if (AreaTriggerTeleport const* at = sObjectMgr->GetAreaTriggerTeleport(entry)) - // telePos = WorldPosition(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation); + // telePos = WorldPosition(at->target_mapId, at->target_X, at->target_Y, at->target_Z, + // at->target_Orientation); // } // else // telePos = movePosition; @@ -424,7 +440,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // } // else { // LOG_DEBUG("playerbots", "!entry"); - // return bot->TeleportTo(movePosition.getMapId(), movePosition.getX(), movePosition.getY(), movePosition.getZ(), movePosition.getO(), 0); + // return bot->TeleportTo(movePosition.getMapId(), movePosition.getX(), movePosition.getY(), + // movePosition.getZ(), movePosition.getO(), 0); // } // } @@ -574,8 +591,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // sPlayerbotAIConfig->log("bot_movement.csv", out.str().c_str()); // } - // // LOG_DEBUG("playerbots", "({}, {}) -> ({}, {})", startPosition.getX(), startPosition.getY(), movePosition.getX(), movePosition.getY()); - // if (!react) + // // LOG_DEBUG("playerbots", "({}, {}) -> ({}, {})", startPosition.getX(), startPosition.getY(), + // movePosition.getX(), movePosition.getY()); if (!react) // if (totalDistance > maxDist) // WaitForReach(startPosition.distance(movePosition) - 10.0f); // else @@ -618,20 +635,23 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // // } // // } - // if (totalDistance > maxDist && !detailedMove && !botAI->HasPlayerNearby(&movePosition)) // Why walk if you can fly? + // if (totalDistance > maxDist && !detailedMove && !botAI->HasPlayerNearby(&movePosition)) // Why walk if you can + // fly? // { // time_t now = time(nullptr); - // AI_VALUE(LastMovement&, "last movement").nextTeleport = now + (time_t)MoveDelay(startPosition.distance(movePosition)); - // LOG_DEBUG("playerbots", "totalDistance > maxDist && !detailedMove && !botAI->HasPlayerNearby(&movePosition)"); - // return bot->TeleportTo(movePosition.getMapId(), movePosition.getX(), movePosition.getY(), movePosition.getZ(), startPosition.getAngleTo(movePosition)); + // AI_VALUE(LastMovement&, "last movement").nextTeleport = now + + // (time_t)MoveDelay(startPosition.distance(movePosition)); LOG_DEBUG("playerbots", "totalDistance > maxDist && + // !detailedMove && !botAI->HasPlayerNearby(&movePosition)"); return bot->TeleportTo(movePosition.getMapId(), + // movePosition.getX(), movePosition.getY(), movePosition.getZ(), startPosition.getAngleTo(movePosition)); // } // // walk if master walks and is close // bool masterWalking = false; // if (botAI->GetMaster()) // { - // if (botAI->GetMaster()->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING) && sServerFacade->GetDistance2d(bot, botAI->GetMaster()) < 20.0f) + // if (botAI->GetMaster()->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING) && + // sServerFacade->GetDistance2d(bot, botAI->GetMaster()) < 20.0f) // masterWalking = true; // } @@ -639,13 +659,14 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // bot->SetWalk(true); // bot->SendMovementFlagUpdate(); - // // LOG_DEBUG("playerbots", "normal move? {} {} {}", !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !bot->HasAuraType(SPELL_AURA_FLY), + // // LOG_DEBUG("playerbots", "normal move? {} {} {}", + // !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !bot->HasAuraType(SPELL_AURA_FLY), // // bot->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE), bot->getStandState()); // if (!bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !bot->HasAuraType(SPELL_AURA_FLY)) // { // bot->SetWalk(masterWalking); - // bot->GetMotionMaster()->MovePoint(movePosition.getMapId(), movePosition.getX(), movePosition.getY(), movePosition.getZ(), generatePath); - // WaitForReach(startPosition.distance(movePosition)); + // bot->GetMotionMaster()->MovePoint(movePosition.getMapId(), movePosition.getX(), movePosition.getY(), + // movePosition.getZ(), generatePath); WaitForReach(startPosition.distance(movePosition)); // // LOG_DEBUG("playerbots", "Movepoint to ({}, {})", movePosition.getX(), movePosition.getY()); // } // else @@ -673,8 +694,9 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // if (isFly) // { // float ground = bot->GetPositionZ(); - // float height = bot->GetMap()->GetWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), ground); - // if (bot->GetPositionZ() > originalZ && (bot->GetPositionZ() - originalZ < 5.0f) && (fabs(originalZ - ground) < 5.0f)) + // float height = bot->GetMap()->GetWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), + // bot->GetPositionZ(), ground); if (bot->GetPositionZ() > originalZ && (bot->GetPositionZ() - originalZ + // < 5.0f) && (fabs(originalZ - ground) < 5.0f)) // needLand = true; // if (needLand) @@ -691,9 +713,9 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, // } // } - // bot->GetMotionMaster()->MovePoint(movePosition.getMapId(), Position(movePosition.getX(), movePosition.getY(), movePosition.getZ(), 0.f)); - // WaitForReach(startPosition.distance(movePosition)); - // LOG_DEBUG("playerbots", "Movepoint to ({}, {})", movePosition.getX(), movePosition.getY()); + // bot->GetMotionMaster()->MovePoint(movePosition.getMapId(), Position(movePosition.getX(), movePosition.getY(), + // movePosition.getZ(), 0.f)); WaitForReach(startPosition.distance(movePosition)); LOG_DEBUG("playerbots", + // "Movepoint to ({}, {})", movePosition.getX(), movePosition.getY()); // } // AI_VALUE(LastMovement&, "last movement").setShort(movePosition); @@ -730,10 +752,13 @@ bool MovementAction::MoveTo(Unit* target, float distance) float dx = cos(angle) * needToGo + bx; float dy = sin(angle) * needToGo + by; - float dz; // = std::max(bz, tz); // calc accurate z position to avoid stuck - if (distanceToTarget > CONTACT_DISTANCE) { + float dz; // = std::max(bz, tz); // calc accurate z position to avoid stuck + if (distanceToTarget > CONTACT_DISTANCE) + { dz = bz + (tz - bz) * (needToGo / distanceToTarget); - } else { + } + else + { dz = tz; } return MoveTo(target->GetMapId(), dx, dy, dz); @@ -764,10 +789,13 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance) float dx = cos(angle) * needToGo + bx; float dy = sin(angle) * needToGo + by; - float dz; // = std::max(bz, tz); // calc accurate z position to avoid stuck - if (distanceToTarget > CONTACT_DISTANCE) { + float dz; // = std::max(bz, tz); // calc accurate z position to avoid stuck + if (distanceToTarget > CONTACT_DISTANCE) + { dz = bz + (tz - bz) * (needToGo / distanceToTarget); - } else { + } + else + { dz = tz; } return MoveTo(target->GetMapId(), dx, dy, dz); @@ -787,7 +815,7 @@ float MovementAction::GetFollowAngle() continue; if (ref->GetSource() == bot) - return 2 * M_PI / (group->GetMembersCount() -1) * index; + return 2 * M_PI / (group->GetMembersCount() - 1) * index; ++index; } @@ -803,7 +831,7 @@ bool MovementAction::IsMovingAllowed(Unit* target) if (bot->GetMapId() != target->GetMapId()) return false; - float distance = sServerFacade->GetDistance2d(bot, target); + float distance = sServerFacade->GetDistance2d(bot, target); if (!bot->InBattleground() && distance > sPlayerbotAIConfig->reactDistance) return false; @@ -825,13 +853,14 @@ bool MovementAction::IsMovingAllowed() if (botAI->IsInVehicle() && !botAI->IsInVehicle(true)) return false; - if (bot->isFrozen() || bot->IsPolymorphed() || (bot->isDead() && !bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) || bot->IsBeingTeleported() || - bot->isInRoots() || bot->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION) || bot->HasAuraType(SPELL_AURA_MOD_CONFUSE) || bot->IsCharmed() || - bot->HasAuraType(SPELL_AURA_MOD_STUN) || bot->HasUnitState(UNIT_STATE_IN_FLIGHT) || - bot->HasUnitState(UNIT_STATE_LOST_CONTROL)) + if (bot->isFrozen() || bot->IsPolymorphed() || (bot->isDead() && !bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) || + bot->IsBeingTeleported() || bot->isInRoots() || bot->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION) || + bot->HasAuraType(SPELL_AURA_MOD_CONFUSE) || bot->IsCharmed() || bot->HasAuraType(SPELL_AURA_MOD_STUN) || + bot->HasUnitState(UNIT_STATE_IN_FLIGHT) || bot->HasUnitState(UNIT_STATE_LOST_CONTROL)) return false; - if (bot->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) != NULL_MOTION_TYPE) { + if (bot->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_CONTROLLED) != NULL_MOTION_TYPE) + { return false; } @@ -841,10 +870,7 @@ bool MovementAction::IsMovingAllowed() return bot->GetMotionMaster()->GetCurrentMovementGeneratorType() != FLIGHT_MOTION_TYPE; } -bool MovementAction::Follow(Unit* target, float distance) -{ - return Follow(target, distance, GetFollowAngle()); -} +bool MovementAction::Follow(Unit* target, float distance) { return Follow(target, distance, GetFollowAngle()); } void MovementAction::UpdateMovementState() { @@ -857,17 +883,21 @@ void MovementAction::UpdateMovementState() bot->SetSwim(false); } - bool onGround = bot->GetPositionZ() < bot->GetMapWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ()) + 1.0f; + bool onGround = bot->GetPositionZ() < + bot->GetMapWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ()) + 1.0f; - if (!bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) && bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !onGround) + if (!bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) && + bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !onGround) { bot->AddUnitMovementFlag(MOVEMENTFLAG_FLYING); } - if (bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) && (!bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) || onGround)) + if (bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) && + (!bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) || onGround)) { bot->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING); } - Transport* newTransport = bot->GetMap()->GetTransportForPos(bot->GetPhaseMask(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), bot); + Transport* newTransport = bot->GetMap()->GetTransportForPos(bot->GetPhaseMask(), bot->GetPositionX(), + bot->GetPositionY(), bot->GetPositionZ(), bot); if (newTransport != bot->GetTransport()) { LOG_DEBUG("playerbots", "Bot {} is on a transport", bot->GetName()); @@ -889,7 +919,8 @@ void MovementAction::UpdateMovementState() // bot->SetSpeedRate(MOVE_RUN, 1.0f); // } // check if target is not reachable (from Vmangos) - // if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE && bot->CanNotReachTarget() && !bot->InBattleground()) + // if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE && bot->CanNotReachTarget() && + // !bot->InBattleground()) // { // if (Unit* pTarget = sServerFacade->GetChaseTarget(bot)) // { @@ -914,15 +945,16 @@ void MovementAction::UpdateMovementState() // // Cheating to prevent getting stuck because of bad mmaps. // bot->StopMoving(); // bot->GetMotionMaster()->Clear(); - // bot->GetMotionMaster()->MovePoint(bot->GetMapId(), pTarget->GetPosition(), FORCED_MOVEMENT_RUN, false); - // return; + // bot->GetMotionMaster()->MovePoint(bot->GetMapId(), pTarget->GetPosition(), FORCED_MOVEMENT_RUN, + // false); return; // }*/ // } // } // } // if ((bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE || - // bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) && bot->CanNotReachTarget() && !bot->InBattleground()) + // bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) && bot->CanNotReachTarget() + // && !bot->InBattleground()) // { // if (Unit* pTarget = sServerFacade->GetChaseTarget(bot)) // { @@ -961,16 +993,19 @@ bool MovementAction::Follow(Unit* target, float distance, float angle) if (!target) return false; - if (!bot->InBattleground() && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target), sPlayerbotAIConfig->followDistance)) + if (!bot->InBattleground() && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target), + sPlayerbotAIConfig->followDistance)) { - //botAI->TellError("No need to follow"); + // botAI->TellError("No need to follow"); return false; } /* if (!bot->InBattleground() - && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target->GetPositionX(), target->GetPositionY()), sPlayerbotAIConfig->sightDistance) - && abs(bot->GetPositionZ() - target->GetPositionZ()) >= sPlayerbotAIConfig->spellDistance && botAI->HasRealPlayerMaster() + && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target->GetPositionX(), + target->GetPositionY()), sPlayerbotAIConfig->sightDistance) + && abs(bot->GetPositionZ() - target->GetPositionZ()) >= sPlayerbotAIConfig->spellDistance && + botAI->HasRealPlayerMaster() && (target->GetMapId() && bot->GetMapId() != target->GetMapId())) { bot->StopMoving(); @@ -981,8 +1016,8 @@ bool MovementAction::Follow(Unit* target, float distance, float angle) float z = target->GetPositionZ(); if (target->GetMapId() && bot->GetMapId() != target->GetMapId()) { - if ((target->GetMap() && target->GetMap()->IsBattlegroundOrArena()) || (bot->GetMap() && bot->GetMap()->IsBattlegroundOrArena())) - return false; + if ((target->GetMap() && target->GetMap()->IsBattlegroundOrArena()) || (bot->GetMap() && + bot->GetMap()->IsBattlegroundOrArena())) return false; bot->TeleportTo(target->GetMapId(), x, y, z, bot->GetOrientation()); } @@ -998,8 +1033,8 @@ bool MovementAction::Follow(Unit* target, float distance, float angle) if (!IsMovingAllowed(target) && botAI->HasRealPlayerMaster()) { - if ((target->GetMap() && target->GetMap()->IsBattlegroundOrArena()) || (bot->GetMap() && bot->GetMap()->IsBattlegroundOrArena())) - return false; + if ((target->GetMap() && target->GetMap()->IsBattlegroundOrArena()) || (bot->GetMap() && + bot->GetMap()->IsBattlegroundOrArena())) return false; if (bot->isDead() && botAI->GetMaster()->IsAlive()) { @@ -1011,8 +1046,8 @@ bool MovementAction::Follow(Unit* target, float distance, float angle) bot->CombatStop(true); botAI->TellMasterNoFacing("I will there soon."); - bot->TeleportTo(target->GetMapId(), target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation()); - return false; + bot->TeleportTo(target->GetMapId(), target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), + target->GetOrientation()); return false; } */ @@ -1028,30 +1063,33 @@ bool MovementAction::Follow(Unit* target, float distance, float angle) WorldPosition botPos(bot); WorldPosition cPos(corpse); - if(botPos.fDist(cPos) > sPlayerbotAIConfig->spellDistance) - return MoveTo(cPos.getMapId(),cPos.getX(),cPos.getY(), cPos.getZ()); + if (botPos.fDist(cPos) > sPlayerbotAIConfig->spellDistance) + return MoveTo(cPos.getMapId(), cPos.getX(), cPos.getY(), cPos.getZ()); } } - if (sServerFacade->IsDistanceGreaterOrEqualThan(sServerFacade->GetDistance2d(bot, target), sPlayerbotAIConfig->sightDistance)) + if (sServerFacade->IsDistanceGreaterOrEqualThan(sServerFacade->GetDistance2d(bot, target), + sPlayerbotAIConfig->sightDistance)) { if (target->GetGUID().IsPlayer()) { Player* pTarget = (Player*)target; PlayerbotAI* targetBotAI = GET_PLAYERBOT_AI(pTarget); - if (targetBotAI) // Try to move to where the bot is going if it is closer and in the same direction. + if (targetBotAI) // Try to move to where the bot is going if it is closer and in the same direction. { WorldPosition botPos(bot); WorldPosition tarPos(target); - WorldPosition longMove = targetBotAI->GetAiObjectContext()->GetValue("last long move")->Get(); + WorldPosition longMove = + targetBotAI->GetAiObjectContext()->GetValue("last long move")->Get(); if (longMove) { float lDist = botPos.fDist(longMove); float tDist = botPos.fDist(tarPos); float ang = botPos.getAngleBetween(tarPos, longMove); - if ((lDist * 1.5 < tDist && ang < static_cast(M_PI) / 2) || target->HasUnitState(UNIT_STATE_IN_FLIGHT)) + if ((lDist * 1.5 < tDist && ang < static_cast(M_PI) / 2) || + target->HasUnitState(UNIT_STATE_IN_FLIGHT)) { return MoveTo(longMove.getMapId(), longMove.getX(), longMove.getY(), longMove.getZ()); } @@ -1059,9 +1097,10 @@ bool MovementAction::Follow(Unit* target, float distance, float angle) } else { - if (pTarget->HasUnitState(UNIT_STATE_IN_FLIGHT)) //Move to where the player is flying to. + if (pTarget->HasUnitState(UNIT_STATE_IN_FLIGHT)) // Move to where the player is flying to. { - TaxiPathNodeList const& tMap = static_cast(pTarget->GetMotionMaster()->top())->GetPath(); + TaxiPathNodeList const& tMap = + static_cast(pTarget->GetMotionMaster()->top())->GetPath(); if (!tMap.empty()) { auto tEnd = tMap.back(); @@ -1076,18 +1115,20 @@ bool MovementAction::Follow(Unit* target, float distance, float angle) return MoveTo(target, sPlayerbotAIConfig->followDistance); } - if (sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target), sPlayerbotAIConfig->followDistance)) + if (sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target), + sPlayerbotAIConfig->followDistance)) { - //botAI->TellError("No need to follow"); + // botAI->TellError("No need to follow"); return false; } if (target->IsFriendlyTo(bot) && bot->IsMounted() && AI_VALUE(GuidVector, "all targets").empty()) distance += angle; - if (!bot->InBattleground() && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target), sPlayerbotAIConfig->followDistance)) + if (!bot->InBattleground() && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target), + sPlayerbotAIConfig->followDistance)) { - //botAI->TellError("No need to follow"); + // botAI->TellError("No need to follow"); return false; } @@ -1107,7 +1148,7 @@ bool MovementAction::Follow(Unit* target, float distance, float angle) if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE) { - Unit *currentTarget = sServerFacade->GetChaseTarget(bot); + Unit* currentTarget = sServerFacade->GetChaseTarget(bot); if (currentTarget && currentTarget->GetGUID() == target->GetGUID()) return false; } @@ -1132,7 +1173,7 @@ bool MovementAction::ChaseTo(WorldObject* obj, float distance, float angle) if (!seat || !seat->CanControl()) return false; - //vehicle->GetMotionMaster()->Clear(); + // vehicle->GetMotionMaster()->Clear(); vehicle->GetBase()->GetMotionMaster()->MoveChase((Unit*)obj, 30.0f); return true; } @@ -1149,7 +1190,7 @@ bool MovementAction::ChaseTo(WorldObject* obj, float distance, float angle) } // bot->GetMotionMaster()->Clear(); - bot->GetMotionMaster()->MoveChase((Unit*) obj, distance); + bot->GetMotionMaster()->MoveChase((Unit*)obj, distance); WaitForReach(bot->GetExactDist2d(obj) - distance); return true; } @@ -1157,11 +1198,16 @@ bool MovementAction::ChaseTo(WorldObject* obj, float distance, float angle) float MovementAction::MoveDelay(float distance) { float speed; - if (bot->isSwimming()) { + if (bot->isSwimming()) + { speed = bot->GetSpeed(MOVE_SWIM); - } else if (bot->IsFlying()) { + } + else if (bot->IsFlying()) + { speed = bot->GetSpeed(MOVE_FLIGHT); - } else { + } + else + { speed = bot->GetSpeed(MOVE_RUN); } float delay = distance / speed - sPlayerbotAIConfig->reactDistance; @@ -1188,7 +1234,7 @@ void MovementAction::WaitForReach(float distance) botAI->SetNextCheckDelay((uint32)delay); } -bool MovementAction::Flee(Unit *target) +bool MovementAction::Flee(Unit* target) { Player* master = GetMaster(); if (!target) @@ -1220,7 +1266,7 @@ bool MovementAction::Flee(Unit *target) } HostileReference* ref = target->GetThreatMgr().getCurrentVictim(); - if (ref && ref->getTarget() == bot) // bot is target - try to flee to tank or master + if (ref && ref->getTarget() == bot) // bot is target - try to flee to tank or master { if (Group* group = bot->GetGroup()) { @@ -1239,7 +1285,7 @@ bool MovementAction::Flee(Unit *target) float distanceToTarget = sServerFacade->GetDistance2d(bot, target); if (distanceToTank < fleeDistance) { - fleeTarget = player; + fleeTarget = player; fleeDistance = distanceToTank; } } @@ -1254,7 +1300,7 @@ bool MovementAction::Flee(Unit *target) } } } - else // bot is not targeted, try to flee dps/healers + else // bot is not targeted, try to flee dps/healers { bool isHealer = botAI->IsHeal(bot); bool isDps = !isHealer && !botAI->IsTank(bot); @@ -1271,7 +1317,7 @@ bool MovementAction::Flee(Unit *target) float spareDistance = botAI->GetRange("shoot") * 2.0f; std::vector possibleTargets; - for (GroupReference *gref = group->GetFirstMember(); gref; gref = gref->next()) + for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next()) { Player* player = gref->GetSource(); if (!player || player == bot || !player->IsAlive()) @@ -1281,7 +1327,9 @@ bool MovementAction::Flee(Unit *target) { float distanceToHealer = sServerFacade->GetDistance2d(bot, player); float distanceToTarget = sServerFacade->GetDistance2d(player, target); - if (distanceToHealer < fleeDistance && distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig->followDistance) && (needHealer || player->IsWithinLOSInMap(target))) + if (distanceToHealer < fleeDistance && + distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig->followDistance) && + (needHealer || player->IsWithinLOSInMap(target))) { fleeTarget = player; fleeDistance = distanceToHealer; @@ -1292,7 +1340,9 @@ bool MovementAction::Flee(Unit *target) { float distanceToRanged = sServerFacade->GetDistance2d(bot, player); float distanceToTarget = sServerFacade->GetDistance2d(player, target); - if (distanceToRanged < fleeDistance && distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig->followDistance) && player->IsWithinLOSInMap(target)) + if (distanceToRanged < fleeDistance && + distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig->followDistance) && + player->IsWithinLOSInMap(target)) { fleeTarget = player; fleeDistance = distanceToRanged; @@ -1302,7 +1352,9 @@ bool MovementAction::Flee(Unit *target) // remember any group member in case no one else found float distanceToFlee = sServerFacade->GetDistance2d(bot, player); float distanceToTarget = sServerFacade->GetDistance2d(player, target); - if (distanceToFlee < spareDistance && distanceToTarget >(botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig->followDistance) && player->IsWithinLOSInMap(target)) + if (distanceToFlee < spareDistance && + distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig->followDistance) && + player->IsWithinLOSInMap(target)) { spareTarget = player; spareDistance = distanceToFlee; @@ -1325,7 +1377,6 @@ bool MovementAction::Flee(Unit *target) if (distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig->followDistance)) foundFlee = MoveNear(master); } - } } @@ -1373,26 +1424,31 @@ void MovementAction::ClearIdleState() bool MovementAction::MoveAway(Unit* target) { - if (!target) { + if (!target) + { return false; } float init_angle = target->GetAngle(bot); - for (float delta = 0; delta <= M_PI / 2; delta += M_PI / 8) { + for (float delta = 0; delta <= M_PI / 2; delta += M_PI / 8) + { float angle = init_angle + delta; float dx = bot->GetPositionX() + cos(angle) * sPlayerbotAIConfig->fleeDistance; float dy = bot->GetPositionY() + sin(angle) * sPlayerbotAIConfig->fleeDistance; float dz = bot->GetPositionZ(); - if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true)) { + if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true)) + { return true; } - if (delta == 0) { + if (delta == 0) + { continue; } angle = init_angle - delta; dx = bot->GetPositionX() + cos(angle) * sPlayerbotAIConfig->fleeDistance; dy = bot->GetPositionY() + sin(angle) * sPlayerbotAIConfig->fleeDistance; dz = bot->GetPositionZ(); - if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true)) { + if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true)) + { return true; } } @@ -1401,13 +1457,15 @@ bool MovementAction::MoveAway(Unit* target) bool MovementAction::MoveInside(uint32 mapId, float x, float y, float z, float distance) { - if (bot->GetDistance2d(x, y) <= distance) { + if (bot->GetDistance2d(x, y) <= distance) + { return false; } return MoveNear(mapId, x, y, z, distance); } -// float MovementAction::SearchBestGroundZForPath(float x, float y, float z, bool generatePath, float range, bool normal_only, float step) +// float MovementAction::SearchBestGroundZForPath(float x, float y, float z, bool generatePath, float range, bool +// normal_only, float step) // { // if (!generatePath) { // return z; @@ -1460,8 +1518,9 @@ bool MovementAction::MoveInside(uint32 mapId, float x, float y, float z, float d // } // return current_z; // } - -const Movement::PointsArray MovementAction::SearchForBestPath(float x, float y, float z, float &modified_z, int maxSearchCount, bool normal_only, float step) + +const Movement::PointsArray MovementAction::SearchForBestPath(float x, float y, float z, float& modified_z, + int maxSearchCount, bool normal_only, float step) { bool found = false; modified_z = INVALID_HEIGHT; @@ -1470,49 +1529,59 @@ const Movement::PointsArray MovementAction::SearchForBestPath(float x, float y, gen.CalculatePath(x, y, tempZ); Movement::PointsArray result = gen.GetPath(); float min_length = gen.getPathLength(); - if ((gen.GetPathType() & PATHFIND_NORMAL) && abs(tempZ - z) < 0.5f) { + if ((gen.GetPathType() & PATHFIND_NORMAL) && abs(tempZ - z) < 0.5f) + { modified_z = tempZ; return result; } // Start searching - if (gen.GetPathType() & PATHFIND_NORMAL) { + if (gen.GetPathType() & PATHFIND_NORMAL) + { modified_z = tempZ; found = true; } int count = 1; - for (float delta = step; count < maxSearchCount / 2 + 1; count++, delta += step) { + for (float delta = step; count < maxSearchCount / 2 + 1; count++, delta += step) + { tempZ = bot->GetMapHeight(x, y, z + delta); - if (tempZ == INVALID_HEIGHT) { + if (tempZ == INVALID_HEIGHT) + { continue; } PathGenerator gen(bot); gen.CalculatePath(x, y, tempZ); - if ((gen.GetPathType() & PATHFIND_NORMAL) && gen.getPathLength() < min_length) { + if ((gen.GetPathType() & PATHFIND_NORMAL) && gen.getPathLength() < min_length) + { found = true; min_length = gen.getPathLength(); result = gen.GetPath(); modified_z = tempZ; } } - for (float delta = -step; count < maxSearchCount; count++, delta -= step) { + for (float delta = -step; count < maxSearchCount; count++, delta -= step) + { tempZ = bot->GetMapHeight(x, y, z + delta); - if (tempZ == INVALID_HEIGHT) { + if (tempZ == INVALID_HEIGHT) + { continue; } PathGenerator gen(bot); gen.CalculatePath(x, y, tempZ); - if ((gen.GetPathType() & PATHFIND_NORMAL) && gen.getPathLength() < min_length) { + if ((gen.GetPathType() & PATHFIND_NORMAL) && gen.getPathLength() < min_length) + { found = true; min_length = gen.getPathLength(); result = gen.GetPath(); modified_z = tempZ; } } - if (!found && normal_only) { + if (!found && normal_only) + { modified_z = INVALID_HEIGHT; return Movement::PointsArray{}; } - if (!found && !normal_only) { + if (!found && !normal_only) + { return result; } return result; @@ -1526,7 +1595,8 @@ bool FleeAction::Execute(Event event) bool FleeAction::isUseful() { - if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL) != nullptr) { + if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL) != nullptr) + { return false; } return true; @@ -1550,7 +1620,8 @@ bool FleeWithPetAction::Execute(Event event) bool AvoidAoeAction::isUseful() { - if (getMSTime() - moveInterval < lastMoveTimer) { + if (getMSTime() - moveInterval < lastMoveTimer) + { return false; } GuidVector traps = AI_VALUE(GuidVector, "nearest trap with damage"); @@ -1561,15 +1632,18 @@ bool AvoidAoeAction::isUseful() bool AvoidAoeAction::Execute(Event event) { // Case #1: Aura with dynamic object (e.g. rain of fire) - if (AvoidAuraWithDynamicObj()) { + if (AvoidAuraWithDynamicObj()) + { return true; } // Case #2: Trap game object with spell (e.g. lava bomb) - if (AvoidGameObjectWithDamage()) { + if (AvoidGameObjectWithDamage()) + { return true; } // Case #3: Trigger npc (e.g. Lesser shadow fissure) - if (AvoidUnitWithDamageAura()) { + if (AvoidUnitWithDamageAura()) + { return true; } return false; @@ -1578,32 +1652,40 @@ bool AvoidAoeAction::Execute(Event event) bool AvoidAoeAction::AvoidAuraWithDynamicObj() { Aura* aura = AI_VALUE(Aura*, "area debuff"); - if (!aura || aura->IsRemoved() || aura->IsExpired()) { + if (!aura || aura->IsRemoved() || aura->IsExpired()) + { return false; } - if (!aura->GetOwner() || !aura->GetOwner()->IsInWorld()) { + if (!aura->GetOwner() || !aura->GetOwner()->IsInWorld()) + { return false; } // Crash fix: maybe change owner due to check interval - if (aura->GetType() != DYNOBJ_AURA_TYPE) { + if (aura->GetType() != DYNOBJ_AURA_TYPE) + { return false; } const SpellInfo* spellInfo = aura->GetSpellInfo(); - if (!spellInfo) { + if (!spellInfo) + { return false; } DynamicObject* dynOwner = aura->GetDynobjOwner(); - if (!dynOwner || !dynOwner->IsInWorld()) { + if (!dynOwner || !dynOwner->IsInWorld()) + { return false; } float radius = dynOwner->GetRadius(); - if (bot->GetDistance(dynOwner) > radius) { + if (bot->GetDistance(dynOwner) > radius) + { return false; } std::ostringstream name; - name << spellInfo->SpellName[LOCALE_enUS]; // << "] (aura)"; - if (FleePosition(dynOwner->GetPosition(), radius)) { - if (sPlayerbotAIConfig->tellWhenAvoidAoe && lastTellTimer < time(NULL) - 10) { + name << spellInfo->SpellName[LOCALE_enUS]; // << "] (aura)"; + if (FleePosition(dynOwner->GetPosition(), radius)) + { + if (sPlayerbotAIConfig->tellWhenAvoidAoe && lastTellTimer < time(NULL) - 10) + { lastTellTimer = time(NULL); lastMoveTimer = getMSTime(); std::ostringstream out; @@ -1618,12 +1700,15 @@ bool AvoidAoeAction::AvoidAuraWithDynamicObj() bool AvoidAoeAction::AvoidGameObjectWithDamage() { GuidVector traps = AI_VALUE(GuidVector, "nearest trap with damage"); - if (traps.empty()) { + if (traps.empty()) + { return false; } - for (ObjectGuid &guid : traps) { + for (ObjectGuid& guid : traps) + { GameObject* go = botAI->GetGameObject(guid); - if (!go || !go->IsInWorld()) { + if (!go || !go->IsInWorld()) + { continue; } if (go->GetGoType() != GAMEOBJECT_TYPE_TRAP) @@ -1641,7 +1726,8 @@ bool AvoidAoeAction::AvoidGameObjectWithDamage() continue; } const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId); - if (!spellInfo || spellInfo->IsPositive()) { + if (!spellInfo || spellInfo->IsPositive()) + { continue; } float radius = (float)goInfo->trap.diameter / 2; @@ -1655,13 +1741,16 @@ bool AvoidAoeAction::AvoidGameObjectWithDamage() // break; // } // } - if (bot->GetDistance(go) > radius) { + if (bot->GetDistance(go) > radius) + { continue; } std::ostringstream name; - name << spellInfo->SpellName[LOCALE_enUS]; // << "] (object)"; - if (FleePosition(go->GetPosition(), radius)) { - if (sPlayerbotAIConfig->tellWhenAvoidAoe && lastTellTimer < time(NULL) - 10) { + name << spellInfo->SpellName[LOCALE_enUS]; // << "] (object)"; + if (FleePosition(go->GetPosition(), radius)) + { + if (sPlayerbotAIConfig->tellWhenAvoidAoe && lastTellTimer < time(NULL) - 10) + { lastTellTimer = time(NULL); lastMoveTimer = getMSTime(); std::ostringstream out; @@ -1670,7 +1759,6 @@ bool AvoidAoeAction::AvoidGameObjectWithDamage() } return true; } - } return false; } @@ -1678,39 +1766,52 @@ bool AvoidAoeAction::AvoidGameObjectWithDamage() bool AvoidAoeAction::AvoidUnitWithDamageAura() { GuidVector triggers = AI_VALUE(GuidVector, "possible triggers"); - if (triggers.empty()) { + if (triggers.empty()) + { return false; } - for (ObjectGuid &guid : triggers) { + for (ObjectGuid& guid : triggers) + { Unit* unit = botAI->GetUnit(guid); - if (!unit || !unit->IsInWorld()) { + if (!unit || !unit->IsInWorld()) + { continue; } - if (!unit->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE)) { + if (!unit->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE)) + { return false; } - Unit::AuraEffectList const& aurasPeriodicTriggerSpell = unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL); - Unit::AuraEffectList const& aurasPeriodicTriggerWithValueSpell = unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE); - for (const Unit::AuraEffectList& list : {aurasPeriodicTriggerSpell, aurasPeriodicTriggerWithValueSpell}) { + Unit::AuraEffectList const& aurasPeriodicTriggerSpell = + unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL); + Unit::AuraEffectList const& aurasPeriodicTriggerWithValueSpell = + unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE); + for (const Unit::AuraEffectList& list : {aurasPeriodicTriggerSpell, aurasPeriodicTriggerWithValueSpell}) + { for (auto i = list.begin(); i != list.end(); ++i) { AuraEffect* aurEff = *i; const SpellInfo* spellInfo = aurEff->GetSpellInfo(); if (!spellInfo) continue; - const SpellInfo* triggerSpellInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[aurEff->GetEffIndex()].TriggerSpell); + const SpellInfo* triggerSpellInfo = + sSpellMgr->GetSpellInfo(spellInfo->Effects[aurEff->GetEffIndex()].TriggerSpell); if (!triggerSpellInfo) continue; - for (int j = 0; j < MAX_SPELL_EFFECTS; j++) { - if (triggerSpellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) { + for (int j = 0; j < MAX_SPELL_EFFECTS; j++) + { + if (triggerSpellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) + { float radius = triggerSpellInfo->Effects[j].CalcRadius(); - if (bot->GetDistance(unit) > radius) { + if (bot->GetDistance(unit) > radius) + { break; } std::ostringstream name; - name << triggerSpellInfo->SpellName[LOCALE_enUS]; //<< "] (unit)"; - if (FleePosition(unit->GetPosition(), radius)) { - if (sPlayerbotAIConfig->tellWhenAvoidAoe && lastTellTimer < time(NULL) - 10) { + name << triggerSpellInfo->SpellName[LOCALE_enUS]; //<< "] (unit)"; + if (FleePosition(unit->GetPosition(), radius)) + { + if (sPlayerbotAIConfig->tellWhenAvoidAoe && lastTellTimer < time(NULL) - 10) + { lastTellTimer = time(NULL); lastMoveTimer = getMSTime(); std::ostringstream out; @@ -1730,7 +1831,8 @@ Position MovementAction::BestPositionForMeleeToFlee(Position pos, float radius) { Unit* currentTarget = AI_VALUE(Unit*, "current target"); std::vector possibleAngles; - if (currentTarget) { + if (currentTarget) + { // Normally, move to left or right is the best position bool isTanking = (currentTarget->CanFreeMove()) && (currentTarget->GetVictim() == bot); float angle = bot->GetAngle(currentTarget); @@ -1739,38 +1841,46 @@ Position MovementAction::BestPositionForMeleeToFlee(Position pos, float radius) possibleAngles.push_back({angleLeft, false}); possibleAngles.push_back({angleRight, false}); possibleAngles.push_back({angle, true}); - if (isTanking) { + if (isTanking) + { possibleAngles.push_back({angle + (float)M_PI, false}); possibleAngles.push_back({bot->GetAngle(&pos) - (float)M_PI, false}); } - } else { + } + else + { float angleTo = bot->GetAngle(&pos) - (float)M_PI; possibleAngles.push_back({angleTo, false}); } float farestDis = 0.0f; Position bestPos; - for (CheckAngle &checkAngle : possibleAngles) { + for (CheckAngle& checkAngle : possibleAngles) + { float angle = checkAngle.angle; auto& infoList = AI_VALUE_REF(std::list, "recently flee info"); - if (!CheckLastFlee(angle, infoList)) { + if (!CheckLastFlee(angle, infoList)) + { continue; } bool strict = checkAngle.strict; float fleeDis = std::min(radius + 1.0f, sPlayerbotAIConfig->fleeDistance); - Position fleePos{bot->GetPositionX() + cos(angle) * fleeDis, - bot->GetPositionY() + sin(angle) * fleeDis, - bot->GetPositionZ()}; - if (strict && currentTarget - && fleePos.GetExactDist(currentTarget) - currentTarget->GetCombatReach() > sPlayerbotAIConfig->tooCloseDistance - && bot->IsWithinMeleeRange(currentTarget)) { + Position fleePos{bot->GetPositionX() + cos(angle) * fleeDis, bot->GetPositionY() + sin(angle) * fleeDis, + bot->GetPositionZ()}; + if (strict && currentTarget && + fleePos.GetExactDist(currentTarget) - currentTarget->GetCombatReach() > + sPlayerbotAIConfig->tooCloseDistance && + bot->IsWithinMeleeRange(currentTarget)) + { continue; } - if (pos.GetExactDist(fleePos) > farestDis) { + if (pos.GetExactDist(fleePos) > farestDis) + { farestDis = pos.GetExactDist(fleePos); bestPos = fleePos; } } - if (farestDis > 0.0f) { + if (farestDis > 0.0f) + { return bestPos; } return Position(); @@ -1782,7 +1892,8 @@ Position MovementAction::BestPositionForRangedToFlee(Position pos, float radius) std::vector possibleAngles; float angleToTarget = 0.0f; float angleFleeFromCenter = bot->GetAngle(&pos) - (float)M_PI; - if (currentTarget) { + if (currentTarget) + { // Normally, move to left or right is the best position angleToTarget = bot->GetAngle(currentTarget); float angleLeft = angleToTarget + (float)M_PI / 2; @@ -1792,36 +1903,44 @@ Position MovementAction::BestPositionForRangedToFlee(Position pos, float radius) possibleAngles.push_back({angleToTarget + (float)M_PI, true}); possibleAngles.push_back({angleToTarget, true}); possibleAngles.push_back({angleFleeFromCenter, true}); - } else { + } + else + { possibleAngles.push_back({angleFleeFromCenter, false}); } float farestDis = 0.0f; Position bestPos; - for (CheckAngle &checkAngle : possibleAngles) { + for (CheckAngle& checkAngle : possibleAngles) + { float angle = checkAngle.angle; auto& infoList = AI_VALUE_REF(std::list, "recently flee info"); - if (!CheckLastFlee(angle, infoList)) { + if (!CheckLastFlee(angle, infoList)) + { continue; } bool strict = checkAngle.strict; float fleeDis = std::min(radius + 1.0f, sPlayerbotAIConfig->fleeDistance); - Position fleePos{bot->GetPositionX() + cos(angle) * fleeDis, - bot->GetPositionY() + sin(angle) * fleeDis, - bot->GetPositionZ()}; - if (strict && currentTarget - && fleePos.GetExactDist(currentTarget) - currentTarget->GetCombatReach() > sPlayerbotAIConfig->spellDistance) { + Position fleePos{bot->GetPositionX() + cos(angle) * fleeDis, bot->GetPositionY() + sin(angle) * fleeDis, + bot->GetPositionZ()}; + if (strict && currentTarget && + fleePos.GetExactDist(currentTarget) - currentTarget->GetCombatReach() > sPlayerbotAIConfig->spellDistance) + { continue; } - if (strict && currentTarget - && fleePos.GetExactDist(currentTarget) - currentTarget->GetCombatReach() < (sPlayerbotAIConfig->tooCloseDistance)) { + if (strict && currentTarget && + fleePos.GetExactDist(currentTarget) - currentTarget->GetCombatReach() < + (sPlayerbotAIConfig->tooCloseDistance)) + { continue; } - if (pos.GetExactDist(fleePos) > farestDis) { + if (pos.GetExactDist(fleePos) > farestDis) + { farestDis = pos.GetExactDist(fleePos); bestPos = fleePos; } } - if (farestDis > 0.0f) { + if (farestDis > 0.0f) + { return bestPos; } return Position(); @@ -1830,19 +1949,29 @@ Position MovementAction::BestPositionForRangedToFlee(Position pos, float radius) bool MovementAction::FleePosition(Position pos, float radius) { Position bestPos; - if (botAI->IsMelee(bot)) { + if (botAI->IsMelee(bot)) + { bestPos = BestPositionForMeleeToFlee(pos, radius); - } else { + } + else + { bestPos = BestPositionForRangedToFlee(pos, radius); } - if (bestPos != Position()) { - if (MoveTo(bot->GetMapId(), bestPos.GetPositionX(), bestPos.GetPositionY(), bestPos.GetPositionZ(), false, false, true)) { + if (bestPos != Position()) + { + if (MoveTo(bot->GetMapId(), bestPos.GetPositionX(), bestPos.GetPositionY(), bestPos.GetPositionZ(), false, + false, true)) + { auto& infoList = AI_VALUE_REF(std::list, "recently flee info"); uint32 curTS = getMSTime(); - while (!infoList.empty()) { - if (infoList.size() > 10 || infoList.front().timestamp + 5000 < curTS) { + while (!infoList.empty()) + { + if (infoList.size() > 10 || infoList.front().timestamp + 5000 < curTS) + { infoList.pop_front(); - } else { + } + else + { break; } } @@ -1857,21 +1986,28 @@ bool MovementAction::CheckLastFlee(float curAngle, std::list& infoList { uint32 curTS = getMSTime(); curAngle = fmod(curAngle, 2 * M_PI); - while (!infoList.empty()) { - if (infoList.size() > 10 || infoList.front().timestamp + 5000 < curTS) { + while (!infoList.empty()) + { + if (infoList.size() > 10 || infoList.front().timestamp + 5000 < curTS) + { infoList.pop_front(); - } else { + } + else + { break; } } - for (FleeInfo& info : infoList) { + for (FleeInfo& info : infoList) + { // more than 5 sec - if (info.timestamp + 5000 < curTS) { + if (info.timestamp + 5000 < curTS) + { continue; } float revAngle = fmod(info.angle + M_PI, 2 * M_PI); // angle too close - if (fabs(revAngle - curAngle) < M_PI / 4) { + if (fabs(revAngle - curAngle) < M_PI / 4) + { return false; } } @@ -1880,10 +2016,12 @@ bool MovementAction::CheckLastFlee(float curAngle, std::list& infoList bool CombatFormationMoveAction::isUseful() { - if (getMSTime() - moveInterval < lastMoveTimer) { + if (getMSTime() - moveInterval < lastMoveTimer) + { return false; } - if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL) != nullptr) { + if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL) != nullptr) + { return false; } float dis = AI_VALUE(float, "disperse distance"); @@ -1894,8 +2032,10 @@ bool CombatFormationMoveAction::Execute(Event event) { float dis = AI_VALUE(float, "disperse distance"); Player* playerToLeave = NearestGroupMember(dis); - if (playerToLeave && bot->GetExactDist(playerToLeave) < dis) { - if (FleePosition(playerToLeave->GetPosition(), dis)) { + if (playerToLeave && bot->GetExactDist(playerToLeave) < dis) + { + if (FleePosition(playerToLeave->GetPosition(), dis)) + { lastMoveTimer = getMSTime(); } } @@ -1907,14 +2047,16 @@ Position CombatFormationMoveAction::AverageGroupPos(float dis) float averageX = 0, averageY = 0, averageZ = 0; int cnt = 0; Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { return Position(); } Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) { - Player *member = ObjectAccessor::FindPlayer(itr->guid); - if (!member || !member->IsAlive() || member->GetMapId() != bot->GetMapId() || member->IsCharmed() || sServerFacade->GetDistance2d(bot, member) > dis) + Player* member = ObjectAccessor::FindPlayer(itr->guid); + if (!member || !member->IsAlive() || member->GetMapId() != bot->GetMapId() || member->IsCharmed() || + sServerFacade->GetDistance2d(bot, member) > dis) continue; cnt++; averageX += member->GetPositionX(); @@ -1932,16 +2074,19 @@ Player* CombatFormationMoveAction::NearestGroupMember(float dis) float nearestDis = 10000.0f; Player* result = nullptr; Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { return result; } Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) { - Player *member = ObjectAccessor::FindPlayer(itr->guid); - if (!member || !member->IsAlive() || member == bot || member->GetMapId() != bot->GetMapId() || member->IsCharmed() || sServerFacade->GetDistance2d(bot, member) > dis) + Player* member = ObjectAccessor::FindPlayer(itr->guid); + if (!member || !member->IsAlive() || member == bot || member->GetMapId() != bot->GetMapId() || + member->IsCharmed() || sServerFacade->GetDistance2d(bot, member) > dis) continue; - if (nearestDis > bot->GetExactDist(member)) { + if (nearestDis > bot->GetExactDist(member)) + { result = member; nearestDis = bot->GetExactDist(member); } @@ -1952,15 +2097,20 @@ Player* CombatFormationMoveAction::NearestGroupMember(float dis) bool DisperseSetAction::Execute(Event event) { std::string const text = event.getParam(); - if (text == "disable") { + if (text == "disable") + { RESET_AI_VALUE(float, "disperse distance"); botAI->TellMasterNoFacing("Disable disperse"); return true; } - if (text == "enable" || text == "reset") { - if (botAI->IsMelee(bot)) { + if (text == "enable" || text == "reset") + { + if (botAI->IsMelee(bot)) + { SET_AI_VALUE(float, "disperse distance", DEFAULT_DISPERSE_DISTANCE_MELEE); - } else { + } + else + { SET_AI_VALUE(float, "disperse distance", DEFAULT_DISPERSE_DISTANCE_RANGED); } float dis = AI_VALUE(float, "disperse distance"); @@ -1969,10 +2119,12 @@ bool DisperseSetAction::Execute(Event event) botAI->TellMasterNoFacing(out.str()); return true; } - if (text == "increase") { + if (text == "increase") + { float dis = AI_VALUE(float, "disperse distance"); std::ostringstream out; - if (dis <= 0.0f) { + if (dis <= 0.0f) + { out << "Enable disperse first"; botAI->TellMasterNoFacing(out.str()); return true; @@ -1983,10 +2135,12 @@ bool DisperseSetAction::Execute(Event event) botAI->TellMasterNoFacing(out.str()); return true; } - if (text == "decrease") { + if (text == "decrease") + { float dis = AI_VALUE(float, "disperse distance"); dis -= 1.0f; - if (dis <= 0.0f) { + if (dis <= 0.0f) + { dis += 1.0f; } SET_AI_VALUE(float, "disperse distance", dis); @@ -1995,13 +2149,18 @@ bool DisperseSetAction::Execute(Event event) botAI->TellMasterNoFacing(out.str()); return true; } - if (text.starts_with("set")) { - float dis = -1.0f;; + if (text.starts_with("set")) + { + float dis = -1.0f; + ; sscanf(text.c_str(), "set %f", &dis); std::ostringstream out; - if (dis < 0 || dis > 100.0f) { + if (dis < 0 || dis > 100.0f) + { out << "Invalid disperse distance " << std::setprecision(2) << dis; - } else { + } + else + { SET_AI_VALUE(float, "disperse distance", dis); out << "Set disperse distance to " << std::setprecision(2) << dis; } @@ -2011,17 +2170,15 @@ bool DisperseSetAction::Execute(Event event) std::ostringstream out; out << "Usage: disperse [enable | disable | increase | decrease | set {distance}]"; float dis = AI_VALUE(float, "disperse distance"); - if (dis > 0.0f) { + if (dis > 0.0f) + { out << "(Current disperse distance: " << std::setprecision(2) << dis << ")"; } botAI->TellMasterNoFacing(out.str()); return true; } -bool RunAwayAction::Execute(Event event) -{ - return Flee(AI_VALUE(Unit*, "master target")); -} +bool RunAwayAction::Execute(Event event) { return Flee(AI_VALUE(Unit*, "master target")); } bool MoveToLootAction::Execute(Event event) { @@ -2041,10 +2198,7 @@ bool MoveOutOfEnemyContactAction::Execute(Event event) return MoveTo(target, sPlayerbotAIConfig->contactDistance); } -bool MoveOutOfEnemyContactAction::isUseful() -{ - return AI_VALUE2(bool, "inside target", "current target"); -} +bool MoveOutOfEnemyContactAction::isUseful() { return AI_VALUE2(bool, "inside target", "current target"); } bool SetFacingTargetAction::Execute(Event event) { @@ -2060,17 +2214,12 @@ bool SetFacingTargetAction::Execute(Event event) return true; } -bool SetFacingTargetAction::isUseful() -{ - return !AI_VALUE2(bool, "facing", "current target"); -} +bool SetFacingTargetAction::isUseful() { return !AI_VALUE2(bool, "facing", "current target"); } bool SetFacingTargetAction::isPossible() { - if (bot->isFrozen() || bot->IsPolymorphed() || - (bot->isDead() && !bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) || - bot->IsBeingTeleported() || - bot->HasAuraType(SPELL_AURA_MOD_CONFUSE) || bot->IsCharmed() || + if (bot->isFrozen() || bot->IsPolymorphed() || (bot->isDead() && !bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) || + bot->IsBeingTeleported() || bot->HasAuraType(SPELL_AURA_MOD_CONFUSE) || bot->IsCharmed() || bot->HasAuraType(SPELL_AURA_MOD_STUN) || bot->HasUnitState(UNIT_STATE_IN_FLIGHT) || bot->HasUnitState(UNIT_STATE_LOST_CONTROL)) return false; @@ -2086,7 +2235,7 @@ bool SetBehindTargetAction::Execute(Event event) float angle = GetFollowAngle() / 3 + target->GetOrientation() + M_PI; - //return ChaseTo(target, 0.f, angle); + // return ChaseTo(target, 0.f, angle); float distance = sPlayerbotAIConfig->contactDistance; float x = target->GetPositionX() + cos(angle) * distance; @@ -2097,10 +2246,7 @@ bool SetBehindTargetAction::Execute(Event event) return MoveTo(bot->GetMapId(), x, y, z); } -bool SetBehindTargetAction::isUseful() -{ - return !AI_VALUE2(bool, "behind", "current target"); -} +bool SetBehindTargetAction::isUseful() { return !AI_VALUE2(bool, "behind", "current target"); } bool SetBehindTargetAction::isPossible() { @@ -2112,7 +2258,8 @@ bool MoveOutOfCollisionAction::Execute(Event event) { float angle = M_PI * 2000 / frand(1.f, 1000.f); float distance = sPlayerbotAIConfig->followDistance; - return MoveTo(bot->GetMapId(), bot->GetPositionX() + cos(angle) * distance, bot->GetPositionY() + sin(angle) * distance, bot->GetPositionZ()); + return MoveTo(bot->GetMapId(), bot->GetPositionX() + cos(angle) * distance, + bot->GetPositionY() + sin(angle) * distance, bot->GetPositionZ()); } bool MoveOutOfCollisionAction::isUseful() @@ -2121,7 +2268,8 @@ bool MoveOutOfCollisionAction::isUseful() if (botAI->IsInVehicle()) return false; - return AI_VALUE2(bool, "collision", "self target") && botAI->GetAiObjectContext()->GetValue("nearest friendly players")->Get().size() < 15; + return AI_VALUE2(bool, "collision", "self target") && + botAI->GetAiObjectContext()->GetValue("nearest friendly players")->Get().size() < 15; } bool MoveRandomAction::Execute(Event event) @@ -2150,20 +2298,15 @@ bool MoveRandomAction::Execute(Event event) return false; } -bool MoveRandomAction::isUseful() -{ - return !AI_VALUE(GuidPosition, "rpg target"); -} +bool MoveRandomAction::isUseful() { return !AI_VALUE(GuidPosition, "rpg target"); } -bool MoveInsideAction::Execute(Event event) -{ - return MoveInside(bot->GetMapId(), x, y, bot->GetPositionZ(), distance); -} +bool MoveInsideAction::Execute(Event event) { return MoveInside(bot->GetMapId(), x, y, bot->GetPositionZ(), distance); } bool RotateAroundTheCenterPointAction::Execute(Event event) { uint32 next_point = GetCurrWaypoint(); - if (MoveTo(bot->GetMapId(), waypoints[next_point].first, waypoints[next_point].second, bot->GetPositionZ())) { + if (MoveTo(bot->GetMapId(), waypoints[next_point].first, waypoints[next_point].second, bot->GetPositionZ())) + { call_counters += 1; return true; } diff --git a/src/strategy/actions/MovementActions.h b/src/strategy/actions/MovementActions.h index 0964ddfb..c0a5b888 100644 --- a/src/strategy/actions/MovementActions.h +++ b/src/strategy/actions/MovementActions.h @@ -1,13 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MOVEMENTACTIONS_H #define _PLAYERBOT_MOVEMENTACTIONS_H +#include + #include "Action.h" #include "PlayerbotAIConfig.h" -#include class Player; class PlayerbotAI; @@ -17,205 +19,223 @@ class Position; class MovementAction : public Action { - public: - MovementAction(PlayerbotAI* botAI, std::string const name); +public: + MovementAction(PlayerbotAI* botAI, std::string const name); - protected: - void JumpTo(uint32 mapId, float x, float y, float z); - bool MoveNear(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->contactDistance); - bool MoveToLOS(WorldObject* target, bool ranged = false); - bool MoveTo(uint32 mapId, float x, float y, float z, bool idle = false, bool react = false, bool normal_only = false); - bool MoveTo(Unit* target, float distance = 0.0f); - bool MoveNear(WorldObject* target, float distance = sPlayerbotAIConfig->contactDistance); - float GetFollowAngle(); - bool Follow(Unit* target, float distance = sPlayerbotAIConfig->followDistance); - bool Follow(Unit* target, float distance, float angle); - bool ChaseTo(WorldObject* obj, float distance = 0.0f, float angle = 0.0f); - bool ReachCombatTo(Unit* target, float distance = 0.0f); - float MoveDelay(float distance); - void WaitForReach(float distance); - bool IsMovingAllowed(Unit* target); - bool IsMovingAllowed(uint32 mapId, float x, float y, float z); - bool IsMovingAllowed(); - bool Flee(Unit *target); - void ClearIdleState(); - void UpdateMovementState(); - bool MoveAway(Unit* target); - bool MoveInside(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->followDistance); - void CreateWp(Player* wpOwner, float x, float y, float z, float o, uint32 entry, bool important = false); - Position BestPositionForMeleeToFlee(Position pos, float radius); - Position BestPositionForRangedToFlee(Position pos, float radius); - bool FleePosition(Position pos, float radius); - bool CheckLastFlee(float curAngle, std::list& infoList); - protected: - struct CheckAngle { - float angle; - bool strict; - }; - private: - // float SearchBestGroundZForPath(float x, float y, float z, bool generatePath, float range = 20.0f, bool normal_only = false, float step = 8.0f); - const Movement::PointsArray SearchForBestPath(float x, float y, float z, float &modified_z, int maxSearchCount = 5, bool normal_only = false, float step = 8.0f); +protected: + void JumpTo(uint32 mapId, float x, float y, float z); + bool MoveNear(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->contactDistance); + bool MoveToLOS(WorldObject* target, bool ranged = false); + bool MoveTo(uint32 mapId, float x, float y, float z, bool idle = false, bool react = false, + bool normal_only = false); + bool MoveTo(Unit* target, float distance = 0.0f); + bool MoveNear(WorldObject* target, float distance = sPlayerbotAIConfig->contactDistance); + float GetFollowAngle(); + bool Follow(Unit* target, float distance = sPlayerbotAIConfig->followDistance); + bool Follow(Unit* target, float distance, float angle); + bool ChaseTo(WorldObject* obj, float distance = 0.0f, float angle = 0.0f); + bool ReachCombatTo(Unit* target, float distance = 0.0f); + float MoveDelay(float distance); + void WaitForReach(float distance); + bool IsMovingAllowed(Unit* target); + bool IsMovingAllowed(uint32 mapId, float x, float y, float z); + bool IsMovingAllowed(); + bool Flee(Unit* target); + void ClearIdleState(); + void UpdateMovementState(); + bool MoveAway(Unit* target); + bool MoveInside(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->followDistance); + void CreateWp(Player* wpOwner, float x, float y, float z, float o, uint32 entry, bool important = false); + Position BestPositionForMeleeToFlee(Position pos, float radius); + Position BestPositionForRangedToFlee(Position pos, float radius); + bool FleePosition(Position pos, float radius); + bool CheckLastFlee(float curAngle, std::list& infoList); + +protected: + struct CheckAngle + { + float angle; + bool strict; + }; + +private: + // float SearchBestGroundZForPath(float x, float y, float z, bool generatePath, float range = 20.0f, bool + // normal_only = false, float step = 8.0f); + const Movement::PointsArray SearchForBestPath(float x, float y, float z, float& modified_z, int maxSearchCount = 5, + bool normal_only = false, float step = 8.0f); }; class FleeAction : public MovementAction { - public: - FleeAction(PlayerbotAI* botAI, float distance = sPlayerbotAIConfig->spellDistance) : MovementAction(botAI, "flee"), distance(distance) { } +public: + FleeAction(PlayerbotAI* botAI, float distance = sPlayerbotAIConfig->spellDistance) + : MovementAction(botAI, "flee"), distance(distance) + { + } - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; - private: - float distance; +private: + float distance; }; class FleeWithPetAction : public MovementAction { - public: - FleeWithPetAction(PlayerbotAI* botAI) : MovementAction(botAI, "flee with pet") { } +public: + FleeWithPetAction(PlayerbotAI* botAI) : MovementAction(botAI, "flee with pet") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class AvoidAoeAction : public MovementAction { - public: - AvoidAoeAction(PlayerbotAI* botAI, int moveInterval = 1000) : MovementAction(botAI, "avoid aoe"), - moveInterval(moveInterval) { } +public: + AvoidAoeAction(PlayerbotAI* botAI, int moveInterval = 1000) + : MovementAction(botAI, "avoid aoe"), moveInterval(moveInterval) + { + } - bool isUseful() override; - bool Execute(Event event) override; - - protected: - bool AvoidAuraWithDynamicObj(); - bool AvoidGameObjectWithDamage(); - bool AvoidUnitWithDamageAura(); - time_t lastTellTimer = 0; - int lastMoveTimer = 0; - int moveInterval; - + bool isUseful() override; + bool Execute(Event event) override; + +protected: + bool AvoidAuraWithDynamicObj(); + bool AvoidGameObjectWithDamage(); + bool AvoidUnitWithDamageAura(); + time_t lastTellTimer = 0; + int lastMoveTimer = 0; + int moveInterval; }; class CombatFormationMoveAction : public MovementAction { - public: - CombatFormationMoveAction(PlayerbotAI* botAI, int moveInterval = 1000) : MovementAction(botAI, "combat formation move"), - moveInterval(moveInterval) { } +public: + CombatFormationMoveAction(PlayerbotAI* botAI, int moveInterval = 1000) + : MovementAction(botAI, "combat formation move"), moveInterval(moveInterval) + { + } - bool isUseful() override; - bool Execute(Event event) override; - - protected: - Position AverageGroupPos(float dis = sPlayerbotAIConfig->sightDistance); - Player* NearestGroupMember(float dis = sPlayerbotAIConfig->sightDistance); - int lastMoveTimer = 0; - int moveInterval; + bool isUseful() override; + bool Execute(Event event) override; + +protected: + Position AverageGroupPos(float dis = sPlayerbotAIConfig->sightDistance); + Player* NearestGroupMember(float dis = sPlayerbotAIConfig->sightDistance); + int lastMoveTimer = 0; + int moveInterval; }; class DisperseSetAction : public Action { - public: - DisperseSetAction(PlayerbotAI* botAI, std::string const name = "disperse set") : Action(botAI, name) { } +public: + DisperseSetAction(PlayerbotAI* botAI, std::string const name = "disperse set") : Action(botAI, name) {} - bool Execute(Event event) override; - float DEFAULT_DISPERSE_DISTANCE_RANGED = 5.0f; - float DEFAULT_DISPERSE_DISTANCE_MELEE = 2.0f; + bool Execute(Event event) override; + float DEFAULT_DISPERSE_DISTANCE_RANGED = 5.0f; + float DEFAULT_DISPERSE_DISTANCE_MELEE = 2.0f; }; class RunAwayAction : public MovementAction { - public: - RunAwayAction(PlayerbotAI* botAI) : MovementAction(botAI, "runaway") { } - - bool Execute(Event event) override; +public: + RunAwayAction(PlayerbotAI* botAI) : MovementAction(botAI, "runaway") {} + + bool Execute(Event event) override; }; class MoveToLootAction : public MovementAction { - public: - MoveToLootAction(PlayerbotAI* botAI) : MovementAction(botAI, "move to loot") { } +public: + MoveToLootAction(PlayerbotAI* botAI) : MovementAction(botAI, "move to loot") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class MoveOutOfEnemyContactAction : public MovementAction { - public: - MoveOutOfEnemyContactAction(PlayerbotAI* botAI) : MovementAction(botAI, "move out of enemy contact") { } +public: + MoveOutOfEnemyContactAction(PlayerbotAI* botAI) : MovementAction(botAI, "move out of enemy contact") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class SetFacingTargetAction : public Action { - public: - SetFacingTargetAction(PlayerbotAI* botAI) : Action(botAI, "set facing") { } +public: + SetFacingTargetAction(PlayerbotAI* botAI) : Action(botAI, "set facing") {} - bool Execute(Event event) override; - bool isUseful() override; - bool isPossible() override; + bool Execute(Event event) override; + bool isUseful() override; + bool isPossible() override; }; class SetBehindTargetAction : public MovementAction { - public: - SetBehindTargetAction(PlayerbotAI* botAI) : MovementAction(botAI, "set behind") { } +public: + SetBehindTargetAction(PlayerbotAI* botAI) : MovementAction(botAI, "set behind") {} - bool Execute(Event event) override; - bool isUseful() override; - bool isPossible() override; + bool Execute(Event event) override; + bool isUseful() override; + bool isPossible() override; }; class MoveOutOfCollisionAction : public MovementAction { - public: - MoveOutOfCollisionAction(PlayerbotAI* botAI) : MovementAction(botAI, "move out of collision") { } +public: + MoveOutOfCollisionAction(PlayerbotAI* botAI) : MovementAction(botAI, "move out of collision") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class MoveRandomAction : public MovementAction { - public: - MoveRandomAction(PlayerbotAI* botAI) : MovementAction(botAI, "move random") { } +public: + MoveRandomAction(PlayerbotAI* botAI) : MovementAction(botAI, "move random") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class MoveInsideAction : public MovementAction { - public: - MoveInsideAction(PlayerbotAI* ai, float x, float y, float distance = 5.0f) : MovementAction(ai, "move inside") { - this->x = x; - this->y = y; - this->distance = distance; - } - virtual bool Execute(Event event); - protected: - float x, y, distance; +public: + MoveInsideAction(PlayerbotAI* ai, float x, float y, float distance = 5.0f) : MovementAction(ai, "move inside") + { + this->x = x; + this->y = y; + this->distance = distance; + } + virtual bool Execute(Event event); + +protected: + float x, y, distance; }; class RotateAroundTheCenterPointAction : public MovementAction { public: - RotateAroundTheCenterPointAction(PlayerbotAI* ai, std::string name, - float center_x, float center_y, float radius = 40.0f, - uint32 intervals = 16, bool clockwise = true, float start_angle = 0) : MovementAction(ai, name) { + RotateAroundTheCenterPointAction(PlayerbotAI* ai, std::string name, float center_x, float center_y, + float radius = 40.0f, uint32 intervals = 16, bool clockwise = true, + float start_angle = 0) + : MovementAction(ai, name) + { this->center_x = center_x; this->center_y = center_y; this->radius = radius; this->intervals = intervals; this->clockwise = clockwise; this->call_counters = 0; - for (int i = 0; i < intervals; i++) { + for (int i = 0; i < intervals; i++) + { float angle = start_angle + 2 * M_PI * i / intervals; waypoints.push_back(std::make_pair(center_x + cos(angle) * radius, center_y + sin(angle) * radius)); } } virtual bool Execute(Event event); + protected: virtual uint32 GetCurrWaypoint() { return 0; } uint32 FindNearestWaypoint(); diff --git a/src/strategy/actions/NonCombatActions.cpp b/src/strategy/actions/NonCombatActions.cpp index 4bc7af6b..6ee977a2 100644 --- a/src/strategy/actions/NonCombatActions.cpp +++ b/src/strategy/actions/NonCombatActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "NonCombatActions.h" + #include "Event.h" #include "Playerbots.h" @@ -17,7 +19,6 @@ bool DrinkAction::Execute(Event event) if (sPlayerbotAIConfig->freeFood) { - // if (bot->IsNonMeleeSpellCast(true)) // return false; @@ -33,7 +34,7 @@ bool DrinkAction::Execute(Event event) bot->SetStandState(UNIT_STAND_STATE_SIT); botAI->InterruptSpell(); - //float hp = bot->GetHealthPercent(); + // float hp = bot->GetHealthPercent(); float mp = bot->GetPowerPct(POWER_MANA); float p = mp; float delay; @@ -44,7 +45,7 @@ bool DrinkAction::Execute(Event event) delay = 20000.0f * (100 - p) / 100.0f; botAI->SetNextCheckDelay(delay); - + bot->AddAura(24707, bot); return true; // return botAI->CastSpell(24707, bot); @@ -53,10 +54,7 @@ bool DrinkAction::Execute(Event event) return UseItemAction::Execute(event); } -bool DrinkAction::isUseful() -{ - return UseItemAction::isUseful() && AI_VALUE2(uint8, "mana", "self target") < 85; -} +bool DrinkAction::isUseful() { return UseItemAction::isUseful() && AI_VALUE2(uint8, "mana", "self target") < 85; } bool DrinkAction::isPossible() { @@ -87,7 +85,7 @@ bool EatAction::Execute(Event event) botAI->InterruptSpell(); float hp = bot->GetHealthPct(); - //float mp = bot->HasMana() ? bot->GetPowerPercent() : 0.f; + // float mp = bot->HasMana() ? bot->GetPowerPercent() : 0.f; float p = hp; float delay; @@ -97,7 +95,7 @@ bool EatAction::Execute(Event event) delay = 20000.0f * (100 - p) / 100.0f; botAI->SetNextCheckDelay(delay); - + bot->AddAura(24707, bot); return true; } @@ -105,10 +103,7 @@ bool EatAction::Execute(Event event) return UseItemAction::Execute(event); } -bool EatAction::isUseful() -{ - return UseItemAction::isUseful() && AI_VALUE2(uint8, "health", "self target") < 85; -} +bool EatAction::isUseful() { return UseItemAction::isUseful() && AI_VALUE2(uint8, "health", "self target") < 85; } bool EatAction::isPossible() { diff --git a/src/strategy/actions/NonCombatActions.h b/src/strategy/actions/NonCombatActions.h index 8eb8a0e6..5d30d498 100644 --- a/src/strategy/actions/NonCombatActions.h +++ b/src/strategy/actions/NonCombatActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_NONCOMBATACTIONS_H @@ -11,22 +12,22 @@ class PlayerbotAI; class DrinkAction : public UseItemAction { - public: - DrinkAction(PlayerbotAI* botAI) : UseItemAction(botAI, "drink") { } +public: + DrinkAction(PlayerbotAI* botAI) : UseItemAction(botAI, "drink") {} - bool Execute(Event event) override; - bool isUseful() override; - bool isPossible() override; + bool Execute(Event event) override; + bool isUseful() override; + bool isPossible() override; }; class EatAction : public UseItemAction { - public: - EatAction(PlayerbotAI* botAI) : UseItemAction(botAI, "food") { } +public: + EatAction(PlayerbotAI* botAI) : UseItemAction(botAI, "food") {} - bool Execute(Event event) override; - bool isUseful() override; - bool isPossible() override; + bool Execute(Event event) override; + bool isUseful() override; + bool isPossible() override; }; #endif diff --git a/src/strategy/actions/OutfitAction.cpp b/src/strategy/actions/OutfitAction.cpp index 92c9f91f..f3c0c715 100644 --- a/src/strategy/actions/OutfitAction.cpp +++ b/src/strategy/actions/OutfitAction.cpp @@ -1,11 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "OutfitAction.h" + #include "Event.h" -#include "Playerbots.h" #include "ItemVisitors.h" +#include "Playerbots.h" bool OutfitAction::Execute(Event event) { diff --git a/src/strategy/actions/OutfitAction.h b/src/strategy/actions/OutfitAction.h index 19d08618..2a6e6785 100644 --- a/src/strategy/actions/OutfitAction.h +++ b/src/strategy/actions/OutfitAction.h @@ -1,26 +1,27 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_OUTFITACTION_H #define _PLAYERBOT_OUTFITACTION_H -#include "EquipAction.h" #include "ChatHelper.h" +#include "EquipAction.h" class PlayerbotAI; class OutfitAction : public EquipAction { - public: - OutfitAction(PlayerbotAI* botAI) : EquipAction(botAI, "outfit") { } +public: + OutfitAction(PlayerbotAI* botAI) : EquipAction(botAI, "outfit") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - void List(); - void Save(std::string const name, ItemIds outfit); - void Update(std::string const name); +private: + void List(); + void Save(std::string const name, ItemIds outfit); + void Update(std::string const name); }; #endif diff --git a/src/strategy/actions/PassLeadershipToMasterAction.cpp b/src/strategy/actions/PassLeadershipToMasterAction.cpp index 03c57b5a..a362c2cb 100644 --- a/src/strategy/actions/PassLeadershipToMasterAction.cpp +++ b/src/strategy/actions/PassLeadershipToMasterAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PassLeadershipToMasterAction.h" + #include "Event.h" #include "Playerbots.h" diff --git a/src/strategy/actions/PassLeadershipToMasterAction.h b/src/strategy/actions/PassLeadershipToMasterAction.h index b451ade8..a4ab15c4 100644 --- a/src/strategy/actions/PassLeadershipToMasterAction.h +++ b/src/strategy/actions/PassLeadershipToMasterAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PASSLEADERSHIPTOMASTERACTION_H @@ -11,22 +12,29 @@ class PlayerbotAI; class PassLeadershipToMasterAction : public Action { - public: - PassLeadershipToMasterAction(PlayerbotAI* botAI, std::string const name = "leader", std::string const message = "Passing leader to you!") : Action(botAI, name), message(message) { } +public: + PassLeadershipToMasterAction(PlayerbotAI* botAI, std::string const name = "leader", + std::string const message = "Passing leader to you!") + : Action(botAI, name), message(message) + { + } - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; - protected: - std::string const message; +protected: + std::string const message; }; class GiveLeaderAction : public PassLeadershipToMasterAction { - public: - GiveLeaderAction(PlayerbotAI* botAI, std::string const message = "Lead the way!") : PassLeadershipToMasterAction(botAI, "give leader", message) { } +public: + GiveLeaderAction(PlayerbotAI* botAI, std::string const message = "Lead the way!") + : PassLeadershipToMasterAction(botAI, "give leader", message) + { + } - bool isUseful() override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/PetitionSignAction.cpp b/src/strategy/actions/PetitionSignAction.cpp index 32f9c773..025f0447 100644 --- a/src/strategy/actions/PetitionSignAction.cpp +++ b/src/strategy/actions/PetitionSignAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PetitionSignAction.h" + #include "ArenaTeam.h" #include "Event.h" #include "Playerbots.h" @@ -17,7 +19,8 @@ bool PetitionSignAction::Execute(Event event) bool isArena = false; p >> petitionGuid >> inviter; - QueryResult result = CharacterDatabase.Query("SELECT `type` FROM `petition` WHERE `petitionguid` = {}", petitionGuid.GetCounter()); + QueryResult result = + CharacterDatabase.Query("SELECT `type` FROM `petition` WHERE `petitionguid` = {}", petitionGuid.GetCounter()); if (!result) { return false; @@ -54,8 +57,8 @@ bool PetitionSignAction::Execute(Event event) } // check for same acc id - /*if (QueryResult* result = CharacterDatabase.Query("SELECT playerguid FROM petition_sign WHERE player_account = {} AND petitionguid = {}'", - bot->GetSession()->GetAccountId(), petitionGuid.GetCounter())) + /*if (QueryResult* result = CharacterDatabase.Query("SELECT playerguid FROM petition_sign WHERE player_account = + {} AND petitionguid = {}'", bot->GetSession()->GetAccountId(), petitionGuid.GetCounter())) { botAI->TellError("Sorry, I already signed this pettition"); accept = false; @@ -75,7 +78,8 @@ bool PetitionSignAction::Execute(Event event) WorldPacket data(MSG_PETITION_DECLINE); data << petitionGuid; bot->GetSession()->HandlePetitionDeclineOpcode(data); - LOG_INFO("playerbots", "Bot {} <{}> declines {} invite", bot->GetGUID().ToString().c_str(), bot->GetName().c_str(), isArena ? "Arena" : "Guild"); + LOG_INFO("playerbots", "Bot {} <{}> declines {} invite", bot->GetGUID().ToString().c_str(), + bot->GetName().c_str(), isArena ? "Arena" : "Guild"); return false; } @@ -85,7 +89,8 @@ bool PetitionSignAction::Execute(Event event) data << petitionGuid << unk; bot->GetSession()->HandlePetitionSignOpcode(data); bot->Say("Thanks for the invite!", LANG_UNIVERSAL); - LOG_INFO("playerbots", "Bot {} <{}> accepts {} invite", bot->GetGUID().ToString().c_str(), bot->GetName().c_str(), isArena ? "Arena" : "Guild"); + LOG_INFO("playerbots", "Bot {} <{}> accepts {} invite", bot->GetGUID().ToString().c_str(), + bot->GetName().c_str(), isArena ? "Arena" : "Guild"); return true; } diff --git a/src/strategy/actions/PetitionSignAction.h b/src/strategy/actions/PetitionSignAction.h index cac56be6..b73e4283 100644 --- a/src/strategy/actions/PetitionSignAction.h +++ b/src/strategy/actions/PetitionSignAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PETITIONSIGNACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class PetitionSignAction : public Action { - public: - PetitionSignAction(PlayerbotAI* botAI) : Action(botAI, "petition sign") { } +public: + PetitionSignAction(PlayerbotAI* botAI) : Action(botAI, "petition sign") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/PositionAction.cpp b/src/strategy/actions/PositionAction.cpp index 3d24603a..df5fd500 100644 --- a/src/strategy/actions/PositionAction.cpp +++ b/src/strategy/actions/PositionAction.cpp @@ -1,11 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PositionAction.h" + #include "Event.h" -#include "PositionValue.h" #include "Playerbots.h" +#include "PositionValue.h" void TellPosition(PlayerbotAI* botAI, std::string const name, PositionInfo pos) { @@ -28,8 +30,8 @@ void TellPosition(PlayerbotAI* botAI, std::string const name, PositionInfo pos) bool PositionAction::Execute(Event event) { std::string const param = event.getParam(); - if (param.empty()) - return false; + if (param.empty()) + return false; Player* master = GetMaster(); if (!master) @@ -56,12 +58,12 @@ bool PositionAction::Execute(Event event) std::string const name = params[0]; std::string const action = params[1]; - PositionInfo pos = posMap[name]; - if (action == "?") - { - TellPosition(botAI, name, pos); - return true; - } + PositionInfo pos = posMap[name]; + if (action == "?") + { + TellPosition(botAI, name, pos); + return true; + } std::vector coords = split(action, ','); if (coords.size() == 3) @@ -75,34 +77,34 @@ bool PositionAction::Execute(Event event) return true; } - if (action == "set") - { - pos.Set( bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), botAI->GetBot()->GetMapId()); - posMap[name] = pos; + if (action == "set") + { + pos.Set(bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), botAI->GetBot()->GetMapId()); + posMap[name] = pos; std::ostringstream out; out << "Position " << name << " is set"; - botAI->TellMaster(out); - return true; - } + botAI->TellMaster(out); + return true; + } - if (action == "reset") - { - pos.Reset(); - posMap[name] = pos; + if (action == "reset") + { + pos.Reset(); + posMap[name] = pos; std::ostringstream out; out << "Position " << name << " is reset"; - botAI->TellMaster(out); - return true; - } + botAI->TellMaster(out); + return true; + } return false; } bool MoveToPositionAction::Execute(Event event) { - PositionInfo pos = context->GetValue("position")->Get()[qualifier]; + PositionInfo pos = context->GetValue("position")->Get()[qualifier]; if (!pos.isSet()) { std::ostringstream out; @@ -121,7 +123,6 @@ bool MoveToPositionAction::isUseful() return pos.isSet() && distance > sPlayerbotAIConfig->followDistance && distance < sPlayerbotAIConfig->reactDistance; } - bool SetReturnPositionAction::Execute(Event event) { PositionMap& posMap = context->GetValue("position")->Get(); diff --git a/src/strategy/actions/PositionAction.h b/src/strategy/actions/PositionAction.h index 98dff0fe..b53ba1b7 100644 --- a/src/strategy/actions/PositionAction.h +++ b/src/strategy/actions/PositionAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_POSITIONACTION_H @@ -11,47 +12,49 @@ class PlayerbotAI; class PositionAction : public Action { - public: - PositionAction(PlayerbotAI* botAI) : Action(botAI, "position") { } +public: + PositionAction(PlayerbotAI* botAI) : Action(botAI, "position") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class MoveToPositionAction : public MovementAction { - public: - MoveToPositionAction(PlayerbotAI* botAI, std::string const name, std::string const qualifier, bool idle = false) : - MovementAction(botAI, name), qualifier(qualifier), idle(idle) { } +public: + MoveToPositionAction(PlayerbotAI* botAI, std::string const name, std::string const qualifier, bool idle = false) + : MovementAction(botAI, name), qualifier(qualifier), idle(idle) + { + } - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; - protected: - std::string const qualifier; - bool idle; +protected: + std::string const qualifier; + bool idle; }; class GuardAction : public MoveToPositionAction { - public: - GuardAction(PlayerbotAI* botAI) : MoveToPositionAction(botAI, "move to position", "guard") { } +public: + GuardAction(PlayerbotAI* botAI) : MoveToPositionAction(botAI, "move to position", "guard") {} }; class SetReturnPositionAction : public Action { - public: - SetReturnPositionAction(PlayerbotAI* botAI) : Action(botAI, "set return position") { } +public: + SetReturnPositionAction(PlayerbotAI* botAI) : Action(botAI, "set return position") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class ReturnAction : public MoveToPositionAction { - public: - ReturnAction(PlayerbotAI* botAI) : MoveToPositionAction(botAI, "return", "return", true) { } +public: + ReturnAction(PlayerbotAI* botAI) : MoveToPositionAction(botAI, "return", "return", true) {} - bool isUseful() override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/QueryItemUsageAction.cpp b/src/strategy/actions/QueryItemUsageAction.cpp index 2a894ced..67db84ae 100644 --- a/src/strategy/actions/QueryItemUsageAction.cpp +++ b/src/strategy/actions/QueryItemUsageAction.cpp @@ -1,11 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "QueryItemUsageAction.h" + +#include "ChatHelper.h" #include "Event.h" #include "ItemUsageValue.h" -#include "ChatHelper.h" #include "Playerbots.h" bool QueryItemUsageAction::Execute(Event event) @@ -37,10 +39,10 @@ bool QueryItemUsageAction::Execute(Event event) uint32 invCount; uint8 bagSlot; - data >> received; // 0=looted, 1=from npc - data >> created; // 0=received, 1=created - data >> isShowChatMessage; // IsShowChatMessage - data >> bagSlot; // item slot, but when added to stack: 0xFFFFFFFF + data >> received; // 0=looted, 1=from npc + data >> created; // 0=received, 1=created + data >> isShowChatMessage; // IsShowChatMessage + data >> bagSlot; // item slot, but when added to stack: 0xFFFFFFFF data >> notUsed; data >> itemId; @@ -127,10 +129,10 @@ std::string const QueryItemUsageAction::QueryItemUsage(ItemTemplate const* item) return "Tradeskill"; case ITEM_USAGE_USE: return "Use"; - case ITEM_USAGE_GUILD_TASK: - return "Guild task"; - case ITEM_USAGE_DISENCHANT: - return "Disenchant"; + case ITEM_USAGE_GUILD_TASK: + return "Guild task"; + case ITEM_USAGE_DISENCHANT: + return "Disenchant"; case ITEM_USAGE_VENDOR: return "Vendor"; case ITEM_USAGE_AH: @@ -139,7 +141,7 @@ std::string const QueryItemUsageAction::QueryItemUsage(ItemTemplate const* item) return "Ammunition"; default: break; - } + } return ""; } @@ -160,7 +162,8 @@ std::string const QueryItemUsageAction::QueryItemPrice(ItemTemplate const* item) for (std::vector::iterator i = items.begin(); i != items.end(); ++i) { Item* sell = *i; - int32 price = sell->GetCount() * sell->GetTemplate()->SellPrice * sRandomPlayerbotMgr->GetSellMultiplier(bot); + int32 price = + sell->GetCount() * sell->GetTemplate()->SellPrice * sRandomPlayerbotMgr->GetSellMultiplier(bot); if (!sellPrice || sellPrice > price) sellPrice = price; } @@ -193,12 +196,13 @@ std::string const QueryItemUsageAction::QueryQuestItem(uint32 itemId) for (QuestStatusMap::const_iterator i = questMap.begin(); i != questMap.end(); i++) { Quest const* questTemplate = sObjectMgr->GetQuestTemplate(i->first); - if (!questTemplate ) + if (!questTemplate) continue; uint32 questId = questTemplate->GetQuestId(); QuestStatus status = bot->GetQuestStatus(questId); - if (status == QUEST_STATUS_INCOMPLETE || (status == QUEST_STATUS_COMPLETE && !bot->GetQuestRewardStatus(questId))) + if (status == QUEST_STATUS_INCOMPLETE || + (status == QUEST_STATUS_COMPLETE && !bot->GetQuestRewardStatus(questId))) { QuestStatusData const& questStatus = i->second; std::string const usage = QueryQuestItem(itemId, questTemplate, &questStatus); @@ -210,7 +214,8 @@ std::string const QueryItemUsageAction::QueryQuestItem(uint32 itemId) return ""; } -std::string const QueryItemUsageAction::QueryQuestItem(uint32 itemId, Quest const* questTemplate, QuestStatusData const* questStatus) +std::string const QueryItemUsageAction::QueryQuestItem(uint32 itemId, Quest const* questTemplate, + QuestStatusData const* questStatus) { for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; i++) { diff --git a/src/strategy/actions/QueryItemUsageAction.h b/src/strategy/actions/QueryItemUsageAction.h index 17792f59..44df2143 100644 --- a/src/strategy/actions/QueryItemUsageAction.h +++ b/src/strategy/actions/QueryItemUsageAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_QUERYITEMUSAGEACTION_H @@ -15,21 +16,23 @@ struct QuestStatusData; class QueryItemUsageAction : public InventoryAction { - public: - QueryItemUsageAction(PlayerbotAI* botAI, std::string const name = "query item usage") : InventoryAction(botAI, name) { } +public: + QueryItemUsageAction(PlayerbotAI* botAI, std::string const name = "query item usage") : InventoryAction(botAI, name) + { + } - bool Execute(Event event) override; + bool Execute(Event event) override; - protected: - uint32 GetCount(ItemTemplate const* item); - std::string const QueryItem(ItemTemplate const* item, uint32 count, uint32 total); - std::string const QueryItemUsage(ItemTemplate const* item); - std::string const QueryItemPrice(ItemTemplate const* item); - std::string const QueryQuestItem(uint32 itemId, Quest const* questTemplate, QuestStatusData const* questStatus); - std::string const QueryQuestItem(uint32 itemId); +protected: + uint32 GetCount(ItemTemplate const* item); + std::string const QueryItem(ItemTemplate const* item, uint32 count, uint32 total); + std::string const QueryItemUsage(ItemTemplate const* item); + std::string const QueryItemPrice(ItemTemplate const* item); + std::string const QueryQuestItem(uint32 itemId, Quest const* questTemplate, QuestStatusData const* questStatus); + std::string const QueryQuestItem(uint32 itemId); - private: - std::ostringstream out; +private: + std::ostringstream out; }; #endif diff --git a/src/strategy/actions/QueryQuestAction.cpp b/src/strategy/actions/QueryQuestAction.cpp index 4ac608bf..f8a22728 100644 --- a/src/strategy/actions/QueryQuestAction.cpp +++ b/src/strategy/actions/QueryQuestAction.cpp @@ -1,10 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "QueryQuestAction.h" -#include "Event.h" + #include "ChatHelper.h" +#include "Event.h" #include "Playerbots.h" void QueryQuestAction::TellObjective(std::string const name, uint32 available, uint32 required) @@ -53,12 +55,14 @@ bool QueryQuestAction::Execute(Event event) if (travel) { uint32 limit = 0; - std::vector allDestinations = sTravelMgr->getQuestTravelDestinations(bot, questId, true, true, -1); + std::vector allDestinations = + sTravelMgr->getQuestTravelDestinations(bot, questId, true, true, -1); - std::sort(allDestinations.begin(), allDestinations.end(), [botPos](TravelDestination* i, TravelDestination* j) - { - return i->distanceTo(const_cast(&botPos)) < j->distanceTo(const_cast(&botPos)); - }); + std::sort(allDestinations.begin(), allDestinations.end(), + [botPos](TravelDestination* i, TravelDestination* j) { + return i->distanceTo(const_cast(&botPos)) < + j->distanceTo(const_cast(&botPos)); + }); for (auto dest : allDestinations) { @@ -70,7 +74,6 @@ bool QueryQuestAction::Execute(Event event) uint32 tpoints = dest->getPoints(true).size(); uint32 apoints = dest->getPoints().size(); - out << round(dest->distanceTo(const_cast(&botPos))); out << " to " << dest->getTitle(); out << " " << apoints; @@ -126,12 +129,12 @@ void QueryQuestAction::TellObjectives(uint32 questId) if (questTemplate->RequiredNpcOrGo[i] < 0) { - if (GameObjectTemplate const* info = sObjectMgr->GetGameObjectTemplate(-questTemplate->RequiredNpcOrGo[i])) + if (GameObjectTemplate const* info = + sObjectMgr->GetGameObjectTemplate(-questTemplate->RequiredNpcOrGo[i])) TellObjective(info->name, available, required); } else { - if (CreatureTemplate const* info = sObjectMgr->GetCreatureTemplate(questTemplate->RequiredNpcOrGo[i])) TellObjective(info->Name, available, required); } diff --git a/src/strategy/actions/QueryQuestAction.h b/src/strategy/actions/QueryQuestAction.h index 05d2cf45..dd0c5819 100644 --- a/src/strategy/actions/QueryQuestAction.h +++ b/src/strategy/actions/QueryQuestAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_QUERYQUESTACTION_H @@ -11,14 +12,14 @@ class PlayerbotAI; class QueryQuestAction : public Action { - public: - QueryQuestAction(PlayerbotAI* botAI) : Action(botAI, "query quest") { } +public: + QueryQuestAction(PlayerbotAI* botAI) : Action(botAI, "query quest") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - void TellObjectives(uint32 questId); - void TellObjective(std::string const name, uint32 available, uint32 required); +private: + void TellObjectives(uint32 questId); + void TellObjective(std::string const name, uint32 available, uint32 required); }; #endif diff --git a/src/strategy/actions/QuestAction.cpp b/src/strategy/actions/QuestAction.cpp index e602afd9..da747337 100644 --- a/src/strategy/actions/QuestAction.cpp +++ b/src/strategy/actions/QuestAction.cpp @@ -1,10 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "QuestAction.h" -#include "Event.h" + #include "ChatHelper.h" +#include "Event.h" #include "Playerbots.h" #include "ReputationMgr.h" @@ -160,16 +162,16 @@ bool QuestAction::AcceptQuest(Quest const* quest, ObjectGuid questGiver) if (bot->GetQuestStatus(questId) == QUEST_STATUS_COMPLETE) out << "Already completed"; - else if (! bot->CanTakeQuest(quest, false)) + else if (!bot->CanTakeQuest(quest, false)) { - if (! bot->SatisfyQuestStatus(quest, false)) + if (!bot->SatisfyQuestStatus(quest, false)) out << "Already on"; else out << "Can't take"; } - else if (! bot->SatisfyQuestLog(false)) + else if (!bot->SatisfyQuestLog(false)) out << "Quest log is full"; - else if (! bot->CanAddQuest(quest, false)) + else if (!bot->CanAddQuest(quest, false)) out << "Bags are full"; else { @@ -179,9 +181,10 @@ bool QuestAction::AcceptQuest(Quest const* quest, ObjectGuid questGiver) p.rpos(0); bot->GetSession()->HandleQuestgiverAcceptQuestOpcode(p); - if (bot->GetQuestStatus(questId ) == QUEST_STATUS_NONE && sPlayerbotAIConfig->syncQuestWithPlayer) + if (bot->GetQuestStatus(questId) == QUEST_STATUS_NONE && sPlayerbotAIConfig->syncQuestWithPlayer) { - Object* pObject = ObjectAccessor::GetObjectByTypeMask(*bot, questGiver, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM); + Object* pObject = ObjectAccessor::GetObjectByTypeMask(*bot, questGiver, + TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM); bot->AddQuest(quest, pObject); } diff --git a/src/strategy/actions/QuestAction.h b/src/strategy/actions/QuestAction.h index 37f83cb2..24a49b81 100644 --- a/src/strategy/actions/QuestAction.h +++ b/src/strategy/actions/QuestAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_QUESTACTION_H @@ -17,25 +18,25 @@ class Object; class QuestAction : public Action { - public: - QuestAction(PlayerbotAI* botAI, std::string const name) : Action(botAI, name) { } +public: + QuestAction(PlayerbotAI* botAI, std::string const name) : Action(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; - protected: - bool CompleteQuest(Player* player, uint32 entry); - virtual void ProcessQuest(Quest const* quest, Object* questGiver) = 0; - bool AcceptQuest(Quest const* quest, ObjectGuid questGiver); - bool ProcessQuests(ObjectGuid questGiver); - bool ProcessQuests(WorldObject* questGiver); +protected: + bool CompleteQuest(Player* player, uint32 entry); + virtual void ProcessQuest(Quest const* quest, Object* questGiver) = 0; + bool AcceptQuest(Quest const* quest, ObjectGuid questGiver); + bool ProcessQuests(ObjectGuid questGiver); + bool ProcessQuests(WorldObject* questGiver); }; class QuestObjectiveCompletedAction : public Action { - public: - QuestObjectiveCompletedAction(PlayerbotAI* botAI) : Action(botAI, "quest objective completed") { } +public: + QuestObjectiveCompletedAction(PlayerbotAI* botAI) : Action(botAI, "quest objective completed") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/QuestConfirmAcceptAction.cpp b/src/strategy/actions/QuestConfirmAcceptAction.cpp index a3bd6bb9..cc23fdaf 100644 --- a/src/strategy/actions/QuestConfirmAcceptAction.cpp +++ b/src/strategy/actions/QuestConfirmAcceptAction.cpp @@ -1,4 +1,5 @@ #include "QuestConfirmAcceptAction.h" + #include "WorldPacket.h" bool QuestConfirmAcceptAction::Execute(Event event) @@ -10,7 +11,8 @@ bool QuestConfirmAcceptAction::Execute(Event event) WorldPacket sendPacket(CMSG_QUEST_CONFIRM_ACCEPT); sendPacket << questId; Quest const* quest = sObjectMgr->GetQuestTemplate(questId); - if (!quest || !bot->CanAddQuest(quest, true)) { + if (!quest || !bot->CanAddQuest(quest, true)) + { return false; } std::ostringstream out; diff --git a/src/strategy/actions/QuestConfirmAcceptAction.h b/src/strategy/actions/QuestConfirmAcceptAction.h index 5b10b292..e5383eba 100644 --- a/src/strategy/actions/QuestConfirmAcceptAction.h +++ b/src/strategy/actions/QuestConfirmAcceptAction.h @@ -1,14 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_QUESTCONFIRMACCEPTACTION_H #define _PLAYERBOT_QUESTCONFIRMACCEPTACTION_H #include "AiObjectContext.h" +#include "Player.h" #include "PlayerbotAI.h" #include "QuestAction.h" -#include "Player.h" class ObjectGuid; class Quest; @@ -18,9 +19,9 @@ class WorldObject; class QuestConfirmAcceptAction : public Action { - public: - QuestConfirmAcceptAction(PlayerbotAI* botAI) : Action(botAI, "quest confirm accept") {} - bool Execute(Event event) override; +public: + QuestConfirmAcceptAction(PlayerbotAI* botAI) : Action(botAI, "quest confirm accept") {} + bool Execute(Event event) override; }; #endif \ No newline at end of file diff --git a/src/strategy/actions/RandomBotUpdateAction.cpp b/src/strategy/actions/RandomBotUpdateAction.cpp index 0351e53b..b4e1248d 100644 --- a/src/strategy/actions/RandomBotUpdateAction.cpp +++ b/src/strategy/actions/RandomBotUpdateAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RandomBotUpdateAction.h" + #include "Event.h" #include "Playerbots.h" @@ -24,7 +26,4 @@ bool RandomBotUpdateAction::Execute(Event event) return sRandomPlayerbotMgr->ProcessBot(bot); } -bool RandomBotUpdateAction::isUseful() -{ - return AI_VALUE(bool, "random bot update"); -} +bool RandomBotUpdateAction::isUseful() { return AI_VALUE(bool, "random bot update"); } diff --git a/src/strategy/actions/RandomBotUpdateAction.h b/src/strategy/actions/RandomBotUpdateAction.h index 4c4d6cda..c615a86b 100644 --- a/src/strategy/actions/RandomBotUpdateAction.h +++ b/src/strategy/actions/RandomBotUpdateAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RANDOMBOTUPDATEACTION_H @@ -11,11 +12,11 @@ class PlayerbotAI; class RandomBotUpdateAction : public Action { - public: - RandomBotUpdateAction(PlayerbotAI* botAI) : Action(botAI, "random bot update") { } +public: + RandomBotUpdateAction(PlayerbotAI* botAI) : Action(botAI, "random bot update") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/RangeAction.cpp b/src/strategy/actions/RangeAction.cpp index c405d516..a06c8532 100644 --- a/src/strategy/actions/RangeAction.cpp +++ b/src/strategy/actions/RangeAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RangeAction.h" + #include "Event.h" #include "Playerbots.h" @@ -30,7 +32,7 @@ bool RangeAction::Execute(Event event) return true; } - float newVal = (float) atof(value.c_str()); + float newVal = (float)atof(value.c_str()); context->GetValue("range", qualifier)->Set(newVal); std::ostringstream out; diff --git a/src/strategy/actions/RangeAction.h b/src/strategy/actions/RangeAction.h index 5184a342..0675a671 100644 --- a/src/strategy/actions/RangeAction.h +++ b/src/strategy/actions/RangeAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RANGEACTION_H @@ -11,14 +12,13 @@ class PlayerbotAI; class RangeAction : public Action { - public: - RangeAction(PlayerbotAI* botAI) : Action(botAI, "range") { } +public: + RangeAction(PlayerbotAI* botAI) : Action(botAI, "range") {} - bool Execute(Event event) override; - - private: - void PrintRange(std::string const type); + bool Execute(Event event) override; +private: + void PrintRange(std::string const type); }; #endif diff --git a/src/strategy/actions/ReachTargetActions.cpp b/src/strategy/actions/ReachTargetActions.cpp index df26d21f..9184336c 100644 --- a/src/strategy/actions/ReachTargetActions.cpp +++ b/src/strategy/actions/ReachTargetActions.cpp @@ -1,57 +1,54 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ReachTargetActions.h" + #include "Event.h" #include "PlayerbotAIConfig.h" #include "Playerbots.h" #include "ServerFacade.h" -bool ReachTargetAction::Execute(Event event) -{ - return ReachCombatTo(AI_VALUE(Unit*, GetTargetName()), distance); -} +bool ReachTargetAction::Execute(Event event) { return ReachCombatTo(AI_VALUE(Unit*, GetTargetName()), distance); } bool ReachTargetAction::isUseful() { // do not move while casting - if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL) != nullptr) { + if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL) != nullptr) + { return false; } Unit* target = GetTarget(); // float dis = distance + CONTACT_DISTANCE; - return target && !bot->IsWithinCombatRange(target, distance); // sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", GetTargetName()), distance); + return target && + !bot->IsWithinCombatRange(target, distance); // sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, + // "distance", GetTargetName()), distance); } -std::string const ReachTargetAction::GetTargetName() -{ - return "current target"; -} +std::string const ReachTargetAction::GetTargetName() { return "current target"; } bool CastReachTargetSpellAction::isUseful() { - return sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "current target"), (distance + sPlayerbotAIConfig->contactDistance)); + return sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "current target"), + (distance + sPlayerbotAIConfig->contactDistance)); } -ReachSpellAction::ReachSpellAction(PlayerbotAI* botAI) : ReachTargetAction(botAI, "reach spell", botAI->GetRange("spell")) +ReachSpellAction::ReachSpellAction(PlayerbotAI* botAI) + : ReachTargetAction(botAI, "reach spell", botAI->GetRange("spell")) { } -ReachPartyMemberToHealAction::ReachPartyMemberToHealAction(PlayerbotAI* botAI) : ReachTargetAction(botAI, "reach party member to heal", botAI->GetRange("heal")) +ReachPartyMemberToHealAction::ReachPartyMemberToHealAction(PlayerbotAI* botAI) + : ReachTargetAction(botAI, "reach party member to heal", botAI->GetRange("heal")) { } -std::string const ReachPartyMemberToHealAction::GetTargetName() -{ - return "party member to heal"; -} +std::string const ReachPartyMemberToHealAction::GetTargetName() { return "party member to heal"; } -ReachPartyMemberToResurrectAction::ReachPartyMemberToResurrectAction(PlayerbotAI* botAI) : ReachTargetAction(botAI, "reach party member to resurrect", botAI->GetRange("spell")) +ReachPartyMemberToResurrectAction::ReachPartyMemberToResurrectAction(PlayerbotAI* botAI) + : ReachTargetAction(botAI, "reach party member to resurrect", botAI->GetRange("spell")) { } -std::string const ReachPartyMemberToResurrectAction::GetTargetName() -{ - return "party member to resurrect"; -} +std::string const ReachPartyMemberToResurrectAction::GetTargetName() { return "party member to resurrect"; } diff --git a/src/strategy/actions/ReachTargetActions.h b/src/strategy/actions/ReachTargetActions.h index 372aa8ba..edf8ab57 100644 --- a/src/strategy/actions/ReachTargetActions.h +++ b/src/strategy/actions/ReachTargetActions.h @@ -1,66 +1,72 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_REACHTARGETACTIONS_H #define _PLAYERBOT_REACHTARGETACTIONS_H -#include "MovementActions.h" #include "GenericSpellActions.h" +#include "MovementActions.h" class PlayerbotAI; class ReachTargetAction : public MovementAction { - public: - ReachTargetAction(PlayerbotAI* botAI, std::string const name, float distance) : MovementAction(botAI, name), distance(distance) { } +public: + ReachTargetAction(PlayerbotAI* botAI, std::string const name, float distance) + : MovementAction(botAI, name), distance(distance) + { + } - bool Execute(Event event) override; - bool isUseful() override; - std::string const GetTargetName() override; + bool Execute(Event event) override; + bool isUseful() override; + std::string const GetTargetName() override; - protected: - float distance; +protected: + float distance; }; class CastReachTargetSpellAction : public CastSpellAction { - public: - CastReachTargetSpellAction(PlayerbotAI* botAI, std::string const spell, float distance) : CastSpellAction(botAI, spell), distance(distance) { } +public: + CastReachTargetSpellAction(PlayerbotAI* botAI, std::string const spell, float distance) + : CastSpellAction(botAI, spell), distance(distance) + { + } - bool isUseful() override; + bool isUseful() override; - protected: - float distance; +protected: + float distance; }; class ReachMeleeAction : public ReachTargetAction { - public: - ReachMeleeAction(PlayerbotAI* botAI) : ReachTargetAction(botAI, "reach melee", sPlayerbotAIConfig->meleeDistance) { } +public: + ReachMeleeAction(PlayerbotAI* botAI) : ReachTargetAction(botAI, "reach melee", sPlayerbotAIConfig->meleeDistance) {} }; class ReachSpellAction : public ReachTargetAction { - public: - ReachSpellAction(PlayerbotAI* botAI); +public: + ReachSpellAction(PlayerbotAI* botAI); }; class ReachPartyMemberToHealAction : public ReachTargetAction { - public: - ReachPartyMemberToHealAction(PlayerbotAI* botAI); +public: + ReachPartyMemberToHealAction(PlayerbotAI* botAI); - std::string const GetTargetName() override; + std::string const GetTargetName() override; }; class ReachPartyMemberToResurrectAction : public ReachTargetAction { - public: - ReachPartyMemberToResurrectAction(PlayerbotAI* botAI); +public: + ReachPartyMemberToResurrectAction(PlayerbotAI* botAI); - std::string const GetTargetName() override; + std::string const GetTargetName() override; }; - #endif diff --git a/src/strategy/actions/ReadyCheckAction.cpp b/src/strategy/actions/ReadyCheckAction.cpp index 77ee2a33..a8a2d8ca 100644 --- a/src/strategy/actions/ReadyCheckAction.cpp +++ b/src/strategy/actions/ReadyCheckAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ReadyCheckAction.h" + #include "Event.h" #include "Playerbots.h" @@ -24,125 +26,126 @@ std::string const formatPercent(std::string const name, uint8 value, float perce class ReadyChecker { - public: - virtual bool Check(PlayerbotAI* botAI, AiObjectContext* context) = 0; - virtual std::string const getName() = 0; - virtual bool PrintAlways() { return true; } +public: + virtual bool Check(PlayerbotAI* botAI, AiObjectContext* context) = 0; + virtual std::string const getName() = 0; + virtual bool PrintAlways() { return true; } - static std::vector checkers; + static std::vector checkers; }; std::vector ReadyChecker::checkers; class HealthChecker : public ReadyChecker { - public: - bool Check(PlayerbotAI* botAI, AiObjectContext* context) override - { - return AI_VALUE2(uint8, "health", "self target") > sPlayerbotAIConfig->almostFullHealth; - } +public: + bool Check(PlayerbotAI* botAI, AiObjectContext* context) override + { + return AI_VALUE2(uint8, "health", "self target") > sPlayerbotAIConfig->almostFullHealth; + } - std::string const getName() override { return "HP"; } + std::string const getName() override { return "HP"; } }; class ManaChecker : public ReadyChecker { - public: - bool Check(PlayerbotAI* botAI, AiObjectContext* context) override - { - return !AI_VALUE2(bool, "has mana", "self target") || AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig->mediumHealth; - } +public: + bool Check(PlayerbotAI* botAI, AiObjectContext* context) override + { + return !AI_VALUE2(bool, "has mana", "self target") || + AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig->mediumHealth; + } - std::string const getName() override { return "MP"; } + std::string const getName() override { return "MP"; } }; class DistanceChecker : public ReadyChecker { - public: - bool Check(PlayerbotAI* botAI, AiObjectContext* context) override +public: + bool Check(PlayerbotAI* botAI, AiObjectContext* context) override + { + Player* bot = botAI->GetBot(); + if (Player* master = botAI->GetMaster()) { - Player* bot = botAI->GetBot(); - if (Player* master = botAI->GetMaster()) + bool distance = bot->GetDistance(master) <= sPlayerbotAIConfig->sightDistance; + if (!distance) { - bool distance = bot->GetDistance(master) <= sPlayerbotAIConfig->sightDistance; - if (!distance) - { - return false; - } + return false; } - - return true; } - bool PrintAlways() override { return false; } - std::string const getName() override { return "Far away"; } + return true; + } + + bool PrintAlways() override { return false; } + std::string const getName() override { return "Far away"; } }; class HunterChecker : public ReadyChecker { - public: - bool Check(PlayerbotAI* botAI, AiObjectContext* context) override +public: + bool Check(PlayerbotAI* botAI, AiObjectContext* context) override + { + Player* bot = botAI->GetBot(); + if (bot->getClass() == CLASS_HUNTER) { - Player* bot = botAI->GetBot(); - if (bot->getClass() == CLASS_HUNTER) + if (!bot->GetUInt32Value(PLAYER_AMMO_ID)) { - if (!bot->GetUInt32Value(PLAYER_AMMO_ID)) - { - botAI->TellError("Out of ammo!"); - return false; - } - - if (!bot->GetPet()) - { - botAI->TellError("No pet!"); - return false; - } - - if (bot->GetPet()->GetHappinessState() == UNHAPPY) - { - botAI->TellError("Pet is unhappy!"); - return false; - } + botAI->TellError("Out of ammo!"); + return false; } - return true; + if (!bot->GetPet()) + { + botAI->TellError("No pet!"); + return false; + } + + if (bot->GetPet()->GetHappinessState() == UNHAPPY) + { + botAI->TellError("Pet is unhappy!"); + return false; + } } - bool PrintAlways() override { return false; } - std::string const getName() override { return "Far away"; } + return true; + } + + bool PrintAlways() override { return false; } + std::string const getName() override { return "Far away"; } }; class ItemCountChecker : public ReadyChecker { - public: - ItemCountChecker(std::string const item, std::string const name) : item(item), name(name) { } +public: + ItemCountChecker(std::string const item, std::string const name) : item(item), name(name) {} - bool Check(PlayerbotAI* botAI, AiObjectContext* context) override - { - return AI_VALUE2(uint32, "item count", item) > 0; - } + bool Check(PlayerbotAI* botAI, AiObjectContext* context) override + { + return AI_VALUE2(uint32, "item count", item) > 0; + } - std::string const getName() override { return name; } + std::string const getName() override { return name; } - private: - std::string const item; - std::string const name; +private: + std::string const item; + std::string const name; }; class ManaPotionChecker : public ItemCountChecker { - public: - ManaPotionChecker(std::string const item, std::string const name) : ItemCountChecker(item, name) { } +public: + ManaPotionChecker(std::string const item, std::string const name) : ItemCountChecker(item, name) {} - bool Check(PlayerbotAI* botAI, AiObjectContext* context) override - { - return !AI_VALUE2(bool, "has mana", "self target") || ItemCountChecker::Check(botAI, context); - } + bool Check(PlayerbotAI* botAI, AiObjectContext* context) override + { + return !AI_VALUE2(bool, "has mana", "self target") || ItemCountChecker::Check(botAI, context); + } }; bool ReadyCheckAction::Execute(Event event) { - WorldPacket &p = event.getPacket(); + WorldPacket& p = event.getPacket(); ObjectGuid player; p.rpos(0); if (!p.empty()) @@ -152,7 +155,7 @@ bool ReadyCheckAction::Execute(Event event) return false; } - return ReadyCheck(); + return ReadyCheck(); } bool ReadyCheckAction::ReadyCheck() @@ -171,7 +174,8 @@ bool ReadyCheckAction::ReadyCheck() } bool result = true; - for (std::vector::iterator i = ReadyChecker::checkers.begin(); i != ReadyChecker::checkers.end(); ++i) + for (std::vector::iterator i = ReadyChecker::checkers.begin(); i != ReadyChecker::checkers.end(); + ++i) { ReadyChecker* checker = *i; bool ok = checker->Check(botAI, context); @@ -210,7 +214,4 @@ bool ReadyCheckAction::ReadyCheck() return true; } -bool FinishReadyCheckAction::Execute(Event event) -{ - return ReadyCheck(); -} +bool FinishReadyCheckAction::Execute(Event event) { return ReadyCheck(); } diff --git a/src/strategy/actions/ReadyCheckAction.h b/src/strategy/actions/ReadyCheckAction.h index ff9c073d..f64c15aa 100644 --- a/src/strategy/actions/ReadyCheckAction.h +++ b/src/strategy/actions/ReadyCheckAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_READYCHECKACTION_H @@ -11,21 +12,21 @@ class PlayerbotAI; class ReadyCheckAction : public InventoryAction { - public: - ReadyCheckAction(PlayerbotAI* botAI, std::string const name = "ready check") : InventoryAction(botAI, name) { } +public: + ReadyCheckAction(PlayerbotAI* botAI, std::string const name = "ready check") : InventoryAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; - protected: - bool ReadyCheck(); +protected: + bool ReadyCheck(); }; class FinishReadyCheckAction : public ReadyCheckAction { - public: - FinishReadyCheckAction(PlayerbotAI* botAI) : ReadyCheckAction(botAI, "finish ready check") { } +public: + FinishReadyCheckAction(PlayerbotAI* botAI) : ReadyCheckAction(botAI, "finish ready check") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ReleaseSpiritAction.cpp b/src/strategy/actions/ReleaseSpiritAction.cpp index e2714c5b..64521c4e 100644 --- a/src/strategy/actions/ReleaseSpiritAction.cpp +++ b/src/strategy/actions/ReleaseSpiritAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ReleaseSpiritAction.h" + #include "Event.h" #include "GameGraveyard.h" #include "ObjectDefines.h" @@ -39,7 +41,8 @@ bool ReleaseSpiritAction::Execute(Event event) context->GetValue("death count")->Set(dCount + 1); } - LOG_INFO("playerbots", "Bot {} {}:{} <{}> released", bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); + LOG_INFO("playerbots", "Bot {} {}:{} <{}> released", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); WorldPacket packet(CMSG_REPOP_REQUEST); packet << uint8(0); @@ -72,13 +75,13 @@ bool ReleaseSpiritAction::Execute(Event event) // bot->GetSession()->HandleGossipHelloOpcode(packet); // } // } - + return true; } bool AutoReleaseSpiritAction::Execute(Event event) { - //Death Count to prevent skeleton piles + // Death Count to prevent skeleton piles Player* master = GetMaster(); if (!master || (master && GET_PLAYERBOT_AI(master))) { @@ -86,13 +89,15 @@ bool AutoReleaseSpiritAction::Execute(Event event) context->GetValue("death count")->Set(dCount + 1); } - LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> auto released", bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); + LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> auto released", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); WorldPacket packet(CMSG_REPOP_REQUEST); packet << uint8(0); bot->GetSession()->HandleRepopRequestOpcode(packet); - LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> releases spirit", bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); + LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> releases spirit", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); if (bot->InBattleground() && (time(NULL) - bg_gossip_time >= 15 || !bot->HasAura(SPELL_WAITING_FOR_RESURRECT))) { @@ -108,12 +113,16 @@ bool AutoReleaseSpiritAction::Execute(Event event) break; } } - if (!guid) { + if (!guid) + { return true; } - if (bot->GetDistance(unit) >= INTERACTION_DISTANCE) { + if (bot->GetDistance(unit) >= INTERACTION_DISTANCE) + { bot->GetMotionMaster()->MoveChase(unit); - } else { + } + else + { bg_gossip_time = time(NULL); WorldPacket packet(CMSG_GOSSIP_HELLO); packet << guid; @@ -150,13 +159,15 @@ bool AutoReleaseSpiritAction::isUseful() if (!botAI->HasActivePlayerMaster()) return true; - if (botAI->HasActivePlayerMaster() && botAI->GetGroupMaster()->GetMapId() == bot->GetMapId() && bot->GetMap() && (bot->GetMap()->IsRaid() || bot->GetMap()->IsDungeon())) + if (botAI->HasActivePlayerMaster() && botAI->GetGroupMaster()->GetMapId() == bot->GetMapId() && bot->GetMap() && + (bot->GetMap()->IsRaid() || bot->GetMap()->IsDungeon())) return false; if (botAI->GetGroupMaster()->isDead()) return true; - if (sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "master target"), sPlayerbotAIConfig->sightDistance)) + if (sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "master target"), + sPlayerbotAIConfig->sightDistance)) return true; return false; @@ -164,7 +175,8 @@ bool AutoReleaseSpiritAction::isUseful() bool RepopAction::Execute(Event event) { - LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> repops at graveyard", bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); + LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> repops at graveyard", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); int64 deadTime; diff --git a/src/strategy/actions/ReleaseSpiritAction.h b/src/strategy/actions/ReleaseSpiritAction.h index 00652188..f21b3cdd 100644 --- a/src/strategy/actions/ReleaseSpiritAction.h +++ b/src/strategy/actions/ReleaseSpiritAction.h @@ -1,42 +1,48 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RELEASESPIRITACTION_H #define _PLAYERBOT_RELEASESPIRITACTION_H +#include + #include "Action.h" #include "ReviveFromCorpseAction.h" -#include class PlayerbotAI; class ReleaseSpiritAction : public Action { - public: - ReleaseSpiritAction(PlayerbotAI* botAI, std::string const name = "release") : Action(botAI, name) { } +public: + ReleaseSpiritAction(PlayerbotAI* botAI, std::string const name = "release") : Action(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class AutoReleaseSpiritAction : public ReleaseSpiritAction { - public: - AutoReleaseSpiritAction(PlayerbotAI* botAI, std::string const name = "auto release") : ReleaseSpiritAction(botAI, name) { } +public: + AutoReleaseSpiritAction(PlayerbotAI* botAI, std::string const name = "auto release") + : ReleaseSpiritAction(botAI, name) + { + } - bool Execute(Event event) override; - bool isUseful() override; - private: - uint32_t bg_gossip_time = 0; + bool Execute(Event event) override; + bool isUseful() override; + +private: + uint32_t bg_gossip_time = 0; }; class RepopAction : public SpiritHealerAction { - public: - RepopAction(PlayerbotAI* botAI, std::string const name = "repop") : SpiritHealerAction(botAI, name) { } +public: + RepopAction(PlayerbotAI* botAI, std::string const name = "repop") : SpiritHealerAction(botAI, name) {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/RememberTaxiAction.cpp b/src/strategy/actions/RememberTaxiAction.cpp index 4c655796..f4922b97 100644 --- a/src/strategy/actions/RememberTaxiAction.cpp +++ b/src/strategy/actions/RememberTaxiAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RememberTaxiAction.h" + #include "Event.h" #include "LastMovementValue.h" #include "Playerbots.h" diff --git a/src/strategy/actions/RememberTaxiAction.h b/src/strategy/actions/RememberTaxiAction.h index 4a0ff49c..6d93f795 100644 --- a/src/strategy/actions/RememberTaxiAction.h +++ b/src/strategy/actions/RememberTaxiAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_REMEMBERTAXIACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class RememberTaxiAction : public Action { - public: - RememberTaxiAction(PlayerbotAI* botAI) : Action(botAI, "remember taxi") { } +public: + RememberTaxiAction(PlayerbotAI* botAI) : Action(botAI, "remember taxi") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/RemoveAuraAction.cpp b/src/strategy/actions/RemoveAuraAction.cpp index 2fe60dba..a84d652a 100644 --- a/src/strategy/actions/RemoveAuraAction.cpp +++ b/src/strategy/actions/RemoveAuraAction.cpp @@ -1,14 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RemoveAuraAction.h" + #include "Event.h" #include "Playerbots.h" -RemoveAuraAction::RemoveAuraAction(PlayerbotAI* botAI) : Action(botAI, "ra") -{ -} +RemoveAuraAction::RemoveAuraAction(PlayerbotAI* botAI) : Action(botAI, "ra") {} bool RemoveAuraAction::Execute(Event event) { diff --git a/src/strategy/actions/RemoveAuraAction.h b/src/strategy/actions/RemoveAuraAction.h index bd63ccd1..297579a8 100644 --- a/src/strategy/actions/RemoveAuraAction.h +++ b/src/strategy/actions/RemoveAuraAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_REMOVEAURAACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class RemoveAuraAction : public Action { - public: - RemoveAuraAction(PlayerbotAI* botAI); +public: + RemoveAuraAction(PlayerbotAI* botAI); - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/RepairAllAction.cpp b/src/strategy/actions/RepairAllAction.cpp index 6b21c41f..2eaf07c3 100644 --- a/src/strategy/actions/RepairAllAction.cpp +++ b/src/strategy/actions/RepairAllAction.cpp @@ -1,10 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RepairAllAction.h" -#include "Event.h" + #include "ChatHelper.h" +#include "Event.h" #include "Playerbots.h" bool RepairAllAction::Execute(Event event) @@ -28,7 +30,7 @@ bool RepairAllAction::Execute(Event event) bot->SetMoney(10000000); } - //Repair weapons first. + // Repair weapons first. uint32 totalCost = bot->DurabilityRepair(EQUIPMENT_SLOT_MAINHAND, true, discountMod, false); totalCost += bot->DurabilityRepair(EQUIPMENT_SLOT_RANGED, true, discountMod, false); totalCost += bot->DurabilityRepair(EQUIPMENT_SLOT_OFFHAND, true, discountMod, false); @@ -46,7 +48,7 @@ bool RepairAllAction::Execute(Event event) out << "Repair: " << chat->formatMoney(totalCost) << " (" << unit->GetName() << ")"; botAI->TellMasterNoFacing(out.str()); - bot->PlayDistanceSound(1116); + bot->PlayDistanceSound(1116); } context->GetValue("death count")->Set(0); diff --git a/src/strategy/actions/RepairAllAction.h b/src/strategy/actions/RepairAllAction.h index e376d2a9..f938ffbf 100644 --- a/src/strategy/actions/RepairAllAction.h +++ b/src/strategy/actions/RepairAllAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_REPAIRALLACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class RepairAllAction : public Action { - public: - RepairAllAction(PlayerbotAI* botAI) : Action(botAI, "repair") { } +public: + RepairAllAction(PlayerbotAI* botAI) : Action(botAI, "repair") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ResetAiAction.cpp b/src/strategy/actions/ResetAiAction.cpp index c7e5af8b..181b0974 100644 --- a/src/strategy/actions/ResetAiAction.cpp +++ b/src/strategy/actions/ResetAiAction.cpp @@ -1,20 +1,24 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ResetAiAction.h" + #include "Event.h" -#include "ObjectGuid.h" -#include "Playerbots.h" -#include "PlayerbotDbStore.h" -#include "WorldPacket.h" #include "Group.h" +#include "ObjectGuid.h" +#include "PlayerbotDbStore.h" +#include "Playerbots.h" +#include "WorldPacket.h" bool ResetAiAction::Execute(Event event) { - if (!event.getPacket().empty()) { + if (!event.getPacket().empty()) + { WorldPacket packet = event.getPacket(); - if (packet.GetOpcode() == SMSG_GROUP_LIST) { + if (packet.GetOpcode() == SMSG_GROUP_LIST) + { uint8 groupType; Group::MemberSlot slot; packet >> groupType; @@ -34,7 +38,8 @@ bool ResetAiAction::Execute(Event event) packet >> guid; packet >> counter; packet >> membersCount; - if (membersCount != 0) { + if (membersCount != 0) + { return false; } } diff --git a/src/strategy/actions/ResetAiAction.h b/src/strategy/actions/ResetAiAction.h index bcfd63fc..b195faef 100644 --- a/src/strategy/actions/ResetAiAction.h +++ b/src/strategy/actions/ResetAiAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RESETAIACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class ResetAiAction : public Action { - public: - ResetAiAction(PlayerbotAI* botAI) : Action(botAI, "reset botAI") { } +public: + ResetAiAction(PlayerbotAI* botAI) : Action(botAI, "reset botAI") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ResetInstancesAction.cpp b/src/strategy/actions/ResetInstancesAction.cpp index fcc8bd32..e8768446 100644 --- a/src/strategy/actions/ResetInstancesAction.cpp +++ b/src/strategy/actions/ResetInstancesAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ResetInstancesAction.h" + #include "Playerbots.h" bool ResetInstancesAction::Execute(Event event) @@ -14,7 +16,4 @@ bool ResetInstancesAction::Execute(Event event) return true; } -bool ResetInstancesAction::isUseful() -{ - return botAI->GetGroupMaster() == bot; -}; +bool ResetInstancesAction::isUseful() { return botAI->GetGroupMaster() == bot; }; diff --git a/src/strategy/actions/ResetInstancesAction.h b/src/strategy/actions/ResetInstancesAction.h index 40e245ba..7f04d4eb 100644 --- a/src/strategy/actions/ResetInstancesAction.h +++ b/src/strategy/actions/ResetInstancesAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RESETINSTANCESACTION_H @@ -11,11 +12,11 @@ class PlayerbotAI; class ResetInstancesAction : public Action { - public: - ResetInstancesAction(PlayerbotAI* botAI) : Action(botAI, "reset instances") { } +public: + ResetInstancesAction(PlayerbotAI* botAI) : Action(botAI, "reset instances") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/RevealGatheringItemAction.cpp b/src/strategy/actions/RevealGatheringItemAction.cpp index 5e1290c2..75b6548d 100644 --- a/src/strategy/actions/RevealGatheringItemAction.cpp +++ b/src/strategy/actions/RevealGatheringItemAction.cpp @@ -1,11 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RevealGatheringItemAction.h" -#include "Event.h" + #include "CellImpl.h" #include "ChatHelper.h" +#include "Event.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "Playerbots.h" @@ -13,20 +15,20 @@ class AnyGameObjectInObjectRangeCheck { - public: - AnyGameObjectInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) { } - WorldObject const& GetFocusObject() const { return *i_obj; } - bool operator()(GameObject* go) - { - if (go && i_obj->IsWithinDistInMap(go, i_range) && go->isSpawned() && go->GetGOInfo()) - return true; +public: + AnyGameObjectInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {} + WorldObject const& GetFocusObject() const { return *i_obj; } + bool operator()(GameObject* go) + { + if (go && i_obj->IsWithinDistInMap(go, i_range) && go->isSpawned() && go->GetGOInfo()) + return true; - return false; - } + return false; + } - private: - WorldObject const* i_obj; - float i_range; +private: + WorldObject const* i_obj; + float i_range; }; bool RevealGatheringItemAction::Execute(Event event) @@ -42,7 +44,9 @@ bool RevealGatheringItemAction::Execute(Event event) std::vector result; for (GameObject* go : targets) { - if (!go || !go->isSpawned() || sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, go), sPlayerbotAIConfig->lootDistance)) + if (!go || !go->isSpawned() || + sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, go), + sPlayerbotAIConfig->lootDistance)) continue; if (LockEntry const* lockInfo = sLockStore.LookupEntry(go->GetGOInfo()->GetLockId())) @@ -53,7 +57,8 @@ bool RevealGatheringItemAction::Execute(Event event) { uint32 skillId = SkillByLockType(LockType(lockInfo->Index[i])); uint32 reqSkillValue = std::max(2u, lockInfo->Skill[i]); - if ((skillId == SKILL_MINING || skillId == SKILL_HERBALISM) && botAI->HasSkill((SkillType)skillId) && uint32(bot->GetSkillValue(skillId)) >= reqSkillValue) + if ((skillId == SKILL_MINING || skillId == SKILL_HERBALISM) && + botAI->HasSkill((SkillType)skillId) && uint32(bot->GetSkillValue(skillId)) >= reqSkillValue) { result.push_back(go); break; @@ -78,14 +83,14 @@ bool RevealGatheringItemAction::Execute(Event event) switch (go->GetGoType()) { - case GAMEOBJECT_TYPE_CHEST: - msg << "Let's look at it."; - break; - case GAMEOBJECT_TYPE_FISHINGNODE: - msg << "Let's fish a bit."; - break; - default: - msg << "Should we go nearer?"; + case GAMEOBJECT_TYPE_CHEST: + msg << "Let's look at it."; + break; + case GAMEOBJECT_TYPE_FISHINGNODE: + msg << "Let's fish a bit."; + break; + default: + msg << "Should we go nearer?"; } // everything is fine, do it diff --git a/src/strategy/actions/RevealGatheringItemAction.h b/src/strategy/actions/RevealGatheringItemAction.h index 9ed8e8ca..f74c9048 100644 --- a/src/strategy/actions/RevealGatheringItemAction.h +++ b/src/strategy/actions/RevealGatheringItemAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_REVEALGATHERINGITEMACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class RevealGatheringItemAction : public Action { - public: - RevealGatheringItemAction(PlayerbotAI* botAI) : Action(botAI, "reveal gathering item") { } +public: + RevealGatheringItemAction(PlayerbotAI* botAI) : Action(botAI, "reveal gathering item") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ReviveFromCorpseAction.cpp b/src/strategy/actions/ReviveFromCorpseAction.cpp index 73d7e3b3..1022beb5 100644 --- a/src/strategy/actions/ReviveFromCorpseAction.cpp +++ b/src/strategy/actions/ReviveFromCorpseAction.cpp @@ -1,14 +1,16 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ReviveFromCorpseAction.h" + #include "Event.h" #include "FleeManager.h" #include "GameGraveyard.h" #include "MapMgr.h" -#include "Playerbots.h" #include "PlayerbotFactory.h" +#include "Playerbots.h" #include "RandomPlayerbotMgr.h" #include "ServerFacade.h" @@ -21,7 +23,8 @@ bool ReviveFromCorpseAction::Execute(Event event) WorldPacket& p = event.getPacket(); if (!p.empty() && p.GetOpcode() == CMSG_RECLAIM_CORPSE && master && !corpse && bot->IsAlive()) { - if (sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "master target"), sPlayerbotAIConfig->farDistance)) + if (sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "master target"), + sPlayerbotAIConfig->farDistance)) { if (!botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT)) { @@ -35,13 +38,15 @@ bool ReviveFromCorpseAction::Execute(Event event) if (!corpse) return false; - // if (corpse->GetGhostTime() + bot->GetCorpseReclaimDelay(corpse->GetType() == CORPSE_RESURRECTABLE_PVP) > time(nullptr)) + // if (corpse->GetGhostTime() + bot->GetCorpseReclaimDelay(corpse->GetType() == CORPSE_RESURRECTABLE_PVP) > + // time(nullptr)) // return false; if (master) { - if (!GET_PLAYERBOT_AI(master) && master->isDead() && master->GetCorpse() - && sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "master target"), sPlayerbotAIConfig->farDistance)) + if (!GET_PLAYERBOT_AI(master) && master->isDead() && master->GetCorpse() && + sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "master target"), + sPlayerbotAIConfig->farDistance)) return false; } @@ -55,7 +60,8 @@ bool ReviveFromCorpseAction::Execute(Event event) } } - LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> revives at body", bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); + LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> revives at body", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); bot->GetMotionMaster()->Clear(); bot->StopMoving(); @@ -80,8 +86,8 @@ bool FindCorpseAction::Execute(Event event) // if (master) // { // if (!GET_PLAYERBOT_AI(master) && - // sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "master target"), sPlayerbotAIConfig->farDistance)) - // return false; + // sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "master target"), + // sPlayerbotAIConfig->farDistance)) return false; // } uint32 dCount = AI_VALUE(uint32, "death count"); @@ -91,7 +97,8 @@ bool FindCorpseAction::Execute(Event event) if (dCount >= 5) { // LOG_INFO("playerbots", "Bot {} {}:{} <{}>: died too many times, was revived and teleported", - // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); + // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + // bot->GetName().c_str()); context->GetValue("death count")->Set(0); // sRandomPlayerbotMgr->RandomTeleportForLevel(bot); sRandomPlayerbotMgr->Revive(bot); @@ -110,21 +117,21 @@ bool FindCorpseAction::Execute(Event event) bool moveToMaster = master && master != bot && masterPos.fDist(corpsePos) < reclaimDist; - //Should we ressurect? If so, return false. + // Should we ressurect? If so, return false. if (corpseDist < reclaimDist) { - if (moveToMaster) //We are near master. + if (moveToMaster) // We are near master. { if (botPos.fDist(masterPos) < sPlayerbotAIConfig->spellDistance) return false; } - else if (deadTime > 8 * MINUTE) //We have walked too long already. + else if (deadTime > 8 * MINUTE) // We have walked too long already. return false; else { GuidVector units = AI_VALUE(GuidVector, "possible targets no los"); - if (botPos.getUnitsAggro(units, bot) == 0) //There are no mobs near. + if (botPos.getUnitsAggro(units, bot) == 0) // There are no mobs near. return false; } } @@ -149,13 +156,14 @@ bool FindCorpseAction::Execute(Event event) } } - //Actual mobing part. + // Actual mobing part. bool moved = false; if (!botAI->AllowActivity(ALL_ACTIVITY)) { - uint32 delay = sServerFacade->GetDistance2d(bot, corpse) / bot->GetSpeed(MOVE_RUN); //Time a bot would take to travel to it's corpse. - delay = std::min(delay, uint32(10 * MINUTE)); //Cap time to get to corpse at 10 minutes. + uint32 delay = sServerFacade->GetDistance2d(bot, corpse) / + bot->GetSpeed(MOVE_RUN); // Time a bot would take to travel to it's corpse. + delay = std::min(delay, uint32(10 * MINUTE)); // Cap time to get to corpse at 10 minutes. if (deadTime > delay) { @@ -163,7 +171,7 @@ bool FindCorpseAction::Execute(Event event) bot->TeleportTo(moveToPos.getMapId(), moveToPos.getX(), moveToPos.getY(), moveToPos.getZ(), 0); } - moved = true; + moved = true; } else { @@ -171,9 +179,10 @@ bool FindCorpseAction::Execute(Event event) moved = true; else { - if (deadTime < 10 * MINUTE && dCount < 5) // Look for corpse up to 30 minutes. + if (deadTime < 10 * MINUTE && dCount < 5) // Look for corpse up to 30 minutes. { - moved = MoveTo(moveToPos.getMapId(), moveToPos.getX(), moveToPos.getY(), moveToPos.getZ(), false, false); + moved = + MoveTo(moveToPos.getMapId(), moveToPos.getX(), moveToPos.getY(), moveToPos.getZ(), false, false); } if (!moved) @@ -215,7 +224,7 @@ GraveyardStruct const* SpiritHealerAction::GetGrave(bool startZone) return ClosestGrave; } } - else if(startZone && AI_VALUE(uint8, "durability")) + else if (startZone && AI_VALUE(uint8, "durability")) { TravelTarget* travelTarget = AI_VALUE(TravelTarget*, "travel target"); @@ -226,9 +235,11 @@ GraveyardStruct const* SpiritHealerAction::GetGrave(bool startZone) { uint32 areaId = 0; uint32 zoneId = 0; - sMapMgr->GetZoneAndAreaId(bot->GetPhaseMask(), zoneId, areaId, travelPos.getMapId(), travelPos.getX(), travelPos.getY(), travelPos.getZ()); - ClosestGrave = sGraveyard->GetClosestGraveyard(travelPos.getMapId(), travelPos.getX(), travelPos.getY(), travelPos.getZ(), bot->GetTeamId(), - areaId, zoneId, bot->getClass() == CLASS_DEATH_KNIGHT); + sMapMgr->GetZoneAndAreaId(bot->GetPhaseMask(), zoneId, areaId, travelPos.getMapId(), travelPos.getX(), + travelPos.getY(), travelPos.getZ()); + ClosestGrave = sGraveyard->GetClosestGraveyard(travelPos.getMapId(), travelPos.getX(), travelPos.getY(), + travelPos.getZ(), bot->GetTeamId(), areaId, zoneId, + bot->getClass() == CLASS_DEATH_KNIGHT); if (ClosestGrave) return ClosestGrave; @@ -239,9 +250,9 @@ GraveyardStruct const* SpiritHealerAction::GetGrave(bool startZone) std::vector races; if (bot->GetTeamId() == TEAM_ALLIANCE) - races = { RACE_HUMAN, RACE_DWARF, RACE_GNOME, RACE_NIGHTELF }; + races = {RACE_HUMAN, RACE_DWARF, RACE_GNOME, RACE_NIGHTELF}; else - races = { RACE_ORC, RACE_TROLL, RACE_TAUREN, RACE_UNDEAD_PLAYER }; + races = {RACE_ORC, RACE_TROLL, RACE_TAUREN, RACE_UNDEAD_PLAYER}; float graveDistance = -1; @@ -257,9 +268,11 @@ GraveyardStruct const* SpiritHealerAction::GetGrave(bool startZone) uint32 areaId = 0; uint32 zoneId = 0; - sMapMgr->GetZoneAndAreaId(bot->GetPhaseMask(), zoneId, areaId, info->mapId, info->positionX, info->positionY, info->positionZ); + sMapMgr->GetZoneAndAreaId(bot->GetPhaseMask(), zoneId, areaId, info->mapId, info->positionX, + info->positionY, info->positionZ); - NewGrave = sGraveyard->GetClosestGraveyard(info->mapId, info->positionX, info->positionY, info->positionZ, bot->GetTeamId(), areaId, zoneId, cls == CLASS_DEATH_KNIGHT); + NewGrave = sGraveyard->GetClosestGraveyard(info->mapId, info->positionX, info->positionY, info->positionZ, + bot->GetTeamId(), areaId, zoneId, cls == CLASS_DEATH_KNIGHT); if (!NewGrave) continue; @@ -290,7 +303,8 @@ bool SpiritHealerAction::Execute(Event event) uint32 dCount = AI_VALUE(uint32, "death count"); int64 deadTime = time(nullptr) - corpse->GetGhostTime(); - GraveyardStruct const* ClosestGrave = GetGrave(dCount > 10 || deadTime > 15 * MINUTE || AI_VALUE(uint8, "durability") < 10); + GraveyardStruct const* ClosestGrave = + GetGrave(dCount > 10 || deadTime > 15 * MINUTE || AI_VALUE(uint8, "durability") < 10); if (bot->GetDistance2d(ClosestGrave->x, ClosestGrave->y) < sPlayerbotAIConfig->sightDistance) { @@ -300,8 +314,8 @@ bool SpiritHealerAction::Execute(Event event) Unit* unit = botAI->GetUnit(*i); if (unit && unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER)) { - LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> revives at spirit healer", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName()); + LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> revives at spirit healer", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName()); PlayerbotChatHandler ch(bot); bot->ResurrectPlayer(0.5f); bot->SpawnCorpseBones(); @@ -339,14 +353,11 @@ bool SpiritHealerAction::Execute(Event event) return bot->TeleportTo(ClosestGrave->Map, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, 0.f); } - LOG_INFO("playerbots", "Bot {} {}:{} <{}> can't find a spirit healer", - bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); + LOG_INFO("playerbots", "Bot {} {}:{} <{}> can't find a spirit healer", bot->GetGUID().ToString().c_str(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str()); botAI->TellError("Cannot find any spirit healer nearby"); return false; } -bool SpiritHealerAction::isUseful() -{ - return bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST); -} +bool SpiritHealerAction::isUseful() { return bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST); } diff --git a/src/strategy/actions/ReviveFromCorpseAction.h b/src/strategy/actions/ReviveFromCorpseAction.h index 4004a08b..58c8572a 100644 --- a/src/strategy/actions/ReviveFromCorpseAction.h +++ b/src/strategy/actions/ReviveFromCorpseAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_REVIVEFROMCORPSEACTION_H @@ -13,29 +14,29 @@ struct GraveyardStruct; class ReviveFromCorpseAction : public MovementAction { - public: - ReviveFromCorpseAction(PlayerbotAI* botAI) : MovementAction(botAI, "revive from corpse") { } +public: + ReviveFromCorpseAction(PlayerbotAI* botAI) : MovementAction(botAI, "revive from corpse") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class FindCorpseAction : public MovementAction { - public: - FindCorpseAction(PlayerbotAI* botAI) : MovementAction(botAI, "find corpse") { } +public: + FindCorpseAction(PlayerbotAI* botAI) : MovementAction(botAI, "find corpse") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class SpiritHealerAction : public MovementAction { - public: - SpiritHealerAction(PlayerbotAI* botAI, std::string const name = "spirit healer") : MovementAction(botAI, name) { } +public: + SpiritHealerAction(PlayerbotAI* botAI, std::string const name = "spirit healer") : MovementAction(botAI, name) {} - GraveyardStruct const* GetGrave(bool startZone); - bool Execute(Event event) override; - bool isUseful() override; + GraveyardStruct const* GetGrave(bool startZone); + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/RewardAction.cpp b/src/strategy/actions/RewardAction.cpp index 84d82b4e..fd5e6ae3 100644 --- a/src/strategy/actions/RewardAction.cpp +++ b/src/strategy/actions/RewardAction.cpp @@ -1,10 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RewardAction.h" -#include "Event.h" + #include "ChatHelper.h" +#include "Event.h" #include "Playerbots.h" bool RewardAction::Execute(Event event) @@ -53,16 +55,17 @@ bool RewardAction::Reward(uint32 itemId, Object* questGiver) QuestStatus status = bot->GetQuestStatus(questID); // if quest is complete, turn it in - if (status == QUEST_STATUS_COMPLETE && !bot->GetQuestRewardStatus(questID) && pQuest->GetRewChoiceItemsCount() > 1 && bot->CanRewardQuest(pQuest, false)) + if (status == QUEST_STATUS_COMPLETE && !bot->GetQuestRewardStatus(questID) && + pQuest->GetRewChoiceItemsCount() > 1 && bot->CanRewardQuest(pQuest, false)) { - for (uint8 rewardIdx=0; rewardIdx < pQuest->GetRewChoiceItemsCount(); ++rewardIdx) + for (uint8 rewardIdx = 0; rewardIdx < pQuest->GetRewChoiceItemsCount(); ++rewardIdx) { ItemTemplate const* pRewardItem = sObjectMgr->GetItemTemplate(pQuest->RewardChoiceItemId[rewardIdx]); if (itemId == pRewardItem->ItemId) { bot->RewardQuest(pQuest, rewardIdx, questGiver, false); - std::string const questTitle = pQuest->GetTitle(); + std::string const questTitle = pQuest->GetTitle(); std::string const itemName = pRewardItem->Name1; std::ostringstream out; diff --git a/src/strategy/actions/RewardAction.h b/src/strategy/actions/RewardAction.h index 3e4930f1..5ae9a0f6 100644 --- a/src/strategy/actions/RewardAction.h +++ b/src/strategy/actions/RewardAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_REWARDACTION_H @@ -12,13 +13,13 @@ class Object; class RewardAction : public InventoryAction { - public: - RewardAction(PlayerbotAI* botAI) : InventoryAction(botAI, "reward") { } +public: + RewardAction(PlayerbotAI* botAI) : InventoryAction(botAI, "reward") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - bool Reward(uint32 itemId, Object* pNpc); +private: + bool Reward(uint32 itemId, Object* pNpc); }; #endif diff --git a/src/strategy/actions/RpgAction.cpp b/src/strategy/actions/RpgAction.cpp index b413d3a1..3723904d 100644 --- a/src/strategy/actions/RpgAction.cpp +++ b/src/strategy/actions/RpgAction.cpp @@ -1,8 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RpgAction.h" + +#include + #include "BattlegroundMgr.h" #include "ChatHelper.h" #include "EmoteAction.h" @@ -11,8 +15,6 @@ #include "Playerbots.h" #include "ServerFacade.h" -#include - bool RpgAction::Execute(Event event) { GuidPosition guidP = AI_VALUE(GuidPosition, "rpg target"); @@ -38,10 +40,7 @@ bool RpgAction::Execute(Event event) return true; } -bool RpgAction::isUseful() -{ - return AI_VALUE(GuidPosition, "rpg target"); -} +bool RpgAction::isUseful() { return AI_VALUE(GuidPosition, "rpg target"); } bool RpgAction::SetNextRpgAction() { diff --git a/src/strategy/actions/RpgAction.h b/src/strategy/actions/RpgAction.h index fe6843b2..deba34e7 100644 --- a/src/strategy/actions/RpgAction.h +++ b/src/strategy/actions/RpgAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RPGACTION_H @@ -13,28 +14,28 @@ class Unit; class RpgAction : public MovementAction { - public: - RpgAction(PlayerbotAI* botAI, std::string const name = "rpg") : MovementAction(botAI, name) { } +public: + RpgAction(PlayerbotAI* botAI, std::string const name = "rpg") : MovementAction(botAI, name) {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; - protected: - virtual bool SetNextRpgAction(); +protected: + virtual bool SetNextRpgAction(); - typedef void (RpgAction::*RpgElement)(ObjectGuid guid); + typedef void (RpgAction::*RpgElement)(ObjectGuid guid); - bool AddIgnore(ObjectGuid guid); - bool RemIgnore(ObjectGuid guid); - bool HasIgnore(ObjectGuid guid); + bool AddIgnore(ObjectGuid guid); + bool RemIgnore(ObjectGuid guid); + bool HasIgnore(ObjectGuid guid); }; class CRpgAction : public RpgAction { - public: - CRpgAction(PlayerbotAI* botAI) : RpgAction(botAI, "crpg") { } +public: + CRpgAction(PlayerbotAI* botAI) : RpgAction(botAI, "crpg") {} - bool isUseful() override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/RpgSubActions.cpp b/src/strategy/actions/RpgSubActions.cpp index e7f5e382..ac84ed2b 100644 --- a/src/strategy/actions/RpgSubActions.cpp +++ b/src/strategy/actions/RpgSubActions.cpp @@ -1,13 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RpgSubActions.h" + #include "ChooseRpgTargetAction.h" -#include "GuildCreateActions.h" #include "EmoteAction.h" #include "Formations.h" #include "GossipDef.h" +#include "GuildCreateActions.h" #include "LastMovementValue.h" #include "MovementActions.h" #include "Playerbots.h" @@ -45,15 +47,9 @@ void RpgHelper::AfterExecute(bool doDelay, bool waitForGroup) setFacing(guidP()); } -GuidPosition RpgHelper::guidP() -{ - return AI_VALUE(GuidPosition, "rpg target"); -} +GuidPosition RpgHelper::guidP() { return AI_VALUE(GuidPosition, "rpg target"); } -ObjectGuid RpgHelper::guid() -{ - return (ObjectGuid)guidP(); -} +ObjectGuid RpgHelper::guid() { return (ObjectGuid)guidP(); } bool RpgHelper::InRange() { @@ -62,7 +58,7 @@ bool RpgHelper::InRange() void RpgHelper::setFacingTo(GuidPosition guidPosition) { - bot->SetFacingTo(guidPosition.getAngleTo(bot)+ static_cast(M_PI)); + bot->SetFacingTo(guidPosition.getAngleTo(bot) + static_cast(M_PI)); } void RpgHelper::setFacing(GuidPosition guidPosition) @@ -73,9 +69,9 @@ void RpgHelper::setFacing(GuidPosition guidPosition) if (guidPosition.IsPlayer()) return; -// Unit* unit = guidPosition.GetUnit(); + // Unit* unit = guidPosition.GetUnit(); -// unit->SetFacingTo(unit->GetAngle(bot)); + // unit->SetFacingTo(unit->GetAngle(bot)); } void RpgHelper::setDelay(bool waitForGroup) @@ -86,15 +82,9 @@ void RpgHelper::setDelay(bool waitForGroup) botAI->SetNextCheckDelay(sPlayerbotAIConfig->rpgDelay / 5); } -bool RpgSubAction::isPossible() -{ - return rpg->guidP() && rpg->guidP().GetWorldObject(); -} +bool RpgSubAction::isPossible() { return rpg->guidP() && rpg->guidP().GetWorldObject(); } -bool RpgSubAction::isUseful() -{ - return rpg->InRange(); -} +bool RpgSubAction::isUseful() { return rpg->InRange(); } bool RpgSubAction::Execute(Event event) { @@ -103,20 +93,11 @@ bool RpgSubAction::Execute(Event event) return doAction; } -std::string const RpgSubAction::ActionName() -{ - return "none"; -} +std::string const RpgSubAction::ActionName() { return "none"; } -Event RpgSubAction::ActionEvent(Event event) -{ - return event; -} +Event RpgSubAction::ActionEvent(Event event) { return event; } -bool RpgStayAction::isUseful() -{ - return rpg->InRange() && !botAI->HasRealPlayerMaster(); -} +bool RpgStayAction::isUseful() { return rpg->InRange() && !botAI->HasRealPlayerMaster(); } bool RpgStayAction::Execute(Event event) { @@ -126,10 +107,7 @@ bool RpgStayAction::Execute(Event event) return true; } -bool RpgWorkAction::isUseful() -{ - return rpg->InRange() && !botAI->HasRealPlayerMaster(); -} +bool RpgWorkAction::isUseful() { return rpg->InRange() && !botAI->HasRealPlayerMaster(); } bool RpgWorkAction::Execute(Event event) { @@ -138,10 +116,7 @@ bool RpgWorkAction::Execute(Event event) return true; } -bool RpgEmoteAction::isUseful() -{ - return rpg->InRange() && !botAI->HasRealPlayerMaster(); -} +bool RpgEmoteAction::isUseful() { return rpg->InRange() && !botAI->HasRealPlayerMaster(); } bool RpgEmoteAction::Execute(Event event) { @@ -165,10 +140,7 @@ bool RpgCancelAction::Execute(Event event) return true; } -bool RpgTaxiAction::isUseful() -{ - return rpg->InRange() && !botAI->HasRealPlayerMaster(); -} +bool RpgTaxiAction::isUseful() { return rpg->InRange() && !botAI->HasRealPlayerMaster(); } bool RpgTaxiAction::Execute(Event event) { @@ -177,7 +149,8 @@ bool RpgTaxiAction::Execute(Event event) WorldPacket emptyPacket; bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket); - uint32 node = sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId()); + uint32 node = + sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId()); std::vector nodes; for (uint32 i = 0; i < sTaxiPathStore.GetNumRows(); ++i) @@ -209,18 +182,19 @@ bool RpgTaxiAction::Execute(Event event) Creature* flightMaster = bot->GetNPCIfCanInteractWith(guidP, UNIT_NPC_FLAG_FLIGHTMASTER); if (!flightMaster) { - LOG_ERROR("playerbots", "Bot {} cannot talk to flightmaster ({} location available)", bot->GetName(), nodes.size()); + LOG_ERROR("playerbots", "Bot {} cannot talk to flightmaster ({} location available)", bot->GetName(), + nodes.size()); return false; } - if (!bot->ActivateTaxiPathTo({ entry->from, entry->to }, flightMaster, 0)) + if (!bot->ActivateTaxiPathTo({entry->from, entry->to}, flightMaster, 0)) { LOG_ERROR("playerbots", "Bot {} cannot fly {} ({} location available)", bot->GetName(), path, nodes.size()); return false; } LOG_INFO("playerbots", "Bot {} <{}> is flying from {} to {} ({} location available)", - bot->GetGUID().ToString().c_str(), bot->GetName(), nodeFrom->name[0], nodeTo->name[0], nodes.size()); + bot->GetGUID().ToString().c_str(), bot->GetName(), nodeFrom->name[0], nodeTo->name[0], nodes.size()); bot->SetMoney(money); @@ -233,7 +207,8 @@ bool RpgDiscoverAction::Execute(Event event) { GuidPosition guidP = rpg->guidP(); - uint32 node = sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId()); + uint32 node = + sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId()); if (!node) return false; @@ -245,10 +220,7 @@ bool RpgDiscoverAction::Execute(Event event) return bot->GetSession()->SendLearnNewTaxiNode(flightMaster); } -std::string const RpgStartQuestAction::ActionName() -{ - return "accept all quests"; -} +std::string const RpgStartQuestAction::ActionName() { return "accept all quests"; } Event RpgStartQuestAction::ActionEvent(Event event) { @@ -258,10 +230,7 @@ Event RpgStartQuestAction::ActionEvent(Event event) return Event("rpg action", p); } -std::string const RpgEndQuestAction::ActionName() -{ - return "talk to quest giver"; -} +std::string const RpgEndQuestAction::ActionName() { return "talk to quest giver"; } Event RpgEndQuestAction::ActionEvent(Event event) { @@ -271,35 +240,17 @@ Event RpgEndQuestAction::ActionEvent(Event event) return Event("rpg action", p); } -std::string const RpgBuyAction::ActionName() -{ - return "buy"; -} +std::string const RpgBuyAction::ActionName() { return "buy"; } -Event RpgBuyAction::ActionEvent(Event event) -{ - return Event("rpg action", "vendor"); -} +Event RpgBuyAction::ActionEvent(Event event) { return Event("rpg action", "vendor"); } -std::string const RpgSellAction::ActionName() -{ - return "sell"; -} +std::string const RpgSellAction::ActionName() { return "sell"; } -Event RpgSellAction::ActionEvent(Event event) -{ - return Event("rpg action", "vendor"); -} +Event RpgSellAction::ActionEvent(Event event) { return Event("rpg action", "vendor"); } -std::string const RpgRepairAction::ActionName() -{ - return "repair"; -} +std::string const RpgRepairAction::ActionName() { return "repair"; } -std::string const RpgTrainAction::ActionName() -{ - return "trainer"; -} +std::string const RpgTrainAction::ActionName() { return "trainer"; } bool RpgHealAction::Execute(Event event) { @@ -311,59 +262,44 @@ bool RpgHealAction::Execute(Event event) retVal = botAI->DoSpecificAction("lesser heal on party", Event(), true); break; case CLASS_DRUID: - retVal=botAI->DoSpecificAction("healing touch on party", Event(), true); + retVal = botAI->DoSpecificAction("healing touch on party", Event(), true); break; case CLASS_PALADIN: - retVal=botAI->DoSpecificAction("holy light on party", Event(), true); + retVal = botAI->DoSpecificAction("holy light on party", Event(), true); break; case CLASS_SHAMAN: - retVal=botAI->DoSpecificAction("healing wave on party", Event(), true); + retVal = botAI->DoSpecificAction("healing wave on party", Event(), true); break; } return retVal; } -std::string const RpgHomeBindAction::ActionName() -{ - return "home"; -} +std::string const RpgHomeBindAction::ActionName() { return "home"; } std::string const RpgQueueBgAction::ActionName() { - SET_AI_VALUE(uint32, "bg type", (uint32) AI_VALUE(BattlegroundTypeId, "rpg bg type")); + SET_AI_VALUE(uint32, "bg type", (uint32)AI_VALUE(BattlegroundTypeId, "rpg bg type")); return "free bg join"; } -std::string const RpgBuyPetitionAction::ActionName() -{ - return "buy petition"; -} +std::string const RpgBuyPetitionAction::ActionName() { return "buy petition"; } -std::string const RpgUseAction::ActionName() -{ - return "use"; -} +std::string const RpgUseAction::ActionName() { return "use"; } Event RpgUseAction::ActionEvent(Event event) { return Event("rpg action", chat->FormatWorldobject(rpg->guidP().GetWorldObject())); } -std::string const RpgSpellAction::ActionName() -{ - return "cast random spell"; -} +std::string const RpgSpellAction::ActionName() { return "cast random spell"; } Event RpgSpellAction::ActionEvent(Event event) { return Event("rpg action", chat->FormatWorldobject(rpg->guidP().GetWorldObject())); } -std::string const RpgCraftAction::ActionName() -{ - return "craft random item"; -} +std::string const RpgCraftAction::ActionName() { return "craft random item"; } Event RpgCraftAction::ActionEvent(Event event) { @@ -379,11 +315,12 @@ std::vector RpgTradeUsefulAction::CanGiveItems(GuidPosition guidPosition) if (botAI->HasActivePlayerMaster() || !GET_PLAYERBOT_AI(player)) return giveItems; - std::vector myUsages = { ITEM_USAGE_NONE , ITEM_USAGE_VENDOR, ITEM_USAGE_AH, ITEM_USAGE_DISENCHANT }; + std::vector myUsages = {ITEM_USAGE_NONE, ITEM_USAGE_VENDOR, ITEM_USAGE_AH, ITEM_USAGE_DISENCHANT}; for (auto& myUsage : myUsages) { - std::vector myItems = AI_VALUE2(std::vector, "inventory items", "usage " + std::to_string(myUsage)); + std::vector myItems = + AI_VALUE2(std::vector, "inventory items", "usage " + std::to_string(myUsage)); std::reverse(myItems.begin(), myItems.end()); for (auto& item : myItems) @@ -433,13 +370,18 @@ bool RpgTradeUsefulAction::Execute(Event event) if (bot->GetTradeData() && bot->GetTradeData()->HasItem(item->GetGUID())) { if (bot->GetGroup() && bot->GetGroup()->IsMember(guidP) && botAI->HasRealPlayerMaster()) - botAI->TellMasterNoFacing("You can use this " + chat->FormatItem(item->GetTemplate()) + " better than me, " + guidP.GetPlayer()->GetName() /*chat->FormatWorldobject(guidP.GetPlayer())*/ + "."); + botAI->TellMasterNoFacing( + "You can use this " + chat->FormatItem(item->GetTemplate()) + " better than me, " + + guidP.GetPlayer()->GetName() /*chat->FormatWorldobject(guidP.GetPlayer())*/ + "."); else - bot->Say("You can use this " + chat->FormatItem(item->GetTemplate()) + " better than me, " + player->GetName() /*chat->FormatWorldobject(player)*/ + ".", (bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH)); + bot->Say("You can use this " + chat->FormatItem(item->GetTemplate()) + " better than me, " + + player->GetName() /*chat->FormatWorldobject(player)*/ + ".", + (bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH)); if (!urand(0, 4) || items.size() < 2) { - //bot->Say("End trade with" + chat->FormatWorldobject(player), (bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH)); + // bot->Say("End trade with" + chat->FormatWorldobject(player), (bot->GetTeamId() == TEAM_ALLIANCE ? + // LANG_COMMON : LANG_ORCISH)); WorldPacket p; uint32 status = TRADE_STATUS_TRADE_ACCEPT; p << status; @@ -447,7 +389,8 @@ bool RpgTradeUsefulAction::Execute(Event event) } } else - bot->Say("Start trade with" + chat->FormatWorldobject(player), (bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH)); + bot->Say("Start trade with" + chat->FormatWorldobject(player), + (bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH)); botAI->SetNextCheckDelay(sPlayerbotAIConfig->rpgDelay); return true; @@ -482,10 +425,10 @@ bool RpgDuelAction::Execute(Event event) if (!player) return false; - return botAI->DoSpecificAction("cast custom spell", Event("rpg action", chat->FormatWorldobject(player) + " 7266"), true); + return botAI->DoSpecificAction("cast custom spell", Event("rpg action", chat->FormatWorldobject(player) + " 7266"), + true); } - bool RpgMountAnimAction::isUseful() { return AI_VALUE2(bool, "mounted", "self target") && !AI_VALUE2(bool, "moving", "self target"); diff --git a/src/strategy/actions/RpgSubActions.h b/src/strategy/actions/RpgSubActions.h index 986e660c..c0b39082 100644 --- a/src/strategy/actions/RpgSubActions.h +++ b/src/strategy/actions/RpgSubActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RPGSUBACTIONS_H @@ -15,253 +16,250 @@ class PlayerbotAI; class RpgHelper : public AiObject { - public: - RpgHelper(PlayerbotAI* botAI) : AiObject(botAI) { } - virtual ~RpgHelper() = default; - void OnExecute(std::string nextAction = "rpg"); - void BeforeExecute(); - void AfterExecute(bool doDelay = true, bool waitForGroup = false); +public: + RpgHelper(PlayerbotAI* botAI) : AiObject(botAI) {} + virtual ~RpgHelper() = default; + void OnExecute(std::string nextAction = "rpg"); + void BeforeExecute(); + void AfterExecute(bool doDelay = true, bool waitForGroup = false); - virtual GuidPosition guidP(); - virtual ObjectGuid guid(); - virtual bool InRange(); + virtual GuidPosition guidP(); + virtual ObjectGuid guid(); + virtual bool InRange(); - private: - void setFacingTo(GuidPosition guidPosition); - void setFacing(GuidPosition guidPosition); - void setDelay(bool waitForGroup); +private: + void setFacingTo(GuidPosition guidPosition); + void setFacing(GuidPosition guidPosition); + void setDelay(bool waitForGroup); }; class RpgEnabled { - public: - RpgEnabled(PlayerbotAI* botAI) - { - rpg = std::make_unique(botAI); - } +public: + RpgEnabled(PlayerbotAI* botAI) { rpg = std::make_unique(botAI); } - protected: - std::unique_ptr rpg; +protected: + std::unique_ptr rpg; }; class RpgSubAction : public Action, public RpgEnabled { - public: - RpgSubAction(PlayerbotAI* botAI, std::string const name = "rpg sub") : Action(botAI, name), RpgEnabled(botAI) { } +public: + RpgSubAction(PlayerbotAI* botAI, std::string const name = "rpg sub") : Action(botAI, name), RpgEnabled(botAI) {} - //Long range is possible? - bool isPossible() override; - //Short range can we do the action now? - bool isUseful() override; + // Long range is possible? + bool isPossible() override; + // Short range can we do the action now? + bool isUseful() override; - bool Execute(Event event) override; + bool Execute(Event event) override; - protected: - virtual std::string const ActionName(); - virtual Event ActionEvent(Event event); +protected: + virtual std::string const ActionName(); + virtual Event ActionEvent(Event event); }; class RpgStayAction : public RpgSubAction { - public: - RpgStayAction(PlayerbotAI* botAI, std::string const name = "rpg stay") : RpgSubAction(botAI, name) { } +public: + RpgStayAction(PlayerbotAI* botAI, std::string const name = "rpg stay") : RpgSubAction(botAI, name) {} - bool isUseful() override; - bool Execute(Event event) override; + bool isUseful() override; + bool Execute(Event event) override; }; class RpgWorkAction : public RpgSubAction { - public: - RpgWorkAction(PlayerbotAI* botAI, std::string const name = "rpg work") : RpgSubAction(botAI, name ) { } +public: + RpgWorkAction(PlayerbotAI* botAI, std::string const name = "rpg work") : RpgSubAction(botAI, name) {} - bool isUseful() override; - bool Execute(Event event) override; + bool isUseful() override; + bool Execute(Event event) override; }; class RpgEmoteAction : public RpgSubAction { - public: - RpgEmoteAction(PlayerbotAI* botAI, std::string const name = "rpg emote") : RpgSubAction(botAI, name) { } +public: + RpgEmoteAction(PlayerbotAI* botAI, std::string const name = "rpg emote") : RpgSubAction(botAI, name) {} - bool isUseful() override; - bool Execute(Event event) override; + bool isUseful() override; + bool Execute(Event event) override; }; class RpgCancelAction : public RpgSubAction { - public: - RpgCancelAction(PlayerbotAI* botAI, std::string const name = "rpg cancel") : RpgSubAction(botAI, name) { } +public: + RpgCancelAction(PlayerbotAI* botAI, std::string const name = "rpg cancel") : RpgSubAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class RpgTaxiAction : public RpgSubAction { - public: - RpgTaxiAction(PlayerbotAI* botAI, std::string const name = "rpg taxi") : RpgSubAction(botAI, name) { } +public: + RpgTaxiAction(PlayerbotAI* botAI, std::string const name = "rpg taxi") : RpgSubAction(botAI, name) {} - bool isUseful() override; - bool Execute(Event event) override; + bool isUseful() override; + bool Execute(Event event) override; }; class RpgDiscoverAction : public RpgTaxiAction { - public: - RpgDiscoverAction(PlayerbotAI* botAI, std::string const name = "rpg discover") : RpgTaxiAction(botAI,name) { } +public: + RpgDiscoverAction(PlayerbotAI* botAI, std::string const name = "rpg discover") : RpgTaxiAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class RpgStartQuestAction : public RpgSubAction { - public: - RpgStartQuestAction(PlayerbotAI* botAI, std::string const name = "rpg start quest") : RpgSubAction(botAI, name) { } +public: + RpgStartQuestAction(PlayerbotAI* botAI, std::string const name = "rpg start quest") : RpgSubAction(botAI, name) {} - private: - std::string const ActionName() override; - Event ActionEvent(Event event) override; +private: + std::string const ActionName() override; + Event ActionEvent(Event event) override; }; class RpgEndQuestAction : public RpgSubAction { - public: - RpgEndQuestAction(PlayerbotAI* botAI, std::string const name = "rpg end quest") : RpgSubAction(botAI, name) { } +public: + RpgEndQuestAction(PlayerbotAI* botAI, std::string const name = "rpg end quest") : RpgSubAction(botAI, name) {} - private: - std::string const ActionName() override; - Event ActionEvent(Event event) override; +private: + std::string const ActionName() override; + Event ActionEvent(Event event) override; }; class RpgBuyAction : public RpgSubAction { - public: - RpgBuyAction(PlayerbotAI* botAI, std::string const name = "rpg buy") : RpgSubAction(botAI, name) { } +public: + RpgBuyAction(PlayerbotAI* botAI, std::string const name = "rpg buy") : RpgSubAction(botAI, name) {} - private: - std::string const ActionName() override; - Event ActionEvent(Event event) override; +private: + std::string const ActionName() override; + Event ActionEvent(Event event) override; }; class RpgSellAction : public RpgSubAction { - public: - RpgSellAction(PlayerbotAI* botAI, std::string const name = "rpg sell") : RpgSubAction(botAI, name) { } +public: + RpgSellAction(PlayerbotAI* botAI, std::string const name = "rpg sell") : RpgSubAction(botAI, name) {} - private: - std::string const ActionName() override; - Event ActionEvent(Event event) override; +private: + std::string const ActionName() override; + Event ActionEvent(Event event) override; }; class RpgRepairAction : public RpgSubAction { - public: - RpgRepairAction(PlayerbotAI* botAI, std::string const name = "rpg repair") : RpgSubAction(botAI, name) { } +public: + RpgRepairAction(PlayerbotAI* botAI, std::string const name = "rpg repair") : RpgSubAction(botAI, name) {} - private: - std::string const ActionName() override; +private: + std::string const ActionName() override; }; class RpgTrainAction : public RpgSubAction { - public: - RpgTrainAction(PlayerbotAI* botAI, std::string const name = "rpg train") : RpgSubAction(botAI, name) { } +public: + RpgTrainAction(PlayerbotAI* botAI, std::string const name = "rpg train") : RpgSubAction(botAI, name) {} - private: - std::string const ActionName() override; +private: + std::string const ActionName() override; }; class RpgHealAction : public RpgSubAction { - public: - RpgHealAction(PlayerbotAI* botAI, std::string const name = "rpg heal") : RpgSubAction(botAI, name) { } +public: + RpgHealAction(PlayerbotAI* botAI, std::string const name = "rpg heal") : RpgSubAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class RpgHomeBindAction : public RpgSubAction { - public: - RpgHomeBindAction(PlayerbotAI* botAI, std::string const name = "rpg home bind") : RpgSubAction(botAI, name) { } +public: + RpgHomeBindAction(PlayerbotAI* botAI, std::string const name = "rpg home bind") : RpgSubAction(botAI, name) {} - private: - std::string const ActionName() override; +private: + std::string const ActionName() override; }; class RpgQueueBgAction : public RpgSubAction { - public: - RpgQueueBgAction(PlayerbotAI* botAI, std::string const name = "rpg queue bg") : RpgSubAction(botAI, name) { } +public: + RpgQueueBgAction(PlayerbotAI* botAI, std::string const name = "rpg queue bg") : RpgSubAction(botAI, name) {} - private: - std::string const ActionName() override; +private: + std::string const ActionName() override; }; class RpgBuyPetitionAction : public RpgSubAction { - public: - RpgBuyPetitionAction(PlayerbotAI* botAI, std::string const name = "rpg buy petition") : RpgSubAction(botAI, name) { } +public: + RpgBuyPetitionAction(PlayerbotAI* botAI, std::string const name = "rpg buy petition") : RpgSubAction(botAI, name) {} - private: - std::string const ActionName() override; +private: + std::string const ActionName() override; }; class RpgUseAction : public RpgSubAction { - public: - RpgUseAction(PlayerbotAI* botAI, std::string const name = "rpg use") : RpgSubAction(botAI, name) { } +public: + RpgUseAction(PlayerbotAI* botAI, std::string const name = "rpg use") : RpgSubAction(botAI, name) {} - private: - std::string const ActionName() override; - Event ActionEvent(Event event) override; +private: + std::string const ActionName() override; + Event ActionEvent(Event event) override; }; class RpgSpellAction : public RpgSubAction { - public: - RpgSpellAction(PlayerbotAI* botAI, std::string const name = "rpg spell") : RpgSubAction(botAI, name) { } +public: + RpgSpellAction(PlayerbotAI* botAI, std::string const name = "rpg spell") : RpgSubAction(botAI, name) {} - private: - std::string const ActionName() override; - Event ActionEvent(Event event) override; +private: + std::string const ActionName() override; + Event ActionEvent(Event event) override; }; class RpgCraftAction : public RpgSubAction { - public: - RpgCraftAction(PlayerbotAI* botAI, std::string const name = "rpg craft") : RpgSubAction(botAI, name) { } +public: + RpgCraftAction(PlayerbotAI* botAI, std::string const name = "rpg craft") : RpgSubAction(botAI, name) {} - private: - std::string const ActionName() override; - Event ActionEvent(Event event) override; +private: + std::string const ActionName() override; + Event ActionEvent(Event event) override; }; class RpgTradeUsefulAction : public RpgSubAction { - public: - RpgTradeUsefulAction(PlayerbotAI* botAI, std::string const name = "rpg trade useful") : RpgSubAction(botAI, name) { } +public: + RpgTradeUsefulAction(PlayerbotAI* botAI, std::string const name = "rpg trade useful") : RpgSubAction(botAI, name) {} - std::vector CanGiveItems(GuidPosition guidPosition); + std::vector CanGiveItems(GuidPosition guidPosition); - bool Execute(Event event) override; + bool Execute(Event event) override; }; class RpgDuelAction : public RpgSubAction { - public: - RpgDuelAction(PlayerbotAI* botAI, std::string const name = "rpg duel") : RpgSubAction(botAI, name) { } +public: + RpgDuelAction(PlayerbotAI* botAI, std::string const name = "rpg duel") : RpgSubAction(botAI, name) {} - bool isUseful() override; - bool Execute(Event event) override; + bool isUseful() override; + bool Execute(Event event) override; }; class RpgMountAnimAction : public RpgSubAction { - public: - RpgMountAnimAction(PlayerbotAI* botAI, std::string const name = "rpg mount anim") : RpgSubAction(botAI, name) {} +public: + RpgMountAnimAction(PlayerbotAI* botAI, std::string const name = "rpg mount anim") : RpgSubAction(botAI, name) {} - bool isUseful() override; - bool Execute(Event event) override; + bool isUseful() override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/RpgValues.h b/src/strategy/actions/RpgValues.h index 6fb73927..b3e30867 100644 --- a/src/strategy/actions/RpgValues.h +++ b/src/strategy/actions/RpgValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RPGVALUES_H @@ -11,8 +12,10 @@ class PlayerbotAI; class NextRpgActionValue : public ManualSetValue { - public: - NextRpgActionValue(PlayerbotAI* botAI, std::string const defaultValue = "", std::string const name = "next rpg action") : ManualSetValue(botAI, defaultValue, name) { }; +public: + NextRpgActionValue(PlayerbotAI* botAI, std::string const defaultValue = "", + std::string const name = "next rpg action") + : ManualSetValue(botAI, defaultValue, name){}; }; #endif diff --git a/src/strategy/actions/RtiAction.cpp b/src/strategy/actions/RtiAction.cpp index d0b71a92..b28b9585 100644 --- a/src/strategy/actions/RtiAction.cpp +++ b/src/strategy/actions/RtiAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RtiAction.h" + #include "Event.h" #include "Playerbots.h" #include "RtiTargetValue.h" @@ -20,12 +22,14 @@ bool RtiAction::Execute(Event event) if (text.empty() || text == "?") { std::ostringstream outRti; - outRti << "rti" << ": "; + outRti << "rti" + << ": "; AppendRti(outRti, "rti"); botAI->TellMaster(outRti); std::ostringstream outRtiCc; - outRtiCc << "rti cc" << ": "; + outRtiCc << "rti cc" + << ": "; AppendRti(outRtiCc, "rti cc"); botAI->TellMaster(outRtiCc); return true; diff --git a/src/strategy/actions/RtiAction.h b/src/strategy/actions/RtiAction.h index dd362d20..5978a7d6 100644 --- a/src/strategy/actions/RtiAction.h +++ b/src/strategy/actions/RtiAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RTIACTION_H @@ -11,21 +12,21 @@ class PlayerbotAI; class RtiAction : public Action { - public: - RtiAction(PlayerbotAI* botAI) : Action(botAI, "rti") { } +public: + RtiAction(PlayerbotAI* botAI) : Action(botAI, "rti") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - void AppendRti(std::ostringstream& out, std::string const type); +private: + void AppendRti(std::ostringstream& out, std::string const type); }; class MarkRtiAction : public Action { - public: - MarkRtiAction(PlayerbotAI* botAI) : Action(botAI, "mark rti") { } +public: + MarkRtiAction(PlayerbotAI* botAI) : Action(botAI, "mark rti") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/RtscAction.cpp b/src/strategy/actions/RtscAction.cpp index 7fc710e6..7d096ea5 100644 --- a/src/strategy/actions/RtscAction.cpp +++ b/src/strategy/actions/RtscAction.cpp @@ -1,148 +1,155 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RtscAction.h" + #include "Playerbots.h" #include "RTSCValues.h" bool RTSCAction::Execute(Event event) { - std::string const command = event.getParam(); + std::string const command = event.getParam(); - Player* master = botAI->GetMaster(); + Player* master = botAI->GetMaster(); - if (!master) - return false; + if (!master) + return false; - if (command != "reset" && !master->HasSpell(RTSC_MOVE_SPELL)) - { - master->learnSpell(RTSC_MOVE_SPELL, false); - botAI->TellMasterNoFacing("RTS control enabled."); - botAI->TellMasterNoFacing("Aedm (Awesome energetic do move) spell trained."); - } - else if (command == "reset") - { - if (master->HasSpell(RTSC_MOVE_SPELL)) - { - master->removeSpell(RTSC_MOVE_SPELL, SPEC_MASK_ALL, false); - botAI->TellMasterNoFacing("RTS control spell removed."); - } + if (command != "reset" && !master->HasSpell(RTSC_MOVE_SPELL)) + { + master->learnSpell(RTSC_MOVE_SPELL, false); + botAI->TellMasterNoFacing("RTS control enabled."); + botAI->TellMasterNoFacing("Aedm (Awesome energetic do move) spell trained."); + } + else if (command == "reset") + { + if (master->HasSpell(RTSC_MOVE_SPELL)) + { + master->removeSpell(RTSC_MOVE_SPELL, SPEC_MASK_ALL, false); + botAI->TellMasterNoFacing("RTS control spell removed."); + } - RESET_AI_VALUE(bool, "RTSC selected"); - RESET_AI_VALUE(std::string, "RTSC next spell action"); + RESET_AI_VALUE(bool, "RTSC selected"); + RESET_AI_VALUE(std::string, "RTSC next spell action"); - for (auto value : botAI->GetAiObjectContext()->GetValues()) - if (value.find("RTSC saved location::") != std::string::npos) - RESET_AI_VALUE(WorldPosition, value.c_str()); + for (auto value : botAI->GetAiObjectContext()->GetValues()) + if (value.find("RTSC saved location::") != std::string::npos) + RESET_AI_VALUE(WorldPosition, value.c_str()); - return true; - } + return true; + } - bool selected = AI_VALUE(bool, "RTSC selected"); + bool selected = AI_VALUE(bool, "RTSC selected"); - if (command == "select" && !selected) - { - SET_AI_VALUE(bool, "RTSC selected", true); - master->SendPlaySpellVisual(bot->GetGUID(), 5036); - return true; - } - else if (command == "cancel") - { - RESET_AI_VALUE(bool, "RTSC selected"); - RESET_AI_VALUE(std::string, "RTSC next spell action"); - if(selected) - master->SendPlaySpellVisual(bot->GetGUID(), 6372); - return true; - } - else if (command == "toggle") - { - if (!selected) - { - SET_AI_VALUE(bool, "RTSC selected", true); - master->SendPlaySpellVisual(bot->GetGUID(), 5036); - } - else - { - SET_AI_VALUE(bool, "RTSC selected", false); - master->SendPlaySpellVisual(bot->GetGUID(), 6372); - } + if (command == "select" && !selected) + { + SET_AI_VALUE(bool, "RTSC selected", true); + master->SendPlaySpellVisual(bot->GetGUID(), 5036); + return true; + } + else if (command == "cancel") + { + RESET_AI_VALUE(bool, "RTSC selected"); + RESET_AI_VALUE(std::string, "RTSC next spell action"); + if (selected) + master->SendPlaySpellVisual(bot->GetGUID(), 6372); + return true; + } + else if (command == "toggle") + { + if (!selected) + { + SET_AI_VALUE(bool, "RTSC selected", true); + master->SendPlaySpellVisual(bot->GetGUID(), 5036); + } + else + { + SET_AI_VALUE(bool, "RTSC selected", false); + master->SendPlaySpellVisual(bot->GetGUID(), 6372); + } - return true; - } - else if (command.find("save here ") != std::string::npos) - { - std::string const locationName = command.substr(10); + return true; + } + else if (command.find("save here ") != std::string::npos) + { + std::string const locationName = command.substr(10); - WorldPosition spellPosition(bot); - SET_AI_VALUE2(WorldPosition, "RTSC saved location", locationName, spellPosition); + WorldPosition spellPosition(bot); + SET_AI_VALUE2(WorldPosition, "RTSC saved location", locationName, spellPosition); - Creature* wpCreature = bot->SummonCreature(15631, spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), spellPosition.getO(), TEMPSUMMON_TIMED_DESPAWN, 2000.0f); - wpCreature->SetObjectScale(0.5f); + Creature* wpCreature = + bot->SummonCreature(15631, spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), + spellPosition.getO(), TEMPSUMMON_TIMED_DESPAWN, 2000.0f); + wpCreature->SetObjectScale(0.5f); - return true; - } - else if (command.find("unsave ") != std::string::npos) - { - std::string const locationName = command.substr(7); + return true; + } + else if (command.find("unsave ") != std::string::npos) + { + std::string const locationName = command.substr(7); - RESET_AI_VALUE2(WorldPosition, "RTSC saved location", locationName); + RESET_AI_VALUE2(WorldPosition, "RTSC saved location", locationName); - return true; - } + return true; + } - if (command.find("save ") != std::string::npos || command == "move") - { - SET_AI_VALUE(std::string, "RTSC next spell action", command); + if (command.find("save ") != std::string::npos || command == "move") + { + SET_AI_VALUE(std::string, "RTSC next spell action", command); - return true; - } + return true; + } - if (command.find("show ") != std::string::npos) - { - std::string const locationName = command.substr(5); - WorldPosition spellPosition = AI_VALUE2(WorldPosition, "RTSC saved location", locationName); + if (command.find("show ") != std::string::npos) + { + std::string const locationName = command.substr(5); + WorldPosition spellPosition = AI_VALUE2(WorldPosition, "RTSC saved location", locationName); - if (spellPosition) - { - Creature* wpCreature = bot->SummonCreature(15631, spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), spellPosition.getO(), TEMPSUMMON_TIMED_DESPAWN, 2000.0f); - wpCreature->SetObjectScale(0.5f); - } + if (spellPosition) + { + Creature* wpCreature = + bot->SummonCreature(15631, spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), + spellPosition.getO(), TEMPSUMMON_TIMED_DESPAWN, 2000.0f); + wpCreature->SetObjectScale(0.5f); + } - return true; - } + return true; + } - if (command.find("show") != std::string::npos) - { - std::ostringstream out; out << "saved: "; + if (command.find("show") != std::string::npos) + { + std::ostringstream out; + out << "saved: "; - for (auto value : botAI->GetAiObjectContext()->GetValues()) - if (value.find("RTSC saved location::") != std::string::npos) - if (AI_VALUE2(WorldPosition, "RTSC saved location", value.substr(21).c_str())) - out << value.substr(21).c_str() << ","; + for (auto value : botAI->GetAiObjectContext()->GetValues()) + if (value.find("RTSC saved location::") != std::string::npos) + if (AI_VALUE2(WorldPosition, "RTSC saved location", value.substr(21).c_str())) + out << value.substr(21).c_str() << ","; - out.seekp(-1, out.cur); - out << "."; + out.seekp(-1, out.cur); + out << "."; - botAI->TellMasterNoFacing(out); - } + botAI->TellMasterNoFacing(out); + } - if (command.find("go ") != std::string::npos) - { - std::string const locationName = command.substr(3); - WorldPosition spellPosition = AI_VALUE2(WorldPosition, "RTSC saved location", locationName); + if (command.find("go ") != std::string::npos) + { + std::string const locationName = command.substr(3); + WorldPosition spellPosition = AI_VALUE2(WorldPosition, "RTSC saved location", locationName); - if(spellPosition) - return MoveToSpell(spellPosition, false); + if (spellPosition) + return MoveToSpell(spellPosition, false); - return true; - } - else if (command == "last") - { - WorldPosition spellPosition = AI_VALUE(WorldPosition, "see spell location"); - if (spellPosition) - return MoveToSpell(spellPosition); - } + return true; + } + else if (command == "last") + { + WorldPosition spellPosition = AI_VALUE(WorldPosition, "see spell location"); + if (spellPosition) + return MoveToSpell(spellPosition); + } - return false; + return false; } diff --git a/src/strategy/actions/RtscAction.h b/src/strategy/actions/RtscAction.h index bfc726a4..062b77ca 100644 --- a/src/strategy/actions/RtscAction.h +++ b/src/strategy/actions/RtscAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RTSCACTION_H @@ -9,14 +10,14 @@ class PlayerbotAI; -#define RTSC_MOVE_SPELL 30758 //Aedm (Awesome Energetic do move) +#define RTSC_MOVE_SPELL 30758 // Aedm (Awesome Energetic do move) class RTSCAction : public SeeSpellAction { - public: - RTSCAction(PlayerbotAI* botAI) : SeeSpellAction(botAI, "rtsc") { } +public: + RTSCAction(PlayerbotAI* botAI) : SeeSpellAction(botAI, "rtsc") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/SaveManaAction.cpp b/src/strategy/actions/SaveManaAction.cpp index 30bbb2d5..34814128 100644 --- a/src/strategy/actions/SaveManaAction.cpp +++ b/src/strategy/actions/SaveManaAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SaveManaAction.h" + #include "Event.h" #include "Playerbots.h" diff --git a/src/strategy/actions/SaveManaAction.h b/src/strategy/actions/SaveManaAction.h index ee8cc70a..0e3a5c93 100644 --- a/src/strategy/actions/SaveManaAction.h +++ b/src/strategy/actions/SaveManaAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SAVEMANAACTION_H @@ -11,13 +12,13 @@ class PlayerbotAI; class SaveManaAction : public Action { - public: - SaveManaAction(PlayerbotAI* botAI) : Action(botAI, "save mana") { } +public: + SaveManaAction(PlayerbotAI* botAI) : Action(botAI, "save mana") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - std::string const Format(double value); +private: + std::string const Format(double value); }; #endif diff --git a/src/strategy/actions/SayAction.cpp b/src/strategy/actions/SayAction.cpp index 2bcca877..a64e2a5e 100644 --- a/src/strategy/actions/SayAction.cpp +++ b/src/strategy/actions/SayAction.cpp @@ -1,28 +1,58 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SayAction.h" -#include "Event.h" -#include "Playerbots.h" -#include "PlayerbotTextMgr.h" -#include "ChannelMgr.h" -#include "GuildMgr.h" + #include -static const std::unordered_set noReplyMsgs = { - "join", "leave", "follow", "attack", "pull", "flee", "reset", "reset ai", - "all ?", "talents", "talents list", "talents auto", "talk", "stay", "stats", - "who", "items", "leave", "join", "repair", "summon", "nc ?", "co ?", "de ?", - "dead ?", "follow", "los", "guard", "do accept invitation", "stats", "react ?", - "reset strats", "home", -}; -static const std::unordered_set noReplyMsgParts = { "+", "-","@" , "follow target", "focus heal", "cast ", "accept [", "e [", "destroy [", "go zone" }; -static const std::unordered_set noReplyMsgStarts = { "e ", "accept ", "cast ", "destroy " }; +#include "ChannelMgr.h" +#include "Event.h" +#include "GuildMgr.h" +#include "PlayerbotTextMgr.h" +#include "Playerbots.h" -SayAction::SayAction(PlayerbotAI* botAI) : Action(botAI, "say"), Qualified() -{ -} +static const std::unordered_set noReplyMsgs = { + "join", + "leave", + "follow", + "attack", + "pull", + "flee", + "reset", + "reset ai", + "all ?", + "talents", + "talents list", + "talents auto", + "talk", + "stay", + "stats", + "who", + "items", + "leave", + "join", + "repair", + "summon", + "nc ?", + "co ?", + "de ?", + "dead ?", + "follow", + "los", + "guard", + "do accept invitation", + "stats", + "react ?", + "reset strats", + "home", +}; +static const std::unordered_set noReplyMsgParts = { + "+", "-", "@", "follow target", "focus heal", "cast ", "accept [", "e [", "destroy [", "go zone"}; +static const std::unordered_set noReplyMsgStarts = {"e ", "accept ", "cast ", "destroy "}; + +SayAction::SayAction(PlayerbotAI* botAI) : Action(botAI, "say"), Qualified() {} bool SayAction::Execute(Event event) { @@ -33,7 +63,8 @@ bool SayAction::Execute(Event event) target = AI_VALUE(Unit*, "current target"); // set replace strings - if (target) placeholders[""] = target->GetName(); + if (target) + placeholders[""] = target->GetName(); placeholders[""] = IsAlliance(bot->getRace()) ? "Alliance" : "Horde"; if (qualifier == "low ammo" || qualifier == "no ammo") { @@ -58,7 +89,6 @@ bool SayAction::Execute(Event event) placeholders[""] = area->area_name[0]; } - // set delay before next say time_t lastSaid = AI_VALUE2(time_t, "last said", qualifier); uint32 nextTime = time(nullptr) + urand(1, 30); @@ -72,7 +102,8 @@ bool SayAction::Execute(Event event) { Player* member = ref->GetSource(); PlayerbotAI* memberAi = GET_PLAYERBOT_AI(member); - if (memberAi) members.push_back(member); + if (memberAi) + members.push_back(member); } uint32 count = members.size(); @@ -90,11 +121,13 @@ bool SayAction::Execute(Event event) } int index = 0; - for (auto & member : members) + for (auto& member : members) { PlayerbotAI* memberAi = GET_PLAYERBOT_AI(member); if (memberAi) - memberAi->GetAiObjectContext()->GetValue("last said", qualifier)->Set(nextTime + (20 * ++index) + urand(1, 15)); + memberAi->GetAiObjectContext() + ->GetValue("last said", qualifier) + ->Set(nextTime + (20 * ++index) + urand(1, 15)); } } @@ -122,14 +155,16 @@ bool SayAction::isUseful() return (time(nullptr) - lastSaid) > 30; } -void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 guid2, std::string msg, std::string chanName, std::string name) +void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 guid2, std::string msg, + std::string chanName, std::string name) { - ChatReplyType replyType = REPLY_NOT_UNDERSTAND; // default not understand + ChatReplyType replyType = REPLY_NOT_UNDERSTAND; // default not understand std::string respondsText = ""; // if we're just commanding bots around, don't respond... // first one is for exact word matches - if (noReplyMsgs.find(msg) != noReplyMsgs.end()) { + if (noReplyMsgs.find(msg) != noReplyMsgs.end()) + { /*std::ostringstream out; out << "DEBUG ChatReplyDo decided to ignore exact blocklist match" << msg; bot->Say(out.str(), LANG_UNIVERSAL);*/ @@ -137,16 +172,21 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 } // second one is for partial matches like + or - where we change strats - if (std::any_of(noReplyMsgParts.begin(), noReplyMsgParts.end(), [&msg](const std::string& part) { return msg.find(part) != std::string::npos; })) { + if (std::any_of(noReplyMsgParts.begin(), noReplyMsgParts.end(), + [&msg](const std::string& part) { return msg.find(part) != std::string::npos; })) + { /*std::ostringstream out; out << "DEBUG ChatReplyDo decided to ignore partial blocklist match" << msg; bot->Say(out.str(), LANG_UNIVERSAL);*/ return; } - if (std::any_of(noReplyMsgStarts.begin(), noReplyMsgStarts.end(), [&msg](const std::string& start) { - return msg.find(start) == 0; // Check if the start matches the beginning of msg - })) { + if (std::any_of(noReplyMsgStarts.begin(), noReplyMsgStarts.end(), + [&msg](const std::string& start) + { + return msg.find(start) == 0; // Check if the start matches the beginning of msg + })) + { /*std::ostringstream out; out << "DEBUG ChatReplyDo decided to ignore start blocklist match" << msg; bot->Say(out.str(), LANG_UNIVERSAL);*/ @@ -199,8 +239,8 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 break; } - if (word[i] == "hi" || word[i] == "hey" || word[i] == "hello" || word[i] == "wazzup" - || word[i] == "salut" || word[i] == "plop" || word[i] == "yo") + if (word[i] == "hi" || word[i] == "hey" || word[i] == "hello" || word[i] == "wazzup" || word[i] == "salut" || + word[i] == "plop" || word[i] == "yo") { replyType = REPLY_HELLO; found = true; @@ -209,29 +249,30 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 if (verb_type < 4) { - if (word[i] == "am" || word[i] == "are" || word[i] == "is" || word[i] == "suis" || word[i] == "as" || word[i] == "est" - || word[i] == "dois" || word[i] == "doit") + if (word[i] == "am" || word[i] == "are" || word[i] == "is" || word[i] == "suis" || word[i] == "as" || + word[i] == "est" || word[i] == "dois" || word[i] == "doit") { verb_pos = i; - verb_type = 2; // present + verb_type = 2; // present if (verb_pos == 0) is_quest = 1; } else if (word[i] == "will" || word[i] == "vais" || word[i] == "sera") { verb_pos = i; - verb_type = 3; // future + verb_type = 3; // future } - else if (word[i] == "was" || word[i] == "were" || word[i] == "été" || word[i] == "ai" || word[i] == "eu" || word[i] == "étions" || word[i] == "etion" ) + else if (word[i] == "was" || word[i] == "were" || word[i] == "été" || word[i] == "ai" || word[i] == "eu" || + word[i] == "étions" || word[i] == "etion") { verb_pos = i; - verb_type = 1; // past + verb_type = 1; // past } else if (word[i] == "shut" || word[i] == "noob" || word[i] == "tg") { if (msg.find(bot->GetName()) == std::string::npos) { - continue; // not react + continue; // not react uint32 rnd = urand(0, 2); std::string msg = ""; if (rnd == 0) @@ -430,13 +471,16 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 switch (rnd) { case 0: - msg = "its true, " + word[verb_pos + 1] + " " + word[verb_pos] + " " + word[verb_pos + 2] + " " + word[verb_pos + 3] + " " + word[verb_pos + 4] + " " + word[verb_pos + 4]; + msg = "its true, " + word[verb_pos + 1] + " " + word[verb_pos] + " " + + word[verb_pos + 2] + " " + word[verb_pos + 3] + " " + word[verb_pos + 4] + " " + + word[verb_pos + 4]; break; case 1: msg = "ya %s but thats in the past"; break; case 2: - msg = "nah, but " + word[verb_pos + 1] + " will " + word[verb_pos + 3] + " again though %s"; + msg = "nah, but " + word[verb_pos + 1] + " will " + word[verb_pos + 3] + + " again though %s"; break; case 3: msg = "afraid that was before i was around or paying attention"; @@ -455,13 +499,16 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 switch (rnd) { case 0: - msg = "its true, " + word[verb_pos + 1] + " " + word[verb_pos] + " " + word[verb_pos + 2] + " " + word[verb_pos + 3] + " " + word[verb_pos + 4] + " " + word[verb_pos + 5]; + msg = "its true, " + word[verb_pos + 1] + " " + word[verb_pos] + " " + + word[verb_pos + 2] + " " + word[verb_pos + 3] + " " + word[verb_pos + 4] + " " + + word[verb_pos + 5]; break; case 1: msg = "ya %s thats true"; break; case 2: - msg = "maybe " + word[verb_pos + 1] + " " + word[verb_pos] + " " + word[verb_pos + 2] + " " + word[verb_pos + 3] + " " + word[verb_pos + 4] + " " + word[verb_pos + 5]; + msg = "maybe " + word[verb_pos + 1] + " " + word[verb_pos] + " " + word[verb_pos + 2] + + " " + word[verb_pos + 3] + " " + word[verb_pos + 4] + " " + word[verb_pos + 5]; break; case 3: msg = "dunno %s"; @@ -587,7 +634,8 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 msg = "%s, what will happen %s?"; break; case 2: - msg = "are you saying " + word[verb_pos - 1] + " will " + word[verb_pos + 1] + " " + word[verb_pos + 2] + " %s?"; + msg = "are you saying " + word[verb_pos - 1] + " will " + word[verb_pos + 1] + " " + + word[verb_pos + 2] + " %s?"; break; } msg = std::regex_replace(msg, std::regex("%s"), name); @@ -606,7 +654,7 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 replyType = REPLY_NAME; found = true; } - else // Does not understand + else // Does not understand { replyType = REPLY_NOT_UNDERSTAND; found = true; @@ -631,7 +679,8 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 if (ChannelMgr* cMgr = ChannelMgr::forTeam(bot->GetTeamId())) { std::string worldChan = "World"; - if (Channel* chn = cMgr->GetJoinChannel(worldChan.c_str(), 0)) { + if (Channel* chn = cMgr->GetJoinChannel(worldChan.c_str(), 0)) + { if (bot->GetTeamId() == TEAM_ALLIANCE) chn->Say(bot->GetGUID(), c, LANG_COMMON); else @@ -684,6 +733,9 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 guild->BroadcastToGuild(bot->GetSession(), false, respondsText, LANG_UNIVERSAL); } } - GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue("last said", "chat")->Set(time(nullptr) + urand(5, 25)); + GET_PLAYERBOT_AI(bot) + ->GetAiObjectContext() + ->GetValue("last said", "chat") + ->Set(time(nullptr) + urand(5, 25)); } } diff --git a/src/strategy/actions/SayAction.h b/src/strategy/actions/SayAction.h index 5afe127f..7eb6c9e5 100644 --- a/src/strategy/actions/SayAction.h +++ b/src/strategy/actions/SayAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SAYACTION_H @@ -12,25 +13,25 @@ class PlayerbotAI; class SayAction : public Action, public Qualified { - public: - SayAction(PlayerbotAI* botAI); +public: + SayAction(PlayerbotAI* botAI); - bool Execute(Event event) override; - bool isUseful() override; - std::string const getName() override { return "say::" + qualifier; } + bool Execute(Event event) override; + bool isUseful() override; + std::string const getName() override { return "say::" + qualifier; } - private: - static std::map> stringTable; - static std::map probabilityTable; +private: + static std::map> stringTable; + static std::map probabilityTable; }; - class ChatReplyAction : public Action { public: ChatReplyAction(PlayerbotAI* ai) : Action(ai, "chat message") {} virtual bool Execute(Event event) { return true; } bool isUseful() { return true; } - static void ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 guid2, std::string msg, std::string chanName, std::string name); + static void ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32 guid2, std::string msg, std::string chanName, + std::string name); }; #endif diff --git a/src/strategy/actions/SecurityCheckAction.cpp b/src/strategy/actions/SecurityCheckAction.cpp index 732736dd..afd0f9d1 100644 --- a/src/strategy/actions/SecurityCheckAction.cpp +++ b/src/strategy/actions/SecurityCheckAction.cpp @@ -1,14 +1,17 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SecurityCheckAction.h" + #include "Event.h" #include "Playerbots.h" bool SecurityCheckAction::isUseful() { - return sRandomPlayerbotMgr->IsRandomBot(bot) && botAI->GetMaster() && botAI->GetMaster()->GetSession()->GetSecurity() < SEC_GAMEMASTER && !GET_PLAYERBOT_AI(botAI->GetMaster()); + return sRandomPlayerbotMgr->IsRandomBot(bot) && botAI->GetMaster() && + botAI->GetMaster()->GetSession()->GetSecurity() < SEC_GAMEMASTER && !GET_PLAYERBOT_AI(botAI->GetMaster()); } bool SecurityCheckAction::Execute(Event event) @@ -19,7 +22,8 @@ bool SecurityCheckAction::Execute(Event event) ItemQualities threshold = group->GetLootThreshold(); if (method == MASTER_LOOT || method == FREE_FOR_ALL || threshold > ITEM_QUALITY_UNCOMMON) { - if ((botAI->GetGroupMaster()->GetSession()->GetSecurity() == SEC_PLAYER) && (!bot->GetGuildId() || bot->GetGuildId() != botAI->GetGroupMaster()->GetGuildId())) + if ((botAI->GetGroupMaster()->GetSession()->GetSecurity() == SEC_PLAYER) && + (!bot->GetGuildId() || bot->GetGuildId() != botAI->GetGroupMaster()->GetGuildId())) { botAI->TellError("I will play with this loot type only if I'm in your guild :/"); botAI->ChangeStrategy("+passive,+stay", BOT_STATE_NON_COMBAT); diff --git a/src/strategy/actions/SecurityCheckAction.h b/src/strategy/actions/SecurityCheckAction.h index 59a0a546..fa068ffa 100644 --- a/src/strategy/actions/SecurityCheckAction.h +++ b/src/strategy/actions/SecurityCheckAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SECURITYCHECKACTION_H @@ -11,11 +12,11 @@ class PlayerbotAI; class SecurityCheckAction : public Action { - public: - SecurityCheckAction(PlayerbotAI* botAI) : Action(botAI, "security check") { } +public: + SecurityCheckAction(PlayerbotAI* botAI) : Action(botAI, "security check") {} - bool isUseful() override; - bool Execute(Event event) override; + bool isUseful() override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/SeeSpellAction.cpp b/src/strategy/actions/SeeSpellAction.cpp index 3cda6396..dcce6952 100644 --- a/src/strategy/actions/SeeSpellAction.cpp +++ b/src/strategy/actions/SeeSpellAction.cpp @@ -1,16 +1,19 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SeeSpellAction.h" + #include "Event.h" #include "Formations.h" #include "PathGenerator.h" #include "Playerbots.h" -#include "RtscAction.h" #include "RTSCValues.h" +#include "RtscAction.h" -Creature* SeeSpellAction::CreateWps(Player* wpOwner, float x, float y, float z, float o, uint32 entry, Creature* lastWp, bool important) +Creature* SeeSpellAction::CreateWps(Player* wpOwner, float x, float y, float z, float o, uint32 entry, Creature* lastWp, + bool important) { float dist = wpOwner->GetDistance(x, y, z); float delay = 1000.0f * dist / wpOwner->GetSpeed(MOVE_RUN) + sPlayerbotAIConfig->reactDelay; @@ -27,7 +30,7 @@ Creature* SeeSpellAction::CreateWps(Player* wpOwner, float x, float y, float z, bool SeeSpellAction::Execute(Event event) { - WorldPacket p(event.getPacket()); // + WorldPacket p(event.getPacket()); // uint32 spellId; uint8 castCount, castFlags; Player* master = botAI->GetMaster(); @@ -38,8 +41,8 @@ bool SeeSpellAction::Execute(Event event) if (!master) return false; - //if (!botAI->HasStrategy("RTSC", botAI->GetState())) - // return false; + // if (!botAI->HasStrategy("RTSC", botAI->GetState())) + // return false; if (spellId != RTSC_MOVE_SPELL) return false; @@ -91,7 +94,9 @@ bool SeeSpellAction::Execute(Event event) SET_AI_VALUE2(WorldPosition, "RTSC saved location", locationName, spellPosition); - Creature* wpCreature = bot->SummonCreature(15631, spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), spellPosition.getO(), TEMPSUMMON_TIMED_DESPAWN, 2000.0f); + Creature* wpCreature = + bot->SummonCreature(15631, spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), + spellPosition.getO(), TEMPSUMMON_TIMED_DESPAWN, 2000.0f); wpCreature->SetObjectScale(0.5f); RESET_AI_VALUE(std::string, "RTSC next spell action"); @@ -121,7 +126,8 @@ bool SeeSpellAction::MoveToSpell(WorldPosition& spellPosition, bool inFormation) if (bot->IsWithinLOS(spellPosition.getX(), spellPosition.getY(), spellPosition.getZ())) return MoveNear(spellPosition.getMapId(), spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), 0); - return MoveTo(spellPosition.getMapId(), spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), false, false); + return MoveTo(spellPosition.getMapId(), spellPosition.getX(), spellPosition.getY(), spellPosition.getZ(), false, + false); } void SeeSpellAction::SetFormationOffset(WorldPosition& spellPosition) diff --git a/src/strategy/actions/SeeSpellAction.h b/src/strategy/actions/SeeSpellAction.h index 462f2f97..1d3178a5 100644 --- a/src/strategy/actions/SeeSpellAction.h +++ b/src/strategy/actions/SeeSpellAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SEESPELLACTION_H @@ -14,19 +15,20 @@ class WorldPosition; class SeeSpellAction : public MovementAction { - public: - SeeSpellAction(PlayerbotAI* botAI, std::string const name = "see spell") : MovementAction(botAI, name) { } +public: + SeeSpellAction(PlayerbotAI* botAI, std::string const name = "see spell") : MovementAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; - bool SelectSpell(WorldPosition& spellPosition); - bool MoveSpell(WorldPosition& spellPosition); + bool SelectSpell(WorldPosition& spellPosition); + bool MoveSpell(WorldPosition& spellPosition); - virtual bool MoveToSpell(WorldPosition& spellPosition, bool inFormation = true); - void SetFormationOffset(WorldPosition& spellPosition); + virtual bool MoveToSpell(WorldPosition& spellPosition, bool inFormation = true); + void SetFormationOffset(WorldPosition& spellPosition); - private: - Creature* CreateWps(Player* wpOwner, float x, float y, float z, float o, uint32 entry, Creature* lastWp, bool important = false); +private: + Creature* CreateWps(Player* wpOwner, float x, float y, float z, float o, uint32 entry, Creature* lastWp, + bool important = false); }; #endif diff --git a/src/strategy/actions/SellAction.cpp b/src/strategy/actions/SellAction.cpp index 9bcf8dac..ea8021ab 100644 --- a/src/strategy/actions/SellAction.cpp +++ b/src/strategy/actions/SellAction.cpp @@ -1,60 +1,59 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SellAction.h" + #include "Event.h" -#include "ItemVisitors.h" #include "ItemUsageValue.h" +#include "ItemVisitors.h" #include "Playerbots.h" class SellItemsVisitor : public IterateItemsVisitor { - public: - SellItemsVisitor(SellAction* action) : IterateItemsVisitor(), action(action) { } +public: + SellItemsVisitor(SellAction* action) : IterateItemsVisitor(), action(action) {} - bool Visit(Item* item) override - { - action->Sell(item); - return true; - } + bool Visit(Item* item) override + { + action->Sell(item); + return true; + } - private: - SellAction* action; +private: + SellAction* action; }; class SellGrayItemsVisitor : public SellItemsVisitor { - public: - SellGrayItemsVisitor(SellAction* action) : SellItemsVisitor(action) { } +public: + SellGrayItemsVisitor(SellAction* action) : SellItemsVisitor(action) {} - bool Visit(Item* item) override - { - if (item->GetTemplate()->Quality != ITEM_QUALITY_POOR) - return true; + bool Visit(Item* item) override + { + if (item->GetTemplate()->Quality != ITEM_QUALITY_POOR) + return true; - return SellItemsVisitor::Visit(item); - } + return SellItemsVisitor::Visit(item); + } }; class SellVendorItemsVisitor : public SellItemsVisitor { - public: - SellVendorItemsVisitor(SellAction* action, AiObjectContext* con) : SellItemsVisitor(action) - { - context = con; - } +public: + SellVendorItemsVisitor(SellAction* action, AiObjectContext* con) : SellItemsVisitor(action) { context = con; } - AiObjectContext* context; + AiObjectContext* context; - bool Visit(Item* item) override - { - ItemUsage usage = context->GetValue("item usage", item->GetEntry())->Get(); - if (usage != ITEM_USAGE_VENDOR && usage != ITEM_USAGE_AH) - return true; + bool Visit(Item* item) override + { + ItemUsage usage = context->GetValue("item usage", item->GetEntry())->Get(); + if (usage != ITEM_USAGE_VENDOR && usage != ITEM_USAGE_AH) + return true; - return SellItemsVisitor::Visit(item); - } + return SellItemsVisitor::Visit(item); + } }; bool SellAction::Execute(Event event) @@ -76,8 +75,8 @@ bool SellAction::Execute(Event event) if (text != "") { - std::vector items = parseItems(text, ITERATE_ITEMS_IN_BAGS); - for (Item *item : items) + std::vector items = parseItems(text, ITERATE_ITEMS_IN_BAGS); + for (Item* item : items) { Sell(item); } @@ -106,7 +105,7 @@ void SellAction::Sell(Item* item) for (ObjectGuid const vendorguid : vendors) { - Creature* pCreature = bot->GetNPCIfCanInteractWith(vendorguid,UNIT_NPC_FLAG_VENDOR); + Creature* pCreature = bot->GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR); if (!pCreature) continue; diff --git a/src/strategy/actions/SellAction.h b/src/strategy/actions/SellAction.h index cbe61a01..0fc61ea9 100644 --- a/src/strategy/actions/SellAction.h +++ b/src/strategy/actions/SellAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SELLACTION_H @@ -13,13 +14,12 @@ class PlayerbotAI; class SellAction : public InventoryAction { - public: - SellAction(PlayerbotAI* botAI, std::string const name = "sell") : InventoryAction(botAI, name) { } - - bool Execute(Event event) override; - void Sell(FindItemVisitor* visitor); - void Sell(Item* item); +public: + SellAction(PlayerbotAI* botAI, std::string const name = "sell") : InventoryAction(botAI, name) {} + bool Execute(Event event) override; + void Sell(FindItemVisitor* visitor); + void Sell(Item* item); }; #endif diff --git a/src/strategy/actions/SendMailAction.cpp b/src/strategy/actions/SendMailAction.cpp index 79687450..f28c0545 100644 --- a/src/strategy/actions/SendMailAction.cpp +++ b/src/strategy/actions/SendMailAction.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SendMailAction.h" -#include "Mail.h" + +#include "ChatHelper.h" #include "Event.h" #include "ItemVisitors.h" -#include "ChatHelper.h" +#include "Mail.h" #include "Playerbots.h" bool SendMailAction::Execute(Event event) @@ -14,7 +16,7 @@ bool SendMailAction::Execute(Event event) uint32 account = bot->GetSession()->GetAccountId(); bool randomBot = sPlayerbotAIConfig->IsInRandomAccountList(account); - GuidVector gos = *context->GetValue("nearest game objects"); + GuidVector gos = *context->GetValue("nearest game objects"); bool mailboxFound = false; for (ObjectGuid const guid : gos) { @@ -55,7 +57,6 @@ bool SendMailAction::Execute(Event event) return false; } - ItemIds ids = chat->parseItems(text); if (ids.size() > 1) { diff --git a/src/strategy/actions/SendMailAction.h b/src/strategy/actions/SendMailAction.h index b497eaa9..a016ad71 100644 --- a/src/strategy/actions/SendMailAction.h +++ b/src/strategy/actions/SendMailAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SENDMAILACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class SendMailAction : public InventoryAction { - public: - SendMailAction(PlayerbotAI* botAI) : InventoryAction(botAI, "sendmail") { } +public: + SendMailAction(PlayerbotAI* botAI) : InventoryAction(botAI, "sendmail") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/SetCraftAction.cpp b/src/strategy/actions/SetCraftAction.cpp index a2bc8553..d514c7f4 100644 --- a/src/strategy/actions/SetCraftAction.cpp +++ b/src/strategy/actions/SetCraftAction.cpp @@ -1,11 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SetCraftAction.h" -#include "Event.h" -#include "CraftValue.h" + #include "ChatHelper.h" +#include "CraftValue.h" +#include "Event.h" #include "Playerbots.h" std::map SetCraftAction::skillSpells; @@ -70,7 +72,8 @@ bool SetCraftAction::Execute(Event event) { for (uint8 i = 0; i < 3; ++i) { - if (spellInfo->Effects[i].Effect == SPELL_EFFECT_CREATE_ITEM && itemId == spellInfo->Effects[i].ItemType) + if (spellInfo->Effects[i].Effect == SPELL_EFFECT_CREATE_ITEM && + itemId == spellInfo->Effects[i].ItemType) { for (uint32 x = 0; x < MAX_SPELL_REAGENTS; ++x) { diff --git a/src/strategy/actions/SetCraftAction.h b/src/strategy/actions/SetCraftAction.h index 581a4b16..8ec59131 100644 --- a/src/strategy/actions/SetCraftAction.h +++ b/src/strategy/actions/SetCraftAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SETCRAFTACTION_H @@ -14,18 +15,17 @@ struct SkillLineAbilityEntry; class SetCraftAction : public Action { - public: - SetCraftAction(PlayerbotAI* botAI) : Action(botAI, "craft") { } +public: + SetCraftAction(PlayerbotAI* botAI) : Action(botAI, "craft") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - static uint32 GetCraftFee(CraftData& craftData); + static uint32 GetCraftFee(CraftData& craftData); - private: - void TellCraft(); - - static std::map skillSpells; +private: + void TellCraft(); + static std::map skillSpells; }; #endif diff --git a/src/strategy/actions/SetHomeAction.cpp b/src/strategy/actions/SetHomeAction.cpp index 6bcb417a..0da185d4 100644 --- a/src/strategy/actions/SetHomeAction.cpp +++ b/src/strategy/actions/SetHomeAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SetHomeAction.h" + #include "Event.h" #include "Playerbots.h" @@ -13,7 +15,8 @@ bool SetHomeAction::Execute(Event event) ObjectGuid selection = bot->GetTarget(); bool isRpgAction = AI_VALUE(GuidPosition, "rpg target") == selection; - if (!isRpgAction) { + if (!isRpgAction) + { if (master) selection = master->GetTarget(); else diff --git a/src/strategy/actions/SetHomeAction.h b/src/strategy/actions/SetHomeAction.h index 2db27dc5..1b9109bf 100644 --- a/src/strategy/actions/SetHomeAction.h +++ b/src/strategy/actions/SetHomeAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SETHOMEACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class SetHomeAction : public MovementAction { - public: - SetHomeAction(PlayerbotAI* botAI) : MovementAction(botAI, "home") { } +public: + SetHomeAction(PlayerbotAI* botAI) : MovementAction(botAI, "home") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/ShareQuestAction.cpp b/src/strategy/actions/ShareQuestAction.cpp index 8ab7c8ba..a71a96b0 100644 --- a/src/strategy/actions/ShareQuestAction.cpp +++ b/src/strategy/actions/ShareQuestAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ShareQuestAction.h" + #include "Event.h" #include "Playerbots.h" diff --git a/src/strategy/actions/ShareQuestAction.h b/src/strategy/actions/ShareQuestAction.h index dc646787..5e9eb5e4 100644 --- a/src/strategy/actions/ShareQuestAction.h +++ b/src/strategy/actions/ShareQuestAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SHAREQUESTACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class ShareQuestAction : public Action { - public: - ShareQuestAction(PlayerbotAI* botAI) : Action(botAI, "share quest") { } +public: + ShareQuestAction(PlayerbotAI* botAI) : Action(botAI, "share quest") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/SkipSpellsListAction.cpp b/src/strategy/actions/SkipSpellsListAction.cpp index 7a17136f..2221731d 100644 --- a/src/strategy/actions/SkipSpellsListAction.cpp +++ b/src/strategy/actions/SkipSpellsListAction.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SkipSpellsListAction.h" -#include "LootAction.h" + #include "Event.h" -#include "SkipSpellsListValue.h" +#include "LootAction.h" #include "Playerbots.h" +#include "SkipSpellsListValue.h" bool SkipSpellsListAction::Execute(Event event) { diff --git a/src/strategy/actions/SkipSpellsListAction.h b/src/strategy/actions/SkipSpellsListAction.h index 442ef7e3..58f77ca6 100644 --- a/src/strategy/actions/SkipSpellsListAction.h +++ b/src/strategy/actions/SkipSpellsListAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SKIPSPELLSLISTACTION_H @@ -12,13 +13,13 @@ class PlayerbotAI; class SkipSpellsListAction : public Action { - public: - SkipSpellsListAction(PlayerbotAI* botAI) : Action(botAI, "ss") { } +public: + SkipSpellsListAction(PlayerbotAI* botAI) : Action(botAI, "ss") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - SpellIds parseIds(std::string const text); +private: + SpellIds parseIds(std::string const text); }; #endif diff --git a/src/strategy/actions/StatsAction.cpp b/src/strategy/actions/StatsAction.cpp index 0cb0a7ec..6d05a8df 100644 --- a/src/strategy/actions/StatsAction.cpp +++ b/src/strategy/actions/StatsAction.cpp @@ -1,10 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "StatsAction.h" -#include "Event.h" + #include "ChatHelper.h" +#include "Event.h" #include "Playerbots.h" bool StatsAction::Execute(Event event) @@ -29,12 +31,9 @@ bool StatsAction::Execute(Event event) return true; } -void StatsAction::ListGold(std::ostringstream &out) -{ - out << chat->formatMoney(bot->GetMoney()); -} +void StatsAction::ListGold(std::ostringstream& out) { out << chat->formatMoney(bot->GetMoney()); } -void StatsAction::ListBagSlots(std::ostringstream &out) +void StatsAction::ListBagSlots(std::ostringstream& out) { uint32 totalused = 0, total = 16; @@ -61,15 +60,14 @@ void StatsAction::ListBagSlots(std::ostringstream &out) totalfree += pBag->GetFreeSlots(); } } - } - std::string color = "ff00ff00"; - if (totalfree < total / 2) - color = "ffffff00"; + std::string color = "ff00ff00"; + if (totalfree < total / 2) + color = "ffffff00"; - if (totalfree < total / 4) - color = "ffff0000"; + if (totalfree < total / 4) + color = "ffff0000"; out << "|h|c" << color << totalfree << "/" << total << "|h|cffffffff Bag"; } @@ -99,7 +97,7 @@ void StatsAction::ListRepairCost(std::ostringstream& out) for (uint32 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) { - uint16 pos = ( (INVENTORY_SLOT_BAG_0 << 8) | i ); + uint16 pos = ((INVENTORY_SLOT_BAG_0 << 8) | i); totalCost += EstRepair(pos); double repair = RepairPercent(pos); if (repair < 100) @@ -136,7 +134,7 @@ uint32 StatsAction::EstRepair(uint16 pos) uint32 curDurability = item->GetUInt32Value(ITEM_FIELD_DURABILITY); uint32 LostDurability = maxDurability - curDurability; - if (LostDurability>0) + if (LostDurability > 0) { ItemTemplate const* ditemProto = item->GetTemplate(); @@ -147,7 +145,7 @@ uint32 StatsAction::EstRepair(uint16 pos) return TotalCost; } - uint32 dQualitymodEntryId = (ditemProto->Quality+1) * 2; + uint32 dQualitymodEntryId = (ditemProto->Quality + 1) * 2; DurabilityQualityEntry const* dQualitymodEntry = sDurabilityQualityStore.LookupEntry(dQualitymodEntryId); if (!dQualitymodEntry) { @@ -155,10 +153,11 @@ uint32 StatsAction::EstRepair(uint16 pos) return TotalCost; } - uint32 dmultiplier = dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class,ditemProto->SubClass)]; - uint32 costs = uint32(LostDurability*dmultiplier*double(dQualitymodEntry->quality_mod)); + uint32 dmultiplier = + dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class, ditemProto->SubClass)]; + uint32 costs = uint32(LostDurability * dmultiplier * double(dQualitymodEntry->quality_mod)); - if (!costs) //fix for ITEM_QUALITY_ARTIFACT + if (!costs) // fix for ITEM_QUALITY_ARTIFACT costs = 1; TotalCost = costs; diff --git a/src/strategy/actions/StatsAction.h b/src/strategy/actions/StatsAction.h index 4922d908..019eb4af 100644 --- a/src/strategy/actions/StatsAction.h +++ b/src/strategy/actions/StatsAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_STATSACTION_H @@ -11,18 +12,18 @@ class PlayerbotAI; class StatsAction : public Action { - public: - StatsAction(PlayerbotAI* botAI) : Action(botAI, "stats") { } +public: + StatsAction(PlayerbotAI* botAI) : Action(botAI, "stats") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - void ListBagSlots(std::ostringstream &out); - void ListXP(std::ostringstream &out); - void ListRepairCost(std::ostringstream &out); - void ListGold(std::ostringstream &out); - uint32 EstRepair(uint16 pos); - double RepairPercent(uint16 pos); +private: + void ListBagSlots(std::ostringstream& out); + void ListXP(std::ostringstream& out); + void ListRepairCost(std::ostringstream& out); + void ListGold(std::ostringstream& out); + uint32 EstRepair(uint16 pos); + double RepairPercent(uint16 pos); }; #endif diff --git a/src/strategy/actions/StayActions.cpp b/src/strategy/actions/StayActions.cpp index ca8a83b1..f725c046 100644 --- a/src/strategy/actions/StayActions.cpp +++ b/src/strategy/actions/StayActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "StayActions.h" + #include "Event.h" #include "LastMovementValue.h" #include "Playerbots.h" @@ -11,8 +13,8 @@ bool StayActionBase::Stay() { AI_VALUE(LastMovement&, "last movement").Set(nullptr); - //if (!urand(0, 10)) - //botAI->PlaySound(TEXT_EMOTE_YAWN); + // if (!urand(0, 10)) + // botAI->PlaySound(TEXT_EMOTE_YAWN); if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE) return false; @@ -36,10 +38,7 @@ bool StayActionBase::Stay() return true; } -bool StayAction::Execute(Event event) -{ - return Stay(); -} +bool StayAction::Execute(Event event) { return Stay(); } bool StayAction::isUseful() { @@ -56,7 +55,4 @@ bool SitAction::Execute(Event event) return true; } -bool SitAction::isUseful() -{ - return !AI_VALUE2(bool, "moving", "self target"); -} +bool SitAction::isUseful() { return !AI_VALUE2(bool, "moving", "self target"); } diff --git a/src/strategy/actions/StayActions.h b/src/strategy/actions/StayActions.h index e54f1acf..5dd9a8e4 100644 --- a/src/strategy/actions/StayActions.h +++ b/src/strategy/actions/StayActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_STAYACTIONS_H @@ -11,29 +12,29 @@ class PlayerbotAI; class StayActionBase : public MovementAction { - public: - StayActionBase(PlayerbotAI* botAI, std::string const name) : MovementAction(botAI, name) { } +public: + StayActionBase(PlayerbotAI* botAI, std::string const name) : MovementAction(botAI, name) {} - protected: - bool Stay(); +protected: + bool Stay(); }; class StayAction : public StayActionBase { - public: - StayAction(PlayerbotAI* botAI) : StayActionBase(botAI, "stay") { } +public: + StayAction(PlayerbotAI* botAI) : StayActionBase(botAI, "stay") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class SitAction : public StayActionBase { - public: - SitAction(PlayerbotAI* botAI) : StayActionBase(botAI, "sit") { } +public: + SitAction(PlayerbotAI* botAI) : StayActionBase(botAI, "sit") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/SuggestWhatToDoAction.cpp b/src/strategy/actions/SuggestWhatToDoAction.cpp index 391978f1..c15d9175 100644 --- a/src/strategy/actions/SuggestWhatToDoAction.cpp +++ b/src/strategy/actions/SuggestWhatToDoAction.cpp @@ -1,27 +1,31 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SuggestWhatToDoAction.h" -#include "ServerFacade.h" -#include "ChannelMgr.h" -#include "Event.h" -#include "ItemVisitors.h" -#include "AiFactory.h" -#include "ChatHelper.h" -#include "Playerbots.h" -#include "PlayerbotTextMgr.h" -#include "GuildMgr.h" -#include "Config.h" #include +#include "AiFactory.h" +#include "ChannelMgr.h" +#include "ChatHelper.h" +#include "Config.h" +#include "Event.h" +#include "GuildMgr.h" +#include "ItemVisitors.h" +#include "PlayerbotTextMgr.h" +#include "Playerbots.h" +#include "ServerFacade.h" + enum eTalkType { /*0x18*/ General = ChannelFlags::CHANNEL_FLAG_GENERAL | ChannelFlags::CHANNEL_FLAG_NOT_LFG, - /*0x3C*/ Trade = ChannelFlags::CHANNEL_FLAG_CITY | ChannelFlags::CHANNEL_FLAG_GENERAL | ChannelFlags::CHANNEL_FLAG_NOT_LFG | ChannelFlags::CHANNEL_FLAG_TRADE, + /*0x3C*/ Trade = ChannelFlags::CHANNEL_FLAG_CITY | ChannelFlags::CHANNEL_FLAG_GENERAL | + ChannelFlags::CHANNEL_FLAG_NOT_LFG | ChannelFlags::CHANNEL_FLAG_TRADE, /*0x18*/ LocalDefence = ChannelFlags::CHANNEL_FLAG_GENERAL | ChannelFlags::CHANNEL_FLAG_NOT_LFG, - /*x038*/ GuildRecruitment = ChannelFlags::CHANNEL_FLAG_CITY | ChannelFlags::CHANNEL_FLAG_GENERAL | ChannelFlags::CHANNEL_FLAG_NOT_LFG, + /*x038*/ GuildRecruitment = + ChannelFlags::CHANNEL_FLAG_CITY | ChannelFlags::CHANNEL_FLAG_GENERAL | ChannelFlags::CHANNEL_FLAG_NOT_LFG, /*0x50*/ LookingForGroup = ChannelFlags::CHANNEL_FLAG_LFG | ChannelFlags::CHANNEL_FLAG_GENERAL }; @@ -29,8 +33,7 @@ std::map SuggestDungeonAction::instances; std::map SuggestWhatToDoAction::factions; SuggestWhatToDoAction::SuggestWhatToDoAction(PlayerbotAI* botAI, std::string const name) - : InventoryAction{ botAI, name } - , _dbc_locale{ sWorld->GetDefaultDbcLocale() } + : InventoryAction{botAI, name}, _dbc_locale{sWorld->GetDefaultDbcLocale()} { suggestions.push_back(std::bind(&SuggestWhatToDoAction::specificQuest, this)); suggestions.push_back(std::bind(&SuggestWhatToDoAction::grindReputation, this)); @@ -101,8 +104,8 @@ void SuggestWhatToDoAction::grindMaterials() /*if (bot->GetLevel() <= 5) return; - auto result = CharacterDatabase.Query("SELECT distinct category, multiplier FROM ahbot_category where category not in ('other', 'quest', 'trade', 'reagent') and multiplier > 3 order by multiplier desc limit 10"); - if (!result) + auto result = CharacterDatabase.Query("SELECT distinct category, multiplier FROM ahbot_category where category not + in ('other', 'quest', 'trade', 'reagent') and multiplier > 3 order by multiplier desc limit 10"); if (!result) return; std::map categories; @@ -133,8 +136,8 @@ void SuggestWhatToDoAction::grindMaterials() placeholders["%role"] = chat->formatClass(bot, AiFactory::GetPlayerSpecTab(bot)); placeholders["%category"] = item; - spam(BOT_TEXT2("suggest_trade", placeholders), urand(0, 1) ? 0x3C : 0x18, !urand(0, 2), !urand(0, 3)); - return; + spam(BOT_TEXT2("suggest_trade", placeholders), urand(0, 1) ? 0x3C : 0x18, !urand(0, 2), !urand(0, + 3)); return; } } } @@ -204,7 +207,7 @@ void SuggestWhatToDoAction::grindReputation() placeholders["%rndK"] = rnd.str(); std::ostringstream itemout; -// itemout << "|c004040b0" << allowedFactions[urand(0, allowedFactions.size() - 1)] << "|r"; + // itemout << "|c004040b0" << allowedFactions[urand(0, allowedFactions.size() - 1)] << "|r"; itemout << allowedFactions[urand(0, allowedFactions.size() - 1)]; placeholders["%faction"] = itemout.str(); @@ -221,11 +224,12 @@ void SuggestWhatToDoAction::something() return; std::ostringstream out; -// out << "|cffb04040" << entry->area_name[0] << "|r"; + // out << "|cffb04040" << entry->area_name[0] << "|r"; out << entry->area_name[_dbc_locale]; placeholders["%zone"] = out.str(); - spam(BOT_TEXT2("suggest_something", placeholders), urand(0, 1) ? eTalkType::General : 0, !urand(0, 2), !urand(0, 3)); + spam(BOT_TEXT2("suggest_something", placeholders), urand(0, 1) ? eTalkType::General : 0, !urand(0, 2), + !urand(0, 3)); } void SuggestWhatToDoAction::spam(std::string msg, uint8 flags, bool worldChat, bool guild) @@ -238,15 +242,18 @@ void SuggestWhatToDoAction::spam(std::string msg, uint8 flags, bool worldChat, b if (!cMgr) return; - AreaTableEntry const* zone = sAreaTableStore.LookupEntry(bot->GetMap()->GetZoneId(bot->GetPhaseMask(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ())); - if (!zone) return; - /*AreaTableEntry const* area = sAreaTableStore.LookupEntry(bot->GetMap()->GetAreaId(bot->GetPhaseMask(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ())); - if (!area) return;*/ + AreaTableEntry const* zone = sAreaTableStore.LookupEntry( + bot->GetMap()->GetZoneId(bot->GetPhaseMask(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ())); + if (!zone) + return; + /*AreaTableEntry const* area = sAreaTableStore.LookupEntry(bot->GetMap()->GetAreaId(bot->GetPhaseMask(), + bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ())); if (!area) return;*/ for (uint32 i = 0; i < sChatChannelsStore.GetNumRows(); ++i) { ChatChannelsEntry const* channel = sChatChannelsStore.LookupEntry(i); - if (!channel) continue; + if (!channel) + continue; // combine full channel name char channelName[100]; @@ -316,44 +323,44 @@ void SuggestWhatToDoAction::spam(std::string msg, uint8 flags, bool worldChat, b class FindTradeItemsVisitor : public IterateItemsVisitor { - public: - FindTradeItemsVisitor(uint32 quality) : quality(quality), IterateItemsVisitor() { } - - bool Visit(Item* item) override - { - ItemTemplate const* proto = item->GetTemplate(); - if (proto->Quality != quality) - return true; - - if (proto->Class == ITEM_CLASS_TRADE_GOODS && proto->Bonding == NO_BIND) - { - if (proto->Quality == ITEM_QUALITY_NORMAL && item->GetCount() > 1 && item->GetCount() == item->GetMaxStackCount()) - stacks.push_back(proto->ItemId); - - items.push_back(proto->ItemId); - count[proto->ItemId] += item->GetCount(); - } +public: + FindTradeItemsVisitor(uint32 quality) : quality(quality), IterateItemsVisitor() {} + bool Visit(Item* item) override + { + ItemTemplate const* proto = item->GetTemplate(); + if (proto->Quality != quality) return true; + + if (proto->Class == ITEM_CLASS_TRADE_GOODS && proto->Bonding == NO_BIND) + { + if (proto->Quality == ITEM_QUALITY_NORMAL && item->GetCount() > 1 && + item->GetCount() == item->GetMaxStackCount()) + stacks.push_back(proto->ItemId); + + items.push_back(proto->ItemId); + count[proto->ItemId] += item->GetCount(); } - std::map count; - std::vector stacks; - std::vector items; + return true; + } - private: - uint32 quality; + std::map count; + std::vector stacks; + std::vector items; + +private: + uint32 quality; }; -SuggestDungeonAction::SuggestDungeonAction(PlayerbotAI* botAI) : SuggestWhatToDoAction(botAI, "suggest dungeon") -{ -} +SuggestDungeonAction::SuggestDungeonAction(PlayerbotAI* botAI) : SuggestWhatToDoAction(botAI, "suggest dungeon") {} bool SuggestDungeonAction::Execute(Event event) { // TODO: use sPlayerbotDungeonSuggestionMgr - if (!sPlayerbotAIConfig->randomBotSuggestDungeons || bot->GetGroup()) return false; + if (!sPlayerbotAIConfig->randomBotSuggestDungeons || bot->GetGroup()) + return false; if (instances.empty()) { @@ -407,23 +414,23 @@ bool SuggestDungeonAction::Execute(Event event) if (bot->GetLevel() >= instance.second) allowedInstances.push_back(instance.first); } - if (allowedInstances.empty()) return false; + if (allowedInstances.empty()) + return false; std::map placeholders; placeholders["%role"] = ChatHelper::FormatClass(bot, AiFactory::GetPlayerSpecTab(bot)); std::ostringstream itemout; - //itemout << "|c00b000b0" << allowedInstances[urand(0, allowedInstances.size() - 1)] << "|r"; + // itemout << "|c00b000b0" << allowedInstances[urand(0, allowedInstances.size() - 1)] << "|r"; itemout << allowedInstances[urand(0, allowedInstances.size() - 1)]; placeholders["%instance"] = itemout.str(); - spam(BOT_TEXT2("suggest_instance", placeholders), urand(0, 1) ? eTalkType::LookingForGroup : 0, !urand(0, 2), !urand(0, 3)); + spam(BOT_TEXT2("suggest_instance", placeholders), urand(0, 1) ? eTalkType::LookingForGroup : 0, !urand(0, 2), + !urand(0, 3)); return true; } -SuggestTradeAction::SuggestTradeAction(PlayerbotAI* botAI) : SuggestWhatToDoAction(botAI, "suggest trade") -{ -} +SuggestTradeAction::SuggestTradeAction(PlayerbotAI* botAI) : SuggestWhatToDoAction(botAI, "suggest trade") {} bool SuggestTradeAction::Execute(Event event) { @@ -481,7 +488,6 @@ bool SuggestTradeAction::Execute(Event event) placeholders["%item"] = chat->FormatItem(proto, count); placeholders["%gold"] = chat->formatMoney(price); - spam(BOT_TEXT2("suggest_sell", placeholders), urand(0, 1) ? eTalkType::Trade : 0, !urand(0, 2), urand(0, 5)); return true; } diff --git a/src/strategy/actions/SuggestWhatToDoAction.h b/src/strategy/actions/SuggestWhatToDoAction.h index 46391ff2..e3ae3c64 100644 --- a/src/strategy/actions/SuggestWhatToDoAction.h +++ b/src/strategy/actions/SuggestWhatToDoAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SUGGESTWHATTODOACTION_H @@ -11,46 +12,47 @@ class PlayerbotAI; class SuggestWhatToDoAction : public InventoryAction { - public: - SuggestWhatToDoAction(PlayerbotAI* botAI, std::string const name = "suggest what to do"); +public: + SuggestWhatToDoAction(PlayerbotAI* botAI, std::string const name = "suggest what to do"); - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; - protected: - using Suggestion = std::function; - std::vector suggestions; - void specificQuest(); - void grindReputation(); - void grindMaterials(); - void something(); - void spam(std::string msg, uint8 flags = 0, bool worldChat = false, bool guild = false); +protected: + using Suggestion = std::function; + std::vector suggestions; + void specificQuest(); + void grindReputation(); + void grindMaterials(); + void something(); + void spam(std::string msg, uint8 flags = 0, bool worldChat = false, bool guild = false); - std::vector GetIncompletedQuests(); + std::vector GetIncompletedQuests(); - private: - static std::map factions; - const int32_t _dbc_locale; +private: + static std::map factions; + const int32_t _dbc_locale; }; class SuggestTradeAction : public SuggestWhatToDoAction { - public: - SuggestTradeAction(PlayerbotAI* botAI); +public: + SuggestTradeAction(PlayerbotAI* botAI); - bool Execute(Event event) override; - bool isUseful() override { return true; } + bool Execute(Event event) override; + bool isUseful() override { return true; } }; class SuggestDungeonAction : public SuggestWhatToDoAction { - public: - SuggestDungeonAction(PlayerbotAI* botAI); +public: + SuggestDungeonAction(PlayerbotAI* botAI); - bool Execute(Event event) override; - bool isUseful() override { return true; } - private: - static std::map instances; + bool Execute(Event event) override; + bool isUseful() override { return true; } + +private: + static std::map instances; }; #endif diff --git a/src/strategy/actions/TalkToQuestGiverAction.cpp b/src/strategy/actions/TalkToQuestGiverAction.cpp index 78f2879c..11effe7f 100644 --- a/src/strategy/actions/TalkToQuestGiverAction.cpp +++ b/src/strategy/actions/TalkToQuestGiverAction.cpp @@ -1,10 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TalkToQuestGiverAction.h" -#include "Event.h" + #include "ChatHelper.h" +#include "Event.h" #include "ItemUsageValue.h" #include "Object.h" #include "Playerbots.h" @@ -32,7 +34,8 @@ void TalkToQuestGiverAction::ProcessQuest(Quest const* quest, Object* questGiver if (sPlayerbotAIConfig->syncQuestWithPlayer) { - if (master && master->GetQuestStatus(quest->GetQuestId()) == QUEST_STATUS_COMPLETE && (status == QUEST_STATUS_INCOMPLETE || status == QUEST_STATUS_FAILED)) + if (master && master->GetQuestStatus(quest->GetQuestId()) == QUEST_STATUS_COMPLETE && + (status == QUEST_STATUS_INCOMPLETE || status == QUEST_STATUS_FAILED)) { CompleteQuest(bot, quest->GetQuestId()); status = bot->GetQuestStatus(quest->GetQuestId()); @@ -116,7 +119,7 @@ ItemIds TalkToQuestGiverAction::BestRewards(Quest const* quest) if (quest->GetRewChoiceItemsCount() == 0) return returnIds; else if (quest->GetRewChoiceItemsCount() == 1) - return { 0 }; + return {0}; else { for (uint8 i = 0; i < quest->GetRewChoiceItemsCount(); ++i) @@ -146,7 +149,7 @@ void TalkToQuestGiverAction::RewardMultipleItem(Quest const* quest, Object* ques std::ostringstream outid; if (!botAI->IsAlt() || sPlayerbotAIConfig->autoPickReward == "yes") { - //Pick the first item of the best rewards. + // Pick the first item of the best rewards. bestIds = BestRewards(quest); if (!bestIds.empty()) { @@ -159,7 +162,6 @@ void TalkToQuestGiverAction::RewardMultipleItem(Quest const* quest, Object* ques out << "Unable to find suitable reward. Asking for help...."; AskToSelectReward(quest, out, true); } - } else if (sPlayerbotAIConfig->autoPickReward == "no") { @@ -168,7 +170,7 @@ void TalkToQuestGiverAction::RewardMultipleItem(Quest const* quest, Object* ques } else { - //Try to pick the usable item. If multiple list usable rewards. + // Try to pick the usable item. If multiple list usable rewards. bestIds = BestRewards(quest); if (!bestIds.empty()) { @@ -176,7 +178,7 @@ void TalkToQuestGiverAction::RewardMultipleItem(Quest const* quest, Object* ques } else { - //Pick the first item + // Pick the first item ItemTemplate const* item = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[*bestIds.begin()]); bot->RewardQuest(quest, *bestIds.begin(), questGiver, true); @@ -212,7 +214,8 @@ bool TurnInQueryQuestAction::Execute(Event event) uint32 questId; ObjectGuid unk1; pakcet >> guid >> questId; - Object* object = ObjectAccessor::GetObjectByTypeMask(*bot, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM); + Object* object = + ObjectAccessor::GetObjectByTypeMask(*bot, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM); if (!object || (!object->hasQuest(questId) && !object->hasInvolvedQuest(questId))) { return false; diff --git a/src/strategy/actions/TalkToQuestGiverAction.h b/src/strategy/actions/TalkToQuestGiverAction.h index 081bfe4a..28c1683b 100644 --- a/src/strategy/actions/TalkToQuestGiverAction.h +++ b/src/strategy/actions/TalkToQuestGiverAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TALKTOQUESTGIVERACTION_H @@ -13,25 +14,25 @@ class WorldObject; class TalkToQuestGiverAction : public QuestAction { - public: - TalkToQuestGiverAction(PlayerbotAI* botAI, std::string name = "talk to quest giver") : QuestAction(botAI, name) { } +public: + TalkToQuestGiverAction(PlayerbotAI* botAI, std::string name = "talk to quest giver") : QuestAction(botAI, name) {} - protected: - void ProcessQuest(Quest const* quest, Object* questGiver) override; - void TurnInQuest(Quest const* quest, Object* questGiver, std::ostringstream& out); +protected: + void ProcessQuest(Quest const* quest, Object* questGiver) override; + void TurnInQuest(Quest const* quest, Object* questGiver, std::ostringstream& out); - private: - void RewardNoItem(Quest const* quest, Object* questGiver, std::ostringstream& out); - void RewardSingleItem(Quest const* quest, Object* questGiver, std::ostringstream& out); - std::set BestRewards(Quest const* quest); - void RewardMultipleItem(Quest const* quest, Object* questGiver, std::ostringstream& out); - void AskToSelectReward(Quest const* quest, std::ostringstream& out, bool forEquip); +private: + void RewardNoItem(Quest const* quest, Object* questGiver, std::ostringstream& out); + void RewardSingleItem(Quest const* quest, Object* questGiver, std::ostringstream& out); + std::set BestRewards(Quest const* quest); + void RewardMultipleItem(Quest const* quest, Object* questGiver, std::ostringstream& out); + void AskToSelectReward(Quest const* quest, std::ostringstream& out, bool forEquip); }; class TurnInQueryQuestAction : public TalkToQuestGiverAction { - public: - TurnInQueryQuestAction(PlayerbotAI* botAI) : TalkToQuestGiverAction(botAI, "turn in query quest") {} - bool Execute(Event event) override; +public: + TurnInQueryQuestAction(PlayerbotAI* botAI) : TalkToQuestGiverAction(botAI, "turn in query quest") {} + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/TaxiAction.cpp b/src/strategy/actions/TaxiAction.cpp index b8e40a12..954eb417 100644 --- a/src/strategy/actions/TaxiAction.cpp +++ b/src/strategy/actions/TaxiAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TaxiAction.h" + #include "Event.h" #include "LastMovementValue.h" #include "Playerbots.h" @@ -15,7 +17,8 @@ bool TaxiAction::Execute(Event event) WorldPacket& p = event.getPacket(); std::string const param = event.getParam(); - if ((!p.empty() && (p.GetOpcode() == CMSG_TAXICLEARALLNODES || p.GetOpcode() == CMSG_TAXICLEARNODE)) || param == "clear") + if ((!p.empty() && (p.GetOpcode() == CMSG_TAXICLEARALLNODES || p.GetOpcode() == CMSG_TAXICLEARNODE)) || + param == "clear") { movement.taxiNodes.clear(); movement.Set(nullptr); @@ -30,7 +33,8 @@ bool TaxiAction::Execute(Event event) if (!npc) continue; - uint32 curloc = sObjectMgr->GetNearestTaxiNode(npc->GetPositionX(), npc->GetPositionY(), npc->GetPositionZ(), npc->GetMapId(), bot->GetTeamId()); + uint32 curloc = sObjectMgr->GetNearestTaxiNode(npc->GetPositionX(), npc->GetPositionY(), npc->GetPositionZ(), + npc->GetMapId(), bot->GetTeamId()); std::vector nodes; for (uint32 i = 0; i < sTaxiPathStore.GetNumRows(); ++i) @@ -75,7 +79,7 @@ bool TaxiAction::Execute(Event event) if (!entry) return false; - return bot->ActivateTaxiPathTo({ entry->from, entry->to }, npc, 0); + return bot->ActivateTaxiPathTo({entry->from, entry->to}, npc, 0); } if (!movement.taxiNodes.empty() && !bot->ActivateTaxiPathTo(movement.taxiNodes, npc)) diff --git a/src/strategy/actions/TaxiAction.h b/src/strategy/actions/TaxiAction.h index 49d7e6bc..fd8f6b7a 100644 --- a/src/strategy/actions/TaxiAction.h +++ b/src/strategy/actions/TaxiAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TAXIACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class TaxiAction : public Action { - public: - TaxiAction(PlayerbotAI* botAI) : Action(botAI, "taxi") { } +public: + TaxiAction(PlayerbotAI* botAI) : Action(botAI, "taxi") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/TeleportAction.cpp b/src/strategy/actions/TeleportAction.cpp index c29c7d80..9f6ad068 100644 --- a/src/strategy/actions/TeleportAction.cpp +++ b/src/strategy/actions/TeleportAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TeleportAction.h" + #include "Event.h" #include "LastMovementValue.h" #include "Playerbots.h" @@ -16,7 +18,7 @@ bool TeleportAction::Execute(Event event) if (!go) continue; - GameObjectTemplate const *goInfo = go->GetGOInfo(); + GameObjectTemplate const* goInfo = go->GetGOInfo(); if (goInfo->type != GAMEOBJECT_TYPE_SPELLCASTER) continue; diff --git a/src/strategy/actions/TeleportAction.h b/src/strategy/actions/TeleportAction.h index 6315c670..f5ea2d08 100644 --- a/src/strategy/actions/TeleportAction.h +++ b/src/strategy/actions/TeleportAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TELEPORTACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class TeleportAction : public Action { - public: - TeleportAction(PlayerbotAI* botAI) : Action(botAI, "teleport") { } +public: + TeleportAction(PlayerbotAI* botAI) : Action(botAI, "teleport") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/TellCastFailedAction.cpp b/src/strategy/actions/TellCastFailedAction.cpp index ff7fb365..ec33aa50 100644 --- a/src/strategy/actions/TellCastFailedAction.cpp +++ b/src/strategy/actions/TellCastFailedAction.cpp @@ -1,10 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TellCastFailedAction.h" -#include "Event.h" + #include "ChatHelper.h" +#include "Event.h" #include "Playerbots.h" bool TellCastFailedAction::Execute(Event event) diff --git a/src/strategy/actions/TellCastFailedAction.h b/src/strategy/actions/TellCastFailedAction.h index 8c1428f2..d5228080 100644 --- a/src/strategy/actions/TellCastFailedAction.h +++ b/src/strategy/actions/TellCastFailedAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TELLCASTFAILEDACTION_H @@ -11,18 +12,18 @@ class PlayerbotAI; class TellSpellAction : public Action { - public: - TellSpellAction(PlayerbotAI* botAI) : Action(botAI, "spell") { } +public: + TellSpellAction(PlayerbotAI* botAI) : Action(botAI, "spell") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class TellCastFailedAction : public Action { - public: - TellCastFailedAction(PlayerbotAI* botAI) : Action(botAI, "tell cast failed") { } +public: + TellCastFailedAction(PlayerbotAI* botAI) : Action(botAI, "tell cast failed") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/TellItemCountAction.cpp b/src/strategy/actions/TellItemCountAction.cpp index 8b66273b..cf55da1d 100644 --- a/src/strategy/actions/TellItemCountAction.cpp +++ b/src/strategy/actions/TellItemCountAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TellItemCountAction.h" + #include "Event.h" #include "ItemCountValue.h" #include "Playerbots.h" diff --git a/src/strategy/actions/TellItemCountAction.h b/src/strategy/actions/TellItemCountAction.h index fbe2dcbb..43da9b07 100644 --- a/src/strategy/actions/TellItemCountAction.h +++ b/src/strategy/actions/TellItemCountAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TELLITEMCOUNTACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class TellItemCountAction : public InventoryAction { - public: - TellItemCountAction(PlayerbotAI* botAI) : InventoryAction(botAI, "c") { } +public: + TellItemCountAction(PlayerbotAI* botAI) : InventoryAction(botAI, "c") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/TellLosAction.cpp b/src/strategy/actions/TellLosAction.cpp index 8917d2ed..1443ff43 100644 --- a/src/strategy/actions/TellLosAction.cpp +++ b/src/strategy/actions/TellLosAction.cpp @@ -1,10 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TellLosAction.h" -#include "Event.h" + #include "ChatHelper.h" +#include "Event.h" #include "Playerbots.h" #include "World.h" @@ -52,11 +54,11 @@ void TellLosAction::ListUnits(std::string const title, GuidVector units) for (ObjectGuid const guid : units) { - if (Unit* unit = botAI->GetUnit(guid)) { + if (Unit* unit = botAI->GetUnit(guid)) + { botAI->TellMaster(unit->GetNameForLocaleIdx(sWorld->GetDefaultDbcLocale())); } } - } void TellLosAction::ListGameObjects(std::string const title, GuidVector gos) { @@ -74,15 +76,15 @@ bool TellAuraAction::Execute(Event event) botAI->TellMaster("--- Auras ---"); sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, "--- Auras ---"); Unit::AuraApplicationMap& map = bot->GetAppliedAuras(); - for (Unit::AuraApplicationMap::iterator i = map.begin(); i != map.end(); ++i) - { - Aura * aura = i->second->GetBase(); - if (!aura) - continue; - const std::string auraName = aura->GetSpellInfo()->SpellName[0]; + for (Unit::AuraApplicationMap::iterator i = map.begin(); i != map.end(); ++i) + { + Aura* aura = i->second->GetBase(); + if (!aura) + continue; + const std::string auraName = aura->GetSpellInfo()->SpellName[0]; sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, "Info of Aura - name: " + auraName); - AuraObjectType type = aura->GetType(); - WorldObject* owner = aura->GetOwner(); + AuraObjectType type = aura->GetType(); + WorldObject* owner = aura->GetOwner(); std::string owner_name = owner ? owner->GetName() : "unknown"; float distance = bot->GetDistance2d(owner); Unit* caster = aura->GetCaster(); @@ -92,50 +94,39 @@ bool TellAuraAction::Execute(Event event) const SpellInfo* spellInfo = aura->GetSpellInfo(); int32 spellId = aura->GetSpellInfo()->Id; bool isPositive = aura->GetSpellInfo()->IsPositive(); - sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, "Info of Aura - name: " + auraName + - " caster: " + caster_name + - " type: " + std::to_string(type) + - " owner: " + owner_name + - " distance: " + std::to_string(distance) + - " isArea: " + std::to_string(is_area) + - " duration: " + std::to_string(duration) + - " spellId: " + std::to_string(spellId) + - " isPositive: " + std::to_string(isPositive)); + sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, + "Info of Aura - name: " + auraName + " caster: " + caster_name + " type: " + + std::to_string(type) + " owner: " + owner_name + " distance: " + std::to_string(distance) + + " isArea: " + std::to_string(is_area) + " duration: " + std::to_string(duration) + + " spellId: " + std::to_string(spellId) + " isPositive: " + std::to_string(isPositive)); - botAI->TellMaster("Info of Aura - name: " + auraName + - " caster: " + caster_name + - " type: " + std::to_string(type) + - " owner: " + owner_name + - " distance: " + std::to_string(distance) + - " isArea: " + std::to_string(is_area) + - " duration: " + std::to_string(duration) + - " spellId: " + std::to_string(spellId) + - " isPositive: " + std::to_string(isPositive)); + botAI->TellMaster("Info of Aura - name: " + auraName + " caster: " + caster_name + " type: " + + std::to_string(type) + " owner: " + owner_name + " distance: " + std::to_string(distance) + + " isArea: " + std::to_string(is_area) + " duration: " + std::to_string(duration) + + " spellId: " + std::to_string(spellId) + " isPositive: " + std::to_string(isPositive)); - if (type == DYNOBJ_AURA_TYPE) { + if (type == DYNOBJ_AURA_TYPE) + { DynamicObject* dyn_owner = aura->GetDynobjOwner(); float radius = dyn_owner->GetRadius(); int32 spellId = dyn_owner->GetSpellId(); int32 duration = dyn_owner->GetDuration(); - sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, std::string("Info of DynamicObject -") + - " name: " + dyn_owner->GetName() + - " radius: " + std::to_string(radius) + - " spell id: " + std::to_string(spellId) + - " duration: " + std::to_string(duration)); + sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, + std::string("Info of DynamicObject -") + " name: " + dyn_owner->GetName() + + " radius: " + std::to_string(radius) + " spell id: " + std::to_string(spellId) + + " duration: " + std::to_string(duration)); - botAI->TellMaster(std::string("Info of DynamicObject -") + - " name: " + dyn_owner->GetName() + - " radius: " + std::to_string(radius) + - " spell id: " + std::to_string(spellId) + - " duration: " + std::to_string(duration)); + botAI->TellMaster(std::string("Info of DynamicObject -") + " name: " + dyn_owner->GetName() + + " radius: " + std::to_string(radius) + " spell id: " + std::to_string(spellId) + + " duration: " + std::to_string(duration)); } - } - return true; + } + return true; } bool TellExpectedDpsAction::Execute(Event event) { float dps = AI_VALUE(float, "expected group dps"); botAI->TellMaster("Expected Group DPS: " + std::to_string(dps)); - return true; + return true; } diff --git a/src/strategy/actions/TellLosAction.h b/src/strategy/actions/TellLosAction.h index 01e1567e..a760b921 100644 --- a/src/strategy/actions/TellLosAction.h +++ b/src/strategy/actions/TellLosAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TELLLOSACTION_H @@ -11,29 +12,29 @@ class PlayerbotAI; class TellLosAction : public Action { - public: - TellLosAction(PlayerbotAI* botAI) : Action(botAI, "los") { } +public: + TellLosAction(PlayerbotAI* botAI) : Action(botAI, "los") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - void ListUnits(std::string const title, GuidVector units); - void ListGameObjects(std::string const title, GuidVector gos); +private: + void ListUnits(std::string const title, GuidVector units); + void ListGameObjects(std::string const title, GuidVector gos); }; -class TellAuraAction : public Action +class TellAuraAction : public Action { - public: - TellAuraAction(PlayerbotAI* ai) : Action(ai, "aura") {} - - virtual bool Execute(Event event); +public: + TellAuraAction(PlayerbotAI* ai) : Action(ai, "aura") {} + + virtual bool Execute(Event event); }; -class TellExpectedDpsAction : public Action +class TellExpectedDpsAction : public Action { - public: - TellExpectedDpsAction(PlayerbotAI* ai) : Action(ai, "tell expected dps") {} - - virtual bool Execute(Event event); +public: + TellExpectedDpsAction(PlayerbotAI* ai) : Action(ai, "tell expected dps") {} + + virtual bool Execute(Event event); }; #endif diff --git a/src/strategy/actions/TellMasterAction.cpp b/src/strategy/actions/TellMasterAction.cpp index a6606db2..10c01c0c 100644 --- a/src/strategy/actions/TellMasterAction.cpp +++ b/src/strategy/actions/TellMasterAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TellMasterAction.h" + #include "Event.h" #include "Playerbots.h" @@ -28,4 +30,3 @@ bool OutOfReactRangeAction::isUseful() return true; } - diff --git a/src/strategy/actions/TellMasterAction.h b/src/strategy/actions/TellMasterAction.h index 5f78e5e6..f1f6dba9 100644 --- a/src/strategy/actions/TellMasterAction.h +++ b/src/strategy/actions/TellMasterAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TELLMASTERACTION_H @@ -11,22 +12,22 @@ class PlayerbotAI; class TellMasterAction : public Action { - public: - TellMasterAction(PlayerbotAI* botAI, std::string const text) : Action(botAI, "tell master"), text(text) { } +public: + TellMasterAction(PlayerbotAI* botAI, std::string const text) : Action(botAI, "tell master"), text(text) {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - std::string const text; +private: + std::string const text; }; class OutOfReactRangeAction : public MovementAction { - public: - OutOfReactRangeAction(PlayerbotAI* botAI) : MovementAction(botAI, "tell out of react range") { } +public: + OutOfReactRangeAction(PlayerbotAI* botAI) : MovementAction(botAI, "tell out of react range") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/actions/TellReputationAction.cpp b/src/strategy/actions/TellReputationAction.cpp index 6d038f2c..686f8a20 100644 --- a/src/strategy/actions/TellReputationAction.cpp +++ b/src/strategy/actions/TellReputationAction.cpp @@ -1,11 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TellReputationAction.h" -#include "ReputationMgr.h" + #include "Event.h" #include "Playerbots.h" +#include "ReputationMgr.h" bool TellReputationAction::Execute(Event event) { diff --git a/src/strategy/actions/TellReputationAction.h b/src/strategy/actions/TellReputationAction.h index c18a49ab..c9f74ef9 100644 --- a/src/strategy/actions/TellReputationAction.h +++ b/src/strategy/actions/TellReputationAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TELLREPUTATIONACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class TellReputationAction : public Action { - public: - TellReputationAction(PlayerbotAI* botAI) : Action(botAI, "reputation") { } +public: + TellReputationAction(PlayerbotAI* botAI) : Action(botAI, "reputation") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/TellTargetAction.cpp b/src/strategy/actions/TellTargetAction.cpp index f54fe5ea..d1d05384 100644 --- a/src/strategy/actions/TellTargetAction.cpp +++ b/src/strategy/actions/TellTargetAction.cpp @@ -1,11 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TellTargetAction.h" -#include "ThreatMgr.h" + #include "Event.h" #include "Playerbots.h" +#include "ThreatMgr.h" bool TellTargetAction::Execute(Event event) { @@ -13,7 +15,7 @@ bool TellTargetAction::Execute(Event event) if (target) { std::ostringstream out; - out << "Attacking " << target->GetName(); + out << "Attacking " << target->GetName(); botAI->TellMaster(out); context->GetValue("old target")->Set(target); @@ -42,7 +44,7 @@ bool TellAttackersAction::Execute(Event event) if (!ref) return true; - while( ref ) + while (ref) { ThreatMgr* threatMgr = ref->GetSource(); Unit* unit = threatMgr->GetOwner(); diff --git a/src/strategy/actions/TellTargetAction.h b/src/strategy/actions/TellTargetAction.h index 2401b664..608c4964 100644 --- a/src/strategy/actions/TellTargetAction.h +++ b/src/strategy/actions/TellTargetAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TELLTARGETACTION_H @@ -11,18 +12,18 @@ class PlayerbotAI; class TellTargetAction : public Action { - public: - TellTargetAction(PlayerbotAI* botAI) : Action(botAI, "tell target") { } +public: + TellTargetAction(PlayerbotAI* botAI) : Action(botAI, "tell target") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class TellAttackersAction : public Action { - public: - TellAttackersAction(PlayerbotAI* botAI) : Action(botAI, "tell attackers") { } +public: + TellAttackersAction(PlayerbotAI* botAI) : Action(botAI, "tell attackers") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/TradeAction.cpp b/src/strategy/actions/TradeAction.cpp index e6b918d2..a365b647 100644 --- a/src/strategy/actions/TradeAction.cpp +++ b/src/strategy/actions/TradeAction.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TradeAction.h" -#include "Event.h" -#include "ItemVisitors.h" -#include "ItemCountValue.h" + #include "ChatHelper.h" +#include "Event.h" +#include "ItemCountValue.h" +#include "ItemVisitors.h" #include "Playerbots.h" bool TradeAction::Execute(Event event) @@ -18,18 +20,18 @@ bool TradeAction::Execute(Event event) GuidVector guids = chat->parseGameobjects(text); Player* player = nullptr; - for(auto& guid: guids) + for (auto& guid : guids) if (guid.IsPlayer()) player = ObjectAccessor::FindPlayer(guid); if (!player && botAI->GetMaster()) player = botAI->GetMaster(); - if (!player) return false; + if (!player) + return false; if (!player->GetTrader()) { - WorldPacket packet(CMSG_INITIATE_TRADE); packet << player->GetGUID(); bot->GetSession()->HandleInitiateTradeOpcode(packet); @@ -88,7 +90,7 @@ bool TradeAction::TradeItem(Item const* item, int8 slot) tradeSlot = i; WorldPacket packet(CMSG_CLEAR_TRADE_ITEM, 1); - packet << (uint8) tradeSlot; + packet << (uint8)tradeSlot; bot->GetSession()->HandleClearTradeItemOpcode(packet); pTrade->SetItem(TradeSlots(i), nullptr); return true; @@ -114,4 +116,3 @@ bool TradeAction::TradeItem(Item const* item, int8 slot) bot->GetSession()->HandleSetTradeItemOpcode(packet); return true; } - diff --git a/src/strategy/actions/TradeAction.h b/src/strategy/actions/TradeAction.h index ede408a2..f9af19f3 100644 --- a/src/strategy/actions/TradeAction.h +++ b/src/strategy/actions/TradeAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TRADEACTION_H @@ -12,15 +13,15 @@ class PlayerbotAI; class TradeAction : public InventoryAction { - public: - TradeAction(PlayerbotAI* botAI) : InventoryAction(botAI, "trade") { } +public: + TradeAction(PlayerbotAI* botAI) : InventoryAction(botAI, "trade") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - bool TradeItem(Item const* item, int8 slot); +private: + bool TradeItem(Item const* item, int8 slot); - static std::map slots; + static std::map slots; }; #endif diff --git a/src/strategy/actions/TradeStatusAction.cpp b/src/strategy/actions/TradeStatusAction.cpp index 1bb80e0f..b1284a80 100644 --- a/src/strategy/actions/TradeStatusAction.cpp +++ b/src/strategy/actions/TradeStatusAction.cpp @@ -1,16 +1,18 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TradeStatusAction.h" -#include "SetCraftAction.h" -#include "Event.h" -#include "ItemVisitors.h" + #include "CraftValue.h" -#include "ItemUsageValue.h" +#include "Event.h" #include "GuildTaskMgr.h" -#include "Playerbots.h" +#include "ItemUsageValue.h" +#include "ItemVisitors.h" #include "PlayerbotSecurity.h" +#include "Playerbots.h" +#include "SetCraftAction.h" bool TradeStatusAction::Execute(Event event) { @@ -22,10 +24,11 @@ bool TradeStatusAction::Execute(Event event) PlayerbotAI* traderBotAI = GET_PLAYERBOT_AI(trader); if (trader != master && !traderBotAI) { - bot->Whisper("I'm kind of busy now", LANG_UNIVERSAL, trader); + bot->Whisper("I'm kind of busy now", LANG_UNIVERSAL, trader); } - if ((trader != master || !botAI->GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_ALLOW_ALL, true, master)) && !traderBotAI) + if ((trader != master || !botAI->GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_ALLOW_ALL, true, master)) && + !traderBotAI) { WorldPacket p; uint32 status = 0; @@ -83,7 +86,6 @@ bool TradeStatusAction::Execute(Event event) sGuildTaskMgr->CheckItemTask(itemId, count, trader, bot); } - for (std::map::iterator i = takenItemIds.begin(); i != takenItemIds.end(); ++i) { uint32 itemId = i->first; @@ -169,10 +171,12 @@ bool TradeStatusAction::CheckTrade() if (isGettingItem) { - if (bot->GetGroup() && bot->GetGroup()->IsMember(bot->GetTrader()->GetGUID()) && botAI->HasRealPlayerMaster()) + if (bot->GetGroup() && bot->GetGroup()->IsMember(bot->GetTrader()->GetGUID()) && + botAI->HasRealPlayerMaster()) botAI->TellMasterNoFacing("Thank you " + chat->FormatWorldobject(bot->GetTrader())); else - bot->Say("Thank you " + chat->FormatWorldobject(bot->GetTrader()), (bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH)); + bot->Say("Thank you " + chat->FormatWorldobject(bot->GetTrader()), + (bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH)); } return isGettingItem; } @@ -206,7 +210,7 @@ bool TradeStatusAction::CheckTrade() return false; } - item = trader->GetTradeData()->GetItem((TradeSlots) slot); + item = trader->GetTradeData()->GetItem((TradeSlots)slot); if (item) { std::ostringstream out; diff --git a/src/strategy/actions/TradeStatusAction.h b/src/strategy/actions/TradeStatusAction.h index ae66f4ee..ab6556f5 100644 --- a/src/strategy/actions/TradeStatusAction.h +++ b/src/strategy/actions/TradeStatusAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TRADESTATUSACTION_H @@ -12,15 +13,15 @@ class PlayerbotAI; class TradeStatusAction : public QueryItemUsageAction { - public: - TradeStatusAction(PlayerbotAI* botAI) : QueryItemUsageAction(botAI, "accept trade") { } +public: + TradeStatusAction(PlayerbotAI* botAI) : QueryItemUsageAction(botAI, "accept trade") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - void BeginTrade(); - bool CheckTrade(); - int32 CalculateCost(Player* player, bool sell); +private: + void BeginTrade(); + bool CheckTrade(); + int32 CalculateCost(Player* player, bool sell); }; #endif diff --git a/src/strategy/actions/TradeValues.cpp b/src/strategy/actions/TradeValues.cpp index fa4d338d..304103d0 100644 --- a/src/strategy/actions/TradeValues.cpp +++ b/src/strategy/actions/TradeValues.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TradeValues.h" + #include "ItemUsageValue.h" #include "Playerbots.h" @@ -17,11 +19,12 @@ std::vector ItemsUsefulToGiveValue::Calculate() if (botAI->HasActivePlayerMaster() || !GET_PLAYERBOT_AI(player)) return giveItems; - std::vector myUsages = { ITEM_USAGE_NONE , ITEM_USAGE_VENDOR, ITEM_USAGE_AH, ITEM_USAGE_DISENCHANT }; + std::vector myUsages = {ITEM_USAGE_NONE, ITEM_USAGE_VENDOR, ITEM_USAGE_AH, ITEM_USAGE_DISENCHANT}; for (auto& myUsage : myUsages) { - std::vector myItems = AI_VALUE2(std::vector, "inventory items", "usage " + std::to_string(myUsage)); + std::vector myItems = + AI_VALUE2(std::vector, "inventory items", "usage " + std::to_string(myUsage)); std::reverse(myItems.begin(), myItems.end()); for (auto& item : myItems) diff --git a/src/strategy/actions/TradeValues.h b/src/strategy/actions/TradeValues.h index 8d1f4f67..d230cf0b 100644 --- a/src/strategy/actions/TradeValues.h +++ b/src/strategy/actions/TradeValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TRADEVALUES_H @@ -13,10 +14,12 @@ class PlayerbotAI; class ItemsUsefulToGiveValue : public CalculatedValue>, public Qualified { - public: - ItemsUsefulToGiveValue(PlayerbotAI* botAI, std::string const name = "useful to give") : CalculatedValue(botAI, name) { } +public: + ItemsUsefulToGiveValue(PlayerbotAI* botAI, std::string const name = "useful to give") : CalculatedValue(botAI, name) + { + } - std::vector Calculate(); + std::vector Calculate(); }; #endif diff --git a/src/strategy/actions/TrainerAction.cpp b/src/strategy/actions/TrainerAction.cpp index 6f13d41f..a582c1a7 100644 --- a/src/strategy/actions/TrainerAction.cpp +++ b/src/strategy/actions/TrainerAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TrainerAction.h" + #include "BudgetValues.h" #include "Event.h" #include "PlayerbotFactory.h" @@ -47,10 +49,11 @@ void TrainerAction::Iterate(Creature* creature, TrainerSpellAction action, Spell TellHeader(creature); TrainerSpellData const* trainer_spells = creature->GetTrainerSpells(); - float fDiscountMod = bot->GetReputationPriceDiscount(creature); + float fDiscountMod = bot->GetReputationPriceDiscount(creature); uint32 totalCost = 0; - for (TrainerSpellMap::const_iterator itr = trainer_spells->spellList.begin(); itr != trainer_spells->spellList.end(); ++itr) + for (TrainerSpellMap::const_iterator itr = trainer_spells->spellList.begin(); + itr != trainer_spells->spellList.end(); ++itr) { TrainerSpell const* tSpell = &itr->second; if (!tSpell) @@ -68,7 +71,7 @@ void TrainerAction::Iterate(Creature* creature, TrainerSpellAction action, Spell if (!spells.empty() && spells.find(tSpell->spell) == spells.end()) continue; - uint32 cost = uint32(floor(tSpell->spellCost * fDiscountMod)); + uint32 cost = uint32(floor(tSpell->spellCost * fDiscountMod)); totalCost += cost; std::ostringstream out; @@ -91,7 +94,8 @@ bool TrainerAction::Execute(Event event) Creature* creature = botAI->GetCreature(bot->GetTarget()); - if (master) { + if (master) + { creature = master->GetSelectedUnit() ? master->GetSelectedUnit()->ToCreature() : nullptr; } // if (AI_VALUE(GuidPosition, "rpg target") != bot->GetTarget()) @@ -122,8 +126,11 @@ bool TrainerAction::Execute(Event event) if (spell) spells.insert(spell); - if (text.find("learn") != std::string::npos || sRandomPlayerbotMgr->IsRandomBot(bot) || (sPlayerbotAIConfig->autoTrainSpells != "no" && - (creature->GetCreatureTemplate()->trainer_type != TRAINER_TYPE_TRADESKILLS || !botAI->HasActivePlayerMaster()))) //Todo rewrite to only exclude start primary profession skills and make config dependent. + if (text.find("learn") != std::string::npos || sRandomPlayerbotMgr->IsRandomBot(bot) || + (sPlayerbotAIConfig->autoTrainSpells != "no" && + (creature->GetCreatureTemplate()->trainer_type != TRAINER_TYPE_TRADESKILLS || + !botAI->HasActivePlayerMaster()))) // Todo rewrite to only exclude start primary profession skills and make + // config dependent. Iterate(creature, &TrainerAction::Learn, spells); else Iterate(creature, nullptr, spells); @@ -150,7 +157,8 @@ void TrainerAction::TellFooter(uint32 totalCost) bool MaintenanceAction::Execute(Event event) { - if (!sPlayerbotAIConfig->maintenanceCommand) { + if (!sPlayerbotAIConfig->maintenanceCommand) + { botAI->TellError("maintenance command is not allowed, please check the configuration."); return false; } @@ -168,7 +176,8 @@ bool MaintenanceAction::Execute(Event event) factory.InitSkills(); factory.InitMounts(); factory.InitGlyphs(true); - if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel) { + if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel) + { factory.ApplyEnchantAndGemsNew(); } bot->DurabilityRepairAll(false, 1.0f, false); @@ -188,20 +197,21 @@ bool RemoveGlyphAction::Execute(Event event) bool AutoGearAction::Execute(Event event) { - if (!sPlayerbotAIConfig->autoGearCommand) { + if (!sPlayerbotAIConfig->autoGearCommand) + { botAI->TellError("autogear command is not allowed, please check the configuration."); return false; } botAI->TellMaster("I'm auto gearing"); - uint32 gs = sPlayerbotAIConfig->autoGearScoreLimit == 0 ? 0 : - PlayerbotFactory::CalcMixedGearScore(sPlayerbotAIConfig->autoGearScoreLimit, sPlayerbotAIConfig->autoGearQualityLimit); - PlayerbotFactory factory(bot, - bot->GetLevel(), - sPlayerbotAIConfig->autoGearQualityLimit, - gs); + uint32 gs = sPlayerbotAIConfig->autoGearScoreLimit == 0 + ? 0 + : PlayerbotFactory::CalcMixedGearScore(sPlayerbotAIConfig->autoGearScoreLimit, + sPlayerbotAIConfig->autoGearQualityLimit); + PlayerbotFactory factory(bot, bot->GetLevel(), sPlayerbotAIConfig->autoGearQualityLimit, gs); factory.InitEquipment(true); factory.InitAmmo(); - if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel) { + if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel) + { factory.ApplyEnchantAndGemsNew(); } bot->DurabilityRepairAll(false, 1.0f, false); diff --git a/src/strategy/actions/TrainerAction.h b/src/strategy/actions/TrainerAction.h index 5ea6300c..b9f4cd34 100644 --- a/src/strategy/actions/TrainerAction.h +++ b/src/strategy/actions/TrainerAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TRAINERACTION_H @@ -15,38 +16,38 @@ struct TrainerSpell; class TrainerAction : public Action { - public: - TrainerAction(PlayerbotAI* botAI) : Action(botAI, "trainer") { } +public: + TrainerAction(PlayerbotAI* botAI) : Action(botAI, "trainer") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - typedef void(TrainerAction::*TrainerSpellAction)(uint32, TrainerSpell const*, std::ostringstream& msg); - void Iterate(Creature* creature, TrainerSpellAction action, SpellIds& spells); - void Learn(uint32 cost, TrainerSpell const* tSpell, std::ostringstream& msg); - void TellHeader(Creature* creature); - void TellFooter(uint32 totalCost); +private: + typedef void (TrainerAction::*TrainerSpellAction)(uint32, TrainerSpell const*, std::ostringstream& msg); + void Iterate(Creature* creature, TrainerSpellAction action, SpellIds& spells); + void Learn(uint32 cost, TrainerSpell const* tSpell, std::ostringstream& msg); + void TellHeader(Creature* creature); + void TellFooter(uint32 totalCost); }; class MaintenanceAction : public Action { - public: - MaintenanceAction(PlayerbotAI* botAI) : Action(botAI, "maintenance") { } - bool Execute(Event event) override; +public: + MaintenanceAction(PlayerbotAI* botAI) : Action(botAI, "maintenance") {} + bool Execute(Event event) override; }; class RemoveGlyphAction : public Action { - public: - RemoveGlyphAction(PlayerbotAI* botAI) : Action(botAI, "remove glyph") { } - bool Execute(Event event) override; +public: + RemoveGlyphAction(PlayerbotAI* botAI) : Action(botAI, "remove glyph") {} + bool Execute(Event event) override; }; class AutoGearAction : public Action { - public: - AutoGearAction(PlayerbotAI* botAI) : Action(botAI, "autogear") { } - bool Execute(Event event) override; +public: + AutoGearAction(PlayerbotAI* botAI) : Action(botAI, "autogear") {} + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/TravelAction.cpp b/src/strategy/actions/TravelAction.cpp index 8a7841d1..60a3244c 100644 --- a/src/strategy/actions/TravelAction.cpp +++ b/src/strategy/actions/TravelAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TravelAction.h" + #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" @@ -10,7 +12,7 @@ bool TravelAction::Execute(Event event) { - TravelTarget * target = AI_VALUE(TravelTarget *, "travel target"); + TravelTarget* target = AI_VALUE(TravelTarget*, "travel target"); if (bot->isMoving()) return false; @@ -54,18 +56,21 @@ bool TravelAction::Execute(Event event) bool TravelAction::isUseful() { - return false && AI_VALUE(TravelTarget*, "travel target")->isActive() && (!AI_VALUE(GuidPosition, "rpg target") || !AI_VALUE(ObjectGuid, "pull target")); + return false && AI_VALUE(TravelTarget*, "travel target")->isActive() && + (!AI_VALUE(GuidPosition, "rpg target") || !AI_VALUE(ObjectGuid, "pull target")); } bool MoveToDarkPortalAction::Execute(Event event) { if (bot->GetGroup()) - if (bot->GetGroup()->GetLeaderGUID() != bot->GetGUID() && !GET_PLAYERBOT_AI(GET_PLAYERBOT_AI(bot)->GetGroupMaster())) + if (bot->GetGroup()->GetLeaderGUID() != bot->GetGUID() && + !GET_PLAYERBOT_AI(GET_PLAYERBOT_AI(bot)->GetGroupMaster())) return false; if (bot->GetLevel() > 57) { - if ((bot->GetTeamId() == TEAM_ALLIANCE && bot->GetQuestStatus(10119) == QUEST_STATUS_NONE) || (bot->GetTeamId() == TEAM_HORDE && bot->GetQuestStatus(9407) == QUEST_STATUS_NONE)) + if ((bot->GetTeamId() == TEAM_ALLIANCE && bot->GetQuestStatus(10119) == QUEST_STATUS_NONE) || + (bot->GetTeamId() == TEAM_HORDE && bot->GetQuestStatus(9407) == QUEST_STATUS_NONE)) { if (!bot->IsInCombat()) { @@ -75,7 +80,8 @@ bool MoveToDarkPortalAction::Execute(Event event) CreatureData const* creatureData = sRandomPlayerbotMgr->GetCreatureDataByEntry(16841); if (quest && creatureData) { - auto creatureBounds = bot->GetMap()->GetCreatureBySpawnIdStore().equal_range(creatureData->spawnId); + auto creatureBounds = + bot->GetMap()->GetCreatureBySpawnIdStore().equal_range(creatureData->spawnId); if (creatureBounds.first != creatureBounds.second) bot->AddQuest(quest, creatureBounds.first->second); } @@ -86,7 +92,8 @@ bool MoveToDarkPortalAction::Execute(Event event) CreatureData const* creatureData = sRandomPlayerbotMgr->GetCreatureDataByEntry(19254); if (quest && creatureData) { - auto creatureBounds = bot->GetMap()->GetCreatureBySpawnIdStore().equal_range(creatureData->spawnId); + auto creatureBounds = + bot->GetMap()->GetCreatureBySpawnIdStore().equal_range(creatureData->spawnId); if (creatureBounds.first != creatureBounds.second) bot->AddQuest(quest, creatureBounds.first->second); } @@ -102,10 +109,7 @@ bool MoveToDarkPortalAction::Execute(Event event) return false; } -bool MoveToDarkPortalAction::isUseful() -{ - return bot->GetLevel() > 54; -} +bool MoveToDarkPortalAction::isUseful() { return bot->GetLevel() > 54; } bool DarkPortalAzerothAction::Execute(Event event) { @@ -120,10 +124,7 @@ bool DarkPortalAzerothAction::Execute(Event event) return false; } -bool DarkPortalAzerothAction::isUseful() -{ - return bot->GetLevel() > 57; -} +bool DarkPortalAzerothAction::isUseful() { return bot->GetLevel() > 57; } bool MoveFromDarkPortalAction::Execute(Event event) { diff --git a/src/strategy/actions/TravelAction.h b/src/strategy/actions/TravelAction.h index 3c392073..94de22bf 100644 --- a/src/strategy/actions/TravelAction.h +++ b/src/strategy/actions/TravelAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TRAVELACTION_H @@ -11,37 +12,37 @@ class PlayerbotAI; class TravelAction : public MovementAction { - public: - TravelAction(PlayerbotAI* botAI) : MovementAction(botAI, "travel") { } +public: + TravelAction(PlayerbotAI* botAI) : MovementAction(botAI, "travel") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class MoveToDarkPortalAction : public MovementAction { - public: - MoveToDarkPortalAction(PlayerbotAI* botAI) : MovementAction(botAI, "move to dark portal") { } +public: + MoveToDarkPortalAction(PlayerbotAI* botAI) : MovementAction(botAI, "move to dark portal") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class DarkPortalAzerothAction : public MovementAction { - public: - DarkPortalAzerothAction(PlayerbotAI* botAI) : MovementAction(botAI, "dark portal azeroth") { } +public: + DarkPortalAzerothAction(PlayerbotAI* botAI) : MovementAction(botAI, "dark portal azeroth") {} - bool Execute(Event event) override; - bool isUseful() override; + bool Execute(Event event) override; + bool isUseful() override; }; class MoveFromDarkPortalAction : public MovementAction { - public: - MoveFromDarkPortalAction(PlayerbotAI* botAI) : MovementAction(botAI, "move from dark portal") { } +public: + MoveFromDarkPortalAction(PlayerbotAI* botAI) : MovementAction(botAI, "move from dark portal") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/UnequipAction.cpp b/src/strategy/actions/UnequipAction.cpp index b3d5306e..3eadbe36 100644 --- a/src/strategy/actions/UnequipAction.cpp +++ b/src/strategy/actions/UnequipAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "UnequipAction.h" + #include "Event.h" #include "ItemCountValue.h" #include "Playerbots.h" @@ -29,7 +31,7 @@ bool UnequipAction::Execute(Event event) } else { - for (ItemIds::iterator i =ids.begin(); i != ids.end(); i++) + for (ItemIds::iterator i = ids.begin(); i != ids.end(); i++) { FindItemByIdVisitor visitor(*i); UnequipItem(&visitor); @@ -43,7 +45,7 @@ void UnequipAction::UnequipItem(FindItemVisitor* visitor) { IterateItems(visitor, ITERATE_ALL_ITEMS); std::vector items = visitor->GetResult(); - if (!items.empty()) + if (!items.empty()) UnequipItem(*items.begin()); } @@ -61,4 +63,3 @@ void UnequipAction::UnequipItem(Item* item) out << chat->FormatItem(item->GetTemplate()) << " unequipped"; botAI->TellMaster(out); } - diff --git a/src/strategy/actions/UnequipAction.h b/src/strategy/actions/UnequipAction.h index 80130c45..d855f539 100644 --- a/src/strategy/actions/UnequipAction.h +++ b/src/strategy/actions/UnequipAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_UNEQUIPACTION_H @@ -13,14 +14,14 @@ class PlayerbotAI; class UnequipAction : public InventoryAction { - public: - UnequipAction(PlayerbotAI* botAI) : InventoryAction(botAI, "unequip") { } +public: + UnequipAction(PlayerbotAI* botAI) : InventoryAction(botAI, "unequip") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - void UnequipItem(Item* item); - void UnequipItem(FindItemVisitor* visitor); +private: + void UnequipItem(Item* item); + void UnequipItem(FindItemVisitor* visitor); }; #endif diff --git a/src/strategy/actions/UseItemAction.cpp b/src/strategy/actions/UseItemAction.cpp index 0c8b49f3..8a41bc6f 100644 --- a/src/strategy/actions/UseItemAction.cpp +++ b/src/strategy/actions/UseItemAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "UseItemAction.h" + #include "ChatHelper.h" #include "Event.h" #include "ItemUsageValue.h" @@ -19,7 +21,8 @@ bool UseItemAction::Execute(Event event) if (gos.empty()) { - if (!items.empty()) { + if (!items.empty()) + { return UseItemAuto(*items.begin()); } } @@ -38,7 +41,7 @@ bool UseItemAction::Execute(Event event) bool UseItemAction::UseGameObject(ObjectGuid guid) { GameObject* go = botAI->GetGameObject(guid); - if (!go || !go->isSpawned()/* || go->GetGoState() != GO_STATE_READY*/) + if (!go || !go->isSpawned() /* || go->GetGoState() != GO_STATE_READY*/) return false; go->Use(bot); @@ -49,20 +52,11 @@ bool UseItemAction::UseGameObject(ObjectGuid guid) return true; } -bool UseItemAction::UseItemAuto(Item* item) -{ - return UseItem(item, ObjectGuid::Empty, nullptr); -} +bool UseItemAction::UseItemAuto(Item* item) { return UseItem(item, ObjectGuid::Empty, nullptr); } -bool UseItemAction::UseItemOnGameObject(Item* item, ObjectGuid go) -{ - return UseItem(item, go, nullptr); -} +bool UseItemAction::UseItemOnGameObject(Item* item, ObjectGuid go) { return UseItem(item, go, nullptr); } -bool UseItemAction::UseItemOnItem(Item* item, Item* itemTarget) -{ - return UseItem(item, ObjectGuid::Empty, itemTarget); -} +bool UseItemAction::UseItemOnItem(Item* item, Item* itemTarget) { return UseItem(item, ObjectGuid::Empty, itemTarget); } bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Unit* unitTarget) { @@ -86,7 +80,8 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni if (item->GetTemplate()->Spells[i].SpellId > 0) { spellId = item->GetTemplate()->Spells[i].SpellId; - if (!botAI->CanCastSpell(spellId, bot, false, itemTarget, item)) { + if (!botAI->CanCastSpell(spellId, bot, false, itemTarget, item)) + { return false; } } @@ -143,21 +138,22 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni } } - Player* master = GetMaster(); - if (!targetSelected && item->GetTemplate()->Class != ITEM_CLASS_CONSUMABLE && master && botAI->HasActivePlayerMaster() && !selfOnly) - { - if (ObjectGuid masterSelection = master->GetTarget()) - { + Player* master = GetMaster(); + if (!targetSelected && item->GetTemplate()->Class != ITEM_CLASS_CONSUMABLE && master && + botAI->HasActivePlayerMaster() && !selfOnly) + { + if (ObjectGuid masterSelection = master->GetTarget()) + { Unit* unit = botAI->GetUnit(masterSelection); if (unit) { - targetFlag = TARGET_FLAG_UNIT; - packet << targetFlag << masterSelection.WriteAsPacked(); - out << " on " << unit->GetName(); - targetSelected = true; - } - } - } + targetFlag = TARGET_FLAG_UNIT; + packet << targetFlag << masterSelection.WriteAsPacked(); + out << " on " << unit->GetName(); + targetSelected = true; + } + } + } if (!targetSelected && item->GetTemplate()->Class != ITEM_CLASS_CONSUMABLE && unitTarget) { @@ -167,7 +163,6 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni targetSelected = true; } - if (uint32 questid = item->GetTemplate()->StartQuest) { if (Quest const* qInfo = sObjectMgr->GetQuestTemplate(questid)) @@ -204,8 +199,8 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni if (!botAI->CanCastSpell(spellId, bot, false)) continue; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); - if (spellInfo->Targets & TARGET_FLAG_ITEM) + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); + if (spellInfo->Targets & TARGET_FLAG_ITEM) { Item* itemForSpell = AI_VALUE2(Item*, "item for spell", spellId); if (!itemForSpell) @@ -230,7 +225,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni packet << targetFlag; packet << itemForSpell->GetGUID().WriteAsPacked(); targetSelected = true; - out << " on "<< chat->FormatItem(itemForSpell->GetTemplate()); + out << " on " << chat->FormatItem(itemForSpell->GetTemplate()); } uint32 castTime = spellInfo->CalcCastTime(); botAI->SetNextCheckDelay(castTime + sPlayerbotAIConfig->reactDelay); @@ -251,7 +246,8 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni ItemTemplate const* proto = item->GetTemplate(); bool isDrink = proto->Spells[0].SpellCategory == 59; bool isFood = proto->Spells[0].SpellCategory == 11; - if (proto->Class == ITEM_CLASS_CONSUMABLE && (proto->SubClass == ITEM_SUBCLASS_FOOD || proto->SubClass == ITEM_SUBCLASS_CONSUMABLE) && (isFood || isDrink)) + if (proto->Class == ITEM_CLASS_CONSUMABLE && + (proto->SubClass == ITEM_SUBCLASS_FOOD || proto->SubClass == ITEM_SUBCLASS_CONSUMABLE) && (isFood || isDrink)) { if (bot->IsInCombat()) return false; @@ -281,10 +277,10 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni botAI->SetNextCheckDelay(std::max(10000.0f, 27000.0f * (100 - p) / 100.0f)); if (!bot->IsInCombat() && bot->InBattleground()) - botAI->SetNextCheckDelay(std::max(10000.0f,20000.0f * (100 - p) / 100.0f)); + botAI->SetNextCheckDelay(std::max(10000.0f, 20000.0f * (100 - p) / 100.0f)); - //botAI->SetNextCheckDelay(27000.0f * (100 - p) / 100.0f); - // botAI->SetNextCheckDelay(20000); + // botAI->SetNextCheckDelay(27000.0f * (100 - p) / 100.0f); + // botAI->SetNextCheckDelay(20000); bot->GetSession()->HandleUseItemOpcode(packet); return true; @@ -307,7 +303,7 @@ void UseItemAction::TellConsumableUse(Item* item, std::string const action, floa if (item->GetTemplate()->Stackable > 1) out << "/x" << item->GetCount(); - out << " (" << round(percent) << "%)"; + out << " (" << round(percent) << "%)"; botAI->TellMasterNoFacing(out.str()); } @@ -317,7 +313,8 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace) *packet << item->GetGUID(); bool fits = false; - for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; + ++enchant_slot) { uint8 SocketColor = item->GetTemplate()->Socket[enchant_slot - SOCK_ENCHANTMENT_SLOT].Color; GemPropertiesEntry const* gemProperty = sGemPropertiesStore.LookupEntry(gem->GetTemplate()->GemProperties); @@ -351,7 +348,6 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace) fits = true; continue; } - } *packet << ObjectGuid::Empty; @@ -370,25 +366,13 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace) return fits; } -bool UseItemAction::isPossible() -{ - return getName() == "use" || AI_VALUE2(uint32, "item count", getName()) > 0; -} +bool UseItemAction::isPossible() { return getName() == "use" || AI_VALUE2(uint32, "item count", getName()) > 0; } -bool UseSpellItemAction::isUseful() -{ - return AI_VALUE2(bool, "spell cast useful", getName()); -} +bool UseSpellItemAction::isUseful() { return AI_VALUE2(bool, "spell cast useful", getName()); } -bool UseHealingPotion::isUseful() -{ - return AI_VALUE2(bool, "combat", "self target"); -} +bool UseHealingPotion::isUseful() { return AI_VALUE2(bool, "combat", "self target"); } -bool UseManaPotion::isUseful() -{ - return AI_VALUE2(bool, "combat", "self target"); -} +bool UseManaPotion::isUseful() { return AI_VALUE2(bool, "combat", "self target"); } bool UseHearthStone::Execute(Event event) { @@ -410,20 +394,14 @@ bool UseHearthStone::Execute(Event event) return used; } -bool UseHearthStone::isUseful() -{ - return !bot->InBattleground(); -} +bool UseHearthStone::isUseful() { return !bot->InBattleground(); } bool UseRandomRecipe::isUseful() { return !bot->IsInCombat() && !botAI->HasActivePlayerMaster() && !bot->InBattleground(); } -bool UseRandomRecipe::isPossible() -{ - return AI_VALUE2(uint32, "item count", "recipe") > 0; -} +bool UseRandomRecipe::isPossible() { return AI_VALUE2(uint32, "item count", "recipe") > 0; } bool UseRandomRecipe::Execute(Event event) { @@ -439,7 +417,7 @@ bool UseRandomRecipe::Execute(Event event) if (recipeName.empty()) return false; - bool used = UseItemAction::Execute(Event(name,recipeName)); + bool used = UseItemAction::Execute(Event(name, recipeName)); if (used) botAI->SetNextCheckDelay(3.0 * IN_MILLISECONDS); @@ -452,10 +430,7 @@ bool UseRandomQuestItem::isUseful() return !botAI->HasActivePlayerMaster() && !bot->InBattleground() && !bot->HasUnitState(UNIT_STATE_IN_FLIGHT); } -bool UseRandomQuestItem::isPossible() -{ - return AI_VALUE2(uint32, "item count", "quest") > 0; -} +bool UseRandomQuestItem::isPossible() { return AI_VALUE2(uint32, "item count", "quest") > 0; } bool UseRandomQuestItem::Execute(Event event) { @@ -542,7 +517,7 @@ bool UseRandomQuestItem::Execute(Event event) bool used = UseItem(item, goTarget, nullptr, unitTarget); if (used) - botAI->SetNextCheckDelay(delay); + botAI->SetNextCheckDelay(delay); return used; } diff --git a/src/strategy/actions/UseItemAction.h b/src/strategy/actions/UseItemAction.h index 7a92cfed..bfbf67d3 100644 --- a/src/strategy/actions/UseItemAction.h +++ b/src/strategy/actions/UseItemAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_USEITEMACTION_H @@ -14,76 +15,82 @@ class Unit; class UseItemAction : public Action { - public: - UseItemAction(PlayerbotAI* botAI, std::string const name = "use", bool selfOnly = false) : Action(botAI, name), selfOnly(selfOnly) { } +public: + UseItemAction(PlayerbotAI* botAI, std::string const name = "use", bool selfOnly = false) + : Action(botAI, name), selfOnly(selfOnly) + { + } - bool Execute(Event event) override; - bool isPossible() override; + bool Execute(Event event) override; + bool isPossible() override; - protected: - bool UseItemAuto(Item* item); - bool UseItemOnGameObject(Item* item, ObjectGuid go); - bool UseItemOnItem(Item* item, Item* itemTarget); - bool UseItem(Item* item, ObjectGuid go, Item* itemTarget, Unit* unitTarget = nullptr); - bool UseGameObject(ObjectGuid guid); - void TellConsumableUse(Item* item, std::string const action, float percent); - bool SocketItem(Item* item, Item* gem, bool replace = false); +protected: + bool UseItemAuto(Item* item); + bool UseItemOnGameObject(Item* item, ObjectGuid go); + bool UseItemOnItem(Item* item, Item* itemTarget); + bool UseItem(Item* item, ObjectGuid go, Item* itemTarget, Unit* unitTarget = nullptr); + bool UseGameObject(ObjectGuid guid); + void TellConsumableUse(Item* item, std::string const action, float percent); + bool SocketItem(Item* item, Item* gem, bool replace = false); - private: - bool selfOnly; +private: + bool selfOnly; }; class UseSpellItemAction : public UseItemAction { - public: - UseSpellItemAction(PlayerbotAI* botAI, std::string const name, bool selfOnly = false) : UseItemAction(botAI, name, selfOnly) { } +public: + UseSpellItemAction(PlayerbotAI* botAI, std::string const name, bool selfOnly = false) + : UseItemAction(botAI, name, selfOnly) + { + } - bool isUseful() override; + bool isUseful() override; }; class UseHealingPotion : public UseItemAction { - public: - UseHealingPotion(PlayerbotAI* botAI) : UseItemAction(botAI, "healing potion") { } +public: + UseHealingPotion(PlayerbotAI* botAI) : UseItemAction(botAI, "healing potion") {} - bool isUseful() override; + bool isUseful() override; }; class UseManaPotion : public UseItemAction { - public: - UseManaPotion(PlayerbotAI* botAI) : UseItemAction(botAI, "mana potion") { } +public: + UseManaPotion(PlayerbotAI* botAI) : UseItemAction(botAI, "mana potion") {} - bool isUseful() override; + bool isUseful() override; }; class UseHearthStone : public UseItemAction { - public: - UseHearthStone(PlayerbotAI* botAI) : UseItemAction(botAI, "hearthstone", true) { } +public: + UseHearthStone(PlayerbotAI* botAI) : UseItemAction(botAI, "hearthstone", true) {} - bool isUseful() override; - bool Execute(Event event) override; + bool isUseful() override; + bool Execute(Event event) override; }; class UseRandomRecipe : public UseItemAction { - public: - UseRandomRecipe(PlayerbotAI* botAI) : UseItemAction(botAI, "random recipe", true) { } +public: + UseRandomRecipe(PlayerbotAI* botAI) : UseItemAction(botAI, "random recipe", true) {} - bool isUseful() override; - bool isPossible() override; - bool Execute(Event event) override; + bool isUseful() override; + bool isPossible() override; + bool Execute(Event event) override; }; class UseRandomQuestItem : public UseItemAction { - public: - UseRandomQuestItem(PlayerbotAI* botAI) : UseItemAction(botAI, "random quest item", true) { } +public: + UseRandomQuestItem(PlayerbotAI* botAI) : UseItemAction(botAI, "random quest item", true) {} - bool isUseful() override; - bool isPossible() override; - bool Execute(Event event) override; + bool isUseful() override; + bool isPossible() override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/UseMeetingStoneAction.cpp b/src/strategy/actions/UseMeetingStoneAction.cpp index 3ef3b0b1..f3eb79fe 100644 --- a/src/strategy/actions/UseMeetingStoneAction.cpp +++ b/src/strategy/actions/UseMeetingStoneAction.cpp @@ -1,10 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "UseMeetingStoneAction.h" -#include "Event.h" + #include "CellImpl.h" +#include "Event.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" #include "PlayerbotAIConfig.h" @@ -21,11 +23,11 @@ bool UseMeetingStoneAction::Execute(Event event) ObjectGuid guid; p >> guid; - if (master->GetTarget() && master->GetTarget() != bot->GetGUID()) - return false; + if (master->GetTarget() && master->GetTarget() != bot->GetGUID()) + return false; - if (!master->GetTarget() && master->GetGroup() != bot->GetGroup()) - return false; + if (!master->GetTarget() && master->GetGroup() != bot->GetGroup()) + return false; if (master->IsBeingTeleported()) return false; @@ -40,12 +42,12 @@ bool UseMeetingStoneAction::Execute(Event event) if (!map) return false; - GameObject *gameObject = map->GetGameObject(guid); + GameObject* gameObject = map->GetGameObject(guid); if (!gameObject) return false; - GameObjectTemplate const* goInfo = gameObject->GetGOInfo(); - if (!goInfo || goInfo->type != GAMEOBJECT_TYPE_SUMMONING_RITUAL) + GameObjectTemplate const* goInfo = gameObject->GetGOInfo(); + if (!goInfo || goInfo->type != GAMEOBJECT_TYPE_SUMMONING_RITUAL) return false; return Teleport(master, bot); @@ -53,20 +55,20 @@ bool UseMeetingStoneAction::Execute(Event event) class AnyGameObjectInObjectRangeCheck { - public: - AnyGameObjectInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) { } - WorldObject const& GetFocusObject() const { return *i_obj; } - bool operator()(GameObject* go) - { - if (go && i_obj->IsWithinDistInMap(go, i_range) && go->isSpawned() && go->GetGOInfo()) - return true; +public: + AnyGameObjectInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {} + WorldObject const& GetFocusObject() const { return *i_obj; } + bool operator()(GameObject* go) + { + if (go && i_obj->IsWithinDistInMap(go, i_range) && go->isSpawned() && go->GetGOInfo()) + return true; - return false; - } + return false; + } - private: - WorldObject const* i_obj; - float i_range; +private: + WorldObject const* i_obj; + float i_range; }; bool SummonAction::Execute(Event event) @@ -74,14 +76,16 @@ bool SummonAction::Execute(Event event) Player* master = GetMaster(); if (!master) return false; - - if (Pet* pet = bot->GetPet()) { + + if (Pet* pet = bot->GetPet()) + { pet->SetReactState(REACT_PASSIVE); pet->GetCharmInfo()->SetIsCommandFollow(true); pet->GetCharmInfo()->IsReturning(); } - if (master->GetSession()->GetSecurity() >= SEC_PLAYER) { + if (master->GetSession()->GetSecurity() >= SEC_PLAYER) + { // botAI->GetAiObjectContext()->GetValue("prioritized targets")->Set({}); SET_AI_VALUE(std::list, "recently flee info", {}); return Teleport(master, bot); @@ -185,7 +189,8 @@ bool SummonAction::Teleport(Player* summoner, Player* player) if (summoner->IsWithinLOS(x, y, z)) { - if (sPlayerbotAIConfig->botRepairWhenSummon) // .conf option to repair bot gear when summoned 0 = off, 1 = on + if (sPlayerbotAIConfig + ->botRepairWhenSummon) // .conf option to repair bot gear when summoned 0 = off, 1 = on bot->DurabilityRepairAll(false, 1.0f, false); if (master->IsInCombat() && !sPlayerbotAIConfig->allowSummonInCombat) @@ -200,13 +205,16 @@ bool SummonAction::Teleport(Player* summoner, Player* player) return false; } - if (bot->isDead() && !bot->HasPlayerFlag(PLAYER_FLAGS_GHOST) && !sPlayerbotAIConfig->allowSummonWhenBotIsDead) + if (bot->isDead() && !bot->HasPlayerFlag(PLAYER_FLAGS_GHOST) && + !sPlayerbotAIConfig->allowSummonWhenBotIsDead) { botAI->TellError("You cannot summon me while I'm dead, you need to release my spirit first"); return false; } - bool revive = sPlayerbotAIConfig->reviveBotWhenSummoned == 2 || (sPlayerbotAIConfig->reviveBotWhenSummoned == 1 && !master->IsInCombat() && master->IsAlive()); + bool revive = + sPlayerbotAIConfig->reviveBotWhenSummoned == 2 || + (sPlayerbotAIConfig->reviveBotWhenSummoned == 1 && !master->IsInCombat() && master->IsAlive()); if (bot->isDead() && revive) { bot->ResurrectPlayer(1.0f, false); diff --git a/src/strategy/actions/UseMeetingStoneAction.h b/src/strategy/actions/UseMeetingStoneAction.h index 6b89391d..1799503d 100644 --- a/src/strategy/actions/UseMeetingStoneAction.h +++ b/src/strategy/actions/UseMeetingStoneAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_USEMEETINGSTONEACTION_H @@ -12,23 +13,23 @@ class PlayerbotAI; class SummonAction : public MovementAction { - public: - SummonAction(PlayerbotAI* botAI, std::string const name = "summon") : MovementAction(botAI, name) { } +public: + SummonAction(PlayerbotAI* botAI, std::string const name = "summon") : MovementAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; - protected: - bool Teleport(Player* summoner, Player* player); - bool SummonUsingGos(Player* summoner, Player* player); - bool SummonUsingNpcs(Player* summoner, Player* player); +protected: + bool Teleport(Player* summoner, Player* player); + bool SummonUsingGos(Player* summoner, Player* player); + bool SummonUsingNpcs(Player* summoner, Player* player); }; class UseMeetingStoneAction : public SummonAction { - public: - UseMeetingStoneAction(PlayerbotAI* botAI) : SummonAction(botAI, "use meeting stone") { } +public: + UseMeetingStoneAction(PlayerbotAI* botAI) : SummonAction(botAI, "use meeting stone") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/VehicleActions.cpp b/src/strategy/actions/VehicleActions.cpp index c92ce62a..b036a036 100644 --- a/src/strategy/actions/VehicleActions.cpp +++ b/src/strategy/actions/VehicleActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "VehicleActions.h" + #include "ItemVisitors.h" #include "Playerbots.h" #include "ServerFacade.h" @@ -29,11 +31,11 @@ bool EnterVehicleAction::Execute(Event event) if (fabs(bot->GetPositionZ() - vehicleBase->GetPositionZ()) < 20.0f) - //if (sServerFacade->GetDistance2d(bot, vehicle) > 100.0f) - // continue; + // if (sServerFacade->GetDistance2d(bot, vehicle) > 100.0f) + // continue; - if (sServerFacade->GetDistance2d(bot, vehicleBase) > 10.0f) - return MoveTo(vehicleBase, INTERACTION_DISTANCE); + if (sServerFacade->GetDistance2d(bot, vehicleBase) > 10.0f) + return MoveTo(vehicleBase, INTERACTION_DISTANCE); bot->EnterVehicle(vehicleBase); @@ -46,7 +48,7 @@ bool EnterVehicleAction::Execute(Event event) return true; } - return false; + return false; } bool LeaveVehicleAction::Execute(Event event) diff --git a/src/strategy/actions/VehicleActions.h b/src/strategy/actions/VehicleActions.h index 54f4a8e2..b48054c5 100644 --- a/src/strategy/actions/VehicleActions.h +++ b/src/strategy/actions/VehicleActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_VEHICLEACTIONS_H @@ -12,18 +13,18 @@ class PlayerbotAI; class EnterVehicleAction : public MovementAction { - public: - EnterVehicleAction(PlayerbotAI* botAI, std::string const& name = "enter vehicle") : MovementAction(botAI, name) { } +public: + EnterVehicleAction(PlayerbotAI* botAI, std::string const& name = "enter vehicle") : MovementAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class LeaveVehicleAction : public MovementAction { - public: - LeaveVehicleAction(PlayerbotAI* botAI, std::string const& name = "leave vehicle") : MovementAction(botAI, name) { } +public: + LeaveVehicleAction(PlayerbotAI* botAI, std::string const& name = "leave vehicle") : MovementAction(botAI, name) {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/WhoAction.cpp b/src/strategy/actions/WhoAction.cpp index 17cd63a0..25606c4f 100644 --- a/src/strategy/actions/WhoAction.cpp +++ b/src/strategy/actions/WhoAction.cpp @@ -1,17 +1,21 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "WhoAction.h" + +#include "AiFactory.h" #include "Event.h" #include "ItemVisitors.h" -#include "AiFactory.h" #include "Playerbots.h" #ifndef WIN32 inline int strcmpi(char const* s1, char const* s2) { - for (; *s1 && *s2 && (toupper(*s1) == toupper(*s2)); ++s1, ++s2) {} + for (; *s1 && *s2 && (toupper(*s1) == toupper(*s2)); ++s1, ++s2) + { + } return *s1 - *s2; } #endif @@ -58,7 +62,7 @@ bool WhoAction::Execute(Event event) return false; // ignore random bot chat filter - bot->Whisper(tell, LANG_UNIVERSAL, owner); + bot->Whisper(tell, LANG_UNIVERSAL, owner); return true; } @@ -69,11 +73,13 @@ std::string const WhoAction::QueryTrade(std::string const text) std::vector items = InventoryAction::parseItems(text); for (Item* sell : items) { - int32 sellPrice = sell->GetTemplate()->SellPrice * sRandomPlayerbotMgr->GetSellMultiplier(bot) * sell->GetCount(); + int32 sellPrice = + sell->GetTemplate()->SellPrice * sRandomPlayerbotMgr->GetSellMultiplier(bot) * sell->GetCount(); if (!sellPrice) continue; - out << "Selling " << chat->FormatItem(sell->GetTemplate(), sell->GetCount()) << " for " << chat->formatMoney(sellPrice); + out << "Selling " << chat->FormatItem(sell->GetTemplate(), sell->GetCount()) << " for " + << chat->formatMoney(sellPrice); return out.str(); } @@ -94,9 +100,10 @@ std::string const WhoAction::QuerySkill(std::string const text) ObjectGuid guid = bot->GetGUID(); std::string const data = "0"; - out << "|cFFFFFF00|Htrade:" << spellId << ":" << value << ":" << maxSkill << ":" << std::hex << std::uppercase << guid.GetRawValue() - << std::nouppercase << std::dec << ":" << data << "|h[" << skillName << "]|h|r" << " |h|cff00ff00" << value << "|h|cffffffff/" - << "|h|cff00ff00" << maxSkill << "|h|cffffffff "; + out << "|cFFFFFF00|Htrade:" << spellId << ":" << value << ":" << maxSkill << ":" << std::hex << std::uppercase + << guid.GetRawValue() << std::nouppercase << std::dec << ":" << data << "|h[" << skillName << "]|h|r" + << " |h|cff00ff00" << value << "|h|cffffffff/" + << "|h|cff00ff00" << maxSkill << "|h|cffffffff "; return out.str(); } @@ -107,7 +114,8 @@ std::string const WhoAction::QuerySpec(std::string const text) uint8 spec = AiFactory::GetPlayerSpecTab(bot); - out << "|h|cffffffff" << chat->FormatRace(bot->getRace()) << " [" << (bot->getGender() == GENDER_MALE ? "M" : "F") << "] " << chat->FormatClass(bot, spec); + out << "|h|cffffffff" << chat->FormatRace(bot->getRace()) << " [" << (bot->getGender() == GENDER_MALE ? "M" : "F") + << "] " << chat->FormatClass(bot, spec); out << " (|h|cff00ff00" << (uint32)bot->GetLevel() << "|h|cffffffff lvl), "; out << "|h|cff00ff00" << botAI->GetEquipGearScore(bot, false, false) << "|h|cffffffff GS ("; diff --git a/src/strategy/actions/WhoAction.h b/src/strategy/actions/WhoAction.h index 6270e9d7..c222fe8f 100644 --- a/src/strategy/actions/WhoAction.h +++ b/src/strategy/actions/WhoAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WHOACTION_H @@ -11,15 +12,15 @@ class PlayerbotAI; class WhoAction : public InventoryAction { - public: - WhoAction(PlayerbotAI* botAI) : InventoryAction(botAI, "who") { } +public: + WhoAction(PlayerbotAI* botAI) : InventoryAction(botAI, "who") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - std::string const QueryTrade(std::string const text); - std::string const QuerySkill(std::string const text); - std::string const QuerySpec(std::string const text); +private: + std::string const QueryTrade(std::string const text); + std::string const QuerySkill(std::string const text); + std::string const QuerySpec(std::string const text); }; #endif diff --git a/src/strategy/actions/WorldBuffAction.cpp b/src/strategy/actions/WorldBuffAction.cpp index e001b1c3..577731bc 100644 --- a/src/strategy/actions/WorldBuffAction.cpp +++ b/src/strategy/actions/WorldBuffAction.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "WorldBuffAction.h" + #include "Event.h" #include "Playerbots.h" @@ -26,7 +28,8 @@ std::vector WorldBuffAction::NeedWorldBuffs(Unit* unit) return std::move(retVec); FactionTemplateEntry const* humanFaction = sFactionTemplateStore.LookupEntry(1); - uint32 factionId = (Unit::GetFactionReactionTo(unit->GetFactionTemplateEntry(), humanFaction) >= REP_NEUTRAL) ? 1 : 2; + uint32 factionId = + (Unit::GetFactionReactionTo(unit->GetFactionTemplateEntry(), humanFaction) >= REP_NEUTRAL) ? 1 : 2; for (auto& wb : sPlayerbotAIConfig->worldBuffs) { @@ -50,4 +53,3 @@ std::vector WorldBuffAction::NeedWorldBuffs(Unit* unit) return std::move(retVec); } - diff --git a/src/strategy/actions/WorldBuffAction.h b/src/strategy/actions/WorldBuffAction.h index f3234544..49bba390 100644 --- a/src/strategy/actions/WorldBuffAction.h +++ b/src/strategy/actions/WorldBuffAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WORLDBUFFACTION_H @@ -12,12 +13,12 @@ class Unit; class WorldBuffAction : public Action { - public: - WorldBuffAction(PlayerbotAI* botAI) : Action(botAI, "world buff") { } +public: + WorldBuffAction(PlayerbotAI* botAI) : Action(botAI, "world buff") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - static std::vector NeedWorldBuffs(Unit* unit); + static std::vector NeedWorldBuffs(Unit* unit); }; #endif diff --git a/src/strategy/actions/WorldPacketActionContext.h b/src/strategy/actions/WorldPacketActionContext.h index 4646da2f..16060af9 100644 --- a/src/strategy/actions/WorldPacketActionContext.h +++ b/src/strategy/actions/WorldPacketActionContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WORLDPACKETACTIONCONTEXT_H @@ -21,132 +22,137 @@ #include "LfgActions.h" #include "LootAction.h" #include "LootRollAction.h" -#include "QuestAction.h" +#include "NamedObjectContext.h" #include "PassLeadershipToMasterAction.h" #include "PetitionSignAction.h" +#include "QuestAction.h" #include "QuestConfirmAcceptAction.h" #include "ReadyCheckAction.h" #include "RememberTaxiAction.h" #include "ReviveFromCorpseAction.h" #include "RewardAction.h" -#include "SeeSpellAction.h" #include "SecurityCheckAction.h" +#include "SeeSpellAction.h" #include "TalkToQuestGiverAction.h" #include "TellCastFailedAction.h" #include "TellMasterAction.h" #include "TradeStatusAction.h" #include "UseMeetingStoneAction.h" -#include "NamedObjectContext.h" -#include "QuestConfirmAcceptAction.h" class PlayerbotAI; class WorldPacketActionContext : public NamedObjectContext { - public: - WorldPacketActionContext() - { - creators["accept invitation"] = &WorldPacketActionContext::accept_invitation; - creators["give leader in dungeon"] = &WorldPacketActionContext::give_leader_in_dungeon; - creators["leader"] = &WorldPacketActionContext::pass_leadership_to_master; - creators["tell not enough money"] = &WorldPacketActionContext::tell_not_enough_money; - creators["tell not enough reputation"] = &WorldPacketActionContext::tell_not_enough_reputation; - creators["tell cannot equip"] = &WorldPacketActionContext::tell_cannot_equip; - creators["talk to quest giver"] = &WorldPacketActionContext::turn_in_quest; - creators["accept quest"] = &WorldPacketActionContext::accept_quest; - creators["accept all quests"] = &WorldPacketActionContext::accept_all_quests; - creators["accept quest share"] = &WorldPacketActionContext::accept_quest_share; - creators["loot roll"] = &WorldPacketActionContext::loot_roll; - creators["master loot roll"] = &WorldPacketActionContext::master_loot_roll; - creators["revive from corpse"] = &WorldPacketActionContext::revive_from_corpse; - creators["find corpse"] = &WorldPacketActionContext::find_corpse; - creators["auto release"] = &WorldPacketActionContext::auto_release; - creators["accept resurrect"] = &WorldPacketActionContext::accept_resurrect; - creators["use meeting stone"] = &WorldPacketActionContext::use_meeting_stone; - creators["area trigger"] = &WorldPacketActionContext::area_trigger; - creators["reach area trigger"] = &WorldPacketActionContext::reach_area_trigger; - creators["check mount state"] = &WorldPacketActionContext::check_mount_state; - creators["remember taxi"] = &WorldPacketActionContext::remember_taxi; - creators["accept trade"] = &WorldPacketActionContext::accept_trade; - creators["store loot"] = &WorldPacketActionContext::store_loot; - creators["quest objective completed"] = &WorldPacketActionContext::quest_objective_completed; - creators["party command"] = &WorldPacketActionContext::party_command; - creators["tell cast failed"] = &WorldPacketActionContext::tell_cast_failed; - creators["accept duel"] = &WorldPacketActionContext::accept_duel; - creators["ready check"] = &WorldPacketActionContext::ready_check; - creators["ready check finished"] = &WorldPacketActionContext::ready_check_finished; - creators["uninvite"] = &WorldPacketActionContext::uninvite; - creators["security check"] = &WorldPacketActionContext::security_check; - creators["guild accept"] = &WorldPacketActionContext::guild_accept; - creators["inventory change failure"] = &WorldPacketActionContext::inventory_change_failure; - creators["bg status check"] = &WorldPacketActionContext::bg_status_check; - creators["bg strategy check"] = &WorldPacketActionContext::bg_strategy_check; - creators["bg status"] = &WorldPacketActionContext::bg_status; - creators["bg join"] = &WorldPacketActionContext::bg_join; - creators["bg leave"] = &WorldPacketActionContext::bg_leave; - creators["arena tactics"] = &WorldPacketActionContext::arena_tactics; - creators["petition sign"] = &WorldPacketActionContext::petition_sign; - creators["lfg join"] = &WorldPacketActionContext::lfg_join; - creators["lfg accept"] = &WorldPacketActionContext::lfg_accept; - creators["lfg role check"] = &WorldPacketActionContext::lfg_role_check; - creators["lfg leave"] = &WorldPacketActionContext::lfg_leave; - creators["lfg teleport"] = &WorldPacketActionContext::lfg_teleport; - creators["see spell"] = &WorldPacketActionContext::see_spell; - creators["arena team accept"] = &WorldPacketActionContext::arena_team_accept; - creators["turn in query quest"] = &WorldPacketActionContext::turn_in_query_quest; - creators["quest confirm accept"] = &WorldPacketActionContext::quest_confirm_accept; - } +public: + WorldPacketActionContext() + { + creators["accept invitation"] = &WorldPacketActionContext::accept_invitation; + creators["give leader in dungeon"] = &WorldPacketActionContext::give_leader_in_dungeon; + creators["leader"] = &WorldPacketActionContext::pass_leadership_to_master; + creators["tell not enough money"] = &WorldPacketActionContext::tell_not_enough_money; + creators["tell not enough reputation"] = &WorldPacketActionContext::tell_not_enough_reputation; + creators["tell cannot equip"] = &WorldPacketActionContext::tell_cannot_equip; + creators["talk to quest giver"] = &WorldPacketActionContext::turn_in_quest; + creators["accept quest"] = &WorldPacketActionContext::accept_quest; + creators["accept all quests"] = &WorldPacketActionContext::accept_all_quests; + creators["accept quest share"] = &WorldPacketActionContext::accept_quest_share; + creators["loot roll"] = &WorldPacketActionContext::loot_roll; + creators["master loot roll"] = &WorldPacketActionContext::master_loot_roll; + creators["revive from corpse"] = &WorldPacketActionContext::revive_from_corpse; + creators["find corpse"] = &WorldPacketActionContext::find_corpse; + creators["auto release"] = &WorldPacketActionContext::auto_release; + creators["accept resurrect"] = &WorldPacketActionContext::accept_resurrect; + creators["use meeting stone"] = &WorldPacketActionContext::use_meeting_stone; + creators["area trigger"] = &WorldPacketActionContext::area_trigger; + creators["reach area trigger"] = &WorldPacketActionContext::reach_area_trigger; + creators["check mount state"] = &WorldPacketActionContext::check_mount_state; + creators["remember taxi"] = &WorldPacketActionContext::remember_taxi; + creators["accept trade"] = &WorldPacketActionContext::accept_trade; + creators["store loot"] = &WorldPacketActionContext::store_loot; + creators["quest objective completed"] = &WorldPacketActionContext::quest_objective_completed; + creators["party command"] = &WorldPacketActionContext::party_command; + creators["tell cast failed"] = &WorldPacketActionContext::tell_cast_failed; + creators["accept duel"] = &WorldPacketActionContext::accept_duel; + creators["ready check"] = &WorldPacketActionContext::ready_check; + creators["ready check finished"] = &WorldPacketActionContext::ready_check_finished; + creators["uninvite"] = &WorldPacketActionContext::uninvite; + creators["security check"] = &WorldPacketActionContext::security_check; + creators["guild accept"] = &WorldPacketActionContext::guild_accept; + creators["inventory change failure"] = &WorldPacketActionContext::inventory_change_failure; + creators["bg status check"] = &WorldPacketActionContext::bg_status_check; + creators["bg strategy check"] = &WorldPacketActionContext::bg_strategy_check; + creators["bg status"] = &WorldPacketActionContext::bg_status; + creators["bg join"] = &WorldPacketActionContext::bg_join; + creators["bg leave"] = &WorldPacketActionContext::bg_leave; + creators["arena tactics"] = &WorldPacketActionContext::arena_tactics; + creators["petition sign"] = &WorldPacketActionContext::petition_sign; + creators["lfg join"] = &WorldPacketActionContext::lfg_join; + creators["lfg accept"] = &WorldPacketActionContext::lfg_accept; + creators["lfg role check"] = &WorldPacketActionContext::lfg_role_check; + creators["lfg leave"] = &WorldPacketActionContext::lfg_leave; + creators["lfg teleport"] = &WorldPacketActionContext::lfg_teleport; + creators["see spell"] = &WorldPacketActionContext::see_spell; + creators["arena team accept"] = &WorldPacketActionContext::arena_team_accept; + creators["turn in query quest"] = &WorldPacketActionContext::turn_in_query_quest; + creators["quest confirm accept"] = &WorldPacketActionContext::quest_confirm_accept; + } - private: - static Action* inventory_change_failure(PlayerbotAI* botAI) { return new InventoryChangeFailureAction(botAI); } - static Action* guild_accept(PlayerbotAI* botAI) { return new GuildAcceptAction(botAI); } - static Action* security_check(PlayerbotAI* botAI) { return new SecurityCheckAction(botAI); } - static Action* uninvite(PlayerbotAI* botAI) { return new UninviteAction(botAI); } - static Action* ready_check_finished(PlayerbotAI* botAI) { return new FinishReadyCheckAction(botAI); } - static Action* ready_check(PlayerbotAI* botAI) { return new ReadyCheckAction(botAI); } - static Action* accept_duel(PlayerbotAI* botAI) { return new AcceptDuelAction(botAI); } - static Action* tell_cast_failed(PlayerbotAI* botAI) { return new TellCastFailedAction(botAI); } - static Action* party_command(PlayerbotAI* botAI) { return new PartyCommandAction(botAI); } - static Action* quest_objective_completed(PlayerbotAI* botAI) { return new QuestObjectiveCompletedAction(botAI); } - static Action* store_loot(PlayerbotAI* botAI) { return new StoreLootAction(botAI); } - static Action* accept_trade(PlayerbotAI* botAI) { return new TradeStatusAction(botAI); } - static Action* remember_taxi(PlayerbotAI* botAI) { return new RememberTaxiAction(botAI); } - static Action* check_mount_state(PlayerbotAI* botAI) { return new CheckMountStateAction(botAI); } - static Action* area_trigger(PlayerbotAI* botAI) { return new AreaTriggerAction(botAI); } - static Action* reach_area_trigger(PlayerbotAI* botAI) { return new ReachAreaTriggerAction(botAI); } - static Action* use_meeting_stone(PlayerbotAI* botAI) { return new UseMeetingStoneAction(botAI); } - static Action* accept_resurrect(PlayerbotAI* botAI) { return new AcceptResurrectAction(botAI); } - static Action* find_corpse(PlayerbotAI* botAI) { return new FindCorpseAction(botAI); } - static Action* auto_release(PlayerbotAI* botAI) { return new AutoReleaseSpiritAction(botAI); } - static Action* revive_from_corpse(PlayerbotAI* botAI) { return new ReviveFromCorpseAction(botAI); } - static Action* accept_invitation(PlayerbotAI* botAI) { return new AcceptInvitationAction(botAI); } - static Action* give_leader_in_dungeon(PlayerbotAI* botAI) { return new GiveLeaderAction(botAI, "I don't know this dungeon, lead the way!"); } - static Action* pass_leadership_to_master(PlayerbotAI* botAI) { return new PassLeadershipToMasterAction(botAI); } - static Action* tell_not_enough_money(PlayerbotAI* botAI) { return new TellMasterAction(botAI, "Not enough money"); } - static Action* tell_not_enough_reputation(PlayerbotAI* botAI) { return new TellMasterAction(botAI, "Not enough reputation"); } - static Action* tell_cannot_equip(PlayerbotAI* botAI) { return new InventoryChangeFailureAction(botAI); } - static Action* turn_in_quest(PlayerbotAI* botAI) { return new TalkToQuestGiverAction(botAI); } - static Action* accept_quest(PlayerbotAI* botAI) { return new AcceptQuestAction(botAI); } - static Action* accept_all_quests(PlayerbotAI* botAI) { return new AcceptAllQuestsAction(botAI); } - static Action* accept_quest_share(PlayerbotAI* botAI) { return new AcceptQuestShareAction(botAI); } - static Action* loot_roll(PlayerbotAI* botAI) { return new LootRollAction(botAI); } - static Action* master_loot_roll(PlayerbotAI* botAI) { return new MasterLootRollAction(botAI); } - static Action* bg_join(PlayerbotAI* botAI) { return new BGJoinAction(botAI); } - static Action* bg_leave(PlayerbotAI* botAI) { return new BGLeaveAction(botAI); } - static Action* bg_status(PlayerbotAI* botAI) { return new BGStatusAction(botAI); } - static Action* bg_status_check(PlayerbotAI* botAI) { return new BGStatusCheckAction(botAI); } - static Action* bg_strategy_check(PlayerbotAI* botAI) { return new BGStrategyCheckAction(botAI); } - static Action* arena_tactics(PlayerbotAI* botAI) { return new ArenaTactics(botAI); } - static Action* petition_sign(PlayerbotAI* botAI) { return new PetitionSignAction(botAI); } - static Action* lfg_teleport(PlayerbotAI* botAI) { return new LfgTeleportAction(botAI); } - static Action* lfg_leave(PlayerbotAI* botAI) { return new LfgLeaveAction(botAI); } - static Action* lfg_accept(PlayerbotAI* botAI) { return new LfgAcceptAction(botAI); } - static Action* lfg_role_check(PlayerbotAI* botAI) { return new LfgRoleCheckAction(botAI); } - static Action* lfg_join(PlayerbotAI* botAI) { return new LfgJoinAction(botAI); } - static Action* see_spell(PlayerbotAI* botAI) { return new SeeSpellAction(botAI); } - static Action* arena_team_accept(PlayerbotAI* botAI) { return new ArenaTeamAcceptAction(botAI); } - static Action* turn_in_query_quest(PlayerbotAI* botAI) { return new TurnInQueryQuestAction(botAI); } - static Action* quest_confirm_accept(PlayerbotAI* botAI) { return new QuestConfirmAcceptAction(botAI); } +private: + static Action* inventory_change_failure(PlayerbotAI* botAI) { return new InventoryChangeFailureAction(botAI); } + static Action* guild_accept(PlayerbotAI* botAI) { return new GuildAcceptAction(botAI); } + static Action* security_check(PlayerbotAI* botAI) { return new SecurityCheckAction(botAI); } + static Action* uninvite(PlayerbotAI* botAI) { return new UninviteAction(botAI); } + static Action* ready_check_finished(PlayerbotAI* botAI) { return new FinishReadyCheckAction(botAI); } + static Action* ready_check(PlayerbotAI* botAI) { return new ReadyCheckAction(botAI); } + static Action* accept_duel(PlayerbotAI* botAI) { return new AcceptDuelAction(botAI); } + static Action* tell_cast_failed(PlayerbotAI* botAI) { return new TellCastFailedAction(botAI); } + static Action* party_command(PlayerbotAI* botAI) { return new PartyCommandAction(botAI); } + static Action* quest_objective_completed(PlayerbotAI* botAI) { return new QuestObjectiveCompletedAction(botAI); } + static Action* store_loot(PlayerbotAI* botAI) { return new StoreLootAction(botAI); } + static Action* accept_trade(PlayerbotAI* botAI) { return new TradeStatusAction(botAI); } + static Action* remember_taxi(PlayerbotAI* botAI) { return new RememberTaxiAction(botAI); } + static Action* check_mount_state(PlayerbotAI* botAI) { return new CheckMountStateAction(botAI); } + static Action* area_trigger(PlayerbotAI* botAI) { return new AreaTriggerAction(botAI); } + static Action* reach_area_trigger(PlayerbotAI* botAI) { return new ReachAreaTriggerAction(botAI); } + static Action* use_meeting_stone(PlayerbotAI* botAI) { return new UseMeetingStoneAction(botAI); } + static Action* accept_resurrect(PlayerbotAI* botAI) { return new AcceptResurrectAction(botAI); } + static Action* find_corpse(PlayerbotAI* botAI) { return new FindCorpseAction(botAI); } + static Action* auto_release(PlayerbotAI* botAI) { return new AutoReleaseSpiritAction(botAI); } + static Action* revive_from_corpse(PlayerbotAI* botAI) { return new ReviveFromCorpseAction(botAI); } + static Action* accept_invitation(PlayerbotAI* botAI) { return new AcceptInvitationAction(botAI); } + static Action* give_leader_in_dungeon(PlayerbotAI* botAI) + { + return new GiveLeaderAction(botAI, "I don't know this dungeon, lead the way!"); + } + static Action* pass_leadership_to_master(PlayerbotAI* botAI) { return new PassLeadershipToMasterAction(botAI); } + static Action* tell_not_enough_money(PlayerbotAI* botAI) { return new TellMasterAction(botAI, "Not enough money"); } + static Action* tell_not_enough_reputation(PlayerbotAI* botAI) + { + return new TellMasterAction(botAI, "Not enough reputation"); + } + static Action* tell_cannot_equip(PlayerbotAI* botAI) { return new InventoryChangeFailureAction(botAI); } + static Action* turn_in_quest(PlayerbotAI* botAI) { return new TalkToQuestGiverAction(botAI); } + static Action* accept_quest(PlayerbotAI* botAI) { return new AcceptQuestAction(botAI); } + static Action* accept_all_quests(PlayerbotAI* botAI) { return new AcceptAllQuestsAction(botAI); } + static Action* accept_quest_share(PlayerbotAI* botAI) { return new AcceptQuestShareAction(botAI); } + static Action* loot_roll(PlayerbotAI* botAI) { return new LootRollAction(botAI); } + static Action* master_loot_roll(PlayerbotAI* botAI) { return new MasterLootRollAction(botAI); } + static Action* bg_join(PlayerbotAI* botAI) { return new BGJoinAction(botAI); } + static Action* bg_leave(PlayerbotAI* botAI) { return new BGLeaveAction(botAI); } + static Action* bg_status(PlayerbotAI* botAI) { return new BGStatusAction(botAI); } + static Action* bg_status_check(PlayerbotAI* botAI) { return new BGStatusCheckAction(botAI); } + static Action* bg_strategy_check(PlayerbotAI* botAI) { return new BGStrategyCheckAction(botAI); } + static Action* arena_tactics(PlayerbotAI* botAI) { return new ArenaTactics(botAI); } + static Action* petition_sign(PlayerbotAI* botAI) { return new PetitionSignAction(botAI); } + static Action* lfg_teleport(PlayerbotAI* botAI) { return new LfgTeleportAction(botAI); } + static Action* lfg_leave(PlayerbotAI* botAI) { return new LfgLeaveAction(botAI); } + static Action* lfg_accept(PlayerbotAI* botAI) { return new LfgAcceptAction(botAI); } + static Action* lfg_role_check(PlayerbotAI* botAI) { return new LfgRoleCheckAction(botAI); } + static Action* lfg_join(PlayerbotAI* botAI) { return new LfgJoinAction(botAI); } + static Action* see_spell(PlayerbotAI* botAI) { return new SeeSpellAction(botAI); } + static Action* arena_team_accept(PlayerbotAI* botAI) { return new ArenaTeamAcceptAction(botAI); } + static Action* turn_in_query_quest(PlayerbotAI* botAI) { return new TurnInQueryQuestAction(botAI); } + static Action* quest_confirm_accept(PlayerbotAI* botAI) { return new QuestConfirmAcceptAction(botAI); } }; #endif diff --git a/src/strategy/actions/WtsAction.cpp b/src/strategy/actions/WtsAction.cpp index 0a9df471..f4adfa7a 100644 --- a/src/strategy/actions/WtsAction.cpp +++ b/src/strategy/actions/WtsAction.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "WtsAction.h" -#include "Event.h" -#include "ItemVisitors.h" -#include "ItemUsageValue.h" + #include "AiFactory.h" +#include "Event.h" +#include "ItemUsageValue.h" +#include "ItemVisitors.h" #include "Playerbots.h" bool WtsAction::Execute(Event event) diff --git a/src/strategy/actions/WtsAction.h b/src/strategy/actions/WtsAction.h index afc9ebc3..7fefb11e 100644 --- a/src/strategy/actions/WtsAction.h +++ b/src/strategy/actions/WtsAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WTSACTION_H @@ -11,10 +12,10 @@ class PlayerbotAI; class WtsAction : public InventoryAction { - public: - WtsAction(PlayerbotAI* botAI) : InventoryAction(botAI, "wts") { } +public: + WtsAction(PlayerbotAI* botAI) : InventoryAction(botAI, "wts") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/actions/XpGainAction.cpp b/src/strategy/actions/XpGainAction.cpp index 8dc98ca6..3a031460 100644 --- a/src/strategy/actions/XpGainAction.cpp +++ b/src/strategy/actions/XpGainAction.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "XpGainAction.h" + #include "Event.h" +#include "GuildMgr.h" #include "PlayerbotAIConfig.h" #include "Playerbots.h" -#include "GuildMgr.h" bool XpGainAction::Execute(Event event) { @@ -15,28 +17,29 @@ bool XpGainAction::Execute(Event event) if (!sRandomPlayerbotMgr->IsRandomBot(bot) || sPlayerbotAIConfig->playerbotsXPrate == 1) return true; - WorldPacket p(event.getPacket()); // (8+4+1+4+8) + WorldPacket p(event.getPacket()); // (8+4+1+4+8) ObjectGuid guid; uint32 xpgain; - uint8 type = 0; // 00-kill_xp type, 01-non_kill_xp type + uint8 type = 0; // 00-kill_xp type, 01-non_kill_xp type uint32 givenXp = 0; float groupBonus = 0; p.rpos(0); - p >> guid; // 8 victim - p >> xpgain; // 1 given experience - p >> type; //1 00-kill_xp type, 01-non_kill_xp type + p >> guid; // 8 victim + p >> xpgain; // 1 given experience + p >> type; // 1 00-kill_xp type, 01-non_kill_xp type if (!type) { - p >> givenXp; // 4 experience without rested bonus - p >> groupBonus; // 8 group bonus + p >> givenXp; // 4 experience without rested bonus + p >> groupBonus; // 8 group bonus } if (sPlayerbotAIConfig->randomBotGuildTalk && bot->GetGuildId() && urand(0, 10)) { Creature* creature = botAI->GetCreature(guid); - if (creature && (creature->isElite() || creature->isWorldBoss() || creature->GetLevel() > 61 || creature->GetLevel() > bot->GetLevel() + 4)) + if (creature && (creature->isElite() || creature->isWorldBoss() || creature->GetLevel() > 61 || + creature->GetLevel() > bot->GetLevel() + 4)) { Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId()); if (guild) @@ -86,7 +89,7 @@ void XpGainAction::GiveXP(uint32 xp, Unit* victim) // XP resting bonus for kill uint32 rested_bonus_xp = victim ? bot->GetXPRestBonus(xp) : 0; - //SendLogXPGain(xp, victim, rested_bonus_xp); + // SendLogXPGain(xp, victim, rested_bonus_xp); uint32 curXP = bot->GetUInt32Value(PLAYER_XP); uint32 nextLvlXP = bot->GetUInt32Value(PLAYER_NEXT_LEVEL_XP); diff --git a/src/strategy/actions/XpGainAction.h b/src/strategy/actions/XpGainAction.h index 348cc1b4..da5926e0 100644 --- a/src/strategy/actions/XpGainAction.h +++ b/src/strategy/actions/XpGainAction.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_XPGAINACTION_H @@ -12,13 +13,13 @@ class Unit; class XpGainAction : public Action { - public: - XpGainAction(PlayerbotAI* botAI) : Action(botAI, "xp gain") { } +public: + XpGainAction(PlayerbotAI* botAI) : Action(botAI, "xp gain") {} - bool Execute(Event event) override; + bool Execute(Event event) override; - private: - void GiveXP(uint32 xp, Unit* victim); +private: + void GiveXP(uint32 xp, Unit* victim); }; #endif diff --git a/src/strategy/deathknight/BloodDKStrategy.cpp b/src/strategy/deathknight/BloodDKStrategy.cpp index f3d20f73..f76d6795 100644 --- a/src/strategy/deathknight/BloodDKStrategy.cpp +++ b/src/strategy/deathknight/BloodDKStrategy.cpp @@ -1,75 +1,77 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "BloodDKStrategy.h" + #include "Playerbots.h" class BloodDKStrategyActionNodeFactory : public NamedObjectFactory { - public: - BloodDKStrategyActionNodeFactory() - { - //creators["melee"] = &melee; - //creators["blood strike"] = &blood_strike; - creators["rune strike"] = &rune_strike; - creators["heart strike"] = &heart_strike; - creators["death strike"] = &death_strike; - //creators["death grip"] = &death_grip; - //creators["plague strike"] = &plague_strike; - //creators["pestilence"] = &pestilence; - creators["icy touch"] = &icy_touch; - //creators["obliterate"] = &obliterate; - //creators["blood boil"] = &blood_boil; - //creators["mark of_blood"] = &mark_of_blood; - //creators["blood presence"] = &blood_presence; - //creators["rune tap"] = &rune_tap; - //creators["vampiric blood"] = &vampiric_blood; - //creators["death pact"] = &death_pact; - //creators["death rune_mastery"] = &death_rune_mastery; - //creators["hysteria"] = &hysteria; - //creators["dancing weapon"] = &dancing_weapon; - creators["dark command"] = &dark_command; - creators["taunt spell"] = &dark_command; - } +public: + BloodDKStrategyActionNodeFactory() + { + // creators["melee"] = &melee; + // creators["blood strike"] = &blood_strike; + creators["rune strike"] = &rune_strike; + creators["heart strike"] = &heart_strike; + creators["death strike"] = &death_strike; + // creators["death grip"] = &death_grip; + // creators["plague strike"] = &plague_strike; + // creators["pestilence"] = &pestilence; + creators["icy touch"] = &icy_touch; + // creators["obliterate"] = &obliterate; + // creators["blood boil"] = &blood_boil; + // creators["mark of_blood"] = &mark_of_blood; + // creators["blood presence"] = &blood_presence; + // creators["rune tap"] = &rune_tap; + // creators["vampiric blood"] = &vampiric_blood; + // creators["death pact"] = &death_pact; + // creators["death rune_mastery"] = &death_rune_mastery; + // creators["hysteria"] = &hysteria; + // creators["dancing weapon"] = &dancing_weapon; + creators["dark command"] = &dark_command; + creators["taunt spell"] = &dark_command; + } - private: - static ActionNode* rune_strike([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("rune strike", - /*P*/ NextAction::array(0, new NextAction("frost presence"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* icy_touch([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("icy touch", - /*P*/ NextAction::array(0, new NextAction("frost presence"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* heart_strike([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("heart strike", - /*P*/ NextAction::array(0, new NextAction("frost presence"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } +private: + static ActionNode* rune_strike([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("rune strike", + /*P*/ NextAction::array(0, new NextAction("frost presence"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* icy_touch([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("icy touch", + /*P*/ NextAction::array(0, new NextAction("frost presence"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* heart_strike([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("heart strike", + /*P*/ NextAction::array(0, new NextAction("frost presence"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* death_strike([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("death strike", - /*P*/ NextAction::array(0, new NextAction("frost presence"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* dark_command([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("dark command", - /*P*/ NextAction::array(0, new NextAction("frost presence"), NULL), - /*A*/ NextAction::array(0, new NextAction("death grip"), NULL), - /*C*/ NULL); - } + static ActionNode* death_strike([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("death strike", + /*P*/ NextAction::array(0, new NextAction("frost presence"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* dark_command([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("dark command", + /*P*/ NextAction::array(0, new NextAction("frost presence"), NULL), + /*A*/ NextAction::array(0, new NextAction("death grip"), NULL), + /*C*/ NULL); + } }; BloodDKStrategy::BloodDKStrategy(PlayerbotAI* botAI) : GenericDKStrategy(botAI) @@ -79,27 +81,28 @@ BloodDKStrategy::BloodDKStrategy(PlayerbotAI* botAI) : GenericDKStrategy(botAI) NextAction** BloodDKStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("rune strike", ACTION_DEFAULT + 0.8f), - new NextAction("icy touch", ACTION_DEFAULT + 0.7f), - new NextAction("heart strike", ACTION_DEFAULT + 0.6f), - new NextAction("blood strike", ACTION_DEFAULT + 0.5f), - new NextAction("dancing rune weapon", ACTION_DEFAULT + 0.4f), - new NextAction("death coil", ACTION_DEFAULT + 0.3f), - new NextAction("plague strike", ACTION_DEFAULT + 0.2f), - new NextAction("horn of winter", ACTION_DEFAULT + 0.1f), - new NextAction("melee", ACTION_DEFAULT), - NULL); + return NextAction::array( + 0, new NextAction("rune strike", ACTION_DEFAULT + 0.8f), new NextAction("icy touch", ACTION_DEFAULT + 0.7f), + new NextAction("heart strike", ACTION_DEFAULT + 0.6f), new NextAction("blood strike", ACTION_DEFAULT + 0.5f), + new NextAction("dancing rune weapon", ACTION_DEFAULT + 0.4f), + new NextAction("death coil", ACTION_DEFAULT + 0.3f), new NextAction("plague strike", ACTION_DEFAULT + 0.2f), + new NextAction("horn of winter", ACTION_DEFAULT + 0.1f), new NextAction("melee", ACTION_DEFAULT), NULL); } void BloodDKStrategy::InitTriggers(std::vector& triggers) { GenericDKStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("rune strike", NextAction::array(0, new NextAction("rune strike", ACTION_NORMAL + 3), nullptr))); - triggers.push_back(new TriggerNode("blood tap", NextAction::array(0, new NextAction("blood tap", ACTION_HIGH + 5), nullptr))); - triggers.push_back(new TriggerNode("lose aggro", NextAction::array(0, new NextAction("dark command", ACTION_HIGH + 3), nullptr))); - triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("army of the dead", ACTION_HIGH + 5), - new NextAction("vampiric blood", ACTION_HIGH + 4), new NextAction("death strike", ACTION_HIGH + 3), nullptr))); - // triggers.push_back(new TriggerNode("army of the dead", NextAction::array(0, new NextAction("army of the dead", ACTION_HIGH + 6), nullptr))); + triggers.push_back(new TriggerNode( + "rune strike", NextAction::array(0, new NextAction("rune strike", ACTION_NORMAL + 3), nullptr))); + triggers.push_back( + new TriggerNode("blood tap", NextAction::array(0, new NextAction("blood tap", ACTION_HIGH + 5), nullptr))); + triggers.push_back( + new TriggerNode("lose aggro", NextAction::array(0, new NextAction("dark command", ACTION_HIGH + 3), nullptr))); + triggers.push_back( + new TriggerNode("low health", NextAction::array(0, new NextAction("army of the dead", ACTION_HIGH + 5), + new NextAction("vampiric blood", ACTION_HIGH + 4), + new NextAction("death strike", ACTION_HIGH + 3), nullptr))); + // triggers.push_back(new TriggerNode("army of the dead", NextAction::array(0, new NextAction("army of the dead", + // ACTION_HIGH + 6), nullptr))); } diff --git a/src/strategy/deathknight/BloodDKStrategy.h b/src/strategy/deathknight/BloodDKStrategy.h index 69a34929..9a726478 100644 --- a/src/strategy/deathknight/BloodDKStrategy.h +++ b/src/strategy/deathknight/BloodDKStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_BLOODDKSTRATEGY_H @@ -11,13 +12,13 @@ class PlayerbotAI; class BloodDKStrategy : public GenericDKStrategy { - public: - BloodDKStrategy(PlayerbotAI* botAI); +public: + BloodDKStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "blood"; } - NextAction** getDefaultActions() override; - uint32 GetType() const override { return STRATEGY_TYPE_TANK | STRATEGY_TYPE_MELEE; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "blood"; } + NextAction** getDefaultActions() override; + uint32 GetType() const override { return STRATEGY_TYPE_TANK | STRATEGY_TYPE_MELEE; } }; #endif diff --git a/src/strategy/deathknight/DKActions.cpp b/src/strategy/deathknight/DKActions.cpp index e0f5b824..575c5aef 100644 --- a/src/strategy/deathknight/DKActions.cpp +++ b/src/strategy/deathknight/DKActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DKActions.h" + #include "Duration.h" #include "GenericSpellActions.h" #include "Playerbots.h" @@ -11,28 +13,33 @@ NextAction** CastDeathchillAction::getPrerequisites() { - return NextAction::merge(NextAction::array(0, new NextAction("frost presence"), nullptr), CastSpellAction::getPrerequisites()); + return NextAction::merge(NextAction::array(0, new NextAction("frost presence"), nullptr), + CastSpellAction::getPrerequisites()); } NextAction** CastUnholyMeleeSpellAction::getPrerequisites() { - return NextAction::merge(NextAction::array(0, new NextAction("unholy presence"), nullptr), CastMeleeSpellAction::getPrerequisites()); + return NextAction::merge(NextAction::array(0, new NextAction("unholy presence"), nullptr), + CastMeleeSpellAction::getPrerequisites()); } NextAction** CastFrostMeleeSpellAction::getPrerequisites() { - return NextAction::merge(NextAction::array(0, new NextAction("frost presence"), nullptr), CastMeleeSpellAction::getPrerequisites()); + return NextAction::merge(NextAction::array(0, new NextAction("frost presence"), nullptr), + CastMeleeSpellAction::getPrerequisites()); } NextAction** CastBloodMeleeSpellAction::getPrerequisites() { - return NextAction::merge(NextAction::array(0, new NextAction("blood presence"), nullptr), CastMeleeSpellAction::getPrerequisites()); + return NextAction::merge(NextAction::array(0, new NextAction("blood presence"), nullptr), + CastMeleeSpellAction::getPrerequisites()); } bool CastRaiseDeadAction::Execute(Event event) { bool result = CastBuffSpellAction::Execute(event); - if (!result) { + if (!result) + { return false; } uint32 spellId = AI_VALUE2(uint32, "spell id", spell); diff --git a/src/strategy/deathknight/DKActions.h b/src/strategy/deathknight/DKActions.h index e4907ac8..9d35de2c 100644 --- a/src/strategy/deathknight/DKActions.h +++ b/src/strategy/deathknight/DKActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DKACTIONS_H @@ -12,34 +13,34 @@ class PlayerbotAI; class CastBloodPresenceAction : public CastBuffSpellAction { - public: - CastBloodPresenceAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "blood presence") { } +public: + CastBloodPresenceAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "blood presence") {} }; class CastFrostPresenceAction : public CastBuffSpellAction { - public: - CastFrostPresenceAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "frost presence") { } +public: + CastFrostPresenceAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "frost presence") {} }; class CastUnholyPresenceAction : public CastBuffSpellAction { - public: - CastUnholyPresenceAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "unholy presence") { } +public: + CastUnholyPresenceAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "unholy presence") {} }; class CastDeathchillAction : public CastBuffSpellAction { - public: - CastDeathchillAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "deathchill") { } +public: + CastDeathchillAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "deathchill") {} - NextAction** getPrerequisites() override; + NextAction** getPrerequisites() override; }; class CastDarkCommandAction : public CastSpellAction { - public: - CastDarkCommandAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "dark command") { } +public: + CastDarkCommandAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "dark command") {} }; BEGIN_RANGED_SPELL_ACTION(CastDeathGripAction, "death grip") @@ -48,117 +49,124 @@ END_SPELL_ACTION() // Unholy presence class CastUnholyMeleeSpellAction : public CastMeleeSpellAction { - public: - CastUnholyMeleeSpellAction(PlayerbotAI* botAI, std::string const spell) : CastMeleeSpellAction(botAI, spell) { } +public: + CastUnholyMeleeSpellAction(PlayerbotAI* botAI, std::string const spell) : CastMeleeSpellAction(botAI, spell) {} - NextAction** getPrerequisites() override; + NextAction** getPrerequisites() override; }; // Frost presence class CastFrostMeleeSpellAction : public CastMeleeSpellAction { - public: - CastFrostMeleeSpellAction(PlayerbotAI* botAI, std::string const spell) : CastMeleeSpellAction(botAI, spell) { } +public: + CastFrostMeleeSpellAction(PlayerbotAI* botAI, std::string const spell) : CastMeleeSpellAction(botAI, spell) {} - NextAction** getPrerequisites() override; + NextAction** getPrerequisites() override; }; // Blood presence class CastBloodMeleeSpellAction : public CastMeleeSpellAction { - public: - CastBloodMeleeSpellAction(PlayerbotAI* botAI, std::string const spell) : CastMeleeSpellAction(botAI, spell) { } +public: + CastBloodMeleeSpellAction(PlayerbotAI* botAI, std::string const spell) : CastMeleeSpellAction(botAI, spell) {} - NextAction** getPrerequisites() override; + NextAction** getPrerequisites() override; }; class CastRuneStrikeAction : public CastMeleeSpellAction { - public: - CastRuneStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "rune strike") { } +public: + CastRuneStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "rune strike") {} }; -//debuff -// BEGIN_DEBUFF_ACTION(CastPestilenceAction, "pestilence") -// END_SPELL_ACTION() +// debuff +// BEGIN_DEBUFF_ACTION(CastPestilenceAction, "pestilence") +// END_SPELL_ACTION() class CastPestilenceAction : public CastSpellAction { - public: - CastPestilenceAction(PlayerbotAI* ai) : CastSpellAction(ai, "pestilence") {} - ActionThreatType getThreatType() override { return ActionThreatType::None; } +public: + CastPestilenceAction(PlayerbotAI* ai) : CastSpellAction(ai, "pestilence") {} + ActionThreatType getThreatType() override { return ActionThreatType::None; } }; - -//debuff -// BEGIN_DEBUFF_ACTION(CastHowlingBlastAction, "howling blast") -// END_SPELL_ACTION() +// debuff +// BEGIN_DEBUFF_ACTION(CastHowlingBlastAction, "howling blast") +// END_SPELL_ACTION() class CastHowlingBlastAction : public CastSpellAction { - public: - CastHowlingBlastAction(PlayerbotAI* ai) : CastSpellAction(ai, "howling blast") {} +public: + CastHowlingBlastAction(PlayerbotAI* ai) : CastSpellAction(ai, "howling blast") {} }; -//debuff it -// BEGIN_DEBUFF_ACTION(CastIcyTouchAction, "icy touch") -// END_SPELL_ACTION() +// debuff it +// BEGIN_DEBUFF_ACTION(CastIcyTouchAction, "icy touch") +// END_SPELL_ACTION() class CastIcyTouchAction : public CastSpellAction { - public: - CastIcyTouchAction(PlayerbotAI* ai) : CastSpellAction(ai, "icy touch") {} +public: + CastIcyTouchAction(PlayerbotAI* ai) : CastSpellAction(ai, "icy touch") {} }; class CastIcyTouchOnAttackerAction : public CastDebuffSpellOnMeleeAttackerAction { - public: - CastIcyTouchOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnMeleeAttackerAction(botAI, "icy touch", true, .0f) { } +public: + CastIcyTouchOnAttackerAction(PlayerbotAI* botAI) + : CastDebuffSpellOnMeleeAttackerAction(botAI, "icy touch", true, .0f) + { + } }; -//debuff ps +// debuff ps class CastPlagueStrikeAction : public CastSpellAction { - public: - CastPlagueStrikeAction(PlayerbotAI* ai) : CastSpellAction(ai, "plague strike") {} +public: + CastPlagueStrikeAction(PlayerbotAI* ai) : CastSpellAction(ai, "plague strike") {} }; // BEGIN_DEBUFF_ACTION(CastPlagueStrikeAction, "plague strike") // END_SPELL_ACTION() class CastPlagueStrikeOnAttackerAction : public CastDebuffSpellOnMeleeAttackerAction { - public: - CastPlagueStrikeOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnMeleeAttackerAction(botAI, "plague strike", true, .0f) { } +public: + CastPlagueStrikeOnAttackerAction(PlayerbotAI* botAI) + : CastDebuffSpellOnMeleeAttackerAction(botAI, "plague strike", true, .0f) + { + } }; -//debuff +// debuff BEGIN_DEBUFF_ACTION(CastMarkOfBloodAction, "mark of blood") END_SPELL_ACTION() class CastMarkOfBloodOnAttackerAction : public CastDebuffSpellOnAttackerAction { - public: - CastMarkOfBloodOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "mark of blood", true) { } +public: + CastMarkOfBloodOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "mark of blood", true) + { + } }; class CastUnholyBlightAction : public CastBuffSpellAction { - public: - CastUnholyBlightAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "unholy blight") { } +public: + CastUnholyBlightAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "unholy blight") {} }; class CastSummonGargoyleAction : public CastSpellAction { - public: - CastSummonGargoyleAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "summon gargoyle") { } +public: + CastSummonGargoyleAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "summon gargoyle") {} }; class CastGhoulFrenzyAction : public CastBuffSpellAction { - public: - CastGhoulFrenzyAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "ghoul frenzy") { } - std::string const GetTargetName() override { return "pet target"; } +public: + CastGhoulFrenzyAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "ghoul frenzy") {} + std::string const GetTargetName() override { return "pet target"; } }; BEGIN_MELEE_SPELL_ACTION(CastCorpseExplosionAction, "corpse explosion") @@ -172,177 +180,177 @@ END_SPELL_ACTION() class CastChainsOfIceAction : public CastSpellAction { - public: - CastChainsOfIceAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "chains of ice") { } +public: + CastChainsOfIceAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "chains of ice") {} }; class CastHungeringColdAction : public CastMeleeSpellAction { - public: - CastHungeringColdAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "hungering cold") { } +public: + CastHungeringColdAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "hungering cold") {} }; class CastHeartStrikeAction : public CastMeleeSpellAction { - public: - CastHeartStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "heart strike") { } +public: + CastHeartStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "heart strike") {} }; class CastBloodStrikeAction : public CastMeleeSpellAction { - public: - CastBloodStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "blood strike") { } +public: + CastBloodStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "blood strike") {} }; class CastFrostStrikeAction : public CastMeleeSpellAction { - public: - CastFrostStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "frost strike") { } +public: + CastFrostStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "frost strike") {} }; class CastObliterateAction : public CastMeleeSpellAction { - public: - CastObliterateAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "obliterate") { } +public: + CastObliterateAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "obliterate") {} }; class CastDeathStrikeAction : public CastMeleeSpellAction { - public: - CastDeathStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "death strike") { } +public: + CastDeathStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "death strike") {} }; class CastScourgeStrikeAction : public CastMeleeSpellAction { - public: - CastScourgeStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "scourge strike") { } +public: + CastScourgeStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "scourge strike") {} }; class CastDeathCoilAction : public CastSpellAction { - public: - CastDeathCoilAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "death coil") { } +public: + CastDeathCoilAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "death coil") {} }; class CastBloodBoilAction : public CastSpellAction { - public: - CastBloodBoilAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "blood boil") { } +public: + CastBloodBoilAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "blood boil") {} }; class CastDeathAndDecayAction : public CastSpellAction { - public: - CastDeathAndDecayAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "death and decay") { } +public: + CastDeathAndDecayAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "death and decay") {} }; class CastHornOfWinterAction : public CastSpellAction { - public: - CastHornOfWinterAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "horn of winter") { } +public: + CastHornOfWinterAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "horn of winter") {} }; class CastImprovedIcyTalonsAction : public CastBuffSpellAction { - public: - CastImprovedIcyTalonsAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "improved icy talons") { } +public: + CastImprovedIcyTalonsAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "improved icy talons") {} }; class CastBoneShieldAction : public CastBuffSpellAction { - public: - CastBoneShieldAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "bone shield") { } +public: + CastBoneShieldAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "bone shield") {} }; class CastDeathPactAction : public CastBuffSpellAction { - public: - CastDeathPactAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "death pact") { } +public: + CastDeathPactAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "death pact") {} }; class CastDeathRuneMasteryAction : public CastBuffSpellAction { - public: - CastDeathRuneMasteryAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "death rune mastery") { } +public: + CastDeathRuneMasteryAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "death rune mastery") {} }; class CastDancingRuneWeaponAction : public CastSpellAction { - public: - CastDancingRuneWeaponAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "dancing rune weapon") { } +public: + CastDancingRuneWeaponAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "dancing rune weapon") {} }; class CastEmpowerRuneWeaponAction : public CastBuffSpellAction { - public: - CastEmpowerRuneWeaponAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "empower rune weapon") { } +public: + CastEmpowerRuneWeaponAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "empower rune weapon") {} }; class CastArmyOfTheDeadAction : public CastBuffSpellAction { - public: - CastArmyOfTheDeadAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "army of the dead") { } +public: + CastArmyOfTheDeadAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "army of the dead") {} }; class CastRaiseDeadAction : public CastBuffSpellAction { - public: - CastRaiseDeadAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "raise dead") { } - virtual bool Execute(Event event) override; +public: + CastRaiseDeadAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "raise dead") {} + virtual bool Execute(Event event) override; }; class CastKillingMachineAction : public CastBuffSpellAction { - public: - CastKillingMachineAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "killing machine") { } +public: + CastKillingMachineAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "killing machine") {} }; class CastIceboundFortitudeAction : public CastBuffSpellAction { - public: - CastIceboundFortitudeAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "icebound fortitude") { } +public: + CastIceboundFortitudeAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "icebound fortitude") {} }; class CastUnbreakableArmorAction : public CastBuffSpellAction { - public: - CastUnbreakableArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "unbreakable armor") { } +public: + CastUnbreakableArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "unbreakable armor") {} }; class CastVampiricBloodAction : public CastBuffSpellAction { - public: - CastVampiricBloodAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "vampiric blood") { } +public: + CastVampiricBloodAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "vampiric blood") {} }; class CastMindFreezeAction : public CastMeleeSpellAction { - public: - CastMindFreezeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "mind freeze") { } +public: + CastMindFreezeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "mind freeze") {} }; class CastStrangulateAction : public CastMeleeSpellAction { - public: - CastStrangulateAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "strangulate") { } +public: + CastStrangulateAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "strangulate") {} }; class CastMindFreezeOnEnemyHealerAction : public CastSpellOnEnemyHealerAction { - public: - CastMindFreezeOnEnemyHealerAction(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, "mind freeze") { } +public: + CastMindFreezeOnEnemyHealerAction(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, "mind freeze") {} }; class CastRuneTapAction : public CastMeleeSpellAction { - public: - CastRuneTapAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "rune tap") { } +public: + CastRuneTapAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "rune tap") {} }; class CastBloodTapAction : public CastMeleeSpellAction { - public: - CastBloodTapAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "blood tap") { } +public: + CastBloodTapAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "blood tap") {} }; #endif diff --git a/src/strategy/deathknight/DKAiObjectContext.cpp b/src/strategy/deathknight/DKAiObjectContext.cpp index e7641e71..9023f8ac 100644 --- a/src/strategy/deathknight/DKAiObjectContext.cpp +++ b/src/strategy/deathknight/DKAiObjectContext.cpp @@ -1,239 +1,251 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DKAiObjectContext.h" + #include "BloodDKStrategy.h" #include "DKActions.h" #include "DKTriggers.h" #include "FrostDKStrategy.h" #include "GenericDKNonCombatStrategy.h" -#include "UnholyDKStrategy.h" #include "Playerbots.h" #include "PullStrategy.h" +#include "UnholyDKStrategy.h" class DeathKnightStrategyFactoryInternal : public NamedObjectContext { - public: - DeathKnightStrategyFactoryInternal() - { - creators["nc"] = &DeathKnightStrategyFactoryInternal::nc; - creators["pull"] = &DeathKnightStrategyFactoryInternal::pull; - creators["frost aoe"] = &DeathKnightStrategyFactoryInternal::frost_aoe; - creators["unholy aoe"] = &DeathKnightStrategyFactoryInternal::unholy_aoe; - } +public: + DeathKnightStrategyFactoryInternal() + { + creators["nc"] = &DeathKnightStrategyFactoryInternal::nc; + creators["pull"] = &DeathKnightStrategyFactoryInternal::pull; + creators["frost aoe"] = &DeathKnightStrategyFactoryInternal::frost_aoe; + creators["unholy aoe"] = &DeathKnightStrategyFactoryInternal::unholy_aoe; + } - private: - static Strategy* nc(PlayerbotAI* botAI) { return new GenericDKNonCombatStrategy(botAI); } - static Strategy* pull(PlayerbotAI* botAI) { return new PullStrategy(botAI, "icy touch"); } - static Strategy* frost_aoe(PlayerbotAI* botAI) { return new FrostDKAoeStrategy(botAI); } - static Strategy* unholy_aoe(PlayerbotAI* botAI) { return new UnholyDKAoeStrategy(botAI); } +private: + static Strategy* nc(PlayerbotAI* botAI) { return new GenericDKNonCombatStrategy(botAI); } + static Strategy* pull(PlayerbotAI* botAI) { return new PullStrategy(botAI, "icy touch"); } + static Strategy* frost_aoe(PlayerbotAI* botAI) { return new FrostDKAoeStrategy(botAI); } + static Strategy* unholy_aoe(PlayerbotAI* botAI) { return new UnholyDKAoeStrategy(botAI); } }; class DeathKnightCombatStrategyFactoryInternal : public NamedObjectContext { - public: - DeathKnightCombatStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["tank"] = &DeathKnightCombatStrategyFactoryInternal::blood; - creators["blood"] = &DeathKnightCombatStrategyFactoryInternal::blood; - creators["frost"] = &DeathKnightCombatStrategyFactoryInternal::frost_dps; - creators["unholy"] = &DeathKnightCombatStrategyFactoryInternal::unholy_dps; - } +public: + DeathKnightCombatStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["tank"] = &DeathKnightCombatStrategyFactoryInternal::blood; + creators["blood"] = &DeathKnightCombatStrategyFactoryInternal::blood; + creators["frost"] = &DeathKnightCombatStrategyFactoryInternal::frost_dps; + creators["unholy"] = &DeathKnightCombatStrategyFactoryInternal::unholy_dps; + } - private: - static Strategy* frost_dps(PlayerbotAI* botAI) { return new FrostDKStrategy(botAI); } - static Strategy* unholy_dps(PlayerbotAI* botAI) { return new UnholyDKStrategy(botAI); } - static Strategy* tank(PlayerbotAI* botAI) { return new BloodDKStrategy(botAI); } - static Strategy* blood(PlayerbotAI* botAI) { return new BloodDKStrategy(botAI); } +private: + static Strategy* frost_dps(PlayerbotAI* botAI) { return new FrostDKStrategy(botAI); } + static Strategy* unholy_dps(PlayerbotAI* botAI) { return new UnholyDKStrategy(botAI); } + static Strategy* tank(PlayerbotAI* botAI) { return new BloodDKStrategy(botAI); } + static Strategy* blood(PlayerbotAI* botAI) { return new BloodDKStrategy(botAI); } }; class DeathKnightDKBuffStrategyFactoryInternal : public NamedObjectContext { - public: - DeathKnightDKBuffStrategyFactoryInternal() : NamedObjectContext(false, true) - { +public: + DeathKnightDKBuffStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["bdps"] = &DeathKnightDKBuffStrategyFactoryInternal::bdps; + } - creators["bdps"] = &DeathKnightDKBuffStrategyFactoryInternal::bdps; - } - - private: - static Strategy* bdps(PlayerbotAI* botAI) { return new DKBuffDpsStrategy(botAI); } +private: + static Strategy* bdps(PlayerbotAI* botAI) { return new DKBuffDpsStrategy(botAI); } }; class DeathKnightTriggerFactoryInternal : public NamedObjectContext { - public: - DeathKnightTriggerFactoryInternal() - { - creators["bone shield"] = &DeathKnightTriggerFactoryInternal::bone_shield; - creators["pestilence glyph"] = &DeathKnightTriggerFactoryInternal::pestilence_glyph; - creators["blood strike"] = &DeathKnightTriggerFactoryInternal::blood_strike; - creators["plague strike"] = &DeathKnightTriggerFactoryInternal::plague_strike; - creators["plague strike on attacker"] = &DeathKnightTriggerFactoryInternal::plague_strike_on_attacker; - creators["icy touch"] = &DeathKnightTriggerFactoryInternal::icy_touch; - creators["death coil"] = &DeathKnightTriggerFactoryInternal::death_coil; - creators["icy touch on attacker"] = &DeathKnightTriggerFactoryInternal::icy_touch_on_attacker; - creators["improved icy talons"] = &DeathKnightTriggerFactoryInternal::improved_icy_talons; - creators["plague strike"] = &DeathKnightTriggerFactoryInternal::plague_strike; - creators["horn of winter"] = &DeathKnightTriggerFactoryInternal::horn_of_winter; - creators["mind freeze"] = &DeathKnightTriggerFactoryInternal::mind_freeze; - creators["mind freeze on enemy healer"] = &DeathKnightTriggerFactoryInternal::mind_freeze_on_enemy_healer; - creators["strangulate"] = &DeathKnightTriggerFactoryInternal::strangulate; - creators["strangulate on enemy healer"] = &DeathKnightTriggerFactoryInternal::strangulate_on_enemy_healer; - creators["blood tap"] = &DeathKnightTriggerFactoryInternal::blood_tap; - creators["raise dead"] = &DeathKnightTriggerFactoryInternal::raise_dead; - creators["chains of ice"] = &DeathKnightTriggerFactoryInternal::chains_of_ice; - creators["unbreakable armor"] = &DeathKnightTriggerFactoryInternal::unbreakable_armor; - creators["high blood rune"] = &DeathKnightTriggerFactoryInternal::high_blood_rune; - creators["freezing fog"] = &DeathKnightTriggerFactoryInternal::freezing_fog; - creators["no desolation"] = &DeathKnightTriggerFactoryInternal::no_desolation; - creators["death and decay cooldown"] = &DeathKnightTriggerFactoryInternal::death_and_decay_cooldown; - creators["army of the dead"] = &DeathKnightTriggerFactoryInternal::army_of_the_dead; - } +public: + DeathKnightTriggerFactoryInternal() + { + creators["bone shield"] = &DeathKnightTriggerFactoryInternal::bone_shield; + creators["pestilence glyph"] = &DeathKnightTriggerFactoryInternal::pestilence_glyph; + creators["blood strike"] = &DeathKnightTriggerFactoryInternal::blood_strike; + creators["plague strike"] = &DeathKnightTriggerFactoryInternal::plague_strike; + creators["plague strike on attacker"] = &DeathKnightTriggerFactoryInternal::plague_strike_on_attacker; + creators["icy touch"] = &DeathKnightTriggerFactoryInternal::icy_touch; + creators["death coil"] = &DeathKnightTriggerFactoryInternal::death_coil; + creators["icy touch on attacker"] = &DeathKnightTriggerFactoryInternal::icy_touch_on_attacker; + creators["improved icy talons"] = &DeathKnightTriggerFactoryInternal::improved_icy_talons; + creators["plague strike"] = &DeathKnightTriggerFactoryInternal::plague_strike; + creators["horn of winter"] = &DeathKnightTriggerFactoryInternal::horn_of_winter; + creators["mind freeze"] = &DeathKnightTriggerFactoryInternal::mind_freeze; + creators["mind freeze on enemy healer"] = &DeathKnightTriggerFactoryInternal::mind_freeze_on_enemy_healer; + creators["strangulate"] = &DeathKnightTriggerFactoryInternal::strangulate; + creators["strangulate on enemy healer"] = &DeathKnightTriggerFactoryInternal::strangulate_on_enemy_healer; + creators["blood tap"] = &DeathKnightTriggerFactoryInternal::blood_tap; + creators["raise dead"] = &DeathKnightTriggerFactoryInternal::raise_dead; + creators["chains of ice"] = &DeathKnightTriggerFactoryInternal::chains_of_ice; + creators["unbreakable armor"] = &DeathKnightTriggerFactoryInternal::unbreakable_armor; + creators["high blood rune"] = &DeathKnightTriggerFactoryInternal::high_blood_rune; + creators["freezing fog"] = &DeathKnightTriggerFactoryInternal::freezing_fog; + creators["no desolation"] = &DeathKnightTriggerFactoryInternal::no_desolation; + creators["death and decay cooldown"] = &DeathKnightTriggerFactoryInternal::death_and_decay_cooldown; + creators["army of the dead"] = &DeathKnightTriggerFactoryInternal::army_of_the_dead; + } - private: - static Trigger* bone_shield(PlayerbotAI* botAI) { return new BoneShieldTrigger(botAI); } - static Trigger* pestilence_glyph(PlayerbotAI* botAI) { return new PestilenceGlyphTrigger(botAI); } - static Trigger* blood_strike(PlayerbotAI* botAI) { return new BloodStrikeTrigger(botAI); } - static Trigger* plague_strike(PlayerbotAI* botAI) { return new PlagueStrikeDebuffTrigger(botAI); } - static Trigger* plague_strike_on_attacker(PlayerbotAI* botAI) { return new PlagueStrikeDebuffOnAttackerTrigger(botAI); } - static Trigger* icy_touch(PlayerbotAI* botAI) { return new IcyTouchDebuffTrigger(botAI); } - static Trigger* death_coil(PlayerbotAI* botAI) { return new DeathCoilTrigger(botAI); } - static Trigger* icy_touch_on_attacker(PlayerbotAI* botAI) { return new IcyTouchDebuffOnAttackerTrigger(botAI); } - static Trigger* improved_icy_talons(PlayerbotAI* botAI) { return new ImprovedIcyTalonsTrigger(botAI); } - static Trigger* horn_of_winter(PlayerbotAI* botAI) { return new HornOfWinterTrigger(botAI); } - static Trigger* mind_freeze(PlayerbotAI* botAI) { return new MindFreezeInterruptSpellTrigger(botAI); } - static Trigger* mind_freeze_on_enemy_healer(PlayerbotAI* botAI) { return new MindFreezeOnEnemyHealerTrigger(botAI); } - static Trigger* strangulate(PlayerbotAI* botAI) { return new StrangulateInterruptSpellTrigger(botAI); } - static Trigger* strangulate_on_enemy_healer(PlayerbotAI* botAI) { return new StrangulateOnEnemyHealerTrigger(botAI); } - static Trigger* blood_tap(PlayerbotAI* botAI) { return new BloodTapTrigger(botAI); } - static Trigger* raise_dead(PlayerbotAI* botAI) { return new RaiseDeadTrigger(botAI); } - static Trigger* chains_of_ice(PlayerbotAI* botAI) { return new ChainsOfIceSnareTrigger(botAI); } - static Trigger* unbreakable_armor(PlayerbotAI* botAI) { return new UnbreakableArmorTrigger(botAI); } - static Trigger* high_blood_rune(PlayerbotAI* botAI) { return new HighBloodRuneTrigger(botAI); } - static Trigger* freezing_fog(PlayerbotAI* botAI) { return new FreezingFogTrigger(botAI); } - static Trigger* no_desolation(PlayerbotAI* botAI) { return new DesolationTrigger(botAI); } - static Trigger* death_and_decay_cooldown(PlayerbotAI* botAI) { return new DeathAndDecayCooldownTrigger(botAI); } - static Trigger* army_of_the_dead(PlayerbotAI* botAI) { return new ArmyOfTheDeadTrigger(botAI); } +private: + static Trigger* bone_shield(PlayerbotAI* botAI) { return new BoneShieldTrigger(botAI); } + static Trigger* pestilence_glyph(PlayerbotAI* botAI) { return new PestilenceGlyphTrigger(botAI); } + static Trigger* blood_strike(PlayerbotAI* botAI) { return new BloodStrikeTrigger(botAI); } + static Trigger* plague_strike(PlayerbotAI* botAI) { return new PlagueStrikeDebuffTrigger(botAI); } + static Trigger* plague_strike_on_attacker(PlayerbotAI* botAI) + { + return new PlagueStrikeDebuffOnAttackerTrigger(botAI); + } + static Trigger* icy_touch(PlayerbotAI* botAI) { return new IcyTouchDebuffTrigger(botAI); } + static Trigger* death_coil(PlayerbotAI* botAI) { return new DeathCoilTrigger(botAI); } + static Trigger* icy_touch_on_attacker(PlayerbotAI* botAI) { return new IcyTouchDebuffOnAttackerTrigger(botAI); } + static Trigger* improved_icy_talons(PlayerbotAI* botAI) { return new ImprovedIcyTalonsTrigger(botAI); } + static Trigger* horn_of_winter(PlayerbotAI* botAI) { return new HornOfWinterTrigger(botAI); } + static Trigger* mind_freeze(PlayerbotAI* botAI) { return new MindFreezeInterruptSpellTrigger(botAI); } + static Trigger* mind_freeze_on_enemy_healer(PlayerbotAI* botAI) + { + return new MindFreezeOnEnemyHealerTrigger(botAI); + } + static Trigger* strangulate(PlayerbotAI* botAI) { return new StrangulateInterruptSpellTrigger(botAI); } + static Trigger* strangulate_on_enemy_healer(PlayerbotAI* botAI) + { + return new StrangulateOnEnemyHealerTrigger(botAI); + } + static Trigger* blood_tap(PlayerbotAI* botAI) { return new BloodTapTrigger(botAI); } + static Trigger* raise_dead(PlayerbotAI* botAI) { return new RaiseDeadTrigger(botAI); } + static Trigger* chains_of_ice(PlayerbotAI* botAI) { return new ChainsOfIceSnareTrigger(botAI); } + static Trigger* unbreakable_armor(PlayerbotAI* botAI) { return new UnbreakableArmorTrigger(botAI); } + static Trigger* high_blood_rune(PlayerbotAI* botAI) { return new HighBloodRuneTrigger(botAI); } + static Trigger* freezing_fog(PlayerbotAI* botAI) { return new FreezingFogTrigger(botAI); } + static Trigger* no_desolation(PlayerbotAI* botAI) { return new DesolationTrigger(botAI); } + static Trigger* death_and_decay_cooldown(PlayerbotAI* botAI) { return new DeathAndDecayCooldownTrigger(botAI); } + static Trigger* army_of_the_dead(PlayerbotAI* botAI) { return new ArmyOfTheDeadTrigger(botAI); } }; class DeathKnightAiObjectContextInternal : public NamedObjectContext { - public: - DeathKnightAiObjectContextInternal() - { - // Unholy - creators["bone shield"] = &DeathKnightAiObjectContextInternal::bone_shield; - creators["plague strike"] = &DeathKnightAiObjectContextInternal::plague_strike; - creators["plague strike on attacker"] = &DeathKnightAiObjectContextInternal::plague_strike_on_attacker; - creators["death grip"] = &DeathKnightAiObjectContextInternal::death_grip; - creators["death coil"] = &DeathKnightAiObjectContextInternal::death_coil; - creators["death strike"] = &DeathKnightAiObjectContextInternal::death_strike; - creators["unholy blight"] = &DeathKnightAiObjectContextInternal::unholy_blight; - creators["scourge strike"] = &DeathKnightAiObjectContextInternal::scourge_strike; - creators["death and decay"] = &DeathKnightAiObjectContextInternal::death_and_decay; - creators["unholy presence"] = &DeathKnightAiObjectContextInternal::unholy_presence; - creators["raise dead"] = &DeathKnightAiObjectContextInternal::raise_dead; - creators["army of the dead"] = &DeathKnightAiObjectContextInternal::army_of_the_dead; - creators["summon gargoyle"] = &DeathKnightAiObjectContextInternal::summon_gargoyle; - creators["anti magic shell"] = &DeathKnightAiObjectContextInternal::anti_magic_shell; - creators["anti magic zone"] = &DeathKnightAiObjectContextInternal::anti_magic_zone; - creators["ghoul frenzy"] = &DeathKnightAiObjectContextInternal::ghoul_frenzy; - creators["corpse explosion"] = &DeathKnightAiObjectContextInternal::corpse_explosion; - // Frost - creators["icy touch"] = &DeathKnightAiObjectContextInternal::icy_touch; - creators["icy touch on attacker"] = &DeathKnightAiObjectContextInternal::icy_touch_on_attacker; - creators["obliterate"] = &DeathKnightAiObjectContextInternal::obliterate; - creators["howling blast"] = &DeathKnightAiObjectContextInternal::howling_blast; - creators["frost strike"] = &DeathKnightAiObjectContextInternal::frost_strike; - creators["chains of ice"] = &DeathKnightAiObjectContextInternal::chains_of_ice; - creators["rune strike"] = &DeathKnightAiObjectContextInternal::rune_strike; - //creators["icy clutch"] = &DeathKnightAiObjectContextInternal::icy_clutch; - creators["horn of winter"] = &DeathKnightAiObjectContextInternal::horn_of_winter; - creators["killing machine"] = &DeathKnightAiObjectContextInternal::killing_machine; - creators["frost presence"] = &DeathKnightAiObjectContextInternal::frost_presence; - creators["deathchill"] = &DeathKnightAiObjectContextInternal::deathchill; - creators["icebound fortitude"] = &DeathKnightAiObjectContextInternal::icebound_fortitude; - creators["mind freeze"] = &DeathKnightAiObjectContextInternal::mind_freeze; - creators["empower rune weapon"] = &DeathKnightAiObjectContextInternal::empower_rune_weapon; - creators["hungering cold"] = &DeathKnightAiObjectContextInternal::hungering_cold; - creators["unbreakable armor"] = &DeathKnightAiObjectContextInternal::unbreakable_armor; - creators["improved icy talons"] = &DeathKnightAiObjectContextInternal::improved_icy_talons; - // blood - creators["blood strike"] = &DeathKnightAiObjectContextInternal::blood_strike; - creators["blood tap"] = &DeathKnightAiObjectContextInternal::blood_tap; - creators["pestilence"] = &DeathKnightAiObjectContextInternal::pestilence; - creators["strangulate"] = &DeathKnightAiObjectContextInternal::strangulate; - creators["blood boil"] = &DeathKnightAiObjectContextInternal::blood_boil; - creators["heart strike"] = &DeathKnightAiObjectContextInternal::heart_strike; - creators["mark of_blood"] = &DeathKnightAiObjectContextInternal::mark_of_blood; - creators["blood presence"] = &DeathKnightAiObjectContextInternal::blood_presence; - creators["rune tap"] = &DeathKnightAiObjectContextInternal::rune_tap; - creators["vampiric blood"] = &DeathKnightAiObjectContextInternal::vampiric_blood; - creators["death pact"] = &DeathKnightAiObjectContextInternal::death_pact; - creators["death rune_mastery"] = &DeathKnightAiObjectContextInternal::death_rune_mastery; - //creators["hysteria"] = &DeathKnightAiObjectContextInternal::hysteria; - creators["dancing rune weapon"] = &DeathKnightAiObjectContextInternal::dancing_rune_weapon; - creators["dark command"] = &DeathKnightAiObjectContextInternal::dark_command; - } +public: + DeathKnightAiObjectContextInternal() + { + // Unholy + creators["bone shield"] = &DeathKnightAiObjectContextInternal::bone_shield; + creators["plague strike"] = &DeathKnightAiObjectContextInternal::plague_strike; + creators["plague strike on attacker"] = &DeathKnightAiObjectContextInternal::plague_strike_on_attacker; + creators["death grip"] = &DeathKnightAiObjectContextInternal::death_grip; + creators["death coil"] = &DeathKnightAiObjectContextInternal::death_coil; + creators["death strike"] = &DeathKnightAiObjectContextInternal::death_strike; + creators["unholy blight"] = &DeathKnightAiObjectContextInternal::unholy_blight; + creators["scourge strike"] = &DeathKnightAiObjectContextInternal::scourge_strike; + creators["death and decay"] = &DeathKnightAiObjectContextInternal::death_and_decay; + creators["unholy presence"] = &DeathKnightAiObjectContextInternal::unholy_presence; + creators["raise dead"] = &DeathKnightAiObjectContextInternal::raise_dead; + creators["army of the dead"] = &DeathKnightAiObjectContextInternal::army_of_the_dead; + creators["summon gargoyle"] = &DeathKnightAiObjectContextInternal::summon_gargoyle; + creators["anti magic shell"] = &DeathKnightAiObjectContextInternal::anti_magic_shell; + creators["anti magic zone"] = &DeathKnightAiObjectContextInternal::anti_magic_zone; + creators["ghoul frenzy"] = &DeathKnightAiObjectContextInternal::ghoul_frenzy; + creators["corpse explosion"] = &DeathKnightAiObjectContextInternal::corpse_explosion; + // Frost + creators["icy touch"] = &DeathKnightAiObjectContextInternal::icy_touch; + creators["icy touch on attacker"] = &DeathKnightAiObjectContextInternal::icy_touch_on_attacker; + creators["obliterate"] = &DeathKnightAiObjectContextInternal::obliterate; + creators["howling blast"] = &DeathKnightAiObjectContextInternal::howling_blast; + creators["frost strike"] = &DeathKnightAiObjectContextInternal::frost_strike; + creators["chains of ice"] = &DeathKnightAiObjectContextInternal::chains_of_ice; + creators["rune strike"] = &DeathKnightAiObjectContextInternal::rune_strike; + // creators["icy clutch"] = &DeathKnightAiObjectContextInternal::icy_clutch; + creators["horn of winter"] = &DeathKnightAiObjectContextInternal::horn_of_winter; + creators["killing machine"] = &DeathKnightAiObjectContextInternal::killing_machine; + creators["frost presence"] = &DeathKnightAiObjectContextInternal::frost_presence; + creators["deathchill"] = &DeathKnightAiObjectContextInternal::deathchill; + creators["icebound fortitude"] = &DeathKnightAiObjectContextInternal::icebound_fortitude; + creators["mind freeze"] = &DeathKnightAiObjectContextInternal::mind_freeze; + creators["empower rune weapon"] = &DeathKnightAiObjectContextInternal::empower_rune_weapon; + creators["hungering cold"] = &DeathKnightAiObjectContextInternal::hungering_cold; + creators["unbreakable armor"] = &DeathKnightAiObjectContextInternal::unbreakable_armor; + creators["improved icy talons"] = &DeathKnightAiObjectContextInternal::improved_icy_talons; + // blood + creators["blood strike"] = &DeathKnightAiObjectContextInternal::blood_strike; + creators["blood tap"] = &DeathKnightAiObjectContextInternal::blood_tap; + creators["pestilence"] = &DeathKnightAiObjectContextInternal::pestilence; + creators["strangulate"] = &DeathKnightAiObjectContextInternal::strangulate; + creators["blood boil"] = &DeathKnightAiObjectContextInternal::blood_boil; + creators["heart strike"] = &DeathKnightAiObjectContextInternal::heart_strike; + creators["mark of_blood"] = &DeathKnightAiObjectContextInternal::mark_of_blood; + creators["blood presence"] = &DeathKnightAiObjectContextInternal::blood_presence; + creators["rune tap"] = &DeathKnightAiObjectContextInternal::rune_tap; + creators["vampiric blood"] = &DeathKnightAiObjectContextInternal::vampiric_blood; + creators["death pact"] = &DeathKnightAiObjectContextInternal::death_pact; + creators["death rune_mastery"] = &DeathKnightAiObjectContextInternal::death_rune_mastery; + // creators["hysteria"] = &DeathKnightAiObjectContextInternal::hysteria; + creators["dancing rune weapon"] = &DeathKnightAiObjectContextInternal::dancing_rune_weapon; + creators["dark command"] = &DeathKnightAiObjectContextInternal::dark_command; + } - private: - - // Unholy - static Action* bone_shield(PlayerbotAI* botAI) { return new CastBoneShieldAction(botAI); } - static Action* plague_strike(PlayerbotAI* botAI) { return new CastPlagueStrikeAction(botAI); } - static Action* plague_strike_on_attacker(PlayerbotAI* botAI) { return new CastPlagueStrikeOnAttackerAction(botAI); } - static Action* death_grip(PlayerbotAI* botAI) { return new CastDeathGripAction(botAI); } - static Action* death_coil(PlayerbotAI* botAI) { return new CastDeathCoilAction(botAI); } - static Action* death_strike(PlayerbotAI* botAI) { return new CastDeathStrikeAction(botAI); } - static Action* unholy_blight(PlayerbotAI* botAI) { return new CastUnholyBlightAction(botAI); } - static Action* scourge_strike(PlayerbotAI* botAI) { return new CastScourgeStrikeAction(botAI); } - static Action* death_and_decay(PlayerbotAI* botAI) { return new CastDeathAndDecayAction(botAI); } - static Action* unholy_presence(PlayerbotAI* botAI) { return new CastUnholyPresenceAction(botAI); } - static Action* raise_dead(PlayerbotAI* botAI) { return new CastRaiseDeadAction(botAI); } - static Action* army_of_the_dead(PlayerbotAI* botAI) { return new CastArmyOfTheDeadAction(botAI); } - static Action* summon_gargoyle(PlayerbotAI* botAI) { return new CastSummonGargoyleAction(botAI); } - static Action* anti_magic_shell(PlayerbotAI* botAI) { return new CastAntiMagicShellAction(botAI); } - static Action* anti_magic_zone(PlayerbotAI* botAI) { return new CastAntiMagicZoneAction(botAI); } - static Action* ghoul_frenzy(PlayerbotAI* botAI) { return new CastGhoulFrenzyAction(botAI); } - static Action* corpse_explosion(PlayerbotAI* botAI) { return new CastCorpseExplosionAction(botAI); } - // Frost - static Action* icy_touch(PlayerbotAI* botAI) { return new CastIcyTouchAction(botAI); } - static Action* icy_touch_on_attacker(PlayerbotAI* botAI) { return new CastIcyTouchOnAttackerAction(botAI); } - static Action* obliterate(PlayerbotAI* botAI) { return new CastObliterateAction(botAI); } - static Action* howling_blast(PlayerbotAI* botAI) { return new CastHowlingBlastAction(botAI); } - static Action* frost_strike(PlayerbotAI* botAI) { return new CastFrostStrikeAction(botAI); } - static Action* chains_of_ice(PlayerbotAI* botAI) { return new CastChainsOfIceAction(botAI); } - static Action* rune_strike(PlayerbotAI* botAI) { return new CastRuneStrikeAction(botAI); } - //static Action* icy_clutch(PlayerbotAI* botAI) { return new CastIcyClutchAction(botAI); } - static Action* horn_of_winter(PlayerbotAI* botAI) { return new CastHornOfWinterAction(botAI); } - static Action* killing_machine(PlayerbotAI* botAI) { return new CastKillingMachineAction(botAI); } - static Action* frost_presence(PlayerbotAI* botAI) { return new CastFrostPresenceAction(botAI); } - static Action* deathchill(PlayerbotAI* botAI) { return new CastDeathchillAction(botAI); } - static Action* icebound_fortitude(PlayerbotAI* botAI) { return new CastIceboundFortitudeAction(botAI); } - static Action* mind_freeze(PlayerbotAI* botAI) { return new CastMindFreezeAction(botAI); } - static Action* empower_rune_weapon(PlayerbotAI* botAI) { return new CastEmpowerRuneWeaponAction(botAI); } - static Action* hungering_cold(PlayerbotAI* botAI) { return new CastHungeringColdAction(botAI); } - static Action* unbreakable_armor(PlayerbotAI* botAI) { return new CastUnbreakableArmorAction(botAI); } - static Action* improved_icy_talons(PlayerbotAI* botAI) { return new CastImprovedIcyTalonsAction(botAI); } - // blood - static Action* blood_strike(PlayerbotAI* botAI) { return new CastBloodStrikeAction(botAI); } - static Action* blood_tap(PlayerbotAI* botAI) { return new CastBloodTapAction(botAI); } - static Action* pestilence(PlayerbotAI* botAI) { return new CastPestilenceAction(botAI); } - static Action* strangulate(PlayerbotAI* botAI) { return new CastStrangulateAction(botAI); } - static Action* blood_boil(PlayerbotAI* botAI) { return new CastBloodBoilAction(botAI); } - static Action* heart_strike(PlayerbotAI* botAI) { return new CastHeartStrikeAction(botAI); } - static Action* mark_of_blood(PlayerbotAI* botAI) { return new CastMarkOfBloodAction(botAI); } - static Action* blood_presence(PlayerbotAI* botAI) { return new CastBloodPresenceAction(botAI); } - static Action* rune_tap(PlayerbotAI* botAI) { return new CastRuneTapAction(botAI); } - static Action* vampiric_blood(PlayerbotAI* botAI) { return new CastVampiricBloodAction(botAI); } - static Action* death_pact(PlayerbotAI* botAI) { return new CastDeathPactAction(botAI); } - static Action* death_rune_mastery(PlayerbotAI* botAI) { return new CastDeathRuneMasteryAction(botAI); } - //static Action* hysteria(PlayerbotAI* botAI) { return new CastHysteriaAction(botAI); } - static Action* dancing_rune_weapon(PlayerbotAI* botAI) { return new CastDancingRuneWeaponAction(botAI); } - static Action* dark_command(PlayerbotAI* botAI) { return new CastDarkCommandAction(botAI); } - static Action* mind_freeze_on_enemy_healer(PlayerbotAI* botAI) { return new CastMindFreezeOnEnemyHealerAction(botAI); } +private: + // Unholy + static Action* bone_shield(PlayerbotAI* botAI) { return new CastBoneShieldAction(botAI); } + static Action* plague_strike(PlayerbotAI* botAI) { return new CastPlagueStrikeAction(botAI); } + static Action* plague_strike_on_attacker(PlayerbotAI* botAI) { return new CastPlagueStrikeOnAttackerAction(botAI); } + static Action* death_grip(PlayerbotAI* botAI) { return new CastDeathGripAction(botAI); } + static Action* death_coil(PlayerbotAI* botAI) { return new CastDeathCoilAction(botAI); } + static Action* death_strike(PlayerbotAI* botAI) { return new CastDeathStrikeAction(botAI); } + static Action* unholy_blight(PlayerbotAI* botAI) { return new CastUnholyBlightAction(botAI); } + static Action* scourge_strike(PlayerbotAI* botAI) { return new CastScourgeStrikeAction(botAI); } + static Action* death_and_decay(PlayerbotAI* botAI) { return new CastDeathAndDecayAction(botAI); } + static Action* unholy_presence(PlayerbotAI* botAI) { return new CastUnholyPresenceAction(botAI); } + static Action* raise_dead(PlayerbotAI* botAI) { return new CastRaiseDeadAction(botAI); } + static Action* army_of_the_dead(PlayerbotAI* botAI) { return new CastArmyOfTheDeadAction(botAI); } + static Action* summon_gargoyle(PlayerbotAI* botAI) { return new CastSummonGargoyleAction(botAI); } + static Action* anti_magic_shell(PlayerbotAI* botAI) { return new CastAntiMagicShellAction(botAI); } + static Action* anti_magic_zone(PlayerbotAI* botAI) { return new CastAntiMagicZoneAction(botAI); } + static Action* ghoul_frenzy(PlayerbotAI* botAI) { return new CastGhoulFrenzyAction(botAI); } + static Action* corpse_explosion(PlayerbotAI* botAI) { return new CastCorpseExplosionAction(botAI); } + // Frost + static Action* icy_touch(PlayerbotAI* botAI) { return new CastIcyTouchAction(botAI); } + static Action* icy_touch_on_attacker(PlayerbotAI* botAI) { return new CastIcyTouchOnAttackerAction(botAI); } + static Action* obliterate(PlayerbotAI* botAI) { return new CastObliterateAction(botAI); } + static Action* howling_blast(PlayerbotAI* botAI) { return new CastHowlingBlastAction(botAI); } + static Action* frost_strike(PlayerbotAI* botAI) { return new CastFrostStrikeAction(botAI); } + static Action* chains_of_ice(PlayerbotAI* botAI) { return new CastChainsOfIceAction(botAI); } + static Action* rune_strike(PlayerbotAI* botAI) { return new CastRuneStrikeAction(botAI); } + // static Action* icy_clutch(PlayerbotAI* botAI) { return new CastIcyClutchAction(botAI); } + static Action* horn_of_winter(PlayerbotAI* botAI) { return new CastHornOfWinterAction(botAI); } + static Action* killing_machine(PlayerbotAI* botAI) { return new CastKillingMachineAction(botAI); } + static Action* frost_presence(PlayerbotAI* botAI) { return new CastFrostPresenceAction(botAI); } + static Action* deathchill(PlayerbotAI* botAI) { return new CastDeathchillAction(botAI); } + static Action* icebound_fortitude(PlayerbotAI* botAI) { return new CastIceboundFortitudeAction(botAI); } + static Action* mind_freeze(PlayerbotAI* botAI) { return new CastMindFreezeAction(botAI); } + static Action* empower_rune_weapon(PlayerbotAI* botAI) { return new CastEmpowerRuneWeaponAction(botAI); } + static Action* hungering_cold(PlayerbotAI* botAI) { return new CastHungeringColdAction(botAI); } + static Action* unbreakable_armor(PlayerbotAI* botAI) { return new CastUnbreakableArmorAction(botAI); } + static Action* improved_icy_talons(PlayerbotAI* botAI) { return new CastImprovedIcyTalonsAction(botAI); } + // blood + static Action* blood_strike(PlayerbotAI* botAI) { return new CastBloodStrikeAction(botAI); } + static Action* blood_tap(PlayerbotAI* botAI) { return new CastBloodTapAction(botAI); } + static Action* pestilence(PlayerbotAI* botAI) { return new CastPestilenceAction(botAI); } + static Action* strangulate(PlayerbotAI* botAI) { return new CastStrangulateAction(botAI); } + static Action* blood_boil(PlayerbotAI* botAI) { return new CastBloodBoilAction(botAI); } + static Action* heart_strike(PlayerbotAI* botAI) { return new CastHeartStrikeAction(botAI); } + static Action* mark_of_blood(PlayerbotAI* botAI) { return new CastMarkOfBloodAction(botAI); } + static Action* blood_presence(PlayerbotAI* botAI) { return new CastBloodPresenceAction(botAI); } + static Action* rune_tap(PlayerbotAI* botAI) { return new CastRuneTapAction(botAI); } + static Action* vampiric_blood(PlayerbotAI* botAI) { return new CastVampiricBloodAction(botAI); } + static Action* death_pact(PlayerbotAI* botAI) { return new CastDeathPactAction(botAI); } + static Action* death_rune_mastery(PlayerbotAI* botAI) { return new CastDeathRuneMasteryAction(botAI); } + // static Action* hysteria(PlayerbotAI* botAI) { return new CastHysteriaAction(botAI); } + static Action* dancing_rune_weapon(PlayerbotAI* botAI) { return new CastDancingRuneWeaponAction(botAI); } + static Action* dark_command(PlayerbotAI* botAI) { return new CastDarkCommandAction(botAI); } + static Action* mind_freeze_on_enemy_healer(PlayerbotAI* botAI) + { + return new CastMindFreezeOnEnemyHealerAction(botAI); + } }; DKAiObjectContext::DKAiObjectContext(PlayerbotAI* botAI) : AiObjectContext(botAI) diff --git a/src/strategy/deathknight/DKAiObjectContext.h b/src/strategy/deathknight/DKAiObjectContext.h index 86a12951..7729868b 100644 --- a/src/strategy/deathknight/DKAiObjectContext.h +++ b/src/strategy/deathknight/DKAiObjectContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DKAIOBJECTCONTEXT_H @@ -11,8 +12,8 @@ class PlayerbotAI; class DKAiObjectContext : public AiObjectContext { - public: - DKAiObjectContext(PlayerbotAI* botAI); +public: + DKAiObjectContext(PlayerbotAI* botAI); }; #endif diff --git a/src/strategy/deathknight/DKTriggers.cpp b/src/strategy/deathknight/DKTriggers.cpp index 3f7f696e..281ed586 100644 --- a/src/strategy/deathknight/DKTriggers.cpp +++ b/src/strategy/deathknight/DKTriggers.cpp @@ -1,48 +1,59 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DKTriggers.h" + +#include + #include "GenericTriggers.h" #include "Playerbots.h" #include "SharedDefines.h" -#include bool DKPresenceTrigger::IsActive() { Unit* target = GetTarget(); - return !botAI->HasAura("blood presence", target) && !botAI->HasAura("unholy presence", target) && !botAI->HasAura("frost presence", target); + return !botAI->HasAura("blood presence", target) && !botAI->HasAura("unholy presence", target) && + !botAI->HasAura("frost presence", target); } -bool PestilenceGlyphTrigger::IsActive() { - if (!SpellTrigger::IsActive()) { +bool PestilenceGlyphTrigger::IsActive() +{ + if (!SpellTrigger::IsActive()) + { return false; } - if (!bot->HasAura(63334)) { + if (!bot->HasAura(63334)) + { return false; } - Aura *blood_plague = botAI->GetAura("blood plague", GetTarget(), true, true); - Aura *frost_fever = botAI->GetAura("frost fever", GetTarget(), true, true); - if ((blood_plague && blood_plague->GetDuration() <= 3000) || - (frost_fever && frost_fever->GetDuration() <= 3000)) { - return true; + Aura* blood_plague = botAI->GetAura("blood plague", GetTarget(), true, true); + Aura* frost_fever = botAI->GetAura("frost fever", GetTarget(), true, true); + if ((blood_plague && blood_plague->GetDuration() <= 3000) || (frost_fever && frost_fever->GetDuration() <= 3000)) + { + return true; } return false; } -bool HighBloodRuneTrigger::IsActive() { - // bot->Say(std::to_string(bot->GetBaseRune(0)) + "_" + std::to_string(bot->GetRuneCooldown(0)) + " " + std::to_string(bot->GetBaseRune(1)) + "_" + std::to_string(bot->GetRuneCooldown(1)), LANG_UNIVERSAL); +bool HighBloodRuneTrigger::IsActive() +{ + // bot->Say(std::to_string(bot->GetBaseRune(0)) + "_" + std::to_string(bot->GetRuneCooldown(0)) + " " + + // std::to_string(bot->GetBaseRune(1)) + "_" + std::to_string(bot->GetRuneCooldown(1)), LANG_UNIVERSAL); return !bot->GetRuneCooldown(0) && !bot->GetRuneCooldown(1); } -bool DesolationTrigger::IsActive() { +bool DesolationTrigger::IsActive() +{ return bot->HasAura(66817) && !botAI->HasAura("desolation", GetTarget(), false, true, -1, true); } -bool DeathAndDecayCooldownTrigger::IsActive() { +bool DeathAndDecayCooldownTrigger::IsActive() +{ uint32 spellId = AI_VALUE2(uint32, "spell id", name); if (!spellId) return true; - + return bot->HasSpellCooldown(spellId); } \ No newline at end of file diff --git a/src/strategy/deathknight/DKTriggers.h b/src/strategy/deathknight/DKTriggers.h index f9dc88dc..ecbf7964 100644 --- a/src/strategy/deathknight/DKTriggers.h +++ b/src/strategy/deathknight/DKTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DKTRIGGERS_H @@ -15,148 +16,153 @@ BUFF_TRIGGER(ImprovedIcyTalonsTrigger, "improved icy talons"); // DEBUFF_CHECKISOWNER_TRIGGER(PlagueStrikeDebuffTrigger, "blood plague"); class PlagueStrikeDebuffTrigger : public DebuffTrigger { - public: - PlagueStrikeDebuffTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "blood plague", true, .0f) { } +public: + PlagueStrikeDebuffTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "blood plague", true, .0f) {} }; // DEBUFF_CHECKISOWNER_TRIGGER(IcyTouchDebuffTrigger, "frost fever"); class IcyTouchDebuffTrigger : public DebuffTrigger { - public: - IcyTouchDebuffTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "frost fever", true, .0f) { } +public: + IcyTouchDebuffTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "frost fever", true, .0f) {} }; BUFF_TRIGGER(UnbreakableArmorTrigger, "unbreakable armor"); class PlagueStrikeDebuffOnAttackerTrigger : public DebuffOnMeleeAttackerTrigger { - public: - PlagueStrikeDebuffOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnMeleeAttackerTrigger(botAI, "blood plague", true, .0f) { } +public: + PlagueStrikeDebuffOnAttackerTrigger(PlayerbotAI* botAI) + : DebuffOnMeleeAttackerTrigger(botAI, "blood plague", true, .0f) + { + } }; class IcyTouchDebuffOnAttackerTrigger : public DebuffOnMeleeAttackerTrigger { - public: - IcyTouchDebuffOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnMeleeAttackerTrigger(botAI, "frost fever", true, .0f) { } +public: + IcyTouchDebuffOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnMeleeAttackerTrigger(botAI, "frost fever", true, .0f) + { + } }; class DKPresenceTrigger : public BuffTrigger { - public: - DKPresenceTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "blood presence") { } +public: + DKPresenceTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "blood presence") {} - bool IsActive() override; + bool IsActive() override; }; class BloodTapTrigger : public BuffTrigger { - public: - BloodTapTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "blood tap") { } +public: + BloodTapTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "blood tap") {} }; class RaiseDeadTrigger : public BuffTrigger { - public: - RaiseDeadTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "raise dead") { } +public: + RaiseDeadTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "raise dead") {} }; class RuneStrikeTrigger : public SpellCanBeCastTrigger { - public: - RuneStrikeTrigger(PlayerbotAI* botAI) : SpellCanBeCastTrigger(botAI, "rune strike") { } +public: + RuneStrikeTrigger(PlayerbotAI* botAI) : SpellCanBeCastTrigger(botAI, "rune strike") {} }; class DeathCoilTrigger : public SpellCanBeCastTrigger { - public: - DeathCoilTrigger(PlayerbotAI* botAI) : SpellCanBeCastTrigger(botAI, "death coil") { } +public: + DeathCoilTrigger(PlayerbotAI* botAI) : SpellCanBeCastTrigger(botAI, "death coil") {} }; class PestilenceGlyphTrigger : public SpellTrigger { - public: - PestilenceGlyphTrigger(PlayerbotAI* botAI) : SpellTrigger(botAI, "pestilence") { } - virtual bool IsActive() override; +public: + PestilenceGlyphTrigger(PlayerbotAI* botAI) : SpellTrigger(botAI, "pestilence") {} + virtual bool IsActive() override; }; class BloodStrikeTrigger : public DebuffTrigger { - public: - BloodStrikeTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "blood strike", 1, true) { } +public: + BloodStrikeTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "blood strike", 1, true) {} }; class HowlingBlastTrigger : public DebuffTrigger { - public: - HowlingBlastTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "howling blast", 1, true) { } +public: + HowlingBlastTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "howling blast", 1, true) {} }; class MindFreezeInterruptSpellTrigger : public InterruptSpellTrigger { - public: - MindFreezeInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "mind freeze") { } +public: + MindFreezeInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "mind freeze") {} }; class StrangulateInterruptSpellTrigger : public InterruptSpellTrigger { - public: - StrangulateInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "strangulate") { } +public: + StrangulateInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "strangulate") {} }; class KillingMachineTrigger : public BoostTrigger { - public: - KillingMachineTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "killing machine") { } +public: + KillingMachineTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "killing machine") {} }; class MindFreezeOnEnemyHealerTrigger : public InterruptEnemyHealerTrigger { - public: - MindFreezeOnEnemyHealerTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "mind freeze") { } +public: + MindFreezeOnEnemyHealerTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "mind freeze") {} }; class ChainsOfIceSnareTrigger : public SnareTargetTrigger { - public: - ChainsOfIceSnareTrigger(PlayerbotAI* botAI) : SnareTargetTrigger(botAI, "chains of ice") { } +public: + ChainsOfIceSnareTrigger(PlayerbotAI* botAI) : SnareTargetTrigger(botAI, "chains of ice") {} }; class StrangulateOnEnemyHealerTrigger : public InterruptEnemyHealerTrigger { - public: - StrangulateOnEnemyHealerTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "strangulate") { } +public: + StrangulateOnEnemyHealerTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "strangulate") {} }; class HighBloodRuneTrigger : public Trigger { - public: - HighBloodRuneTrigger(PlayerbotAI* botAI) : Trigger(botAI, "high blood rune") { } - bool IsActive() override; +public: + HighBloodRuneTrigger(PlayerbotAI* botAI) : Trigger(botAI, "high blood rune") {} + bool IsActive() override; }; class FreezingFogTrigger : public HasAuraTrigger { - public: - FreezingFogTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "freezing fog") { } +public: + FreezingFogTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "freezing fog") {} }; class DesolationTrigger : public BuffTrigger { - public: - DesolationTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "desolation") { } - bool IsActive() override; +public: + DesolationTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "desolation") {} + bool IsActive() override; }; class DeathAndDecayCooldownTrigger : public SpellCooldownTrigger { - public: - DeathAndDecayCooldownTrigger(PlayerbotAI* botAI) : SpellCooldownTrigger(botAI, "death and decay") { } - bool IsActive() override; +public: + DeathAndDecayCooldownTrigger(PlayerbotAI* botAI) : SpellCooldownTrigger(botAI, "death and decay") {} + bool IsActive() override; }; class ArmyOfTheDeadTrigger : public BoostTrigger { - public: - ArmyOfTheDeadTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "army of the dead") { } +public: + ArmyOfTheDeadTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "army of the dead") {} }; #endif diff --git a/src/strategy/deathknight/FrostDKStrategy.cpp b/src/strategy/deathknight/FrostDKStrategy.cpp index fd886226..87d12b17 100644 --- a/src/strategy/deathknight/FrostDKStrategy.cpp +++ b/src/strategy/deathknight/FrostDKStrategy.cpp @@ -1,105 +1,109 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "FrostDKStrategy.h" + #include "Playerbots.h" class FrostDKStrategyActionNodeFactory : public NamedObjectFactory { - public: - FrostDKStrategyActionNodeFactory() - { - creators["icy touch"] = &icy_touch; - creators["obliterate"] = &obliterate; - creators["howling blast"] = &howling_blast; - creators["frost strike"] = &frost_strike; - //creators["chains of ice"] = &chains_of_ice; - creators["rune strike"] = &rune_strike; - //creators["icy clutch"] = &icy_clutch; - //creators["horn of winter"] = &horn_of_winter; - //creators["killing machine"] = &killing_machine; - //creators["frost presence"] = &frost_presence; - //creators["deathchill"] = &deathchill; - //creators["icebound fortitude"] = &icebound_fortitude; - //creators["mind freeze"] = &mind_freeze; - //creators["hungering cold"] = &hungering_cold; - //creators["unbreakable armor"] = &unbreakable_armor; - //creators["improved icy talons"] = &improved_icy_talons; - } +public: + FrostDKStrategyActionNodeFactory() + { + creators["icy touch"] = &icy_touch; + creators["obliterate"] = &obliterate; + creators["howling blast"] = &howling_blast; + creators["frost strike"] = &frost_strike; + // creators["chains of ice"] = &chains_of_ice; + creators["rune strike"] = &rune_strike; + // creators["icy clutch"] = &icy_clutch; + // creators["horn of winter"] = &horn_of_winter; + // creators["killing machine"] = &killing_machine; + // creators["frost presence"] = &frost_presence; + // creators["deathchill"] = &deathchill; + // creators["icebound fortitude"] = &icebound_fortitude; + // creators["mind freeze"] = &mind_freeze; + // creators["hungering cold"] = &hungering_cold; + // creators["unbreakable armor"] = &unbreakable_armor; + // creators["improved icy talons"] = &improved_icy_talons; + } - private: - static ActionNode* icy_touch([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("icy touch", - /*P*/ NextAction::array(0, new NextAction("blood presence"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } +private: + static ActionNode* icy_touch([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("icy touch", + /*P*/ NextAction::array(0, new NextAction("blood presence"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* obliterate([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("obliterate", - /*P*/ NextAction::array(0, new NextAction("blood presence"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* obliterate([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("obliterate", + /*P*/ NextAction::array(0, new NextAction("blood presence"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* rune_strike([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("rune strike", - /*P*/ NextAction::array(0, new NextAction("blood presence"), nullptr), - /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), - /*C*/ nullptr); - } + static ActionNode* rune_strike([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("rune strike", + /*P*/ NextAction::array(0, new NextAction("blood presence"), nullptr), + /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), + /*C*/ nullptr); + } - static ActionNode* frost_strike([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("frost strike", - /*P*/ NextAction::array(0, new NextAction("blood presence"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* frost_strike([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("frost strike", + /*P*/ NextAction::array(0, new NextAction("blood presence"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* howling_blast([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("howling blast", - /*P*/ NextAction::array(0, new NextAction("blood presence"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* howling_blast([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("howling blast", + /*P*/ NextAction::array(0, new NextAction("blood presence"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } }; FrostDKStrategy::FrostDKStrategy(PlayerbotAI* botAI) : GenericDKStrategy(botAI) { - actionNodeFactories.Add(new FrostDKStrategyActionNodeFactory()); + actionNodeFactories.Add(new FrostDKStrategyActionNodeFactory()); } NextAction** FrostDKStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("obliterate", ACTION_DEFAULT + 0.5f), - new NextAction("frost strike", ACTION_DEFAULT + 0.4f), - // new NextAction("death strike", ACTION_NORMAL + 3), - new NextAction("empower rune weapon", ACTION_DEFAULT + 0.2f), - new NextAction("horn of winter", ACTION_DEFAULT + 0.1f), - new NextAction("melee", ACTION_DEFAULT), - NULL - ); + return NextAction::array( + 0, new NextAction("obliterate", ACTION_DEFAULT + 0.5f), new NextAction("frost strike", ACTION_DEFAULT + 0.4f), + // new NextAction("death strike", ACTION_NORMAL + 3), + new NextAction("empower rune weapon", ACTION_DEFAULT + 0.2f), + new NextAction("horn of winter", ACTION_DEFAULT + 0.1f), new NextAction("melee", ACTION_DEFAULT), NULL); } void FrostDKStrategy::InitTriggers(std::vector& triggers) { GenericDKStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("army of the dead", NextAction::array(0, new NextAction("army of the dead", ACTION_HIGH + 6), nullptr))); - triggers.push_back(new TriggerNode("unbreakable armor", NextAction::array(0, new NextAction("unbreakable armor", ACTION_NORMAL + 4), nullptr))); - triggers.push_back(new TriggerNode("high blood rune", NextAction::array(0, new NextAction("blood strike", ACTION_NORMAL + 1), nullptr))); - triggers.push_back(new TriggerNode("freezing fog", NextAction::array(0, new NextAction("howling blast", ACTION_HIGH + 1), nullptr))); - - // triggers.push_back(new TriggerNode("empower rune weapon", NextAction::array(0, new NextAction("empower rune weapon", ACTION_NORMAL + 4), nullptr))); + triggers.push_back(new TriggerNode( + "army of the dead", NextAction::array(0, new NextAction("army of the dead", ACTION_HIGH + 6), nullptr))); + triggers.push_back(new TriggerNode( + "unbreakable armor", NextAction::array(0, new NextAction("unbreakable armor", ACTION_NORMAL + 4), nullptr))); + triggers.push_back(new TriggerNode( + "high blood rune", NextAction::array(0, new NextAction("blood strike", ACTION_NORMAL + 1), nullptr))); + triggers.push_back(new TriggerNode( + "freezing fog", NextAction::array(0, new NextAction("howling blast", ACTION_HIGH + 1), nullptr))); + + // triggers.push_back(new TriggerNode("empower rune weapon", NextAction::array(0, new NextAction("empower rune + // weapon", ACTION_NORMAL + 4), nullptr))); } void FrostDKAoeStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("howling blast", ACTION_HIGH + 4), nullptr))); + triggers.push_back( + new TriggerNode("medium aoe", NextAction::array(0, new NextAction("howling blast", ACTION_HIGH + 4), nullptr))); } diff --git a/src/strategy/deathknight/FrostDKStrategy.h b/src/strategy/deathknight/FrostDKStrategy.h index 5428a91d..3a4b6e72 100644 --- a/src/strategy/deathknight/FrostDKStrategy.h +++ b/src/strategy/deathknight/FrostDKStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_FROSTDKSTRATEGY_H @@ -11,22 +12,22 @@ class PlayerbotAI; class FrostDKStrategy : public GenericDKStrategy { - public: - FrostDKStrategy(PlayerbotAI* botAI); +public: + FrostDKStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "frost"; } - NextAction** getDefaultActions() override; - uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_MELEE; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "frost"; } + NextAction** getDefaultActions() override; + uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_MELEE; } }; class FrostDKAoeStrategy : public CombatStrategy { - public: - FrostDKAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + FrostDKAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "frost aoe"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "frost aoe"; } }; #endif diff --git a/src/strategy/deathknight/GenericDKNonCombatStrategy.cpp b/src/strategy/deathknight/GenericDKNonCombatStrategy.cpp index e648bec7..2a696322 100644 --- a/src/strategy/deathknight/GenericDKNonCombatStrategy.cpp +++ b/src/strategy/deathknight/GenericDKNonCombatStrategy.cpp @@ -1,35 +1,37 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericDKNonCombatStrategy.h" + #include "Playerbots.h" class GenericDKNonCombatStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericDKNonCombatStrategyActionNodeFactory() - { - creators["bone shield"] = &bone_shield; - creators["horn of winter"] = &horn_of_winter; - } +public: + GenericDKNonCombatStrategyActionNodeFactory() + { + creators["bone shield"] = &bone_shield; + creators["horn of winter"] = &horn_of_winter; + } - private: - static ActionNode* bone_shield([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("bone shield", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } +private: + static ActionNode* bone_shield([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("bone shield", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* horn_of_winter([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("horn of winter", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* horn_of_winter([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("horn of winter", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } }; GenericDKNonCombatStrategy::GenericDKNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) @@ -41,13 +43,18 @@ void GenericDKNonCombatStrategy::InitTriggers(std::vector& trigger { NonCombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("no pet", NextAction::array(0, new NextAction("raise dead", ACTION_NORMAL + 1), nullptr))); - triggers.push_back(new TriggerNode("horn of winter", NextAction::array(0, new NextAction("horn of winter", 21.0f), nullptr))); - triggers.push_back(new TriggerNode("bone shield", NextAction::array(0, new NextAction("bone shield", 21.0f), nullptr))); - triggers.push_back(new TriggerNode("has pet", NextAction::array(0, new NextAction("toggle pet spell", 11.0f), NULL))); + triggers.push_back( + new TriggerNode("no pet", NextAction::array(0, new NextAction("raise dead", ACTION_NORMAL + 1), nullptr))); + triggers.push_back( + new TriggerNode("horn of winter", NextAction::array(0, new NextAction("horn of winter", 21.0f), nullptr))); + triggers.push_back( + new TriggerNode("bone shield", NextAction::array(0, new NextAction("bone shield", 21.0f), nullptr))); + triggers.push_back( + new TriggerNode("has pet", NextAction::array(0, new NextAction("toggle pet spell", 11.0f), NULL))); } void DKBuffDpsStrategy::InitTriggers(std::vector& triggers) { - // triggers.push_back(new TriggerNode("improved icy talons", NextAction::array(0, new NextAction("improved icy talons", 19.0f), nullptr))); + // triggers.push_back(new TriggerNode("improved icy talons", NextAction::array(0, new NextAction("improved icy + // talons", 19.0f), nullptr))); } diff --git a/src/strategy/deathknight/GenericDKNonCombatStrategy.h b/src/strategy/deathknight/GenericDKNonCombatStrategy.h index b83336a5..f94be4c9 100644 --- a/src/strategy/deathknight/GenericDKNonCombatStrategy.h +++ b/src/strategy/deathknight/GenericDKNonCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICDKNONCOMBATSTRATEGY_H @@ -12,20 +13,20 @@ class PlayerbotAI; class GenericDKNonCombatStrategy : public NonCombatStrategy { - public: - GenericDKNonCombatStrategy(PlayerbotAI* botAI); +public: + GenericDKNonCombatStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "nc"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "nc"; } + void InitTriggers(std::vector& triggers) override; }; class DKBuffDpsStrategy : public Strategy { - public: - DKBuffDpsStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + DKBuffDpsStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "bdps"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bdps"; } }; #endif diff --git a/src/strategy/deathknight/GenericDKStrategy.cpp b/src/strategy/deathknight/GenericDKStrategy.cpp index 3e26cae2..23693bcf 100644 --- a/src/strategy/deathknight/GenericDKStrategy.cpp +++ b/src/strategy/deathknight/GenericDKStrategy.cpp @@ -3,157 +3,157 @@ */ #include "GenericDKStrategy.h" + #include "DKAiObjectContext.h" #include "Playerbots.h" class GenericDKStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericDKStrategyActionNodeFactory() - { - //blood - //creators["rune tap"] = &rune_tap; cd - //creators["vampiric blood"] = &vampiric_blood; - //creators["death pact"] = &death_pact; - //creators["hysteria"] = &hysteria; boost party - //creators["dancing rune weapon"] = &dancing_rune_weapon; //cd - //creators["dark command"] = &dark_command; taunt +public: + GenericDKStrategyActionNodeFactory() + { + // blood + // creators["rune tap"] = &rune_tap; cd + // creators["vampiric blood"] = &vampiric_blood; + // creators["death pact"] = &death_pact; + // creators["hysteria"] = &hysteria; boost party + // creators["dancing rune weapon"] = &dancing_rune_weapon; //cd + // creators["dark command"] = &dark_command; taunt - //frost - //creators["chains of ice"] = &chains_of_ice; - //creators["icy clutch"] = &icy_clutch; - creators["horn of winter"] = &horn_of_winter; - creators["killing machine"] = &killing_machine; // buff - //creators["deathchill"] = &deathchill; //boost - creators["icebound fortitude"] = &icebound_fortitude; - //creators["mind freeze"] = &mind_freeze; interrupt - //creators["empower rune weapon"] = &empower_rune_weapon; boost - //creators["hungering cold"] = &hungering_cold; snare - //creators["unbreakable armor"] = &unbreakable_armor; boost +cd - //creators["improved icy talons"] = &improved_icy_talons; boost party + // frost + // creators["chains of ice"] = &chains_of_ice; + // creators["icy clutch"] = &icy_clutch; + creators["horn of winter"] = &horn_of_winter; + creators["killing machine"] = &killing_machine; // buff + // creators["deathchill"] = &deathchill; //boost + creators["icebound fortitude"] = &icebound_fortitude; + // creators["mind freeze"] = &mind_freeze; interrupt + // creators["empower rune weapon"] = &empower_rune_weapon; boost + // creators["hungering cold"] = &hungering_cold; snare + // creators["unbreakable armor"] = &unbreakable_armor; boost +cd + // creators["improved icy talons"] = &improved_icy_talons; boost party - //unholy - creators["death and decay"] = &death_and_decay; - //creators["raise dead"] = &raise_dead; - //creators["army of the dead"] = &army of the dead; - //creators["summon gargoyle"] = &army of the dead; - //creators["anti magic shell"] = &anti_magic_shell; cd - creators["anti magic zone"] = &anti_magic_zone; - //creators["ghoul frenzy"] = &ghoul_frenzy; - creators["corpse explosion"] = &corpse_explosion; - creators["bone shield"] = &bone_shield; - creators["heart strike"] = &heart_strike; - creators["death grip"] = &death_grip; - creators["plague strike"] = &plague_strike; - creators["pestilence"] = &pestilence; - creators["icy touch"] = &icy_touch; + // unholy + creators["death and decay"] = &death_and_decay; + // creators["raise dead"] = &raise_dead; + // creators["army of the dead"] = &army of the dead; + // creators["summon gargoyle"] = &army of the dead; + // creators["anti magic shell"] = &anti_magic_shell; cd + creators["anti magic zone"] = &anti_magic_zone; + // creators["ghoul frenzy"] = &ghoul_frenzy; + creators["corpse explosion"] = &corpse_explosion; + creators["bone shield"] = &bone_shield; + creators["heart strike"] = &heart_strike; + creators["death grip"] = &death_grip; + creators["plague strike"] = &plague_strike; + creators["pestilence"] = &pestilence; + creators["icy touch"] = &icy_touch; + } - } - private: - static ActionNode* death_coil([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("death coil", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } +private: + static ActionNode* death_coil([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("death coil", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* death_grip([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("death grip", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("icy touch"), nullptr), - /*C*/ nullptr); - } + static ActionNode* death_grip([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("death grip", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("icy touch"), nullptr), + /*C*/ nullptr); + } - static ActionNode* plague_strike([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("plague strike", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* plague_strike([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("plague strike", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* icy_touch([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("icy touch", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* icy_touch([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("icy touch", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* heart_strike([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("heart strike", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* heart_strike([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("heart strike", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* pestilence([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("pestilence", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* pestilence([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("pestilence", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* horn_of_winter([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("horn of winter", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* horn_of_winter([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("horn of winter", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* bone_shield([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("bone shield", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* bone_shield([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("bone shield", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* killing_machine([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("killing machine", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("improved icy talons"), nullptr), - /*C*/ nullptr); - } + static ActionNode* killing_machine([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("killing machine", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("improved icy talons"), nullptr), + /*C*/ nullptr); + } - static ActionNode* corpse_explosion([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("corpse explosion", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* corpse_explosion([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("corpse explosion", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* death_and_decay([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("death and decay", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("blood tap"), nullptr), - /*C*/ nullptr); - } + static ActionNode* death_and_decay([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("death and decay", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("blood tap"), nullptr), + /*C*/ nullptr); + } - static ActionNode* anti_magic_zone([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("anti magic zone", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("anti magic shell"), nullptr), - /*C*/ nullptr); - } + static ActionNode* anti_magic_zone([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("anti magic zone", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("anti magic shell"), nullptr), + /*C*/ nullptr); + } - static ActionNode* icebound_fortitude([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("icebound fortitude", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - - } + static ActionNode* icebound_fortitude([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("icebound fortitude", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } }; GenericDKStrategy::GenericDKStrategy(PlayerbotAI* botAI) : MeleeCombatStrategy(botAI) @@ -163,34 +163,53 @@ GenericDKStrategy::GenericDKStrategy(PlayerbotAI* botAI) : MeleeCombatStrategy(b void GenericDKStrategy::InitTriggers(std::vector& triggers) { - MeleeCombatStrategy::InitTriggers(triggers); + MeleeCombatStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("high aoe", NextAction::array(0, new NextAction("anti magic shell", ACTION_NORMAL + 3), nullptr))); - // triggers.push_back(new TriggerNode("death coil", NextAction::array(0, new NextAction("death coil", ACTION_NORMAL + 3), nullptr))); - // triggers.push_back(new TriggerNode("critical aoe heal", NextAction::array(0, new NextAction("anti magic zone", ACTION_EMERGENCY + 1), nullptr))); - triggers.push_back(new TriggerNode("no pet", NextAction::array(0, new NextAction("raise dead", ACTION_NORMAL + 5), nullptr))); - triggers.push_back(new TriggerNode("mind freeze", NextAction::array(0, new NextAction("mind freeze", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("mind freeze on enemy healer", NextAction::array(0, new NextAction("mind freeze on enemy healer", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("bone shield", NextAction::array(0, new NextAction("bone shield", ACTION_NORMAL + 1), nullptr))); - triggers.push_back(new TriggerNode("horn of winter", NextAction::array(0, new NextAction("horn of winter", ACTION_NORMAL + 1), nullptr))); - // triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("reach melee", ACTION_NORMAL + 8), nullptr))); - triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("icebound fortitude", ACTION_HIGH + 5), new NextAction("rune tap", ACTION_HIGH + 4), nullptr))); - triggers.push_back(new TriggerNode("medium health", NextAction::array(0, new NextAction("rune tap", ACTION_NORMAL + 4), new NextAction("death strike", ACTION_NORMAL + 3), nullptr))); - triggers.push_back(new TriggerNode("icy touch", NextAction::array(0, new NextAction("icy touch", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode("icy touch on attacker", NextAction::array(0, new NextAction("icy touch on attacker", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("plague strike", NextAction::array(0, new NextAction("plague strike", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode("plague strike on attacker", NextAction::array(0, new NextAction("plague strike on attacker", ACTION_HIGH + 1), nullptr))); - // triggers.push_back(new TriggerNode("high aoe", - // NextAction::array(0, - // new NextAction("death and decay", ACTION_NORMAL + 5), - // new NextAction("pestilence", ACTION_NORMAL + 4), - // new NextAction("blood boil", ACTION_NORMAL + 3), nullptr))); - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, - new NextAction("death and decay", ACTION_HIGH + 9), - new NextAction("pestilence", ACTION_NORMAL + 4), - new NextAction("blood boil", ACTION_NORMAL + 3), nullptr))); - // triggers.push_back(new TriggerNode("light aoe", NextAction::array(0, - // new NextAction("pestilence", ACTION_NORMAL + 4), - // nullptr))); - triggers.push_back(new TriggerNode("pestilence glyph", NextAction::array(0, new NextAction("pestilence", ACTION_HIGH + 9), NULL))); + // triggers.push_back(new TriggerNode("high aoe", NextAction::array(0, new NextAction("anti magic shell", + // ACTION_NORMAL + 3), nullptr))); triggers.push_back(new TriggerNode("death coil", NextAction::array(0, new + // NextAction("death coil", ACTION_NORMAL + 3), nullptr))); triggers.push_back(new TriggerNode("critical aoe heal", + // NextAction::array(0, new NextAction("anti magic zone", ACTION_EMERGENCY + 1), nullptr))); + triggers.push_back( + new TriggerNode("no pet", NextAction::array(0, new NextAction("raise dead", ACTION_NORMAL + 5), nullptr))); + triggers.push_back( + new TriggerNode("mind freeze", NextAction::array(0, new NextAction("mind freeze", ACTION_HIGH + 1), nullptr))); + triggers.push_back( + new TriggerNode("mind freeze on enemy healer", + NextAction::array(0, new NextAction("mind freeze on enemy healer", ACTION_HIGH + 1), nullptr))); + triggers.push_back(new TriggerNode( + "bone shield", NextAction::array(0, new NextAction("bone shield", ACTION_NORMAL + 1), nullptr))); + triggers.push_back(new TriggerNode( + "horn of winter", NextAction::array(0, new NextAction("horn of winter", ACTION_NORMAL + 1), nullptr))); + // triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("reach melee", + // ACTION_NORMAL + 8), nullptr))); + triggers.push_back( + new TriggerNode("low health", NextAction::array(0, new NextAction("icebound fortitude", ACTION_HIGH + 5), + new NextAction("rune tap", ACTION_HIGH + 4), nullptr))); + triggers.push_back(new TriggerNode("medium health", + NextAction::array(0, new NextAction("rune tap", ACTION_NORMAL + 4), + new NextAction("death strike", ACTION_NORMAL + 3), nullptr))); + triggers.push_back( + new TriggerNode("icy touch", NextAction::array(0, new NextAction("icy touch", ACTION_HIGH + 2), nullptr))); + triggers.push_back( + new TriggerNode("icy touch on attacker", + NextAction::array(0, new NextAction("icy touch on attacker", ACTION_HIGH + 1), nullptr))); + triggers.push_back(new TriggerNode( + "plague strike", NextAction::array(0, new NextAction("plague strike", ACTION_HIGH + 2), nullptr))); + triggers.push_back( + new TriggerNode("plague strike on attacker", + NextAction::array(0, new NextAction("plague strike on attacker", ACTION_HIGH + 1), nullptr))); + // triggers.push_back(new TriggerNode("high aoe", + // NextAction::array(0, + // new NextAction("death and decay", ACTION_NORMAL + 5), + // new NextAction("pestilence", ACTION_NORMAL + 4), + // new NextAction("blood boil", ACTION_NORMAL + 3), nullptr))); + triggers.push_back( + new TriggerNode("medium aoe", NextAction::array(0, new NextAction("death and decay", ACTION_HIGH + 9), + new NextAction("pestilence", ACTION_NORMAL + 4), + new NextAction("blood boil", ACTION_NORMAL + 3), nullptr))); + // triggers.push_back(new TriggerNode("light aoe", NextAction::array(0, + // new NextAction("pestilence", ACTION_NORMAL + 4), + // nullptr))); + triggers.push_back( + new TriggerNode("pestilence glyph", NextAction::array(0, new NextAction("pestilence", ACTION_HIGH + 9), NULL))); } diff --git a/src/strategy/deathknight/GenericDKStrategy.h b/src/strategy/deathknight/GenericDKStrategy.h index 6bf6f8c0..4169d611 100644 --- a/src/strategy/deathknight/GenericDKStrategy.h +++ b/src/strategy/deathknight/GenericDKStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICDKSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class GenericDKStrategy : public MeleeCombatStrategy { - public: - GenericDKStrategy(PlayerbotAI* botAI); +public: + GenericDKStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "DK"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "DK"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/deathknight/UnholyDKStrategy.cpp b/src/strategy/deathknight/UnholyDKStrategy.cpp index 8edab828..a5174f36 100644 --- a/src/strategy/deathknight/UnholyDKStrategy.cpp +++ b/src/strategy/deathknight/UnholyDKStrategy.cpp @@ -3,64 +3,65 @@ */ #include "UnholyDKStrategy.h" + #include "Playerbots.h" class UnholyDKStrategyActionNodeFactory : public NamedObjectFactory { - public: - UnholyDKStrategyActionNodeFactory() - { - // Unholy - //creators["bone shield"] = &bone_shield; - //creators["plague strike"] = &plague_strike; - //creators["death grip"] = &death_grip; - //creators["death coil"] = &death_coil; - creators["death strike"] = &death_strike; - //creators["unholy blight"] = &unholy_blight; - creators["scourge strike"] = &scourge_strike; - //creators["death and decay"] = &death_and_decay; - //creators["unholy pressence"] = &unholy_pressence; - //creators["raise dead"] = &raise_dead; - //creators["army of the dead"] = &army of the dead; - //creators["summon gargoyle"] = &army of the dead; - //creators["anti magic shell"] = &anti_magic_shell; - //creators["anti magic zone"] = &anti_magic_zone; - //creators["ghoul frenzy"] = &ghoul_frenzy; - creators["corpse explosion"] = &corpse_explosion; - creators["icy touch"] = &icy_touch; - } +public: + UnholyDKStrategyActionNodeFactory() + { + // Unholy + // creators["bone shield"] = &bone_shield; + // creators["plague strike"] = &plague_strike; + // creators["death grip"] = &death_grip; + // creators["death coil"] = &death_coil; + creators["death strike"] = &death_strike; + // creators["unholy blight"] = &unholy_blight; + creators["scourge strike"] = &scourge_strike; + // creators["death and decay"] = &death_and_decay; + // creators["unholy pressence"] = &unholy_pressence; + // creators["raise dead"] = &raise_dead; + // creators["army of the dead"] = &army of the dead; + // creators["summon gargoyle"] = &army of the dead; + // creators["anti magic shell"] = &anti_magic_shell; + // creators["anti magic zone"] = &anti_magic_zone; + // creators["ghoul frenzy"] = &ghoul_frenzy; + creators["corpse explosion"] = &corpse_explosion; + creators["icy touch"] = &icy_touch; + } - private: - static ActionNode* death_strike([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("death strike", - /*P*/ NextAction::array(0, new NextAction("unholy presence"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } +private: + static ActionNode* death_strike([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("death strike", + /*P*/ NextAction::array(0, new NextAction("unholy presence"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* corpse_explosion([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("corpse explosion", - /*P*/ NextAction::array(0, new NextAction("unholy presence"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* corpse_explosion([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("corpse explosion", + /*P*/ NextAction::array(0, new NextAction("unholy presence"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* scourge_strike([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("scourge strike", - /*P*/ NextAction::array(0, new NextAction("unholy presence"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* icy_touch([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("icy touch", - /*P*/ NextAction::array(0, new NextAction("unholy presence"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* scourge_strike([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("scourge strike", + /*P*/ NextAction::array(0, new NextAction("unholy presence"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* icy_touch([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("icy touch", + /*P*/ NextAction::array(0, new NextAction("unholy presence"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } }; UnholyDKStrategy::UnholyDKStrategy(PlayerbotAI* botAI) : GenericDKStrategy(botAI) @@ -68,40 +69,39 @@ UnholyDKStrategy::UnholyDKStrategy(PlayerbotAI* botAI) : GenericDKStrategy(botAI actionNodeFactories.Add(new UnholyDKStrategyActionNodeFactory()); } - NextAction** UnholyDKStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("death and decay", ACTION_DEFAULT + 0.5f), - new NextAction("horn of winter", ACTION_DEFAULT + 0.4f), - new NextAction("summon gargoyle", ACTION_DEFAULT + 0.3f), - new NextAction("death coil", ACTION_DEFAULT + 0.2f), - new NextAction("scourge strike", ACTION_NORMAL + 0.1f), - new NextAction("melee", ACTION_DEFAULT), - nullptr); + return NextAction::array( + 0, new NextAction("death and decay", ACTION_DEFAULT + 0.5f), + new NextAction("horn of winter", ACTION_DEFAULT + 0.4f), + new NextAction("summon gargoyle", ACTION_DEFAULT + 0.3f), new NextAction("death coil", ACTION_DEFAULT + 0.2f), + new NextAction("scourge strike", ACTION_NORMAL + 0.1f), new NextAction("melee", ACTION_DEFAULT), nullptr); } void UnholyDKStrategy::InitTriggers(std::vector& triggers) { GenericDKStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction(, ACTION_NORMAL + 2), nullptr))); - triggers.push_back(new TriggerNode("army of the dead", NextAction::array(0, new NextAction("army of the dead", ACTION_HIGH + 6), nullptr))); - triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("death pact", ACTION_HIGH + 5), nullptr))); - triggers.push_back(new TriggerNode("no desolation", NextAction::array(0, new NextAction("blood strike", ACTION_HIGH + 4), nullptr))); - triggers.push_back(new TriggerNode("death and decay cooldown", - NextAction::array(0, - new NextAction("ghoul frenzy", ACTION_NORMAL + 5.0f), - new NextAction("scourge strike", ACTION_NORMAL + 4.0f), - new NextAction("blood boil", ACTION_NORMAL + 3.0f), - new NextAction("icy touch", ACTION_NORMAL + 2.0f), - new NextAction("plague strike", ACTION_NORMAL + 1.0f), - nullptr))); + // triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction(, ACTION_NORMAL + 2), nullptr))); + triggers.push_back(new TriggerNode( + "army of the dead", NextAction::array(0, new NextAction("army of the dead", ACTION_HIGH + 6), nullptr))); + triggers.push_back(new TriggerNode("critical health", + NextAction::array(0, new NextAction("death pact", ACTION_HIGH + 5), nullptr))); + triggers.push_back(new TriggerNode("no desolation", + NextAction::array(0, new NextAction("blood strike", ACTION_HIGH + 4), nullptr))); + triggers.push_back(new TriggerNode( + "death and decay cooldown", NextAction::array(0, new NextAction("ghoul frenzy", ACTION_NORMAL + 5.0f), + new NextAction("scourge strike", ACTION_NORMAL + 4.0f), + new NextAction("blood boil", ACTION_NORMAL + 3.0f), + new NextAction("icy touch", ACTION_NORMAL + 2.0f), + new NextAction("plague strike", ACTION_NORMAL + 1.0f), nullptr))); } void UnholyDKAoeStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("loot available", NextAction::array(0, new NextAction("corpse explosion", ACTION_NORMAL + 1), nullptr))); - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("death and decay", ACTION_NORMAL + 3), - new NextAction("corpse explosion", ACTION_NORMAL + 3), nullptr))); + triggers.push_back(new TriggerNode( + "loot available", NextAction::array(0, new NextAction("corpse explosion", ACTION_NORMAL + 1), nullptr))); + triggers.push_back(new TriggerNode( + "medium aoe", NextAction::array(0, new NextAction("death and decay", ACTION_NORMAL + 3), + new NextAction("corpse explosion", ACTION_NORMAL + 3), nullptr))); } diff --git a/src/strategy/deathknight/UnholyDKStrategy.h b/src/strategy/deathknight/UnholyDKStrategy.h index 7e190509..3e69bc09 100644 --- a/src/strategy/deathknight/UnholyDKStrategy.h +++ b/src/strategy/deathknight/UnholyDKStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_UNHOLYDKSTRATEGY_H @@ -11,22 +12,22 @@ class PlayerbotAI; class UnholyDKStrategy : public GenericDKStrategy { - public: - UnholyDKStrategy(PlayerbotAI* botAI); +public: + UnholyDKStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "unholy"; } - NextAction** getDefaultActions() override; - uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_MELEE; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "unholy"; } + NextAction** getDefaultActions() override; + uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_MELEE; } }; class UnholyDKAoeStrategy : public CombatStrategy { - public: - UnholyDKAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + UnholyDKAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "unholy aoe"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "unholy aoe"; } }; #endif diff --git a/src/strategy/druid/BearTankDruidStrategy.cpp b/src/strategy/druid/BearTankDruidStrategy.cpp index ab74c3f2..e732357d 100644 --- a/src/strategy/druid/BearTankDruidStrategy.cpp +++ b/src/strategy/druid/BearTankDruidStrategy.cpp @@ -1,135 +1,137 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "BearTankDruidStrategy.h" + #include "Playerbots.h" class BearTankDruidStrategyActionNodeFactory : public NamedObjectFactory { - public: - BearTankDruidStrategyActionNodeFactory() - { - creators["melee"] = &melee; - creators["feral charge - bear"] = &feral_charge_bear; - creators["swipe (bear)"] = &swipe_bear; - creators["faerie fire (feral)"] = &faerie_fire_feral; - creators["bear form"] = &bear_form; - creators["dire bear form"] = &dire_bear_form; - creators["mangle (bear)"] = &mangle_bear; - creators["maul"] = &maul; - creators["bash"] = &bash; - creators["swipe"] = &swipe; - creators["lacerate"] = &lacerate; - creators["demoralizing roar"] = &demoralizing_roar; - creators["taunt spell"] = &growl; - } +public: + BearTankDruidStrategyActionNodeFactory() + { + creators["melee"] = &melee; + creators["feral charge - bear"] = &feral_charge_bear; + creators["swipe (bear)"] = &swipe_bear; + creators["faerie fire (feral)"] = &faerie_fire_feral; + creators["bear form"] = &bear_form; + creators["dire bear form"] = &dire_bear_form; + creators["mangle (bear)"] = &mangle_bear; + creators["maul"] = &maul; + creators["bash"] = &bash; + creators["swipe"] = &swipe; + creators["lacerate"] = &lacerate; + creators["demoralizing roar"] = &demoralizing_roar; + creators["taunt spell"] = &growl; + } - private: - static ActionNode* melee([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("melee", - /*P*/ NextAction::array(0, new NextAction("feral charge - bear"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } +private: + static ActionNode* melee([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("melee", + /*P*/ NextAction::array(0, new NextAction("feral charge - bear"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* feral_charge_bear([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("feral charge - bear", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("reach melee"), nullptr), - /*C*/ nullptr); - } + static ActionNode* feral_charge_bear([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("feral charge - bear", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("reach melee"), nullptr), + /*C*/ nullptr); + } - static ActionNode* swipe_bear([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("swipe (bear)", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* swipe_bear([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("swipe (bear)", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* faerie_fire_feral([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("faerie fire (feral)", - /*P*/ NextAction::array(0, new NextAction("feral charge - bear"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* faerie_fire_feral([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("faerie fire (feral)", + /*P*/ NextAction::array(0, new NextAction("feral charge - bear"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* bear_form([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("bear form", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* bear_form([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("bear form", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* dire_bear_form([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("dire bear form", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ NextAction::array(0, new NextAction("bear form"), nullptr), - /*C*/ nullptr); - } + static ActionNode* dire_bear_form([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("dire bear form", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ NextAction::array(0, new NextAction("bear form"), nullptr), + /*C*/ nullptr); + } - static ActionNode* mangle_bear([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("mangle (bear)", - /*P*/ nullptr, - // /*A*/ NextAction::array(0, new NextAction("lacerate"), nullptr), - nullptr, - /*C*/ nullptr); - } + static ActionNode* mangle_bear([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("mangle (bear)", + /*P*/ nullptr, + // /*A*/ NextAction::array(0, new NextAction("lacerate"), nullptr), + nullptr, + /*C*/ nullptr); + } - static ActionNode* maul([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("maul", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), - /*C*/ nullptr); - } + static ActionNode* maul([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("maul", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), + /*C*/ nullptr); + } - static ActionNode* bash([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("bash", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), - /*C*/ nullptr); - } + static ActionNode* bash([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("bash", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), + /*C*/ nullptr); + } - static ActionNode* swipe([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("swipe", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), - /*C*/ nullptr); - } + static ActionNode* swipe([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("swipe", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), + /*C*/ nullptr); + } - static ActionNode* lacerate([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("lacerate", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("maul"), nullptr), - /*C*/ nullptr); - } + static ActionNode* lacerate([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("lacerate", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("maul"), nullptr), + /*C*/ nullptr); + } - static ActionNode* growl([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("growl", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* growl([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("growl", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* demoralizing_roar([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("demoralizing roar", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* demoralizing_roar([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("demoralizing roar", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } }; BearTankDruidStrategy::BearTankDruidStrategy(PlayerbotAI* botAI) : FeralDruidStrategy(botAI) @@ -139,27 +141,36 @@ BearTankDruidStrategy::BearTankDruidStrategy(PlayerbotAI* botAI) : FeralDruidStr NextAction** BearTankDruidStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("mangle (bear)", ACTION_DEFAULT + 0.5f), - new NextAction("faerie fire (feral)", ACTION_DEFAULT + 0.4f), - new NextAction("lacerate", ACTION_DEFAULT + 0.3f), - new NextAction("maul", ACTION_DEFAULT + 0.2f), - new NextAction("enrage", ACTION_DEFAULT + 0.1f), - new NextAction("melee", ACTION_DEFAULT), - nullptr); + return NextAction::array( + 0, new NextAction("mangle (bear)", ACTION_DEFAULT + 0.5f), + new NextAction("faerie fire (feral)", ACTION_DEFAULT + 0.4f), new NextAction("lacerate", ACTION_DEFAULT + 0.3f), + new NextAction("maul", ACTION_DEFAULT + 0.2f), new NextAction("enrage", ACTION_DEFAULT + 0.1f), + new NextAction("melee", ACTION_DEFAULT), nullptr); } -void BearTankDruidStrategy::InitTriggers(std::vector &triggers) +void BearTankDruidStrategy::InitTriggers(std::vector& triggers) { FeralDruidStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("feral charge - bear", ACTION_NORMAL + 8), nullptr))); - // triggers.push_back(new TriggerNode("thorns", NextAction::array(0, new NextAction("thorns", ACTION_HIGH + 9), nullptr))); - triggers.push_back(new TriggerNode("bear form", NextAction::array(0, new NextAction("dire bear form", ACTION_HIGH + 8), nullptr))); - triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("frenzied regeneration", ACTION_HIGH + 7), nullptr))); - triggers.push_back(new TriggerNode("faerie fire (feral)", NextAction::array(0, new NextAction("faerie fire (feral)", ACTION_HIGH + 7), nullptr))); - triggers.push_back(new TriggerNode("lose aggro", NextAction::array(0, new NextAction("growl", ACTION_HIGH + 8), nullptr))); - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("demoralizing roar", ACTION_HIGH + 6), new NextAction("swipe (bear)", ACTION_HIGH + 6), nullptr))); - triggers.push_back(new TriggerNode("light aoe", NextAction::array(0, new NextAction("swipe (bear)", ACTION_HIGH + 5), nullptr))); - triggers.push_back(new TriggerNode("bash", NextAction::array(0, new NextAction("bash", ACTION_INTERRUPT + 2), nullptr))); - triggers.push_back(new TriggerNode("bash on enemy healer", NextAction::array(0, new NextAction("bash on enemy healer", ACTION_INTERRUPT + 1), nullptr))); + triggers.push_back(new TriggerNode( + "enemy out of melee", NextAction::array(0, new NextAction("feral charge - bear", ACTION_NORMAL + 8), nullptr))); + // triggers.push_back(new TriggerNode("thorns", NextAction::array(0, new NextAction("thorns", ACTION_HIGH + 9), + // nullptr))); + triggers.push_back( + new TriggerNode("bear form", NextAction::array(0, new NextAction("dire bear form", ACTION_HIGH + 8), nullptr))); + triggers.push_back(new TriggerNode( + "low health", NextAction::array(0, new NextAction("frenzied regeneration", ACTION_HIGH + 7), nullptr))); + triggers.push_back(new TriggerNode( + "faerie fire (feral)", NextAction::array(0, new NextAction("faerie fire (feral)", ACTION_HIGH + 7), nullptr))); + triggers.push_back( + new TriggerNode("lose aggro", NextAction::array(0, new NextAction("growl", ACTION_HIGH + 8), nullptr))); + triggers.push_back( + new TriggerNode("medium aoe", NextAction::array(0, new NextAction("demoralizing roar", ACTION_HIGH + 6), + new NextAction("swipe (bear)", ACTION_HIGH + 6), nullptr))); + triggers.push_back( + new TriggerNode("light aoe", NextAction::array(0, new NextAction("swipe (bear)", ACTION_HIGH + 5), nullptr))); + triggers.push_back( + new TriggerNode("bash", NextAction::array(0, new NextAction("bash", ACTION_INTERRUPT + 2), nullptr))); + triggers.push_back( + new TriggerNode("bash on enemy healer", + NextAction::array(0, new NextAction("bash on enemy healer", ACTION_INTERRUPT + 1), nullptr))); } diff --git a/src/strategy/druid/BearTankDruidStrategy.h b/src/strategy/druid/BearTankDruidStrategy.h index 50c60b87..6bc96d97 100644 --- a/src/strategy/druid/BearTankDruidStrategy.h +++ b/src/strategy/druid/BearTankDruidStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_BEARTANKDRUIDSTRATEGY_H @@ -11,13 +12,13 @@ class PlayerbotAI; class BearTankDruidStrategy : public FeralDruidStrategy { - public: - BearTankDruidStrategy(PlayerbotAI* botAI); +public: + BearTankDruidStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "bear"; } - NextAction** getDefaultActions() override; - uint32 GetType() const override { return STRATEGY_TYPE_TANK | STRATEGY_TYPE_MELEE; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bear"; } + NextAction** getDefaultActions() override; + uint32 GetType() const override { return STRATEGY_TYPE_TANK | STRATEGY_TYPE_MELEE; } }; #endif diff --git a/src/strategy/druid/CasterDruidStrategy.cpp b/src/strategy/druid/CasterDruidStrategy.cpp index ad8bccdc..1dfeadfa 100644 --- a/src/strategy/druid/CasterDruidStrategy.cpp +++ b/src/strategy/druid/CasterDruidStrategy.cpp @@ -1,109 +1,110 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CasterDruidStrategy.h" + #include "AiObjectContext.h" #include "FeralDruidStrategy.h" class CasterDruidStrategyActionNodeFactory : public NamedObjectFactory { - public: - CasterDruidStrategyActionNodeFactory() - { - creators["faerie fire"] = &faerie_fire; - creators["hibernate"] = &hibernate; - creators["entangling roots"] = &entangling_roots; - creators["entangling roots on cc"] = &entangling_roots_on_cc; - creators["wrath"] = &wrath; - creators["starfall"] = &starfall; - creators["insect swarm"] = &insect_swarm; - creators["moonfire"] = &moonfire; - creators["starfire"] = &starfire; - creators["moonkin form"] = &moonkin_form; - } +public: + CasterDruidStrategyActionNodeFactory() + { + creators["faerie fire"] = &faerie_fire; + creators["hibernate"] = &hibernate; + creators["entangling roots"] = &entangling_roots; + creators["entangling roots on cc"] = &entangling_roots_on_cc; + creators["wrath"] = &wrath; + creators["starfall"] = &starfall; + creators["insect swarm"] = &insect_swarm; + creators["moonfire"] = &moonfire; + creators["starfire"] = &starfire; + creators["moonkin form"] = &moonkin_form; + } - private: - static ActionNode* faerie_fire([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("faerie fire", - /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } +private: + static ActionNode* faerie_fire([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("faerie fire", + /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* hibernate([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("hibernate", - /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), - /*A*/ NextAction::array(0, new NextAction("entangling roots"), nullptr), - /*C*/ nullptr); - } + static ActionNode* hibernate([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("hibernate", + /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), + /*A*/ NextAction::array(0, new NextAction("entangling roots"), nullptr), + /*C*/ nullptr); + } - static ActionNode* entangling_roots([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("entangling roots", - /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* entangling_roots([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("entangling roots", + /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* entangling_roots_on_cc([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("entangling roots on cc", - /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* entangling_roots_on_cc([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("entangling roots on cc", + /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* wrath([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("wrath", - /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* wrath([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("wrath", + /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* starfall([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("starfall", - /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* starfall([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("starfall", + /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* insect_swarm([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("insect swarm", - /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* insect_swarm([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("insect swarm", + /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* moonfire([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("moonfire", - /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* moonfire([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("moonfire", + /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* starfire([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("starfire", - /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* starfire([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("starfire", + /*P*/ NextAction::array(0, new NextAction("moonkin form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* moonkin_form([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("moonkin form", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } - + static ActionNode* moonkin_form([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("moonkin form", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } }; CasterDruidStrategy::CasterDruidStrategy(PlayerbotAI* botAI) : GenericDruidStrategy(botAI) @@ -114,45 +115,53 @@ CasterDruidStrategy::CasterDruidStrategy(PlayerbotAI* botAI) : GenericDruidStrat NextAction** CasterDruidStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("starfall", ACTION_DEFAULT + 0.2f), - new NextAction("wrath", ACTION_DEFAULT + 0.1f), - // new NextAction("starfire", ACTION_NORMAL), - nullptr); + return NextAction::array(0, new NextAction("starfall", ACTION_DEFAULT + 0.2f), + new NextAction("wrath", ACTION_DEFAULT + 0.1f), + // new NextAction("starfire", ACTION_NORMAL), + nullptr); } void CasterDruidStrategy::InitTriggers(std::vector& triggers) { GenericDruidStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", ACTION_MOVE), nullptr))); - triggers.push_back(new TriggerNode("insect swarm", NextAction::array(0, new NextAction("insect swarm", ACTION_NORMAL + 5), nullptr))); - triggers.push_back(new TriggerNode("moonfire", NextAction::array(0, new NextAction("moonfire", ACTION_NORMAL + 4), nullptr))); - triggers.push_back(new TriggerNode("eclipse (solar)", NextAction::array(0, new NextAction("wrath", ACTION_NORMAL + 6), nullptr))); - triggers.push_back(new TriggerNode("eclipse (lunar) cooldown", NextAction::array(0, new NextAction("starfire", ACTION_NORMAL + 2), nullptr))); - triggers.push_back(new TriggerNode("eclipse (lunar)", NextAction::array(0, new NextAction("starfire", ACTION_NORMAL + 6), nullptr))); - triggers.push_back(new TriggerNode("eclipse (solar) cooldown", NextAction::array(0, new NextAction("wrath", ACTION_NORMAL + 2), nullptr))); - triggers.push_back(new TriggerNode("moonfire", NextAction::array(0, new NextAction("moonfire", ACTION_NORMAL + 4), nullptr))); - triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new NextAction("innervate", ACTION_HIGH + 9), NULL))); - triggers.push_back(new TriggerNode("enemy too close for spell", NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); + // triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", + // ACTION_MOVE), nullptr))); triggers.push_back(new TriggerNode( - "party member remove curse", - NextAction::array(0, new NextAction("remove curse on party", ACTION_DISPEL + 7), NULL))); + "insect swarm", NextAction::array(0, new NextAction("insect swarm", ACTION_NORMAL + 5), nullptr))); + triggers.push_back( + new TriggerNode("moonfire", NextAction::array(0, new NextAction("moonfire", ACTION_NORMAL + 4), nullptr))); + triggers.push_back( + new TriggerNode("eclipse (solar)", NextAction::array(0, new NextAction("wrath", ACTION_NORMAL + 6), nullptr))); + triggers.push_back(new TriggerNode("eclipse (lunar) cooldown", + NextAction::array(0, new NextAction("starfire", ACTION_NORMAL + 2), nullptr))); + triggers.push_back(new TriggerNode("eclipse (lunar)", + NextAction::array(0, new NextAction("starfire", ACTION_NORMAL + 6), nullptr))); + triggers.push_back(new TriggerNode("eclipse (solar) cooldown", + NextAction::array(0, new NextAction("wrath", ACTION_NORMAL + 2), nullptr))); + triggers.push_back( + new TriggerNode("moonfire", NextAction::array(0, new NextAction("moonfire", ACTION_NORMAL + 4), nullptr))); + triggers.push_back( + new TriggerNode("medium mana", NextAction::array(0, new NextAction("innervate", ACTION_HIGH + 9), NULL))); + triggers.push_back(new TriggerNode("enemy too close for spell", + NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); + triggers.push_back( + new TriggerNode("party member remove curse", + NextAction::array(0, new NextAction("remove curse on party", ACTION_DISPEL + 7), NULL))); } void CasterDruidAoeStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("high aoe", NextAction::array(0, new NextAction("hurricane", ACTION_HIGH + 1), nullptr))); + triggers.push_back( + new TriggerNode("high aoe", NextAction::array(0, new NextAction("hurricane", ACTION_HIGH + 1), nullptr))); triggers.push_back(new TriggerNode( - "light aoe", - NextAction::array(0, - new NextAction("starfall", ACTION_NORMAL + 5), - new NextAction("insect swarm on attacker", ACTION_NORMAL + 3), - new NextAction("moonfire on attacker", ACTION_NORMAL + 3), - NULL))); + "light aoe", NextAction::array(0, new NextAction("starfall", ACTION_NORMAL + 5), + new NextAction("insect swarm on attacker", ACTION_NORMAL + 3), + new NextAction("moonfire on attacker", ACTION_NORMAL + 3), NULL))); } void CasterDruidDebuffStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("faerie fire", NextAction::array(0, new NextAction("faerie fire", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("faerie fire", NextAction::array(0, new NextAction("faerie fire", ACTION_HIGH), nullptr))); } diff --git a/src/strategy/druid/CasterDruidStrategy.h b/src/strategy/druid/CasterDruidStrategy.h index 284dc8d9..b7b16d84 100644 --- a/src/strategy/druid/CasterDruidStrategy.h +++ b/src/strategy/druid/CasterDruidStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CASTERDRUIDSTRATEGY_H @@ -11,34 +12,34 @@ class PlayerbotAI; class CasterDruidStrategy : public GenericDruidStrategy { - public: - CasterDruidStrategy(PlayerbotAI* botAI); +public: + CasterDruidStrategy(PlayerbotAI* botAI); - public: - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "caster"; } - NextAction** getDefaultActions() override; - uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_RANGED; } +public: + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "caster"; } + NextAction** getDefaultActions() override; + uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_RANGED; } }; class CasterDruidAoeStrategy : public CombatStrategy { - public: - CasterDruidAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + CasterDruidAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - public: - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "caster aoe"; } +public: + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "caster aoe"; } }; class CasterDruidDebuffStrategy : public CombatStrategy { - public: - CasterDruidDebuffStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + CasterDruidDebuffStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - public: - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "caster debuff"; } +public: + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "caster debuff"; } }; #endif diff --git a/src/strategy/druid/CatDpsDruidStrategy.cpp b/src/strategy/druid/CatDpsDruidStrategy.cpp index 4f536c57..80120330 100644 --- a/src/strategy/druid/CatDpsDruidStrategy.cpp +++ b/src/strategy/druid/CatDpsDruidStrategy.cpp @@ -1,116 +1,118 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CatDpsDruidStrategy.h" + #include "AiObjectContext.h" class CatDpsDruidStrategyActionNodeFactory : public NamedObjectFactory { - public: - CatDpsDruidStrategyActionNodeFactory() - { - creators["faerie fire (feral)"] = &faerie_fire_feral; - creators["melee"] = &melee; - creators["feral charge - cat"] = &feral_charge_cat; - creators["cat form"] = &cat_form; - creators["claw"] = &claw; - creators["mangle (cat)"] = &mangle_cat; - creators["rake"] = &rake; - creators["ferocious bite"] = &ferocious_bite; - creators["rip"] = &rip; - creators["pounce"] = &pounce; - creators["ravage"] = &ravage; - } +public: + CatDpsDruidStrategyActionNodeFactory() + { + creators["faerie fire (feral)"] = &faerie_fire_feral; + creators["melee"] = &melee; + creators["feral charge - cat"] = &feral_charge_cat; + creators["cat form"] = &cat_form; + creators["claw"] = &claw; + creators["mangle (cat)"] = &mangle_cat; + creators["rake"] = &rake; + creators["ferocious bite"] = &ferocious_bite; + creators["rip"] = &rip; + creators["pounce"] = &pounce; + creators["ravage"] = &ravage; + } - private: - static ActionNode* faerie_fire_feral([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("faerie fire (feral)", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } +private: + static ActionNode* faerie_fire_feral([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("faerie fire (feral)", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* melee([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("melee", - /*P*/ NextAction::array(0, new NextAction("feral charge - cat"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* melee([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("melee", + /*P*/ NextAction::array(0, new NextAction("feral charge - cat"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* feral_charge_cat([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("feral charge - cat", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("reach melee"), nullptr), - /*C*/ nullptr); - } + static ActionNode* feral_charge_cat([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("feral charge - cat", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("reach melee"), nullptr), + /*C*/ nullptr); + } - static ActionNode* cat_form([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("cat form", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* cat_form([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("cat form", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* claw([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("claw", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), - /*C*/ nullptr); - } + static ActionNode* claw([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("claw", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), + /*C*/ nullptr); + } - static ActionNode* mangle_cat([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("mangle (cat)", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("claw"), nullptr), - /*C*/ nullptr); - } + static ActionNode* mangle_cat([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("mangle (cat)", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("claw"), nullptr), + /*C*/ nullptr); + } - static ActionNode* rake([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("rake", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* rake([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("rake", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* ferocious_bite([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("ferocious bite", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("rip"), nullptr), - /*C*/ nullptr); - } + static ActionNode* ferocious_bite([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("ferocious bite", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("rip"), nullptr), + /*C*/ nullptr); + } - static ActionNode* rip([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("rip", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* rip([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("rip", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* pounce([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("pounce", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("ravage"), nullptr), - /*C*/ nullptr); - } + static ActionNode* pounce([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("pounce", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("ravage"), nullptr), + /*C*/ nullptr); + } - static ActionNode* ravage([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("ravage", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("shred"), nullptr), - /*C*/ nullptr); - } + static ActionNode* ravage([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("ravage", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("shred"), nullptr), + /*C*/ nullptr); + } }; CatDpsDruidStrategy::CatDpsDruidStrategy(PlayerbotAI* botAI) : FeralDruidStrategy(botAI) @@ -127,21 +129,31 @@ void CatDpsDruidStrategy::InitTriggers(std::vector& triggers) { FeralDruidStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("cat form", NextAction::array(0, new NextAction("cat form", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode("rake", NextAction::array(0, new NextAction("rake", ACTION_NORMAL + 5), nullptr))); - triggers.push_back(new TriggerNode("combo points available", NextAction::array(0, new NextAction("ferocious bite", ACTION_NORMAL + 9), nullptr))); - triggers.push_back(new TriggerNode("medium threat", NextAction::array(0, new NextAction("cower", ACTION_EMERGENCY + 1), nullptr))); - triggers.push_back(new TriggerNode("faerie fire (feral)", NextAction::array(0, new NextAction("faerie fire (feral)", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("tiger's fury", NextAction::array(0, new NextAction("tiger's fury", ACTION_EMERGENCY + 1), nullptr))); - triggers.push_back(new TriggerNode("behind target", NextAction::array(0, new NextAction("pounce", ACTION_HIGH + 1), nullptr))); - //triggers.push_back(new TriggerNode("player has no flag", NextAction::array(0, new NextAction("prowl", ACTION_HIGH), nullptr))); - //triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("prowl", ACTION_INTERRUPT + 1), nullptr))); - triggers.push_back(new TriggerNode("player has flag", NextAction::array(0, new NextAction("dash", ACTION_EMERGENCY), nullptr))); - triggers.push_back(new TriggerNode("enemy flagcarrier near", NextAction::array(0, new NextAction("dash", ACTION_EMERGENCY), nullptr))); + triggers.push_back( + new TriggerNode("cat form", NextAction::array(0, new NextAction("cat form", ACTION_HIGH + 2), nullptr))); + triggers.push_back( + new TriggerNode("rake", NextAction::array(0, new NextAction("rake", ACTION_NORMAL + 5), nullptr))); + triggers.push_back(new TriggerNode( + "combo points available", NextAction::array(0, new NextAction("ferocious bite", ACTION_NORMAL + 9), nullptr))); + triggers.push_back( + new TriggerNode("medium threat", NextAction::array(0, new NextAction("cower", ACTION_EMERGENCY + 1), nullptr))); + triggers.push_back(new TriggerNode( + "faerie fire (feral)", NextAction::array(0, new NextAction("faerie fire (feral)", ACTION_HIGH), nullptr))); + triggers.push_back(new TriggerNode( + "tiger's fury", NextAction::array(0, new NextAction("tiger's fury", ACTION_EMERGENCY + 1), nullptr))); + triggers.push_back( + new TriggerNode("behind target", NextAction::array(0, new NextAction("pounce", ACTION_HIGH + 1), nullptr))); + // triggers.push_back(new TriggerNode("player has no flag", NextAction::array(0, new NextAction("prowl", + // ACTION_HIGH), nullptr))); triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new + // NextAction("prowl", ACTION_INTERRUPT + 1), nullptr))); + triggers.push_back( + new TriggerNode("player has flag", NextAction::array(0, new NextAction("dash", ACTION_EMERGENCY), nullptr))); + triggers.push_back(new TriggerNode("enemy flagcarrier near", + NextAction::array(0, new NextAction("dash", ACTION_EMERGENCY), nullptr))); } void CatAoeDruidStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("swipe (cat)", ACTION_HIGH + 2), nullptr))); + triggers.push_back( + new TriggerNode("medium aoe", NextAction::array(0, new NextAction("swipe (cat)", ACTION_HIGH + 2), nullptr))); } - diff --git a/src/strategy/druid/CatDpsDruidStrategy.h b/src/strategy/druid/CatDpsDruidStrategy.h index ce5631ba..96b8d3af 100644 --- a/src/strategy/druid/CatDpsDruidStrategy.h +++ b/src/strategy/druid/CatDpsDruidStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CATDPSDRUIDSTRATEGY_H @@ -11,24 +12,24 @@ class PlayerbotAI; class CatDpsDruidStrategy : public FeralDruidStrategy { - public: - CatDpsDruidStrategy(PlayerbotAI* botAI); +public: + CatDpsDruidStrategy(PlayerbotAI* botAI); - public: - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "cat"; } - NextAction** getDefaultActions() override; - uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_MELEE; } +public: + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cat"; } + NextAction** getDefaultActions() override; + uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_MELEE; } }; class CatAoeDruidStrategy : public CombatStrategy { - public: - CatAoeDruidStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + CatAoeDruidStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - public: - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "cat aoe"; } +public: + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cat aoe"; } }; #endif diff --git a/src/strategy/druid/DruidActions.cpp b/src/strategy/druid/DruidActions.cpp index aee2a145..739ac941 100644 --- a/src/strategy/druid/DruidActions.cpp +++ b/src/strategy/druid/DruidActions.cpp @@ -1,19 +1,23 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DruidActions.h" + #include "Event.h" #include "Playerbots.h" NextAction** CastAbolishPoisonAction::getAlternatives() { - return NextAction::merge(NextAction::array(0, new NextAction("cure poison"), nullptr), CastSpellAction::getPrerequisites()); + return NextAction::merge(NextAction::array(0, new NextAction("cure poison"), nullptr), + CastSpellAction::getPrerequisites()); } NextAction** CastAbolishPoisonOnPartyAction::getAlternatives() { - return NextAction::merge(NextAction::array(0, new NextAction("cure poison on party"), nullptr), CastSpellAction::getPrerequisites()); + return NextAction::merge(NextAction::array(0, new NextAction("cure poison on party"), nullptr), + CastSpellAction::getPrerequisites()); } Value* CastEntanglingRootsCcAction::GetTargetValue() @@ -21,32 +25,26 @@ Value* CastEntanglingRootsCcAction::GetTargetValue() return context->GetValue("cc target", "entangling roots"); } -bool CastEntanglingRootsCcAction::Execute(Event event) -{ - return botAI->CastSpell("entangling roots", GetTarget()); -} +bool CastEntanglingRootsCcAction::Execute(Event event) { return botAI->CastSpell("entangling roots", GetTarget()); } -Value* CastHibernateCcAction::GetTargetValue() -{ - return context->GetValue("cc target", "hibernate"); -} +Value* CastHibernateCcAction::GetTargetValue() { return context->GetValue("cc target", "hibernate"); } -bool CastHibernateCcAction::Execute(Event event) -{ - return botAI->CastSpell("hibernate", GetTarget()); -} +bool CastHibernateCcAction::Execute(Event event) { return botAI->CastSpell("hibernate", GetTarget()); } NextAction** CastReviveAction::getPrerequisites() { - return NextAction::merge(NextAction::array(0, new NextAction("caster form"), nullptr), ResurrectPartyMemberAction::getPrerequisites()); + return NextAction::merge(NextAction::array(0, new NextAction("caster form"), nullptr), + ResurrectPartyMemberAction::getPrerequisites()); } NextAction** CastRebirthAction::getPrerequisites() { - return NextAction::merge(NextAction::array(0, new NextAction("caster form"), nullptr), ResurrectPartyMemberAction::getPrerequisites()); + return NextAction::merge(NextAction::array(0, new NextAction("caster form"), nullptr), + ResurrectPartyMemberAction::getPrerequisites()); } bool CastRebirthAction::isUseful() { - return CastSpellAction::isUseful() && AI_VALUE2(float, "distance", GetTargetName()) <= sPlayerbotAIConfig->spellDistance; + return CastSpellAction::isUseful() && + AI_VALUE2(float, "distance", GetTargetName()) <= sPlayerbotAIConfig->spellDistance; } \ No newline at end of file diff --git a/src/strategy/druid/DruidActions.h b/src/strategy/druid/DruidActions.h index 3ae7efb0..f73a6864 100644 --- a/src/strategy/druid/DruidActions.h +++ b/src/strategy/druid/DruidActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DRUIDACTIONS_H @@ -13,284 +14,301 @@ class Unit; class CastFaerieFireAction : public CastDebuffSpellAction { - public: - CastFaerieFireAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "faerie fire") { } +public: + CastFaerieFireAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "faerie fire") {} }; class CastFaerieFireFeralAction : public CastSpellAction { - public: - CastFaerieFireFeralAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "faerie fire (feral)") { } +public: + CastFaerieFireFeralAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "faerie fire (feral)") {} }; class CastRejuvenationAction : public CastHealingSpellAction { - public: - CastRejuvenationAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "rejuvenation") { } +public: + CastRejuvenationAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "rejuvenation") {} }; class CastRegrowthAction : public CastHealingSpellAction { - public: - CastRegrowthAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "regrowth") { } - +public: + CastRegrowthAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "regrowth") {} }; class CastHealingTouchAction : public CastHealingSpellAction { - public: - CastHealingTouchAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "healing touch") { } - +public: + CastHealingTouchAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "healing touch") {} }; class CastRejuvenationOnPartyAction : public HealPartyMemberAction { - public: - CastRejuvenationOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "rejuvenation", 15.0f, HealingManaEfficiency::VERY_HIGH) { } +public: + CastRejuvenationOnPartyAction(PlayerbotAI* botAI) + : HealPartyMemberAction(botAI, "rejuvenation", 15.0f, HealingManaEfficiency::VERY_HIGH) + { + } }; class CastRegrowthOnPartyAction : public HealPartyMemberAction { - public: - CastRegrowthOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "regrowth", 35.0f, HealingManaEfficiency::HIGH) { } +public: + CastRegrowthOnPartyAction(PlayerbotAI* botAI) + : HealPartyMemberAction(botAI, "regrowth", 35.0f, HealingManaEfficiency::HIGH) + { + } }; class CastHealingTouchOnPartyAction : public HealPartyMemberAction { - public: - CastHealingTouchOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "healing touch", 50.0f, HealingManaEfficiency::LOW) { } +public: + CastHealingTouchOnPartyAction(PlayerbotAI* botAI) + : HealPartyMemberAction(botAI, "healing touch", 50.0f, HealingManaEfficiency::LOW) + { + } }; class CastReviveAction : public ResurrectPartyMemberAction { - public: - CastReviveAction(PlayerbotAI* botAI) : ResurrectPartyMemberAction(botAI, "revive") { } +public: + CastReviveAction(PlayerbotAI* botAI) : ResurrectPartyMemberAction(botAI, "revive") {} - NextAction** getPrerequisites() override; + NextAction** getPrerequisites() override; }; class CastRebirthAction : public ResurrectPartyMemberAction { - public: - CastRebirthAction(PlayerbotAI* botAI) : ResurrectPartyMemberAction(botAI, "rebirth") { } +public: + CastRebirthAction(PlayerbotAI* botAI) : ResurrectPartyMemberAction(botAI, "rebirth") {} - NextAction** getPrerequisites() override; - bool isUseful() override; + NextAction** getPrerequisites() override; + bool isUseful() override; }; class CastMarkOfTheWildAction : public CastBuffSpellAction { - public: - CastMarkOfTheWildAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "mark of the wild") { } +public: + CastMarkOfTheWildAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "mark of the wild") {} }; class CastMarkOfTheWildOnPartyAction : public BuffOnPartyAction { - public: - CastMarkOfTheWildOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "mark of the wild") { } +public: + CastMarkOfTheWildOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "mark of the wild") {} }; class CastSurvivalInstinctsAction : public CastBuffSpellAction { - public: - CastSurvivalInstinctsAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "survival instincts") { } +public: + CastSurvivalInstinctsAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "survival instincts") {} }; class CastFrenziedRegenerationAction : public CastBuffSpellAction { - public: - CastFrenziedRegenerationAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "frenzied regeneration") { } +public: + CastFrenziedRegenerationAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "frenzied regeneration") {} }; - class CastThornsAction : public CastBuffSpellAction { - public: - CastThornsAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "thorns") { } +public: + CastThornsAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "thorns") {} }; class CastThornsOnPartyAction : public BuffOnPartyAction { - public: - CastThornsOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "thorns") { } +public: + CastThornsOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "thorns") {} }; class CastThornsOnMainTankAction : public BuffOnMainTankAction { - public: - CastThornsOnMainTankAction(PlayerbotAI* botAI) : BuffOnMainTankAction(botAI, "thorns", false) { } +public: + CastThornsOnMainTankAction(PlayerbotAI* botAI) : BuffOnMainTankAction(botAI, "thorns", false) {} }; class CastOmenOfClarityAction : public CastBuffSpellAction { - public: - CastOmenOfClarityAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "omen of clarity") { } +public: + CastOmenOfClarityAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "omen of clarity") {} }; class CastWrathAction : public CastSpellAction { - public: - CastWrathAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "wrath") { } +public: + CastWrathAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "wrath") {} }; class CastStarfallAction : public CastSpellAction { - public: - CastStarfallAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "starfall") { } +public: + CastStarfallAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "starfall") {} }; class CastHurricaneAction : public CastSpellAction { - public: - CastHurricaneAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "hurricane") { } - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } +public: + CastHurricaneAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "hurricane") {} + ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } }; class CastMoonfireAction : public CastDebuffSpellAction { - public: - CastMoonfireAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "moonfire", true) { } +public: + CastMoonfireAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "moonfire", true) {} }; class CastInsectSwarmAction : public CastDebuffSpellAction { - public: - CastInsectSwarmAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "insect swarm", true) { } +public: + CastInsectSwarmAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "insect swarm", true) {} }; class CastStarfireAction : public CastSpellAction { - public: - CastStarfireAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "starfire") { } +public: + CastStarfireAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "starfire") {} }; class CastEntanglingRootsAction : public CastSpellAction { - public: - CastEntanglingRootsAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "entangling roots") { } +public: + CastEntanglingRootsAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "entangling roots") {} }; class CastEntanglingRootsCcAction : public CastSpellAction { - public: - CastEntanglingRootsCcAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "entangling roots on cc") { } - Value* GetTargetValue() override; - bool Execute(Event event) override; +public: + CastEntanglingRootsCcAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "entangling roots on cc") {} + Value* GetTargetValue() override; + bool Execute(Event event) override; }; class CastHibernateAction : public CastSpellAction { - public: - CastHibernateAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "hibernate") { } +public: + CastHibernateAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "hibernate") {} }; class CastHibernateCcAction : public CastSpellAction { - public: - CastHibernateCcAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "hibernate on cc") { } - Value* GetTargetValue() override; - bool Execute(Event event) override; +public: + CastHibernateCcAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "hibernate on cc") {} + Value* GetTargetValue() override; + bool Execute(Event event) override; }; class CastNaturesGraspAction : public CastBuffSpellAction { - public: - CastNaturesGraspAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "nature's grasp") { } +public: + CastNaturesGraspAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "nature's grasp") {} }; class CastCurePoisonAction : public CastCureSpellAction { - public: - CastCurePoisonAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "cure poison") { } +public: + CastCurePoisonAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "cure poison") {} }; class CastCurePoisonOnPartyAction : public CurePartyMemberAction { - public: - CastCurePoisonOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "cure poison", DISPEL_POISON) { } +public: + CastCurePoisonOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "cure poison", DISPEL_POISON) {} }; class CastAbolishPoisonAction : public CastCureSpellAction { - public: - CastAbolishPoisonAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "abolish poison") { } - NextAction** getAlternatives() override; +public: + CastAbolishPoisonAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "abolish poison") {} + NextAction** getAlternatives() override; }; class CastAbolishPoisonOnPartyAction : public CurePartyMemberAction { - public: - CastAbolishPoisonOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "abolish poison", DISPEL_POISON) { } +public: + CastAbolishPoisonOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "abolish poison", DISPEL_POISON) + { + } - NextAction** getAlternatives() override; + NextAction** getAlternatives() override; }; class CastBarskinAction : public CastBuffSpellAction { - public: - CastBarskinAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "barskin") { } +public: + CastBarskinAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "barskin") {} }; class CastInnervateAction : public CastSpellAction { - public: - CastInnervateAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "innervate") { } +public: + CastInnervateAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "innervate") {} - std::string const GetTargetName() override { return "self target"; } + std::string const GetTargetName() override { return "self target"; } }; class CastTranquilityAction : public CastAoeHealSpellAction { - public: - CastTranquilityAction(PlayerbotAI* botAI) : CastAoeHealSpellAction(botAI, "tranquility", 15.0f, HealingManaEfficiency::MEDIUM) { } +public: + CastTranquilityAction(PlayerbotAI* botAI) + : CastAoeHealSpellAction(botAI, "tranquility", 15.0f, HealingManaEfficiency::MEDIUM) + { + } }; class CastNaturesSwiftnessAction : public CastBuffSpellAction { - public: - CastNaturesSwiftnessAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "nature's swiftness") { } +public: + CastNaturesSwiftnessAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "nature's swiftness") {} }; class CastWildGrowthOnPartyAction : public HealPartyMemberAction { public: - CastWildGrowthOnPartyAction(PlayerbotAI* ai) : HealPartyMemberAction(ai, "wild growth", 15.0f, HealingManaEfficiency::VERY_HIGH) {} + CastWildGrowthOnPartyAction(PlayerbotAI* ai) + : HealPartyMemberAction(ai, "wild growth", 15.0f, HealingManaEfficiency::VERY_HIGH) + { + } }; class CastPartySwiftmendAction : public HealPartyMemberAction { public: - CastPartySwiftmendAction(PlayerbotAI* ai) : HealPartyMemberAction(ai, "swiftmend", 15.0f, HealingManaEfficiency::MEDIUM) {} + CastPartySwiftmendAction(PlayerbotAI* ai) + : HealPartyMemberAction(ai, "swiftmend", 15.0f, HealingManaEfficiency::MEDIUM) + { + } }; class CastPartyNourishAction : public HealPartyMemberAction { public: - CastPartyNourishAction(PlayerbotAI* ai) : HealPartyMemberAction(ai, "nourish", 25.0f, HealingManaEfficiency::LOW) {} + CastPartyNourishAction(PlayerbotAI* ai) : HealPartyMemberAction(ai, "nourish", 25.0f, HealingManaEfficiency::LOW) {} }; class CastDruidRemoveCurseOnPartyAction : public CurePartyMemberAction { - public: - CastDruidRemoveCurseOnPartyAction(PlayerbotAI* ai) : CurePartyMemberAction(ai, "remove curse", DISPEL_CURSE) {} +public: + CastDruidRemoveCurseOnPartyAction(PlayerbotAI* ai) : CurePartyMemberAction(ai, "remove curse", DISPEL_CURSE) {} }; class CastInsectSwarmOnAttackerAction : public CastDebuffSpellOnAttackerAction { public: - CastInsectSwarmOnAttackerAction(PlayerbotAI* ai) : CastDebuffSpellOnAttackerAction(ai, "insect swarm") {} + CastInsectSwarmOnAttackerAction(PlayerbotAI* ai) : CastDebuffSpellOnAttackerAction(ai, "insect swarm") {} }; class CastMoonfireOnAttackerAction : public CastDebuffSpellOnAttackerAction { public: - CastMoonfireOnAttackerAction(PlayerbotAI* ai) : CastDebuffSpellOnAttackerAction(ai, "moonfire") {} + CastMoonfireOnAttackerAction(PlayerbotAI* ai) : CastDebuffSpellOnAttackerAction(ai, "moonfire") {} }; class CastEnrageAction : public CastBuffSpellAction { public: - CastEnrageAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, "enrage") {} + CastEnrageAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, "enrage") {} }; #endif diff --git a/src/strategy/druid/DruidAiObjectContext.cpp b/src/strategy/druid/DruidAiObjectContext.cpp index 593481b1..1a938842 100644 --- a/src/strategy/druid/DruidAiObjectContext.cpp +++ b/src/strategy/druid/DruidAiObjectContext.cpp @@ -1,301 +1,303 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DruidAiObjectContext.h" + #include "BearTankDruidStrategy.h" -#include "CatDpsDruidStrategy.h" #include "CasterDruidStrategy.h" -#include "GenericDruidNonCombatStrategy.h" +#include "CatDpsDruidStrategy.h" #include "DruidActions.h" #include "DruidBearActions.h" #include "DruidCatActions.h" #include "DruidShapeshiftActions.h" #include "DruidTriggers.h" +#include "GenericDruidNonCombatStrategy.h" #include "HealDruidStrategy.h" #include "MeleeDruidStrategy.h" #include "Playerbots.h" class DruidStrategyFactoryInternal : public NamedObjectContext { - public: - DruidStrategyFactoryInternal() - { - creators["nc"] = &DruidStrategyFactoryInternal::nc; - creators["cat aoe"] = &DruidStrategyFactoryInternal::cat_aoe; - creators["caster aoe"] = &DruidStrategyFactoryInternal::caster_aoe; - creators["caster debuff"] = &DruidStrategyFactoryInternal::caster_debuff; - creators["dps debuff"] = &DruidStrategyFactoryInternal::caster_debuff; - creators["cure"] = &DruidStrategyFactoryInternal::cure; - creators["melee"] = &DruidStrategyFactoryInternal::melee; - creators["buff"] = &DruidStrategyFactoryInternal::buff; - creators["boost"] = &DruidStrategyFactoryInternal::boost; - creators["cc"] = &DruidStrategyFactoryInternal::cc; - } +public: + DruidStrategyFactoryInternal() + { + creators["nc"] = &DruidStrategyFactoryInternal::nc; + creators["cat aoe"] = &DruidStrategyFactoryInternal::cat_aoe; + creators["caster aoe"] = &DruidStrategyFactoryInternal::caster_aoe; + creators["caster debuff"] = &DruidStrategyFactoryInternal::caster_debuff; + creators["dps debuff"] = &DruidStrategyFactoryInternal::caster_debuff; + creators["cure"] = &DruidStrategyFactoryInternal::cure; + creators["melee"] = &DruidStrategyFactoryInternal::melee; + creators["buff"] = &DruidStrategyFactoryInternal::buff; + creators["boost"] = &DruidStrategyFactoryInternal::boost; + creators["cc"] = &DruidStrategyFactoryInternal::cc; + } - private: - static Strategy* nc(PlayerbotAI* botAI) { return new GenericDruidNonCombatStrategy(botAI); } - static Strategy* cat_aoe(PlayerbotAI* botAI) { return new CatAoeDruidStrategy(botAI); } - static Strategy* caster_aoe(PlayerbotAI* botAI) { return new CasterDruidAoeStrategy(botAI); } - static Strategy* caster_debuff(PlayerbotAI* botAI) { return new CasterDruidDebuffStrategy(botAI); } - static Strategy* cure(PlayerbotAI* botAI) { return new DruidCureStrategy(botAI); } - static Strategy* melee(PlayerbotAI* botAI) { return new MeleeDruidStrategy(botAI); } - static Strategy* buff(PlayerbotAI* botAI) { return new GenericDruidBuffStrategy(botAI); } - static Strategy* boost(PlayerbotAI* botAI) { return new DruidBoostStrategy(botAI); } - static Strategy* cc(PlayerbotAI* botAI) { return new DruidCcStrategy(botAI); } +private: + static Strategy* nc(PlayerbotAI* botAI) { return new GenericDruidNonCombatStrategy(botAI); } + static Strategy* cat_aoe(PlayerbotAI* botAI) { return new CatAoeDruidStrategy(botAI); } + static Strategy* caster_aoe(PlayerbotAI* botAI) { return new CasterDruidAoeStrategy(botAI); } + static Strategy* caster_debuff(PlayerbotAI* botAI) { return new CasterDruidDebuffStrategy(botAI); } + static Strategy* cure(PlayerbotAI* botAI) { return new DruidCureStrategy(botAI); } + static Strategy* melee(PlayerbotAI* botAI) { return new MeleeDruidStrategy(botAI); } + static Strategy* buff(PlayerbotAI* botAI) { return new GenericDruidBuffStrategy(botAI); } + static Strategy* boost(PlayerbotAI* botAI) { return new DruidBoostStrategy(botAI); } + static Strategy* cc(PlayerbotAI* botAI) { return new DruidCcStrategy(botAI); } }; class DruidDruidStrategyFactoryInternal : public NamedObjectContext { - public: - DruidDruidStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["bear"] = &DruidDruidStrategyFactoryInternal::bear; - creators["tank"] = &DruidDruidStrategyFactoryInternal::bear; - creators["cat"] = &DruidDruidStrategyFactoryInternal::cat; - creators["caster"] = &DruidDruidStrategyFactoryInternal::caster; - creators["dps"] = &DruidDruidStrategyFactoryInternal::cat; - creators["heal"] = &DruidDruidStrategyFactoryInternal::heal; - } +public: + DruidDruidStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["bear"] = &DruidDruidStrategyFactoryInternal::bear; + creators["tank"] = &DruidDruidStrategyFactoryInternal::bear; + creators["cat"] = &DruidDruidStrategyFactoryInternal::cat; + creators["caster"] = &DruidDruidStrategyFactoryInternal::caster; + creators["dps"] = &DruidDruidStrategyFactoryInternal::cat; + creators["heal"] = &DruidDruidStrategyFactoryInternal::heal; + } - private: - static Strategy* bear(PlayerbotAI* botAI) { return new BearTankDruidStrategy(botAI); } - static Strategy* cat(PlayerbotAI* botAI) { return new CatDpsDruidStrategy(botAI); } - static Strategy* caster(PlayerbotAI* botAI) { return new CasterDruidStrategy(botAI); } - static Strategy* heal(PlayerbotAI* botAI) { return new HealDruidStrategy(botAI); } +private: + static Strategy* bear(PlayerbotAI* botAI) { return new BearTankDruidStrategy(botAI); } + static Strategy* cat(PlayerbotAI* botAI) { return new CatDpsDruidStrategy(botAI); } + static Strategy* caster(PlayerbotAI* botAI) { return new CasterDruidStrategy(botAI); } + static Strategy* heal(PlayerbotAI* botAI) { return new HealDruidStrategy(botAI); } }; class DruidTriggerFactoryInternal : public NamedObjectContext { - public: - DruidTriggerFactoryInternal() - { - creators["omen of clarity"] = &DruidTriggerFactoryInternal::omen_of_clarity; - creators["thorns"] = &DruidTriggerFactoryInternal::thorns; - creators["thorns on party"] = &DruidTriggerFactoryInternal::thorns_on_party; - creators["thorns on main tank"] = &DruidTriggerFactoryInternal::thorns_on_main_tank; - creators["bash"] = &DruidTriggerFactoryInternal::bash; - creators["faerie fire (feral)"] = &DruidTriggerFactoryInternal::faerie_fire_feral; - creators["faerie fire"] = &DruidTriggerFactoryInternal::faerie_fire; - creators["insect swarm"] = &DruidTriggerFactoryInternal::insect_swarm; - creators["moonfire"] = &DruidTriggerFactoryInternal::moonfire; - creators["nature's grasp"] = &DruidTriggerFactoryInternal::natures_grasp; - creators["tiger's fury"] = &DruidTriggerFactoryInternal::tigers_fury; - creators["rake"] = &DruidTriggerFactoryInternal::rake; - creators["mark of the wild"] = &DruidTriggerFactoryInternal::mark_of_the_wild; - creators["mark of the wild on party"] = &DruidTriggerFactoryInternal::mark_of_the_wild_on_party; - creators["cure poison"] = &DruidTriggerFactoryInternal::cure_poison; - creators["party member cure poison"] = &DruidTriggerFactoryInternal::party_member_cure_poison; - creators["entangling roots"] = &DruidTriggerFactoryInternal::entangling_roots; - creators["entangling roots kite"] = &DruidTriggerFactoryInternal::entangling_roots_kite; - creators["hibernate"] = &DruidTriggerFactoryInternal::hibernate; - creators["bear form"] = &DruidTriggerFactoryInternal::bear_form; - creators["cat form"] = &DruidTriggerFactoryInternal::cat_form; - creators["tree form"] = &DruidTriggerFactoryInternal::tree_form; - creators["eclipse (solar)"] = &DruidTriggerFactoryInternal::eclipse_solar; - creators["eclipse (lunar)"] = &DruidTriggerFactoryInternal::eclipse_lunar; - creators["bash on enemy healer"] = &DruidTriggerFactoryInternal::bash_on_enemy_healer; - creators["nature's swiftness"] = &DruidTriggerFactoryInternal::natures_swiftness; - creators["party member remove curse"] = &DruidTriggerFactoryInternal::party_member_remove_curse; - creators["eclipse (solar) cooldown"] = &DruidTriggerFactoryInternal::eclipse_solar_cooldown; - creators["eclipse (lunar) cooldown"] = &DruidTriggerFactoryInternal::eclipse_lunar_cooldown; - } +public: + DruidTriggerFactoryInternal() + { + creators["omen of clarity"] = &DruidTriggerFactoryInternal::omen_of_clarity; + creators["thorns"] = &DruidTriggerFactoryInternal::thorns; + creators["thorns on party"] = &DruidTriggerFactoryInternal::thorns_on_party; + creators["thorns on main tank"] = &DruidTriggerFactoryInternal::thorns_on_main_tank; + creators["bash"] = &DruidTriggerFactoryInternal::bash; + creators["faerie fire (feral)"] = &DruidTriggerFactoryInternal::faerie_fire_feral; + creators["faerie fire"] = &DruidTriggerFactoryInternal::faerie_fire; + creators["insect swarm"] = &DruidTriggerFactoryInternal::insect_swarm; + creators["moonfire"] = &DruidTriggerFactoryInternal::moonfire; + creators["nature's grasp"] = &DruidTriggerFactoryInternal::natures_grasp; + creators["tiger's fury"] = &DruidTriggerFactoryInternal::tigers_fury; + creators["rake"] = &DruidTriggerFactoryInternal::rake; + creators["mark of the wild"] = &DruidTriggerFactoryInternal::mark_of_the_wild; + creators["mark of the wild on party"] = &DruidTriggerFactoryInternal::mark_of_the_wild_on_party; + creators["cure poison"] = &DruidTriggerFactoryInternal::cure_poison; + creators["party member cure poison"] = &DruidTriggerFactoryInternal::party_member_cure_poison; + creators["entangling roots"] = &DruidTriggerFactoryInternal::entangling_roots; + creators["entangling roots kite"] = &DruidTriggerFactoryInternal::entangling_roots_kite; + creators["hibernate"] = &DruidTriggerFactoryInternal::hibernate; + creators["bear form"] = &DruidTriggerFactoryInternal::bear_form; + creators["cat form"] = &DruidTriggerFactoryInternal::cat_form; + creators["tree form"] = &DruidTriggerFactoryInternal::tree_form; + creators["eclipse (solar)"] = &DruidTriggerFactoryInternal::eclipse_solar; + creators["eclipse (lunar)"] = &DruidTriggerFactoryInternal::eclipse_lunar; + creators["bash on enemy healer"] = &DruidTriggerFactoryInternal::bash_on_enemy_healer; + creators["nature's swiftness"] = &DruidTriggerFactoryInternal::natures_swiftness; + creators["party member remove curse"] = &DruidTriggerFactoryInternal::party_member_remove_curse; + creators["eclipse (solar) cooldown"] = &DruidTriggerFactoryInternal::eclipse_solar_cooldown; + creators["eclipse (lunar) cooldown"] = &DruidTriggerFactoryInternal::eclipse_lunar_cooldown; + } - private: - static Trigger* natures_swiftness(PlayerbotAI* botAI) { return new NaturesSwiftnessTrigger(botAI); } - static Trigger* eclipse_solar(PlayerbotAI* botAI) { return new EclipseSolarTrigger(botAI); } - static Trigger* eclipse_lunar(PlayerbotAI* botAI) { return new EclipseLunarTrigger(botAI); } - static Trigger* thorns(PlayerbotAI* botAI) { return new ThornsTrigger(botAI); } - static Trigger* thorns_on_party(PlayerbotAI* botAI) { return new ThornsOnPartyTrigger(botAI); } - static Trigger* thorns_on_main_tank(PlayerbotAI* botAI) { return new ThornsOnMainTankTrigger(botAI); } - static Trigger* bash(PlayerbotAI* botAI) { return new BashInterruptSpellTrigger(botAI); } - static Trigger* faerie_fire_feral(PlayerbotAI* botAI) { return new FaerieFireFeralTrigger(botAI); } - static Trigger* insect_swarm(PlayerbotAI* botAI) { return new InsectSwarmTrigger(botAI); } - static Trigger* moonfire(PlayerbotAI* botAI) { return new MoonfireTrigger(botAI); } - static Trigger* faerie_fire(PlayerbotAI* botAI) { return new FaerieFireTrigger(botAI); } - static Trigger* natures_grasp(PlayerbotAI* botAI) { return new NaturesGraspTrigger(botAI); } - static Trigger* tigers_fury(PlayerbotAI* botAI) { return new TigersFuryTrigger(botAI); } - static Trigger* rake(PlayerbotAI* botAI) { return new RakeTrigger(botAI); } - static Trigger* mark_of_the_wild(PlayerbotAI* botAI) { return new MarkOfTheWildTrigger(botAI); } - static Trigger* mark_of_the_wild_on_party(PlayerbotAI* botAI) { return new MarkOfTheWildOnPartyTrigger(botAI); } - static Trigger* cure_poison(PlayerbotAI* botAI) { return new CurePoisonTrigger(botAI); } - static Trigger* party_member_cure_poison(PlayerbotAI* botAI) { return new PartyMemberCurePoisonTrigger(botAI); } - static Trigger* entangling_roots(PlayerbotAI* botAI) { return new EntanglingRootsTrigger(botAI); } - static Trigger* entangling_roots_kite(PlayerbotAI* botAI) { return new EntanglingRootsKiteTrigger(botAI); } - static Trigger* hibernate(PlayerbotAI* botAI) { return new HibernateTrigger(botAI); } - static Trigger* bear_form(PlayerbotAI* botAI) { return new BearFormTrigger(botAI); } - static Trigger* cat_form(PlayerbotAI* botAI) { return new CatFormTrigger(botAI); } - static Trigger* tree_form(PlayerbotAI* botAI) { return new TreeFormTrigger(botAI); } - static Trigger* bash_on_enemy_healer(PlayerbotAI* botAI) { return new BashInterruptEnemyHealerSpellTrigger(botAI); } - static Trigger* omen_of_clarity(PlayerbotAI* botAI) { return new OmenOfClarityTrigger(botAI); } - static Trigger* party_member_remove_curse(PlayerbotAI* ai) { return new DruidPartyMemberRemoveCurseTrigger(ai); } - static Trigger* eclipse_solar_cooldown(PlayerbotAI* ai) { return new EclipseSolarCooldownTrigger(ai); } - static Trigger* eclipse_lunar_cooldown(PlayerbotAI* ai) { return new EclipseLunarCooldownTrigger(ai); } +private: + static Trigger* natures_swiftness(PlayerbotAI* botAI) { return new NaturesSwiftnessTrigger(botAI); } + static Trigger* eclipse_solar(PlayerbotAI* botAI) { return new EclipseSolarTrigger(botAI); } + static Trigger* eclipse_lunar(PlayerbotAI* botAI) { return new EclipseLunarTrigger(botAI); } + static Trigger* thorns(PlayerbotAI* botAI) { return new ThornsTrigger(botAI); } + static Trigger* thorns_on_party(PlayerbotAI* botAI) { return new ThornsOnPartyTrigger(botAI); } + static Trigger* thorns_on_main_tank(PlayerbotAI* botAI) { return new ThornsOnMainTankTrigger(botAI); } + static Trigger* bash(PlayerbotAI* botAI) { return new BashInterruptSpellTrigger(botAI); } + static Trigger* faerie_fire_feral(PlayerbotAI* botAI) { return new FaerieFireFeralTrigger(botAI); } + static Trigger* insect_swarm(PlayerbotAI* botAI) { return new InsectSwarmTrigger(botAI); } + static Trigger* moonfire(PlayerbotAI* botAI) { return new MoonfireTrigger(botAI); } + static Trigger* faerie_fire(PlayerbotAI* botAI) { return new FaerieFireTrigger(botAI); } + static Trigger* natures_grasp(PlayerbotAI* botAI) { return new NaturesGraspTrigger(botAI); } + static Trigger* tigers_fury(PlayerbotAI* botAI) { return new TigersFuryTrigger(botAI); } + static Trigger* rake(PlayerbotAI* botAI) { return new RakeTrigger(botAI); } + static Trigger* mark_of_the_wild(PlayerbotAI* botAI) { return new MarkOfTheWildTrigger(botAI); } + static Trigger* mark_of_the_wild_on_party(PlayerbotAI* botAI) { return new MarkOfTheWildOnPartyTrigger(botAI); } + static Trigger* cure_poison(PlayerbotAI* botAI) { return new CurePoisonTrigger(botAI); } + static Trigger* party_member_cure_poison(PlayerbotAI* botAI) { return new PartyMemberCurePoisonTrigger(botAI); } + static Trigger* entangling_roots(PlayerbotAI* botAI) { return new EntanglingRootsTrigger(botAI); } + static Trigger* entangling_roots_kite(PlayerbotAI* botAI) { return new EntanglingRootsKiteTrigger(botAI); } + static Trigger* hibernate(PlayerbotAI* botAI) { return new HibernateTrigger(botAI); } + static Trigger* bear_form(PlayerbotAI* botAI) { return new BearFormTrigger(botAI); } + static Trigger* cat_form(PlayerbotAI* botAI) { return new CatFormTrigger(botAI); } + static Trigger* tree_form(PlayerbotAI* botAI) { return new TreeFormTrigger(botAI); } + static Trigger* bash_on_enemy_healer(PlayerbotAI* botAI) { return new BashInterruptEnemyHealerSpellTrigger(botAI); } + static Trigger* omen_of_clarity(PlayerbotAI* botAI) { return new OmenOfClarityTrigger(botAI); } + static Trigger* party_member_remove_curse(PlayerbotAI* ai) { return new DruidPartyMemberRemoveCurseTrigger(ai); } + static Trigger* eclipse_solar_cooldown(PlayerbotAI* ai) { return new EclipseSolarCooldownTrigger(ai); } + static Trigger* eclipse_lunar_cooldown(PlayerbotAI* ai) { return new EclipseLunarCooldownTrigger(ai); } }; class DruidAiObjectContextInternal : public NamedObjectContext { - public: - DruidAiObjectContextInternal() - { - creators["feral charge - bear"] = &DruidAiObjectContextInternal::feral_charge_bear; - creators["feral charge - cat"] = &DruidAiObjectContextInternal::feral_charge_cat; - creators["swipe (bear)"] = &DruidAiObjectContextInternal::swipe_bear; - creators["faerie fire (feral)"] = &DruidAiObjectContextInternal::faerie_fire_feral; - creators["faerie fire"] = &DruidAiObjectContextInternal::faerie_fire; - creators["bear form"] = &DruidAiObjectContextInternal::bear_form; - creators["dire bear form"] = &DruidAiObjectContextInternal::dire_bear_form; - creators["moonkin form"] = &DruidAiObjectContextInternal::moonkin_form; - creators["cat form"] = &DruidAiObjectContextInternal::cat_form; - creators["tree form"] = &DruidAiObjectContextInternal::tree_form; - creators["travel form"] = &DruidAiObjectContextInternal::travel_form; - creators["aquatic form"] = &DruidAiObjectContextInternal::aquatic_form; - creators["caster form"] = &DruidAiObjectContextInternal::caster_form; - creators["mangle (bear)"] = &DruidAiObjectContextInternal::mangle_bear; - creators["maul"] = &DruidAiObjectContextInternal::maul; - creators["bash"] = &DruidAiObjectContextInternal::bash; - creators["swipe"] = &DruidAiObjectContextInternal::swipe; - creators["growl"] = &DruidAiObjectContextInternal::growl; - creators["demoralizing roar"] = &DruidAiObjectContextInternal::demoralizing_roar; - creators["hibernate"] = &DruidAiObjectContextInternal::hibernate; - creators["entangling roots"] = &DruidAiObjectContextInternal::entangling_roots; - creators["entangling roots on cc"] = &DruidAiObjectContextInternal::entangling_roots_on_cc; - creators["hibernate"] = &DruidAiObjectContextInternal::hibernate; - creators["hibernate on cc"] = &DruidAiObjectContextInternal::hibernate_on_cc; - creators["wrath"] = &DruidAiObjectContextInternal::wrath; - creators["starfall"] = &DruidAiObjectContextInternal::starfall; - creators["insect swarm"] = &DruidAiObjectContextInternal::insect_swarm; - creators["moonfire"] = &DruidAiObjectContextInternal::moonfire; - creators["starfire"] = &DruidAiObjectContextInternal::starfire; - creators["nature's grasp"] = &DruidAiObjectContextInternal::natures_grasp; - creators["claw"] = &DruidAiObjectContextInternal::claw; - creators["mangle (cat)"] = &DruidAiObjectContextInternal::mangle_cat; - creators["swipe (cat)"] = &DruidAiObjectContextInternal::swipe_cat; - creators["rake"] = &DruidAiObjectContextInternal::rake; - creators["ferocious bite"] = &DruidAiObjectContextInternal::ferocious_bite; - creators["rip"] = &DruidAiObjectContextInternal::rip; - creators["cower"] = &DruidAiObjectContextInternal::cower; - creators["survival instincts"] = &DruidAiObjectContextInternal::survival_instincts; - creators["frenzied regeneration"] = &DruidAiObjectContextInternal::frenzied_regeneration; - creators["thorns"] = &DruidAiObjectContextInternal::thorns; - creators["thorns on party"] = &DruidAiObjectContextInternal::thorns_on_party; - creators["thorns on main tank"] = &DruidAiObjectContextInternal::thorns_on_main_tank; - creators["cure poison"] = &DruidAiObjectContextInternal::cure_poison; - creators["cure poison on party"] = &DruidAiObjectContextInternal::cure_poison_on_party; - creators["abolish poison"] = &DruidAiObjectContextInternal::abolish_poison; - creators["abolish poison on party"] = &DruidAiObjectContextInternal::abolish_poison_on_party; - creators["berserk"] = &DruidAiObjectContextInternal::berserk; - creators["tiger's fury"] = &DruidAiObjectContextInternal::tigers_fury; - creators["mark of the wild"] = &DruidAiObjectContextInternal::mark_of_the_wild; - creators["mark of the wild on party"] = &DruidAiObjectContextInternal::mark_of_the_wild_on_party; - creators["regrowth"] = &DruidAiObjectContextInternal::regrowth; - creators["rejuvenation"] = &DruidAiObjectContextInternal::rejuvenation; - creators["healing touch"] = &DruidAiObjectContextInternal::healing_touch; - creators["regrowth on party"] = &DruidAiObjectContextInternal::regrowth_on_party; - creators["rejuvenation on party"] = &DruidAiObjectContextInternal::rejuvenation_on_party; - creators["healing touch on party"] = &DruidAiObjectContextInternal::healing_touch_on_party; - creators["rebirth"] = &DruidAiObjectContextInternal::rebirth; - creators["revive"] = &DruidAiObjectContextInternal::revive; - creators["barskin"] = &DruidAiObjectContextInternal::barskin; - creators["lacerate"] = &DruidAiObjectContextInternal::lacerate; - creators["hurricane"] = &DruidAiObjectContextInternal::hurricane; - creators["innervate"] = &DruidAiObjectContextInternal::innervate; - creators["tranquility"] = &DruidAiObjectContextInternal::tranquility; - creators["bash on enemy healer"] = &DruidAiObjectContextInternal::bash_on_enemy_healer; - creators["omen of clarity"] = &DruidAiObjectContextInternal::omen_of_clarity; - creators["nature's swiftness"] = &DruidAiObjectContextInternal::natures_swiftness; - creators["prowl"] = &DruidAiObjectContextInternal::prowl; - creators["dash"] = &DruidAiObjectContextInternal::dash; - creators["shred"] = &DruidAiObjectContextInternal::shred; - creators["ravage"] = &DruidAiObjectContextInternal::ravage; - creators["pounce"] = &DruidAiObjectContextInternal::pounce; - creators["wild growth on party"] = &DruidAiObjectContextInternal::wild_growth_on_party; - creators["swiftmend on party"] = &DruidAiObjectContextInternal::swiftmend_on_party; - creators["nourish on party"] = &DruidAiObjectContextInternal::nourish_on_party; - creators["remove curse on party"] = &DruidAiObjectContextInternal::remove_curse_on_party; - creators["insect swarm on attacker"] = &DruidAiObjectContextInternal::insect_swarm_on_attacker; - creators["moonfire on attacker"] = &DruidAiObjectContextInternal::moonfire_on_attacker; - creators["enrage"] = &DruidAiObjectContextInternal::enrage; - } +public: + DruidAiObjectContextInternal() + { + creators["feral charge - bear"] = &DruidAiObjectContextInternal::feral_charge_bear; + creators["feral charge - cat"] = &DruidAiObjectContextInternal::feral_charge_cat; + creators["swipe (bear)"] = &DruidAiObjectContextInternal::swipe_bear; + creators["faerie fire (feral)"] = &DruidAiObjectContextInternal::faerie_fire_feral; + creators["faerie fire"] = &DruidAiObjectContextInternal::faerie_fire; + creators["bear form"] = &DruidAiObjectContextInternal::bear_form; + creators["dire bear form"] = &DruidAiObjectContextInternal::dire_bear_form; + creators["moonkin form"] = &DruidAiObjectContextInternal::moonkin_form; + creators["cat form"] = &DruidAiObjectContextInternal::cat_form; + creators["tree form"] = &DruidAiObjectContextInternal::tree_form; + creators["travel form"] = &DruidAiObjectContextInternal::travel_form; + creators["aquatic form"] = &DruidAiObjectContextInternal::aquatic_form; + creators["caster form"] = &DruidAiObjectContextInternal::caster_form; + creators["mangle (bear)"] = &DruidAiObjectContextInternal::mangle_bear; + creators["maul"] = &DruidAiObjectContextInternal::maul; + creators["bash"] = &DruidAiObjectContextInternal::bash; + creators["swipe"] = &DruidAiObjectContextInternal::swipe; + creators["growl"] = &DruidAiObjectContextInternal::growl; + creators["demoralizing roar"] = &DruidAiObjectContextInternal::demoralizing_roar; + creators["hibernate"] = &DruidAiObjectContextInternal::hibernate; + creators["entangling roots"] = &DruidAiObjectContextInternal::entangling_roots; + creators["entangling roots on cc"] = &DruidAiObjectContextInternal::entangling_roots_on_cc; + creators["hibernate"] = &DruidAiObjectContextInternal::hibernate; + creators["hibernate on cc"] = &DruidAiObjectContextInternal::hibernate_on_cc; + creators["wrath"] = &DruidAiObjectContextInternal::wrath; + creators["starfall"] = &DruidAiObjectContextInternal::starfall; + creators["insect swarm"] = &DruidAiObjectContextInternal::insect_swarm; + creators["moonfire"] = &DruidAiObjectContextInternal::moonfire; + creators["starfire"] = &DruidAiObjectContextInternal::starfire; + creators["nature's grasp"] = &DruidAiObjectContextInternal::natures_grasp; + creators["claw"] = &DruidAiObjectContextInternal::claw; + creators["mangle (cat)"] = &DruidAiObjectContextInternal::mangle_cat; + creators["swipe (cat)"] = &DruidAiObjectContextInternal::swipe_cat; + creators["rake"] = &DruidAiObjectContextInternal::rake; + creators["ferocious bite"] = &DruidAiObjectContextInternal::ferocious_bite; + creators["rip"] = &DruidAiObjectContextInternal::rip; + creators["cower"] = &DruidAiObjectContextInternal::cower; + creators["survival instincts"] = &DruidAiObjectContextInternal::survival_instincts; + creators["frenzied regeneration"] = &DruidAiObjectContextInternal::frenzied_regeneration; + creators["thorns"] = &DruidAiObjectContextInternal::thorns; + creators["thorns on party"] = &DruidAiObjectContextInternal::thorns_on_party; + creators["thorns on main tank"] = &DruidAiObjectContextInternal::thorns_on_main_tank; + creators["cure poison"] = &DruidAiObjectContextInternal::cure_poison; + creators["cure poison on party"] = &DruidAiObjectContextInternal::cure_poison_on_party; + creators["abolish poison"] = &DruidAiObjectContextInternal::abolish_poison; + creators["abolish poison on party"] = &DruidAiObjectContextInternal::abolish_poison_on_party; + creators["berserk"] = &DruidAiObjectContextInternal::berserk; + creators["tiger's fury"] = &DruidAiObjectContextInternal::tigers_fury; + creators["mark of the wild"] = &DruidAiObjectContextInternal::mark_of_the_wild; + creators["mark of the wild on party"] = &DruidAiObjectContextInternal::mark_of_the_wild_on_party; + creators["regrowth"] = &DruidAiObjectContextInternal::regrowth; + creators["rejuvenation"] = &DruidAiObjectContextInternal::rejuvenation; + creators["healing touch"] = &DruidAiObjectContextInternal::healing_touch; + creators["regrowth on party"] = &DruidAiObjectContextInternal::regrowth_on_party; + creators["rejuvenation on party"] = &DruidAiObjectContextInternal::rejuvenation_on_party; + creators["healing touch on party"] = &DruidAiObjectContextInternal::healing_touch_on_party; + creators["rebirth"] = &DruidAiObjectContextInternal::rebirth; + creators["revive"] = &DruidAiObjectContextInternal::revive; + creators["barskin"] = &DruidAiObjectContextInternal::barskin; + creators["lacerate"] = &DruidAiObjectContextInternal::lacerate; + creators["hurricane"] = &DruidAiObjectContextInternal::hurricane; + creators["innervate"] = &DruidAiObjectContextInternal::innervate; + creators["tranquility"] = &DruidAiObjectContextInternal::tranquility; + creators["bash on enemy healer"] = &DruidAiObjectContextInternal::bash_on_enemy_healer; + creators["omen of clarity"] = &DruidAiObjectContextInternal::omen_of_clarity; + creators["nature's swiftness"] = &DruidAiObjectContextInternal::natures_swiftness; + creators["prowl"] = &DruidAiObjectContextInternal::prowl; + creators["dash"] = &DruidAiObjectContextInternal::dash; + creators["shred"] = &DruidAiObjectContextInternal::shred; + creators["ravage"] = &DruidAiObjectContextInternal::ravage; + creators["pounce"] = &DruidAiObjectContextInternal::pounce; + creators["wild growth on party"] = &DruidAiObjectContextInternal::wild_growth_on_party; + creators["swiftmend on party"] = &DruidAiObjectContextInternal::swiftmend_on_party; + creators["nourish on party"] = &DruidAiObjectContextInternal::nourish_on_party; + creators["remove curse on party"] = &DruidAiObjectContextInternal::remove_curse_on_party; + creators["insect swarm on attacker"] = &DruidAiObjectContextInternal::insect_swarm_on_attacker; + creators["moonfire on attacker"] = &DruidAiObjectContextInternal::moonfire_on_attacker; + creators["enrage"] = &DruidAiObjectContextInternal::enrage; + } - private: - static Action* natures_swiftness(PlayerbotAI* botAI) { return new CastNaturesSwiftnessAction(botAI); } - static Action* omen_of_clarity(PlayerbotAI* botAI) { return new CastOmenOfClarityAction(botAI); } - static Action* tranquility(PlayerbotAI* botAI) { return new CastTranquilityAction(botAI); } - static Action* feral_charge_bear(PlayerbotAI* botAI) { return new CastFeralChargeBearAction(botAI); } - static Action* feral_charge_cat(PlayerbotAI* botAI) { return new CastFeralChargeCatAction(botAI); } - static Action* swipe_bear(PlayerbotAI* botAI) { return new CastSwipeBearAction(botAI); } - static Action* faerie_fire_feral(PlayerbotAI* botAI) { return new CastFaerieFireFeralAction(botAI); } - static Action* faerie_fire(PlayerbotAI* botAI) { return new CastFaerieFireAction(botAI); } - static Action* bear_form(PlayerbotAI* botAI) { return new CastBearFormAction(botAI); } - static Action* dire_bear_form(PlayerbotAI* botAI) { return new CastDireBearFormAction(botAI); } - static Action* cat_form(PlayerbotAI* botAI) { return new CastCatFormAction(botAI); } - static Action* tree_form(PlayerbotAI* botAI) { return new CastTreeFormAction(botAI); } - static Action* travel_form(PlayerbotAI* botAI) { return new CastTravelFormAction(botAI); } - static Action* aquatic_form(PlayerbotAI* botAI) { return new CastAquaticFormAction(botAI); } - static Action* caster_form(PlayerbotAI* botAI) { return new CastCasterFormAction(botAI); } - static Action* mangle_bear(PlayerbotAI* botAI) { return new CastMangleBearAction(botAI); } - static Action* maul(PlayerbotAI* botAI) { return new CastMaulAction(botAI); } - static Action* bash(PlayerbotAI* botAI) { return new CastBashAction(botAI); } - static Action* swipe(PlayerbotAI* botAI) { return new CastSwipeAction(botAI); } - static Action* growl(PlayerbotAI* botAI) { return new CastGrowlAction(botAI); } - static Action* demoralizing_roar(PlayerbotAI* botAI) { return new CastDemoralizingRoarAction(botAI); } - static Action* moonkin_form(PlayerbotAI* botAI) { return new CastMoonkinFormAction(botAI); } - static Action* hibernate(PlayerbotAI* botAI) { return new CastHibernateAction(botAI); } - static Action* entangling_roots(PlayerbotAI* botAI) { return new CastEntanglingRootsAction(botAI); } - static Action* hibernate_on_cc(PlayerbotAI* botAI) { return new CastHibernateCcAction(botAI); } - static Action* entangling_roots_on_cc(PlayerbotAI* botAI) { return new CastEntanglingRootsCcAction(botAI); } - static Action* wrath(PlayerbotAI* botAI) { return new CastWrathAction(botAI); } - static Action* starfall(PlayerbotAI* botAI) { return new CastStarfallAction(botAI); } - static Action* insect_swarm(PlayerbotAI* botAI) { return new CastInsectSwarmAction(botAI); } - static Action* moonfire(PlayerbotAI* botAI) { return new CastMoonfireAction(botAI); } - static Action* starfire(PlayerbotAI* botAI) { return new CastStarfireAction(botAI); } - static Action* natures_grasp(PlayerbotAI* botAI) { return new CastNaturesGraspAction(botAI); } - static Action* claw(PlayerbotAI* botAI) { return new CastClawAction(botAI); } - static Action* mangle_cat(PlayerbotAI* botAI) { return new CastMangleCatAction(botAI); } - static Action* swipe_cat(PlayerbotAI* botAI) { return new CastSwipeCatAction(botAI); } - static Action* rake(PlayerbotAI* botAI) { return new CastRakeAction(botAI); } - static Action* ferocious_bite(PlayerbotAI* botAI) { return new CastFerociousBiteAction(botAI); } - static Action* rip(PlayerbotAI* botAI) { return new CastRipAction(botAI); } - static Action* cower(PlayerbotAI* botAI) { return new CastCowerAction(botAI); } - static Action* survival_instincts(PlayerbotAI* botAI) { return new CastSurvivalInstinctsAction(botAI); } - static Action* frenzied_regeneration(PlayerbotAI* botAI) { return new CastFrenziedRegenerationAction(botAI); } - static Action* thorns(PlayerbotAI* botAI) { return new CastThornsAction(botAI); } - static Action* thorns_on_party(PlayerbotAI* botAI) { return new CastThornsOnPartyAction(botAI); } - static Action* thorns_on_main_tank(PlayerbotAI* botAI) { return new CastThornsOnMainTankAction(botAI); } - static Action* cure_poison(PlayerbotAI* botAI) { return new CastCurePoisonAction(botAI); } - static Action* cure_poison_on_party(PlayerbotAI* botAI) { return new CastCurePoisonOnPartyAction(botAI); } - static Action* abolish_poison(PlayerbotAI* botAI) { return new CastAbolishPoisonAction(botAI); } - static Action* abolish_poison_on_party(PlayerbotAI* botAI) { return new CastAbolishPoisonOnPartyAction(botAI); } - static Action* berserk(PlayerbotAI* botAI) { return new CastBerserkAction(botAI); } - static Action* tigers_fury(PlayerbotAI* botAI) { return new CastTigersFuryAction(botAI); } - static Action* mark_of_the_wild(PlayerbotAI* botAI) { return new CastMarkOfTheWildAction(botAI); } - static Action* mark_of_the_wild_on_party(PlayerbotAI* botAI) { return new CastMarkOfTheWildOnPartyAction(botAI); } - static Action* regrowth(PlayerbotAI* botAI) { return new CastRegrowthAction(botAI); } - static Action* rejuvenation(PlayerbotAI* botAI) { return new CastRejuvenationAction(botAI); } - static Action* healing_touch(PlayerbotAI* botAI) { return new CastHealingTouchAction(botAI); } - static Action* regrowth_on_party(PlayerbotAI* botAI) { return new CastRegrowthOnPartyAction(botAI); } - static Action* rejuvenation_on_party(PlayerbotAI* botAI) { return new CastRejuvenationOnPartyAction(botAI); } - static Action* healing_touch_on_party(PlayerbotAI* botAI) { return new CastHealingTouchOnPartyAction(botAI); } - static Action* rebirth(PlayerbotAI* botAI) { return new CastRebirthAction(botAI); } - static Action* revive(PlayerbotAI* botAI) { return new CastReviveAction(botAI); } - static Action* barskin(PlayerbotAI* botAI) { return new CastBarskinAction(botAI); } - static Action* lacerate(PlayerbotAI* botAI) { return new CastLacerateAction(botAI); } - static Action* hurricane(PlayerbotAI* botAI) { return new CastHurricaneAction(botAI); } - static Action* innervate(PlayerbotAI* botAI) { return new CastInnervateAction(botAI); } - static Action* bash_on_enemy_healer(PlayerbotAI* botAI) { return new CastBashOnEnemyHealerAction(botAI); } - static Action* ravage(PlayerbotAI* botAI) { return new CastRavageAction(botAI); } - static Action* pounce(PlayerbotAI* botAI) { return new CastPounceAction(botAI); } - static Action* prowl(PlayerbotAI* botAI) { return new CastProwlAction(botAI); } - static Action* dash(PlayerbotAI* botAI) { return new CastDashAction(botAI); } - static Action* shred(PlayerbotAI* botAI) { return new CastShredAction(botAI); } - static Action* wild_growth_on_party(PlayerbotAI* ai) { return new CastWildGrowthOnPartyAction(ai); } - static Action* swiftmend_on_party(PlayerbotAI *ai) { return new CastPartySwiftmendAction(ai); } - static Action* nourish_on_party(PlayerbotAI *ai) { return new CastPartyNourishAction(ai); } - static Action* remove_curse_on_party(PlayerbotAI *ai) { return new CastDruidRemoveCurseOnPartyAction(ai); } - static Action* insect_swarm_on_attacker(PlayerbotAI* ai) { return new CastInsectSwarmOnAttackerAction(ai); } - static Action* moonfire_on_attacker(PlayerbotAI* ai) { return new CastMoonfireOnAttackerAction(ai); } - static Action* enrage(PlayerbotAI* ai) { return new CastEnrageAction(ai); } +private: + static Action* natures_swiftness(PlayerbotAI* botAI) { return new CastNaturesSwiftnessAction(botAI); } + static Action* omen_of_clarity(PlayerbotAI* botAI) { return new CastOmenOfClarityAction(botAI); } + static Action* tranquility(PlayerbotAI* botAI) { return new CastTranquilityAction(botAI); } + static Action* feral_charge_bear(PlayerbotAI* botAI) { return new CastFeralChargeBearAction(botAI); } + static Action* feral_charge_cat(PlayerbotAI* botAI) { return new CastFeralChargeCatAction(botAI); } + static Action* swipe_bear(PlayerbotAI* botAI) { return new CastSwipeBearAction(botAI); } + static Action* faerie_fire_feral(PlayerbotAI* botAI) { return new CastFaerieFireFeralAction(botAI); } + static Action* faerie_fire(PlayerbotAI* botAI) { return new CastFaerieFireAction(botAI); } + static Action* bear_form(PlayerbotAI* botAI) { return new CastBearFormAction(botAI); } + static Action* dire_bear_form(PlayerbotAI* botAI) { return new CastDireBearFormAction(botAI); } + static Action* cat_form(PlayerbotAI* botAI) { return new CastCatFormAction(botAI); } + static Action* tree_form(PlayerbotAI* botAI) { return new CastTreeFormAction(botAI); } + static Action* travel_form(PlayerbotAI* botAI) { return new CastTravelFormAction(botAI); } + static Action* aquatic_form(PlayerbotAI* botAI) { return new CastAquaticFormAction(botAI); } + static Action* caster_form(PlayerbotAI* botAI) { return new CastCasterFormAction(botAI); } + static Action* mangle_bear(PlayerbotAI* botAI) { return new CastMangleBearAction(botAI); } + static Action* maul(PlayerbotAI* botAI) { return new CastMaulAction(botAI); } + static Action* bash(PlayerbotAI* botAI) { return new CastBashAction(botAI); } + static Action* swipe(PlayerbotAI* botAI) { return new CastSwipeAction(botAI); } + static Action* growl(PlayerbotAI* botAI) { return new CastGrowlAction(botAI); } + static Action* demoralizing_roar(PlayerbotAI* botAI) { return new CastDemoralizingRoarAction(botAI); } + static Action* moonkin_form(PlayerbotAI* botAI) { return new CastMoonkinFormAction(botAI); } + static Action* hibernate(PlayerbotAI* botAI) { return new CastHibernateAction(botAI); } + static Action* entangling_roots(PlayerbotAI* botAI) { return new CastEntanglingRootsAction(botAI); } + static Action* hibernate_on_cc(PlayerbotAI* botAI) { return new CastHibernateCcAction(botAI); } + static Action* entangling_roots_on_cc(PlayerbotAI* botAI) { return new CastEntanglingRootsCcAction(botAI); } + static Action* wrath(PlayerbotAI* botAI) { return new CastWrathAction(botAI); } + static Action* starfall(PlayerbotAI* botAI) { return new CastStarfallAction(botAI); } + static Action* insect_swarm(PlayerbotAI* botAI) { return new CastInsectSwarmAction(botAI); } + static Action* moonfire(PlayerbotAI* botAI) { return new CastMoonfireAction(botAI); } + static Action* starfire(PlayerbotAI* botAI) { return new CastStarfireAction(botAI); } + static Action* natures_grasp(PlayerbotAI* botAI) { return new CastNaturesGraspAction(botAI); } + static Action* claw(PlayerbotAI* botAI) { return new CastClawAction(botAI); } + static Action* mangle_cat(PlayerbotAI* botAI) { return new CastMangleCatAction(botAI); } + static Action* swipe_cat(PlayerbotAI* botAI) { return new CastSwipeCatAction(botAI); } + static Action* rake(PlayerbotAI* botAI) { return new CastRakeAction(botAI); } + static Action* ferocious_bite(PlayerbotAI* botAI) { return new CastFerociousBiteAction(botAI); } + static Action* rip(PlayerbotAI* botAI) { return new CastRipAction(botAI); } + static Action* cower(PlayerbotAI* botAI) { return new CastCowerAction(botAI); } + static Action* survival_instincts(PlayerbotAI* botAI) { return new CastSurvivalInstinctsAction(botAI); } + static Action* frenzied_regeneration(PlayerbotAI* botAI) { return new CastFrenziedRegenerationAction(botAI); } + static Action* thorns(PlayerbotAI* botAI) { return new CastThornsAction(botAI); } + static Action* thorns_on_party(PlayerbotAI* botAI) { return new CastThornsOnPartyAction(botAI); } + static Action* thorns_on_main_tank(PlayerbotAI* botAI) { return new CastThornsOnMainTankAction(botAI); } + static Action* cure_poison(PlayerbotAI* botAI) { return new CastCurePoisonAction(botAI); } + static Action* cure_poison_on_party(PlayerbotAI* botAI) { return new CastCurePoisonOnPartyAction(botAI); } + static Action* abolish_poison(PlayerbotAI* botAI) { return new CastAbolishPoisonAction(botAI); } + static Action* abolish_poison_on_party(PlayerbotAI* botAI) { return new CastAbolishPoisonOnPartyAction(botAI); } + static Action* berserk(PlayerbotAI* botAI) { return new CastBerserkAction(botAI); } + static Action* tigers_fury(PlayerbotAI* botAI) { return new CastTigersFuryAction(botAI); } + static Action* mark_of_the_wild(PlayerbotAI* botAI) { return new CastMarkOfTheWildAction(botAI); } + static Action* mark_of_the_wild_on_party(PlayerbotAI* botAI) { return new CastMarkOfTheWildOnPartyAction(botAI); } + static Action* regrowth(PlayerbotAI* botAI) { return new CastRegrowthAction(botAI); } + static Action* rejuvenation(PlayerbotAI* botAI) { return new CastRejuvenationAction(botAI); } + static Action* healing_touch(PlayerbotAI* botAI) { return new CastHealingTouchAction(botAI); } + static Action* regrowth_on_party(PlayerbotAI* botAI) { return new CastRegrowthOnPartyAction(botAI); } + static Action* rejuvenation_on_party(PlayerbotAI* botAI) { return new CastRejuvenationOnPartyAction(botAI); } + static Action* healing_touch_on_party(PlayerbotAI* botAI) { return new CastHealingTouchOnPartyAction(botAI); } + static Action* rebirth(PlayerbotAI* botAI) { return new CastRebirthAction(botAI); } + static Action* revive(PlayerbotAI* botAI) { return new CastReviveAction(botAI); } + static Action* barskin(PlayerbotAI* botAI) { return new CastBarskinAction(botAI); } + static Action* lacerate(PlayerbotAI* botAI) { return new CastLacerateAction(botAI); } + static Action* hurricane(PlayerbotAI* botAI) { return new CastHurricaneAction(botAI); } + static Action* innervate(PlayerbotAI* botAI) { return new CastInnervateAction(botAI); } + static Action* bash_on_enemy_healer(PlayerbotAI* botAI) { return new CastBashOnEnemyHealerAction(botAI); } + static Action* ravage(PlayerbotAI* botAI) { return new CastRavageAction(botAI); } + static Action* pounce(PlayerbotAI* botAI) { return new CastPounceAction(botAI); } + static Action* prowl(PlayerbotAI* botAI) { return new CastProwlAction(botAI); } + static Action* dash(PlayerbotAI* botAI) { return new CastDashAction(botAI); } + static Action* shred(PlayerbotAI* botAI) { return new CastShredAction(botAI); } + static Action* wild_growth_on_party(PlayerbotAI* ai) { return new CastWildGrowthOnPartyAction(ai); } + static Action* swiftmend_on_party(PlayerbotAI* ai) { return new CastPartySwiftmendAction(ai); } + static Action* nourish_on_party(PlayerbotAI* ai) { return new CastPartyNourishAction(ai); } + static Action* remove_curse_on_party(PlayerbotAI* ai) { return new CastDruidRemoveCurseOnPartyAction(ai); } + static Action* insect_swarm_on_attacker(PlayerbotAI* ai) { return new CastInsectSwarmOnAttackerAction(ai); } + static Action* moonfire_on_attacker(PlayerbotAI* ai) { return new CastMoonfireOnAttackerAction(ai); } + static Action* enrage(PlayerbotAI* ai) { return new CastEnrageAction(ai); } }; DruidAiObjectContext::DruidAiObjectContext(PlayerbotAI* botAI) : AiObjectContext(botAI) diff --git a/src/strategy/druid/DruidAiObjectContext.h b/src/strategy/druid/DruidAiObjectContext.h index 0401adab..22d00e18 100644 --- a/src/strategy/druid/DruidAiObjectContext.h +++ b/src/strategy/druid/DruidAiObjectContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DRUIDAIOBJECTCONTEXT_H @@ -11,8 +12,8 @@ class PlayerbotAI; class DruidAiObjectContext : public AiObjectContext { - public: - DruidAiObjectContext(PlayerbotAI* botAI); +public: + DruidAiObjectContext(PlayerbotAI* botAI); }; #endif diff --git a/src/strategy/druid/DruidBearActions.cpp b/src/strategy/druid/DruidBearActions.cpp index fd97e049..b04ed968 100644 --- a/src/strategy/druid/DruidBearActions.cpp +++ b/src/strategy/druid/DruidBearActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DruidBearActions.h" + #include "Playerbots.h" bool CastMaulAction::isUseful() diff --git a/src/strategy/druid/DruidBearActions.h b/src/strategy/druid/DruidBearActions.h index 835d4087..8377bdd1 100644 --- a/src/strategy/druid/DruidBearActions.h +++ b/src/strategy/druid/DruidBearActions.h @@ -1,75 +1,76 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DRUIDBEARACTIONS_H #define _PLAYERBOT_DRUIDBEARACTIONS_H -#include "ReachTargetActions.h" #include "GenericSpellActions.h" +#include "ReachTargetActions.h" class PlayerbotAI; class CastFeralChargeBearAction : public CastReachTargetSpellAction { - public: - CastFeralChargeBearAction(PlayerbotAI* botAI) : CastReachTargetSpellAction(botAI, "feral charge - bear", 1.5f) { } +public: + CastFeralChargeBearAction(PlayerbotAI* botAI) : CastReachTargetSpellAction(botAI, "feral charge - bear", 1.5f) {} }; class CastGrowlAction : public CastSpellAction { - public: - CastGrowlAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "growl") { } +public: + CastGrowlAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "growl") {} }; class CastMaulAction : public CastMeleeSpellAction { - public: - CastMaulAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "maul") { } +public: + CastMaulAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "maul") {} - bool isUseful() override; + bool isUseful() override; }; class CastBashAction : public CastMeleeSpellAction { - public: - CastBashAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "bash") { } +public: + CastBashAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "bash") {} }; class CastSwipeAction : public CastMeleeSpellAction { - public: - CastSwipeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "swipe") { } +public: + CastSwipeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "swipe") {} }; class CastDemoralizingRoarAction : public CastDebuffSpellAction { - public: - CastDemoralizingRoarAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "demoralizing roar") { } +public: + CastDemoralizingRoarAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "demoralizing roar") {} }; class CastMangleBearAction : public CastMeleeSpellAction { - public: - CastMangleBearAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "mangle (bear)") { } +public: + CastMangleBearAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "mangle (bear)") {} }; class CastSwipeBearAction : public CastMeleeSpellAction { - public: - CastSwipeBearAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "swipe (bear)") { } +public: + CastSwipeBearAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "swipe (bear)") {} }; class CastLacerateAction : public CastMeleeSpellAction { - public: - CastLacerateAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "lacerate") { } +public: + CastLacerateAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "lacerate") {} }; class CastBashOnEnemyHealerAction : public CastSpellOnEnemyHealerAction { - public: - CastBashOnEnemyHealerAction(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, "bash") { } +public: + CastBashOnEnemyHealerAction(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, "bash") {} }; #endif diff --git a/src/strategy/druid/DruidCatActions.h b/src/strategy/druid/DruidCatActions.h index 343f902e..579bdd00 100644 --- a/src/strategy/druid/DruidCatActions.h +++ b/src/strategy/druid/DruidCatActions.h @@ -1,103 +1,104 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DRUIDCATACTIONS_H #define _PLAYERBOT_DRUIDCATACTIONS_H -#include "ReachTargetActions.h" #include "GenericSpellActions.h" +#include "ReachTargetActions.h" class PlayerbotAI; class CastFeralChargeCatAction : public CastReachTargetSpellAction { - public: - CastFeralChargeCatAction(PlayerbotAI* botAI) : CastReachTargetSpellAction(botAI, "feral charge - cat", 1.5f) { } +public: + CastFeralChargeCatAction(PlayerbotAI* botAI) : CastReachTargetSpellAction(botAI, "feral charge - cat", 1.5f) {} }; class CastCowerAction : public CastBuffSpellAction { - public: - CastCowerAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "cower") { } +public: + CastCowerAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "cower") {} }; class CastBerserkAction : public CastBuffSpellAction { - public: - CastBerserkAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "berserk") { } +public: + CastBerserkAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "berserk") {} }; class CastTigersFuryAction : public CastBuffSpellAction { - public: - CastTigersFuryAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "tiger's fury") { } +public: + CastTigersFuryAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "tiger's fury") {} }; class CastRakeAction : public CastDebuffSpellAction { - public: - CastRakeAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "rake") { } +public: + CastRakeAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "rake") {} }; class CastClawAction : public CastMeleeSpellAction { - public: - CastClawAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "claw") { } +public: + CastClawAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "claw") {} }; class CastMangleCatAction : public CastMeleeSpellAction { - public: - CastMangleCatAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "mangle (cat)") { } +public: + CastMangleCatAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "mangle (cat)") {} }; class CastSwipeCatAction : public CastMeleeSpellAction { - public: - CastSwipeCatAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "swipe (cat)") { } +public: + CastSwipeCatAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "swipe (cat)") {} }; class CastFerociousBiteAction : public CastMeleeSpellAction { - public: - CastFerociousBiteAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "ferocious bite") { } +public: + CastFerociousBiteAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "ferocious bite") {} }; class CastRipAction : public CastMeleeSpellAction { - public: - CastRipAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "rip") { } +public: + CastRipAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "rip") {} }; class CastShredAction : public CastMeleeSpellAction { - public: - CastShredAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "shred") { } +public: + CastShredAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "shred") {} }; class CastProwlAction : public CastBuffSpellAction { - public: - CastProwlAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "prowl") { } +public: + CastProwlAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "prowl") {} }; class CastDashAction : public CastBuffSpellAction { - public: - CastDashAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "dash") { } +public: + CastDashAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "dash") {} }; class CastRavageAction : public CastMeleeSpellAction { - public: - CastRavageAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "ravage") { } +public: + CastRavageAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "ravage") {} }; class CastPounceAction : public CastMeleeSpellAction { - public: - CastPounceAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "pounce") { } +public: + CastPounceAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "pounce") {} }; #endif diff --git a/src/strategy/druid/DruidShapeshiftActions.cpp b/src/strategy/druid/DruidShapeshiftActions.cpp index 89bb2014..9894b1f5 100644 --- a/src/strategy/druid/DruidShapeshiftActions.cpp +++ b/src/strategy/druid/DruidShapeshiftActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DruidShapeshiftActions.h" + #include "Playerbots.h" bool CastBearFormAction::isPossible() @@ -17,7 +19,8 @@ bool CastBearFormAction::isUseful() NextAction** CastDireBearFormAction::getAlternatives() { - return NextAction::merge(NextAction::array(0, new NextAction("bear form"), nullptr), CastSpellAction::getAlternatives()); + return NextAction::merge(NextAction::array(0, new NextAction("bear form"), nullptr), + CastSpellAction::getAlternatives()); } bool CastTravelFormAction::isUseful() @@ -25,13 +28,15 @@ bool CastTravelFormAction::isUseful() bool firstmount = bot->GetLevel() >= 20; // useful if no mount or with wsg flag - return !bot->IsMounted() && (!firstmount || (bot->HasAura(23333) || bot->HasAura(23335) || bot->HasAura(34976))) && !botAI->HasAura("dash", bot); + return !bot->IsMounted() && (!firstmount || (bot->HasAura(23333) || bot->HasAura(23335) || bot->HasAura(34976))) && + !botAI->HasAura("dash", bot); } bool CastCasterFormAction::isUseful() { return botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form", "aquatic form", - "flight form", "swift flight form", "moonkin form", nullptr) && AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig->mediumHealth; + "flight form", "swift flight form", "moonkin form", nullptr) && + AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig->mediumHealth; } bool CastCasterFormAction::Execute(Event event) @@ -40,7 +45,7 @@ bool CastCasterFormAction::Execute(Event event) return true; } -bool CastTreeFormAction::isUseful() { - return GetTarget() && - CastSpellAction::isUseful() && !botAI->HasAura(33891, bot); +bool CastTreeFormAction::isUseful() +{ + return GetTarget() && CastSpellAction::isUseful() && !botAI->HasAura(33891, bot); } \ No newline at end of file diff --git a/src/strategy/druid/DruidShapeshiftActions.h b/src/strategy/druid/DruidShapeshiftActions.h index 49409a3d..1f8fc082 100644 --- a/src/strategy/druid/DruidShapeshiftActions.h +++ b/src/strategy/druid/DruidShapeshiftActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DRUIDSHAPESHIFTACTIONS_H @@ -11,62 +12,62 @@ class PlayerbotAI; class CastBearFormAction : public CastBuffSpellAction { - public: - CastBearFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "bear form") { } +public: + CastBearFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "bear form") {} - bool isPossible() override; - bool isUseful() override; + bool isPossible() override; + bool isUseful() override; }; class CastDireBearFormAction : public CastBuffSpellAction { - public: - CastDireBearFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "dire bear form") { } +public: + CastDireBearFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "dire bear form") {} - NextAction** getAlternatives() override; + NextAction** getAlternatives() override; }; class CastCatFormAction : public CastBuffSpellAction { - public: - CastCatFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "cat form") { } +public: + CastCatFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "cat form") {} }; class CastTreeFormAction : public CastBuffSpellAction { - public: - CastTreeFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "tree of life") { } - bool isUseful() override; +public: + CastTreeFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "tree of life") {} + bool isUseful() override; }; class CastMoonkinFormAction : public CastBuffSpellAction { - public: - CastMoonkinFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "moonkin form") { } +public: + CastMoonkinFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "moonkin form") {} }; class CastAquaticFormAction : public CastBuffSpellAction { - public: - CastAquaticFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aquatic form") { } +public: + CastAquaticFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aquatic form") {} }; class CastTravelFormAction : public CastBuffSpellAction { - public: - CastTravelFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "travel form") { } +public: + CastTravelFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "travel form") {} - bool isUseful() override; + bool isUseful() override; }; class CastCasterFormAction : public CastBuffSpellAction { - public: - CastCasterFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "caster form") { } +public: + CastCasterFormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "caster form") {} - bool isUseful() override; - bool isPossible() override { return true; } - bool Execute(Event event) override; + bool isUseful() override; + bool isPossible() override { return true; } + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/druid/DruidTriggers.cpp b/src/strategy/druid/DruidTriggers.cpp index 137dfc37..d839f973 100644 --- a/src/strategy/druid/DruidTriggers.cpp +++ b/src/strategy/druid/DruidTriggers.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DruidTriggers.h" + #include "Playerbots.h" bool MarkOfTheWildOnPartyTrigger::IsActive() @@ -20,32 +22,17 @@ bool ThornsOnPartyTrigger::IsActive() return BuffOnPartyTrigger::IsActive() && !botAI->HasAura("thorns", GetTarget()); } -bool MoonfireTrigger::IsActive() -{ - return DebuffTrigger::IsActive() && !GetTarget()->HasUnitState(UNIT_STATE_ROOT); -} +bool MoonfireTrigger::IsActive() { return DebuffTrigger::IsActive() && !GetTarget()->HasUnitState(UNIT_STATE_ROOT); } bool EntanglingRootsKiteTrigger::IsActive() { return DebuffTrigger::IsActive() && AI_VALUE(uint8, "attacker count") < 3 && !GetTarget()->GetPower(POWER_MANA); } -bool ThornsTrigger::IsActive() -{ - return BuffTrigger::IsActive() && !botAI->HasAura("thorns", GetTarget()); -} +bool ThornsTrigger::IsActive() { return BuffTrigger::IsActive() && !botAI->HasAura("thorns", GetTarget()); } -bool BearFormTrigger::IsActive() -{ - return !botAI->HasAnyAuraOf(bot, "bear form", "dire bear form", nullptr); -} +bool BearFormTrigger::IsActive() { return !botAI->HasAnyAuraOf(bot, "bear form", "dire bear form", nullptr); } -bool TreeFormTrigger::IsActive() -{ - return !botAI->HasAura(33891, bot); -} +bool TreeFormTrigger::IsActive() { return !botAI->HasAura(33891, bot); } -bool CatFormTrigger::IsActive() -{ - return !botAI->HasAura("cat form", bot); -} +bool CatFormTrigger::IsActive() { return !botAI->HasAura("cat form", bot); } diff --git a/src/strategy/druid/DruidTriggers.h b/src/strategy/druid/DruidTriggers.h index bafa9b63..392b487e 100644 --- a/src/strategy/druid/DruidTriggers.h +++ b/src/strategy/druid/DruidTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DRUIDTRIGGERS_H @@ -7,208 +8,208 @@ #include "CureTriggers.h" #include "GenericTriggers.h" -#include "SharedDefines.h" #include "Player.h" +#include "SharedDefines.h" class PlayerbotAI; class MarkOfTheWildOnPartyTrigger : public BuffOnPartyTrigger { - public: - MarkOfTheWildOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "mark of the wild", 2 * 2000) { } +public: + MarkOfTheWildOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "mark of the wild", 2 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class MarkOfTheWildTrigger : public BuffTrigger { - public: - MarkOfTheWildTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "mark of the wild", 2 * 2000) { } +public: + MarkOfTheWildTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "mark of the wild", 2 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class ThornsOnPartyTrigger : public BuffOnPartyTrigger { - public: - ThornsOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "thorns", 2 * 2000) { } +public: + ThornsOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "thorns", 2 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class ThornsOnMainTankTrigger : public BuffOnMainTankTrigger { - public: - ThornsOnMainTankTrigger(PlayerbotAI* botAI) : BuffOnMainTankTrigger(botAI, "thorns", false, 2 * 2000) { } - +public: + ThornsOnMainTankTrigger(PlayerbotAI* botAI) : BuffOnMainTankTrigger(botAI, "thorns", false, 2 * 2000) {} }; class ThornsTrigger : public BuffTrigger { - public: - ThornsTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "thorns", 2 * 2000) { } +public: + ThornsTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "thorns", 2 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class OmenOfClarityTrigger : public BuffTrigger { - public: - OmenOfClarityTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "omen of clarity") { } +public: + OmenOfClarityTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "omen of clarity") {} }; class RakeTrigger : public DebuffTrigger { - public: - RakeTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "rake", 1, true) { } +public: + RakeTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "rake", 1, true) {} }; class InsectSwarmTrigger : public DebuffTrigger { - public: - InsectSwarmTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "insect swarm", 1, true) { } +public: + InsectSwarmTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "insect swarm", 1, true) {} }; class MoonfireTrigger : public DebuffTrigger { - public: - MoonfireTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "moonfire", 1, true) { } +public: + MoonfireTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "moonfire", 1, true) {} - bool IsActive() override; + bool IsActive() override; }; class FaerieFireTrigger : public DebuffTrigger { - public: - FaerieFireTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "faerie fire", 1, false, 25.0f) { } +public: + FaerieFireTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "faerie fire", 1, false, 25.0f) {} }; class FaerieFireFeralTrigger : public DebuffTrigger { - public: - FaerieFireFeralTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "faerie fire (feral)") { } +public: + FaerieFireFeralTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "faerie fire (feral)") {} }; class BashInterruptSpellTrigger : public InterruptSpellTrigger { - public: - BashInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "bash") { } +public: + BashInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "bash") {} }; class TigersFuryTrigger : public BoostTrigger { - public: - TigersFuryTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "tiger's fury") { } +public: + TigersFuryTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "tiger's fury") {} }; class NaturesGraspTrigger : public BoostTrigger { - public: - NaturesGraspTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "nature's grasp") { } +public: + NaturesGraspTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "nature's grasp") {} }; class EntanglingRootsTrigger : public HasCcTargetTrigger { - public: - EntanglingRootsTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "entangling roots") { } +public: + EntanglingRootsTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "entangling roots") {} }; class EntanglingRootsKiteTrigger : public DebuffTrigger { - public: - EntanglingRootsKiteTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "entangling roots") { } +public: + EntanglingRootsKiteTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "entangling roots") {} - bool IsActive() override; + bool IsActive() override; }; class HibernateTrigger : public HasCcTargetTrigger { - public: - HibernateTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "hibernate") { } +public: + HibernateTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "hibernate") {} }; class CurePoisonTrigger : public NeedCureTrigger { - public: - CurePoisonTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cure poison", DISPEL_POISON) { } +public: + CurePoisonTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cure poison", DISPEL_POISON) {} }; class PartyMemberCurePoisonTrigger : public PartyMemberNeedCureTrigger { - public: - PartyMemberCurePoisonTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "cure poison", DISPEL_POISON) { } +public: + PartyMemberCurePoisonTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "cure poison", DISPEL_POISON) + { + } }; class BearFormTrigger : public BuffTrigger { - public: - BearFormTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "bear form") { } +public: + BearFormTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "bear form") {} - bool IsActive() override; + bool IsActive() override; }; class TreeFormTrigger : public BuffTrigger { - public: - TreeFormTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "tree of life") { } +public: + TreeFormTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "tree of life") {} - bool IsActive() override; + bool IsActive() override; }; class CatFormTrigger : public BuffTrigger { - public: - CatFormTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "cat form") { } +public: + CatFormTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "cat form") {} - bool IsActive() override; + bool IsActive() override; }; class EclipseSolarTrigger : public HasAuraTrigger { - public: - EclipseSolarTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "eclipse (solar)") { } +public: + EclipseSolarTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "eclipse (solar)") {} }; class EclipseLunarTrigger : public HasAuraTrigger { - public: - EclipseLunarTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "eclipse (lunar)") { } +public: + EclipseLunarTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "eclipse (lunar)") {} }; class BashInterruptEnemyHealerSpellTrigger : public InterruptEnemyHealerTrigger { - public: - BashInterruptEnemyHealerSpellTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "bash") { } +public: + BashInterruptEnemyHealerSpellTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "bash") {} }; class NaturesSwiftnessTrigger : public BuffTrigger { - public: - NaturesSwiftnessTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "nature's swiftness") { } +public: + NaturesSwiftnessTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "nature's swiftness") {} }; class DruidPartyMemberRemoveCurseTrigger : public PartyMemberNeedCureTrigger { - public: - DruidPartyMemberRemoveCurseTrigger(PlayerbotAI* ai) : PartyMemberNeedCureTrigger(ai, "druid remove curse", DISPEL_CURSE) {} +public: + DruidPartyMemberRemoveCurseTrigger(PlayerbotAI* ai) + : PartyMemberNeedCureTrigger(ai, "druid remove curse", DISPEL_CURSE) + { + } }; class EclipseSolarCooldownTrigger : public SpellCooldownTrigger { - public: - EclipseSolarCooldownTrigger(PlayerbotAI* ai): SpellCooldownTrigger(ai, "eclipse (solar)") {} - bool IsActive() override { - return bot->HasSpellCooldown(48517); - } +public: + EclipseSolarCooldownTrigger(PlayerbotAI* ai) : SpellCooldownTrigger(ai, "eclipse (solar)") {} + bool IsActive() override { return bot->HasSpellCooldown(48517); } }; class EclipseLunarCooldownTrigger : public SpellCooldownTrigger { - public: - EclipseLunarCooldownTrigger(PlayerbotAI* ai): SpellCooldownTrigger(ai, "eclipse (lunar)") {} - bool IsActive() override { - return bot->HasSpellCooldown(48518); - } +public: + EclipseLunarCooldownTrigger(PlayerbotAI* ai) : SpellCooldownTrigger(ai, "eclipse (lunar)") {} + bool IsActive() override { return bot->HasSpellCooldown(48518); } }; #endif diff --git a/src/strategy/druid/FeralDruidStrategy.cpp b/src/strategy/druid/FeralDruidStrategy.cpp index a3779405..c00e4620 100644 --- a/src/strategy/druid/FeralDruidStrategy.cpp +++ b/src/strategy/druid/FeralDruidStrategy.cpp @@ -1,89 +1,91 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "FeralDruidStrategy.h" + #include "Playerbots.h" class FeralDruidStrategyActionNodeFactory : public NamedObjectFactory { - public: - FeralDruidStrategyActionNodeFactory() - { - creators["survival instincts"] = &survival_instincts; - creators["thorns"] = þs; - creators["omen of clarity"] = &omen_of_clarity; - creators["cure poison"] = &cure_poison; - creators["cure poison on party"] = &cure_poison_on_party; - creators["abolish poison"] = &abolish_poison; - creators["abolish poison on party"] = &abolish_poison_on_party; - creators["prowl"] = &prowl; - } +public: + FeralDruidStrategyActionNodeFactory() + { + creators["survival instincts"] = &survival_instincts; + creators["thorns"] = þs; + creators["omen of clarity"] = &omen_of_clarity; + creators["cure poison"] = &cure_poison; + creators["cure poison on party"] = &cure_poison_on_party; + creators["abolish poison"] = &abolish_poison; + creators["abolish poison on party"] = &abolish_poison_on_party; + creators["prowl"] = &prowl; + } - private: - static ActionNode* survival_instincts([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("survival instincts", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("barskin"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* survival_instincts([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("survival instincts", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("barskin"), nullptr), + /*C*/ nullptr); + } - static ActionNode* thorns([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("thorns", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* thorns([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("thorns", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* omen_of_clarity([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("omen of clarity", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* omen_of_clarity([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("omen of clarity", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* cure_poison([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("cure poison", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* cure_poison([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("cure poison", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* cure_poison_on_party([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("cure poison on party", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* cure_poison_on_party([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("cure poison on party", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* abolish_poison([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("abolish poison", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* abolish_poison([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("abolish poison", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* abolish_poison_on_party([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("abolish poison on party", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* abolish_poison_on_party([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("abolish poison on party", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* prowl([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("prowl", - /*P*/ NextAction::array(0, new NextAction("cat form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* prowl([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("prowl", + /*P*/ NextAction::array(0, new NextAction("cat form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } }; FeralDruidStrategy::FeralDruidStrategy(PlayerbotAI* botAI) : GenericDruidStrategy(botAI) @@ -96,12 +98,18 @@ void FeralDruidStrategy::InitTriggers(std::vector& triggers) { GenericDruidStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("not facing target", NextAction::array(0, new NextAction("set facing", ACTION_NORMAL + 7), nullptr))); - triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("reach melee", ACTION_NORMAL + 8), nullptr))); - // triggers.push_back(new TriggerNode("enemy too close for melee", NextAction::array(0, new NextAction("move out of enemy contact", ACTION_NORMAL + 8), nullptr))); - triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("survival instincts", ACTION_EMERGENCY + 1), nullptr))); - triggers.push_back(new TriggerNode("omen of clarity", NextAction::array(0, new NextAction("omen of clarity", ACTION_HIGH + 9), nullptr))); - triggers.push_back(new TriggerNode("player has flag", NextAction::array(0, new NextAction("dash", ACTION_EMERGENCY + 2), nullptr))); - triggers.push_back(new TriggerNode("enemy flagcarrier near", NextAction::array(0, new NextAction("dash", ACTION_EMERGENCY + 2), nullptr))); + // triggers.push_back(new TriggerNode("not facing target", NextAction::array(0, new NextAction("set facing", + // ACTION_NORMAL + 7), nullptr))); + triggers.push_back(new TriggerNode( + "enemy out of melee", NextAction::array(0, new NextAction("reach melee", ACTION_NORMAL + 8), nullptr))); + // triggers.push_back(new TriggerNode("enemy too close for melee", NextAction::array(0, new NextAction("move out of + // enemy contact", ACTION_NORMAL + 8), nullptr))); + triggers.push_back(new TriggerNode( + "critical health", NextAction::array(0, new NextAction("survival instincts", ACTION_EMERGENCY + 1), nullptr))); + triggers.push_back(new TriggerNode( + "omen of clarity", NextAction::array(0, new NextAction("omen of clarity", ACTION_HIGH + 9), nullptr))); + triggers.push_back(new TriggerNode("player has flag", + NextAction::array(0, new NextAction("dash", ACTION_EMERGENCY + 2), nullptr))); + triggers.push_back(new TriggerNode("enemy flagcarrier near", + NextAction::array(0, new NextAction("dash", ACTION_EMERGENCY + 2), nullptr))); } - diff --git a/src/strategy/druid/FeralDruidStrategy.h b/src/strategy/druid/FeralDruidStrategy.h index 8eb5bfae..bc27c34b 100644 --- a/src/strategy/druid/FeralDruidStrategy.h +++ b/src/strategy/druid/FeralDruidStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_FERALRUIDSTRATEGY_H @@ -11,75 +12,75 @@ class PlayerbotAI; class ShapeshiftDruidStrategyActionNodeFactory : public NamedObjectFactory { - public: - ShapeshiftDruidStrategyActionNodeFactory() - { - creators["rejuvenation"] = &rejuvenation; - creators["regrowth"] = ®rowth; - creators["healing touch"] = &healing_touch; - creators["rejuvenation on party"] = &rejuvenation_on_party; - creators["regrowth on party"] = ®rowth_on_party; - creators["healing touch on party"] = &healing_touch_on_party; - } +public: + ShapeshiftDruidStrategyActionNodeFactory() + { + creators["rejuvenation"] = &rejuvenation; + creators["regrowth"] = ®rowth; + creators["healing touch"] = &healing_touch; + creators["rejuvenation on party"] = &rejuvenation_on_party; + creators["regrowth on party"] = ®rowth_on_party; + creators["healing touch on party"] = &healing_touch_on_party; + } - private: - static ActionNode* regrowth(PlayerbotAI* botAI) - { - return new ActionNode ("regrowth", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ NextAction::array(0, new NextAction("healing touch"), nullptr), - /*C*/ NextAction::array(0, new NextAction("melee", 10.0f), nullptr)); - } +private: + static ActionNode* regrowth(PlayerbotAI* botAI) + { + return new ActionNode("regrowth", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ NextAction::array(0, new NextAction("healing touch"), nullptr), + /*C*/ NextAction::array(0, new NextAction("melee", 10.0f), nullptr)); + } - static ActionNode* rejuvenation(PlayerbotAI* botAI) - { - return new ActionNode ("rejuvenation", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* rejuvenation(PlayerbotAI* botAI) + { + return new ActionNode("rejuvenation", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* healing_touch(PlayerbotAI* botAI) - { - return new ActionNode ("healing touch", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* healing_touch(PlayerbotAI* botAI) + { + return new ActionNode("healing touch", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* regrowth_on_party(PlayerbotAI* botAI) - { - return new ActionNode ("regrowth on party", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ NextAction::array(0, new NextAction("healing touch on party"), nullptr), - /*C*/ NextAction::array(0, new NextAction("melee", 10.0f), nullptr)); - } + static ActionNode* regrowth_on_party(PlayerbotAI* botAI) + { + return new ActionNode("regrowth on party", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ NextAction::array(0, new NextAction("healing touch on party"), nullptr), + /*C*/ NextAction::array(0, new NextAction("melee", 10.0f), nullptr)); + } - static ActionNode* rejuvenation_on_party(PlayerbotAI* botAI) - { - return new ActionNode ("rejuvenation on party", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* rejuvenation_on_party(PlayerbotAI* botAI) + { + return new ActionNode("rejuvenation on party", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* healing_touch_on_party(PlayerbotAI* botAI) - { - return new ActionNode ("healing touch on party", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* healing_touch_on_party(PlayerbotAI* botAI) + { + return new ActionNode("healing touch on party", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } }; class FeralDruidStrategy : public GenericDruidStrategy { - protected: - FeralDruidStrategy(PlayerbotAI* botAI); +protected: + FeralDruidStrategy(PlayerbotAI* botAI); - public: - void InitTriggers(std::vector& triggers) override; - uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_MELEE; } +public: + void InitTriggers(std::vector& triggers) override; + uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_MELEE; } }; #endif diff --git a/src/strategy/druid/GenericDruidNonCombatStrategy.cpp b/src/strategy/druid/GenericDruidNonCombatStrategy.cpp index 172776f7..398ba274 100644 --- a/src/strategy/druid/GenericDruidNonCombatStrategy.cpp +++ b/src/strategy/druid/GenericDruidNonCombatStrategy.cpp @@ -1,101 +1,103 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericDruidNonCombatStrategy.h" + #include "Playerbots.h" class GenericDruidNonCombatStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericDruidNonCombatStrategyActionNodeFactory() - { - creators["thorns"] = þs; - creators["thorns on party"] = þs_on_party; - creators["mark of the wild"] = &mark_of_the_wild; - creators["mark of the wild on party"] = &mark_of_the_wild_on_party; - // creators["innervate"] = &innervate; - creators["regrowth_on_party"] = ®rowth_on_party; - creators["rejuvenation on party"] = &rejuvenation_on_party; - creators["remove curse on party"] = &remove_curse_on_party; - creators["abolish poison on party"] = &abolish_poison_on_party; - creators["revive"] = &revive; - } +public: + GenericDruidNonCombatStrategyActionNodeFactory() + { + creators["thorns"] = þs; + creators["thorns on party"] = þs_on_party; + creators["mark of the wild"] = &mark_of_the_wild; + creators["mark of the wild on party"] = &mark_of_the_wild_on_party; + // creators["innervate"] = &innervate; + creators["regrowth_on_party"] = ®rowth_on_party; + creators["rejuvenation on party"] = &rejuvenation_on_party; + creators["remove curse on party"] = &remove_curse_on_party; + creators["abolish poison on party"] = &abolish_poison_on_party; + creators["revive"] = &revive; + } - private: - static ActionNode* thorns([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("thorns", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } +private: + static ActionNode* thorns([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("thorns", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* thorns_on_party([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("thorns on party", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* thorns_on_party([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("thorns on party", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* mark_of_the_wild([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("mark of the wild", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* mark_of_the_wild([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("mark of the wild", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* mark_of_the_wild_on_party([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("mark of the wild on party", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* regrowth_on_party(PlayerbotAI* ai) - { - return new ActionNode ("regrowth on party", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* rejuvenation_on_party(PlayerbotAI* ai) - { - return new ActionNode ("rejuvenation on party", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* remove_curse_on_party(PlayerbotAI* ai) - { - return new ActionNode ("remove curse on party", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* abolish_poison_on_party(PlayerbotAI* ai) - { - return new ActionNode ("abolish poison on party", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* revive(PlayerbotAI* ai) - { - return new ActionNode ("revive", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ NULL, - /*C*/ NULL); - } - // static ActionNode* innervate([[maybe_unused]] PlayerbotAI* botAI) - // { - // return new ActionNode ("innervate", - // /*P*/ nullptr, - // /*A*/ NextAction::array(0, new NextAction("drink"), nullptr), - // /*C*/ nullptr); - // } + static ActionNode* mark_of_the_wild_on_party([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("mark of the wild on party", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* regrowth_on_party(PlayerbotAI* ai) + { + return new ActionNode("regrowth on party", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* rejuvenation_on_party(PlayerbotAI* ai) + { + return new ActionNode("rejuvenation on party", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* remove_curse_on_party(PlayerbotAI* ai) + { + return new ActionNode("remove curse on party", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* abolish_poison_on_party(PlayerbotAI* ai) + { + return new ActionNode("abolish poison on party", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* revive(PlayerbotAI* ai) + { + return new ActionNode("revive", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ NULL, + /*C*/ NULL); + } + // static ActionNode* innervate([[maybe_unused]] PlayerbotAI* botAI) + // { + // return new ActionNode ("innervate", + // /*P*/ nullptr, + // /*A*/ NextAction::array(0, new NextAction("drink"), nullptr), + // /*C*/ nullptr); + // } }; GenericDruidNonCombatStrategy::GenericDruidNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) @@ -107,32 +109,42 @@ void GenericDruidNonCombatStrategy::InitTriggers(std::vector& trig { NonCombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("mark of the wild", NextAction::array(0, new NextAction("mark of the wild", 14.0f), nullptr))); + triggers.push_back( + new TriggerNode("mark of the wild", NextAction::array(0, new NextAction("mark of the wild", 14.0f), nullptr))); // triggers.push_back(new TriggerNode("thorns", NextAction::array(0, new NextAction("thorns", 12.0f), nullptr))); - // triggers.push_back(new TriggerNode("cure poison", NextAction::array(0, new NextAction("abolish poison", 21.0f), nullptr))); - triggers.push_back(new TriggerNode("party member cure poison", NextAction::array(0, new NextAction("abolish poison on party", 20.0f), nullptr))); - triggers.push_back(new TriggerNode("party member dead", NextAction::array(0, new NextAction("revive", ACTION_CRITICAL_HEAL + 10), nullptr))); - // triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("innervate", ACTION_EMERGENCY + 5), nullptr))); - // triggers.push_back(new TriggerNode("swimming", NextAction::array(0, new NextAction("aquatic form", 1.0f), nullptr))); + // triggers.push_back(new TriggerNode("cure poison", NextAction::array(0, new NextAction("abolish poison", 21.0f), + // nullptr))); + triggers.push_back(new TriggerNode( + "party member cure poison", NextAction::array(0, new NextAction("abolish poison on party", 20.0f), nullptr))); + triggers.push_back(new TriggerNode( + "party member dead", NextAction::array(0, new NextAction("revive", ACTION_CRITICAL_HEAL + 10), nullptr))); + // triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("innervate", ACTION_EMERGENCY + // + 5), nullptr))); triggers.push_back(new TriggerNode("swimming", NextAction::array(0, new NextAction("aquatic + // form", 1.0f), nullptr))); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("apply oil", 1.0f), nullptr))); - triggers.push_back(new TriggerNode("party member critical health", - NextAction::array(0, new NextAction("rejuvenation on party", ACTION_MEDIUM_HEAL + 5), - new NextAction("regrowth on party", ACTION_MEDIUM_HEAL + 6), NULL))); + triggers.push_back( + new TriggerNode("party member critical health", + NextAction::array(0, new NextAction("rejuvenation on party", ACTION_MEDIUM_HEAL + 5), + new NextAction("regrowth on party", ACTION_MEDIUM_HEAL + 6), NULL))); - triggers.push_back(new TriggerNode("party member low health", - NextAction::array(0, new NextAction("rejuvenation on party", ACTION_MEDIUM_HEAL + 3), - new NextAction("regrowth on party", ACTION_MEDIUM_HEAL + 4), NULL))); + triggers.push_back( + new TriggerNode("party member low health", + NextAction::array(0, new NextAction("rejuvenation on party", ACTION_MEDIUM_HEAL + 3), + new NextAction("regrowth on party", ACTION_MEDIUM_HEAL + 4), NULL))); - triggers.push_back(new TriggerNode("party member medium health", - NextAction::array(0, new NextAction("rejuvenation on party", ACTION_MEDIUM_HEAL + 1), - new NextAction("regrowth on party", ACTION_MEDIUM_HEAL + 2), NULL))); + triggers.push_back( + new TriggerNode("party member medium health", + NextAction::array(0, new NextAction("rejuvenation on party", ACTION_MEDIUM_HEAL + 1), + new NextAction("regrowth on party", ACTION_MEDIUM_HEAL + 2), NULL))); - triggers.push_back(new TriggerNode("party member almost full health", - NextAction::array(0, new NextAction("rejuvenation on party", ACTION_LIGHT_HEAL + 2), NULL))); - - triggers.push_back(new TriggerNode("party member remove curse", - NextAction::array(0, new NextAction("remove curse on party", ACTION_DISPEL + 7), NULL))); + triggers.push_back( + new TriggerNode("party member almost full health", + NextAction::array(0, new NextAction("rejuvenation on party", ACTION_LIGHT_HEAL + 2), NULL))); + + triggers.push_back( + new TriggerNode("party member remove curse", + NextAction::array(0, new NextAction("remove curse on party", ACTION_DISPEL + 7), NULL))); } GenericDruidBuffStrategy::GenericDruidBuffStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) @@ -144,6 +156,9 @@ void GenericDruidBuffStrategy::InitTriggers(std::vector& triggers) { NonCombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("mark of the wild on party", NextAction::array(0, new NextAction("mark of the wild on party", 13.0f), nullptr))); - triggers.push_back(new TriggerNode("thorns on main tank", NextAction::array(0, new NextAction("thorns on main tank", 11.0f), nullptr))); + triggers.push_back( + new TriggerNode("mark of the wild on party", + NextAction::array(0, new NextAction("mark of the wild on party", 13.0f), nullptr))); + triggers.push_back(new TriggerNode("thorns on main tank", + NextAction::array(0, new NextAction("thorns on main tank", 11.0f), nullptr))); } diff --git a/src/strategy/druid/GenericDruidNonCombatStrategy.h b/src/strategy/druid/GenericDruidNonCombatStrategy.h index f3bb0d1a..31add8ea 100644 --- a/src/strategy/druid/GenericDruidNonCombatStrategy.h +++ b/src/strategy/druid/GenericDruidNonCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICDRUIDNONCOMBATSTRATEGY_H @@ -11,20 +12,20 @@ class PlayerbotAI; class GenericDruidNonCombatStrategy : public NonCombatStrategy { - public: - GenericDruidNonCombatStrategy(PlayerbotAI* botAI); +public: + GenericDruidNonCombatStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "nc"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "nc"; } + void InitTriggers(std::vector& triggers) override; }; class GenericDruidBuffStrategy : public NonCombatStrategy { - public: - GenericDruidBuffStrategy(PlayerbotAI* botAI); +public: + GenericDruidBuffStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "buff"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "buff"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/druid/GenericDruidStrategy.cpp b/src/strategy/druid/GenericDruidStrategy.cpp index 6bc23c87..5d820c36 100644 --- a/src/strategy/druid/GenericDruidStrategy.cpp +++ b/src/strategy/druid/GenericDruidStrategy.cpp @@ -1,98 +1,100 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericDruidStrategy.h" + #include "Playerbots.h" class GenericDruidStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericDruidStrategyActionNodeFactory() - { - creators["melee"] = &melee; - creators["caster form"] = &caster_form; - creators["cure poison"] = &cure_poison; - creators["cure poison on party"] = &cure_poison_on_party; - creators["abolish poison"] = &abolish_poison; - creators["abolish poison on party"] = &abolish_poison_on_party; - creators["rebirth"] = &rebirth; - creators["entangling roots on cc"] = &entangling_roots_on_cc; - creators["innervate"] = &innervate; - } +public: + GenericDruidStrategyActionNodeFactory() + { + creators["melee"] = &melee; + creators["caster form"] = &caster_form; + creators["cure poison"] = &cure_poison; + creators["cure poison on party"] = &cure_poison_on_party; + creators["abolish poison"] = &abolish_poison; + creators["abolish poison on party"] = &abolish_poison_on_party; + creators["rebirth"] = &rebirth; + creators["entangling roots on cc"] = &entangling_roots_on_cc; + creators["innervate"] = &innervate; + } - private: - static ActionNode* melee([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("melee", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } +private: + static ActionNode* melee([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("melee", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* caster_form([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("caster form", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* caster_form([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("caster form", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* cure_poison([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("cure poison", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* cure_poison([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("cure poison", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* cure_poison_on_party([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("cure poison on party", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* cure_poison_on_party([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("cure poison on party", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* abolish_poison([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("abolish poison", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* abolish_poison([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("abolish poison", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* abolish_poison_on_party([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("abolish poison on party", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* abolish_poison_on_party([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("abolish poison on party", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* rebirth([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("rebirth", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* rebirth([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("rebirth", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* entangling_roots_on_cc([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("entangling roots on cc", - /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* entangling_roots_on_cc([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("entangling roots on cc", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* innervate([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("innervate", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("mana potion"), nullptr), - /*C*/ nullptr); - } + static ActionNode* innervate([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("innervate", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("mana potion"), nullptr), + /*C*/ nullptr); + } }; GenericDruidStrategy::GenericDruidStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) @@ -104,31 +106,41 @@ void GenericDruidStrategy::InitTriggers(std::vector& triggers) { CombatStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("regrowth", ACTION_MEDIUM_HEAL + 2), nullptr))); - // triggers.push_back(new TriggerNode("party member low health", NextAction::array(0, new NextAction("regrowth on party", ACTION_MEDIUM_HEAL + 1), nullptr))); - // triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("regrowth", ACTION_CRITICAL_HEAL + 2), new NextAction("healing touch", ACTION_CRITICAL_HEAL + 2), nullptr))); - // triggers.push_back(new TriggerNode("party member critical health", NextAction::array(0, new NextAction("regrowth on party", ACTION_CRITICAL_HEAL + 1), new NextAction("healing touch on party", ACTION_CRITICAL_HEAL + 1), nullptr))); - // triggers.push_back(new TriggerNode("party member dead", NextAction::array(0, new NextAction("rebirth", ACTION_HIGH + 1), nullptr))); - // triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("innervate", ACTION_EMERGENCY + 5), nullptr))); - triggers.push_back(new TriggerNode( - "combat party member dead", - NextAction::array(0, new NextAction("rebirth", ACTION_HIGH + 9), NULL))); + // triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("regrowth", + // ACTION_MEDIUM_HEAL + 2), nullptr))); triggers.push_back(new TriggerNode("party member low health", + // NextAction::array(0, new NextAction("regrowth on party", ACTION_MEDIUM_HEAL + 1), nullptr))); + // triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("regrowth", + // ACTION_CRITICAL_HEAL + 2), new NextAction("healing touch", ACTION_CRITICAL_HEAL + 2), nullptr))); + // triggers.push_back(new TriggerNode("party member critical health", NextAction::array(0, new NextAction("regrowth + // on party", ACTION_CRITICAL_HEAL + 1), new NextAction("healing touch on party", ACTION_CRITICAL_HEAL + 1), + // nullptr))); triggers.push_back(new TriggerNode("party member dead", NextAction::array(0, new + // NextAction("rebirth", ACTION_HIGH + 1), nullptr))); triggers.push_back(new TriggerNode("low mana", + // NextAction::array(0, new NextAction("innervate", ACTION_EMERGENCY + 5), nullptr))); + triggers.push_back(new TriggerNode("combat party member dead", + NextAction::array(0, new NextAction("rebirth", ACTION_HIGH + 9), NULL))); } void DruidCureStrategy::InitTriggers(std::vector& triggers) { - // triggers.push_back(new TriggerNode("cure poison", NextAction::array(0, new NextAction("abolish poison", ACTION_DISPEL + 2), nullptr))); - triggers.push_back(new TriggerNode("party member cure poison", NextAction::array(0, new NextAction("abolish poison on party", ACTION_DISPEL + 1), nullptr))); + // triggers.push_back(new TriggerNode("cure poison", NextAction::array(0, new NextAction("abolish poison", + // ACTION_DISPEL + 2), nullptr))); + triggers.push_back( + new TriggerNode("party member cure poison", + NextAction::array(0, new NextAction("abolish poison on party", ACTION_DISPEL + 1), nullptr))); } void DruidBoostStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("nature's swiftness", NextAction::array(0, new NextAction("nature's swiftness", ACTION_HIGH + 9), nullptr))); + triggers.push_back(new TriggerNode( + "nature's swiftness", NextAction::array(0, new NextAction("nature's swiftness", ACTION_HIGH + 9), nullptr))); } void DruidCcStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("entangling roots", NextAction::array(0, new NextAction("entangling roots on cc", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode("entangling roots kite", NextAction::array(0, new NextAction("entangling roots", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode("hibernate", NextAction::array(0, new NextAction("hibernate on cc", ACTION_HIGH + 3), nullptr))); + triggers.push_back(new TriggerNode( + "entangling roots", NextAction::array(0, new NextAction("entangling roots on cc", ACTION_HIGH + 2), nullptr))); + triggers.push_back(new TriggerNode( + "entangling roots kite", NextAction::array(0, new NextAction("entangling roots", ACTION_HIGH + 2), nullptr))); + triggers.push_back(new TriggerNode( + "hibernate", NextAction::array(0, new NextAction("hibernate on cc", ACTION_HIGH + 3), nullptr))); } diff --git a/src/strategy/druid/GenericDruidStrategy.h b/src/strategy/druid/GenericDruidStrategy.h index 14108ad9..db6631b2 100644 --- a/src/strategy/druid/GenericDruidStrategy.h +++ b/src/strategy/druid/GenericDruidStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICDRUIDSTRATEGY_H @@ -11,38 +12,38 @@ class PlayerbotAI; class GenericDruidStrategy : public CombatStrategy { - protected: - GenericDruidStrategy(PlayerbotAI* botAI); +protected: + GenericDruidStrategy(PlayerbotAI* botAI); - public: - void InitTriggers(std::vector& triggers) override; +public: + void InitTriggers(std::vector& triggers) override; }; class DruidCureStrategy : public Strategy { - public: - DruidCureStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + DruidCureStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "cure"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cure"; } }; class DruidBoostStrategy : public Strategy { - public: - DruidBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + DruidBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "boost"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "boost"; } }; class DruidCcStrategy : public Strategy { - public: - DruidCcStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + DruidCcStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "cc"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cc"; } }; #endif diff --git a/src/strategy/druid/HealDruidStrategy.cpp b/src/strategy/druid/HealDruidStrategy.cpp index b539d596..0da13563 100644 --- a/src/strategy/druid/HealDruidStrategy.cpp +++ b/src/strategy/druid/HealDruidStrategy.cpp @@ -1,24 +1,25 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HealDruidStrategy.h" + #include "Playerbots.h" class HealDruidStrategyActionNodeFactory : public NamedObjectFactory { - public: - HealDruidStrategyActionNodeFactory() { - creators["nourish on party"] = &nourtish_on_party; - } - private: - static ActionNode* nourtish_on_party([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("nourish on party", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("healing touch on party"), nullptr), - /*C*/ nullptr); - } +public: + HealDruidStrategyActionNodeFactory() { creators["nourish on party"] = &nourtish_on_party; } + +private: + static ActionNode* nourtish_on_party([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("nourish on party", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("healing touch on party"), nullptr), + /*C*/ nullptr); + } }; HealDruidStrategy::HealDruidStrategy(PlayerbotAI* botAI) : GenericDruidStrategy(botAI) @@ -30,61 +31,62 @@ void HealDruidStrategy::InitTriggers(std::vector& triggers) { GenericDruidStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", ACTION_NORMAL + 9), nullptr))); - triggers.push_back(new TriggerNode("tree form", NextAction::array(0, new NextAction("tree form", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("party member to heal out of spell range", NextAction::array(0, new NextAction("reach party member to heal", ACTION_CRITICAL_HEAL + 9), nullptr))); + // triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", + // ACTION_NORMAL + 9), nullptr))); + triggers.push_back( + new TriggerNode("tree form", NextAction::array(0, new NextAction("tree form", ACTION_HIGH + 1), nullptr))); triggers.push_back(new TriggerNode( - "party member remove curse", - NextAction::array(0, new NextAction("remove curse on party", ACTION_DISPEL + 7), NULL))); + "party member to heal out of spell range", + NextAction::array(0, new NextAction("reach party member to heal", ACTION_CRITICAL_HEAL + 9), nullptr))); + triggers.push_back( + new TriggerNode("party member remove curse", + NextAction::array(0, new NextAction("remove curse on party", ACTION_DISPEL + 7), NULL))); // CRITICAL - triggers.push_back(new TriggerNode( - "party member critical health", - NextAction::array(0, - new NextAction("swiftmend on party", ACTION_CRITICAL_HEAL + 4), - new NextAction("wild growth", ACTION_CRITICAL_HEAL + 3), - new NextAction("regrowth on party", ACTION_CRITICAL_HEAL + 2), - new NextAction("nourish on party", ACTION_CRITICAL_HEAL + 1), - // new NextAction("healing touch on party", ACTION_CRITICAL_HEAL + 0), - NULL))); + triggers.push_back( + new TriggerNode("party member critical health", + NextAction::array(0, new NextAction("swiftmend on party", ACTION_CRITICAL_HEAL + 4), + new NextAction("wild growth", ACTION_CRITICAL_HEAL + 3), + new NextAction("regrowth on party", ACTION_CRITICAL_HEAL + 2), + new NextAction("nourish on party", ACTION_CRITICAL_HEAL + 1), + // new NextAction("healing touch on party", ACTION_CRITICAL_HEAL + 0), + NULL))); - triggers.push_back(new TriggerNode( - "party member critical health", - NextAction::array(0, new NextAction("nature's swiftness", ACTION_CRITICAL_HEAL + 4), NULL))); + triggers.push_back( + new TriggerNode("party member critical health", + NextAction::array(0, new NextAction("nature's swiftness", ACTION_CRITICAL_HEAL + 4), NULL))); - triggers.push_back(new TriggerNode( - "medium group heal occasion", - NextAction::array(0, new NextAction("tranquility", ACTION_CRITICAL_HEAL + 5), NULL))); + triggers.push_back( + new TriggerNode("medium group heal occasion", + NextAction::array(0, new NextAction("tranquility", ACTION_CRITICAL_HEAL + 5), NULL))); // LOW - triggers.push_back(new TriggerNode( - "party member low health", - NextAction::array(0, new NextAction("wild growth on party", ACTION_MEDIUM_HEAL + 9), - new NextAction("regrowth on party", ACTION_MEDIUM_HEAL + 8), - new NextAction("swiftmend on party", ACTION_MEDIUM_HEAL + 7), - new NextAction("nourish on party", ACTION_MEDIUM_HEAL + 6), - // new NextAction("healing touch on party", ACTION_MEDIUM_HEAL + 5), - NULL))); + triggers.push_back( + new TriggerNode("party member low health", + NextAction::array(0, new NextAction("wild growth on party", ACTION_MEDIUM_HEAL + 9), + new NextAction("regrowth on party", ACTION_MEDIUM_HEAL + 8), + new NextAction("swiftmend on party", ACTION_MEDIUM_HEAL + 7), + new NextAction("nourish on party", ACTION_MEDIUM_HEAL + 6), + // new NextAction("healing touch on party", ACTION_MEDIUM_HEAL + 5), + NULL))); // MEDIUM - triggers.push_back(new TriggerNode( - "party member medium health", - NextAction::array(0, new NextAction("wild growth on party", ACTION_MEDIUM_HEAL + 4), - new NextAction("rejuvenation on party", ACTION_MEDIUM_HEAL + 3), - new NextAction("regrowth on party", ACTION_MEDIUM_HEAL + 2), - new NextAction("nourish on party", ACTION_MEDIUM_HEAL + 1), - NULL))); + triggers.push_back( + new TriggerNode("party member medium health", + NextAction::array(0, new NextAction("wild growth on party", ACTION_MEDIUM_HEAL + 4), + new NextAction("rejuvenation on party", ACTION_MEDIUM_HEAL + 3), + new NextAction("regrowth on party", ACTION_MEDIUM_HEAL + 2), + new NextAction("nourish on party", ACTION_MEDIUM_HEAL + 1), NULL))); // almost full - triggers.push_back(new TriggerNode( - "party member almost full health", - NextAction::array(0, new NextAction("wild growth on party", ACTION_LIGHT_HEAL + 3), - new NextAction("rejuvenation on party", ACTION_LIGHT_HEAL + 2), - new NextAction("regrowth on party", ACTION_LIGHT_HEAL + 1), - NULL))); - - triggers.push_back(new TriggerNode( - "medium mana", - NextAction::array(0, new NextAction("innervate", ACTION_HIGH + 5), NULL))); - - triggers.push_back(new TriggerNode("enemy too close for spell", NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); + triggers.push_back( + new TriggerNode("party member almost full health", + NextAction::array(0, new NextAction("wild growth on party", ACTION_LIGHT_HEAL + 3), + new NextAction("rejuvenation on party", ACTION_LIGHT_HEAL + 2), + new NextAction("regrowth on party", ACTION_LIGHT_HEAL + 1), NULL))); + + triggers.push_back( + new TriggerNode("medium mana", NextAction::array(0, new NextAction("innervate", ACTION_HIGH + 5), NULL))); + + triggers.push_back(new TriggerNode("enemy too close for spell", + NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); } diff --git a/src/strategy/druid/HealDruidStrategy.h b/src/strategy/druid/HealDruidStrategy.h index 1547c64a..e0833d29 100644 --- a/src/strategy/druid/HealDruidStrategy.h +++ b/src/strategy/druid/HealDruidStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HEALDRUIDSTRATEGY_H @@ -12,12 +13,12 @@ class PlayerbotAI; class HealDruidStrategy : public GenericDruidStrategy { - public: - HealDruidStrategy(PlayerbotAI* botAI); +public: + HealDruidStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "heal"; } - uint32 GetType() const override { return STRATEGY_TYPE_RANGED | STRATEGY_TYPE_HEAL; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "heal"; } + uint32 GetType() const override { return STRATEGY_TYPE_RANGED | STRATEGY_TYPE_HEAL; } }; #endif diff --git a/src/strategy/druid/MeleeDruidStrategy.cpp b/src/strategy/druid/MeleeDruidStrategy.cpp index 7a017821..2b709836 100644 --- a/src/strategy/druid/MeleeDruidStrategy.cpp +++ b/src/strategy/druid/MeleeDruidStrategy.cpp @@ -1,25 +1,24 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "MeleeDruidStrategy.h" + #include "Playerbots.h" -MeleeDruidStrategy::MeleeDruidStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) -{ -} +MeleeDruidStrategy::MeleeDruidStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} NextAction** MeleeDruidStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("faerie fire", ACTION_DEFAULT + 0.1f), - new NextAction("melee", ACTION_DEFAULT), - nullptr); + return NextAction::array(0, new NextAction("faerie fire", ACTION_DEFAULT + 0.1f), + new NextAction("melee", ACTION_DEFAULT), nullptr); } void MeleeDruidStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("omen of clarity", NextAction::array(0, new NextAction("omen of clarity", ACTION_HIGH + 9), nullptr))); + triggers.push_back(new TriggerNode( + "omen of clarity", NextAction::array(0, new NextAction("omen of clarity", ACTION_HIGH + 9), nullptr))); CombatStrategy::InitTriggers(triggers); } diff --git a/src/strategy/druid/MeleeDruidStrategy.h b/src/strategy/druid/MeleeDruidStrategy.h index acf6eab2..5302212b 100644 --- a/src/strategy/druid/MeleeDruidStrategy.h +++ b/src/strategy/druid/MeleeDruidStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MELEEDRUIDSTRATEGY_H @@ -9,12 +10,12 @@ class MeleeDruidStrategy : public CombatStrategy { - public: - MeleeDruidStrategy(PlayerbotAI* botAI); +public: + MeleeDruidStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "melee"; } - NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "melee"; } + NextAction** getDefaultActions() override; }; #endif diff --git a/src/strategy/generic/AttackEnemyPlayersStrategy.cpp b/src/strategy/generic/AttackEnemyPlayersStrategy.cpp index 6120fde3..794efe41 100644 --- a/src/strategy/generic/AttackEnemyPlayersStrategy.cpp +++ b/src/strategy/generic/AttackEnemyPlayersStrategy.cpp @@ -1,11 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AttackEnemyPlayersStrategy.h" + #include "Playerbots.h" void AttackEnemyPlayersStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("enemy player near", NextAction::array(0, new NextAction("attack enemy player", 55.0f), nullptr))); + triggers.push_back(new TriggerNode("enemy player near", + NextAction::array(0, new NextAction("attack enemy player", 55.0f), nullptr))); } diff --git a/src/strategy/generic/AttackEnemyPlayersStrategy.h b/src/strategy/generic/AttackEnemyPlayersStrategy.h index 1601bd15..d0f79efe 100644 --- a/src/strategy/generic/AttackEnemyPlayersStrategy.h +++ b/src/strategy/generic/AttackEnemyPlayersStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ATTACKENEMYPAYERSSTRATEGYACTION_H @@ -9,11 +10,11 @@ class AttackEnemyPlayersStrategy : public NonCombatStrategy { - public: - AttackEnemyPlayersStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + AttackEnemyPlayersStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "pvp"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "pvp"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/BattlegroundStrategy.cpp b/src/strategy/generic/BattlegroundStrategy.cpp index 3c3abcd3..2a74b2f0 100644 --- a/src/strategy/generic/BattlegroundStrategy.cpp +++ b/src/strategy/generic/BattlegroundStrategy.cpp @@ -1,83 +1,112 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "BattlegroundStrategy.h" + #include "Playerbots.h" -void BGStrategy::InitTriggers(std::vector &triggers) +void BGStrategy::InitTriggers(std::vector& triggers) { triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("bg join", relevance), nullptr))); - triggers.push_back(new TriggerNode("bg invite active", NextAction::array(0, new NextAction("bg status check", relevance), nullptr))); - triggers.push_back(new TriggerNode("timer", NextAction::array(0, new NextAction("bg strategy check", relevance), nullptr))); + triggers.push_back(new TriggerNode("bg invite active", + NextAction::array(0, new NextAction("bg status check", relevance), nullptr))); + triggers.push_back( + new TriggerNode("timer", NextAction::array(0, new NextAction("bg strategy check", relevance), nullptr))); } -BGStrategy::BGStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) -{ -} +BGStrategy::BGStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) {} -void WarsongStrategy::InitTriggers(std::vector &triggers) +void WarsongStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", 70.0f), nullptr))); + triggers.push_back( + new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", 70.0f), nullptr))); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); - triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); - triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); - triggers.push_back(new TriggerNode("enemy flagcarrier near", NextAction::array(0, new NextAction("attack enemy flag carrier", 80.0f), nullptr))); - triggers.push_back(new TriggerNode("player has flag", NextAction::array(0, new NextAction("bg move to objective", 90.0f), nullptr))); + triggers.push_back( + new TriggerNode("low health", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); + triggers.push_back( + new TriggerNode("low mana", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); + triggers.push_back(new TriggerNode( + "enemy flagcarrier near", NextAction::array(0, new NextAction("attack enemy flag carrier", 80.0f), nullptr))); + triggers.push_back(new TriggerNode("player has flag", + NextAction::array(0, new NextAction("bg move to objective", 90.0f), nullptr))); } -void AlteracStrategy::InitTriggers(std::vector &triggers) -{ - /* placeholder */ +void AlteracStrategy::InitTriggers(std::vector& triggers) +{ /* placeholder */ } -void ArathiStrategy::InitTriggers(std::vector &triggers) +void ArathiStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", 70.0f), nullptr))); + triggers.push_back( + new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", 70.0f), nullptr))); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); - triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); - triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); + triggers.push_back( + new TriggerNode("low health", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); + triggers.push_back( + new TriggerNode("low mana", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); } -void BattlegroundStrategy::InitTriggers(std::vector &triggers) +void BattlegroundStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("bg waiting", NextAction::array(0, new NextAction("bg move to start", 1.0f), nullptr))); - triggers.push_back(new TriggerNode("bg active", NextAction::array(0, new NextAction("bg move to objective", 1.0f), nullptr))); - triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("bg check objective", 10.0f), nullptr))); - //triggers.push_back(new TriggerNode("enemy flagcarrier near", NextAction::array(0, new NextAction("attack enemy flag carrier", 80.0f), nullptr))); - //triggers.push_back(new TriggerNode("team flagcarrier near", NextAction::array(0, new NextAction("bg protect fc", 40.0f), nullptr))); - //triggers.push_back(new TriggerNode("player has flag", NextAction::array(0, new NextAction("bg move to objective", 90.0f), nullptr))); + triggers.push_back( + new TriggerNode("bg waiting", NextAction::array(0, new NextAction("bg move to start", 1.0f), nullptr))); + triggers.push_back( + new TriggerNode("bg active", NextAction::array(0, new NextAction("bg move to objective", 1.0f), nullptr))); + triggers.push_back( + new TriggerNode("often", NextAction::array(0, new NextAction("bg check objective", 10.0f), nullptr))); + // triggers.push_back(new TriggerNode("enemy flagcarrier near", NextAction::array(0, new NextAction("attack enemy + // flag carrier", 80.0f), nullptr))); triggers.push_back(new TriggerNode("team flagcarrier near", + // NextAction::array(0, new NextAction("bg protect fc", 40.0f), nullptr))); triggers.push_back(new + // TriggerNode("player has flag", NextAction::array(0, new NextAction("bg move to objective", 90.0f), nullptr))); } void EyeStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", 70.0f), nullptr))); + triggers.push_back( + new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", 70.0f), nullptr))); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); - triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); - triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); - triggers.push_back(new TriggerNode("enemy flagcarrier near", NextAction::array(0, new NextAction("attack enemy flag carrier", 80.0f), nullptr))); - triggers.push_back(new TriggerNode("player has flag", NextAction::array(0, new NextAction("bg move to objective", 90.0f), nullptr))); + triggers.push_back( + new TriggerNode("low health", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); + triggers.push_back( + new TriggerNode("low mana", NextAction::array(0, new NextAction("bg use buff", 30.0f), nullptr))); + triggers.push_back(new TriggerNode( + "enemy flagcarrier near", NextAction::array(0, new NextAction("attack enemy flag carrier", 80.0f), nullptr))); + triggers.push_back(new TriggerNode("player has flag", + NextAction::array(0, new NextAction("bg move to objective", 90.0f), nullptr))); } void IsleStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", 70.0f), nullptr))); + triggers.push_back( + new TriggerNode("bg active", NextAction::array(0, new NextAction("bg check flag", 70.0f), nullptr))); triggers.push_back(new TriggerNode("timer", NextAction::array(0, new NextAction("enter vehicle", 85.0f), nullptr))); - triggers.push_back(new TriggerNode("random", NextAction::array(0, new NextAction("leave vehicle", 80.0f), nullptr))); - triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("hurl boulder", 70.0f), nullptr))); - triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("fire cannon", 70.0f), nullptr))); + triggers.push_back( + new TriggerNode("random", NextAction::array(0, new NextAction("leave vehicle", 80.0f), nullptr))); + triggers.push_back( + new TriggerNode("in vehicle", NextAction::array(0, new NextAction("hurl boulder", 70.0f), nullptr))); + triggers.push_back( + new TriggerNode("in vehicle", NextAction::array(0, new NextAction("fire cannon", 70.0f), nullptr))); triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("napalm", 70.0f), nullptr))); - triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new NextAction("steam blast", 80.0f), nullptr))); + triggers.push_back( + new TriggerNode("enemy is close", NextAction::array(0, new NextAction("steam blast", 80.0f), nullptr))); triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("ram", 70.0f), nullptr))); triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new NextAction("ram", 79.0f), nullptr))); - triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("steam rush", 81.0f), nullptr))); - triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("incendiary rocket", 70.0f), nullptr))); - triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("rocket blast", 70.0f), nullptr))); - triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("blade salvo", 71.0f), nullptr))); - triggers.push_back(new TriggerNode("in vehicle", NextAction::array(0, new NextAction("glaive throw", 70.0f), nullptr))); + triggers.push_back( + new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("steam rush", 81.0f), nullptr))); + triggers.push_back( + new TriggerNode("in vehicle", NextAction::array(0, new NextAction("incendiary rocket", 70.0f), nullptr))); + triggers.push_back( + new TriggerNode("in vehicle", NextAction::array(0, new NextAction("rocket blast", 70.0f), nullptr))); + triggers.push_back( + new TriggerNode("in vehicle", NextAction::array(0, new NextAction("blade salvo", 71.0f), nullptr))); + triggers.push_back( + new TriggerNode("in vehicle", NextAction::array(0, new NextAction("glaive throw", 70.0f), nullptr))); } void ArenaStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("no possible targets", NextAction::array(0, new NextAction("arena tactics", 1.0f), nullptr))); + triggers.push_back( + new TriggerNode("no possible targets", NextAction::array(0, new NextAction("arena tactics", 1.0f), nullptr))); } diff --git a/src/strategy/generic/BattlegroundStrategy.h b/src/strategy/generic/BattlegroundStrategy.h index f05e9711..3f535248 100644 --- a/src/strategy/generic/BattlegroundStrategy.h +++ b/src/strategy/generic/BattlegroundStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_BATTLEGROUNDSTRATEGY_H @@ -9,82 +10,82 @@ class BGStrategy : public PassTroughStrategy { - public: - BGStrategy(PlayerbotAI* botAI); +public: + BGStrategy(PlayerbotAI* botAI); - uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "bg"; } + uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bg"; } }; class BattlegroundStrategy : public Strategy { - public: - BattlegroundStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + BattlegroundStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "Battleground"; } + uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "Battleground"; } }; class WarsongStrategy : public Strategy { - public: - WarsongStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + WarsongStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "warsong"; } + uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "warsong"; } }; class AlteracStrategy : public Strategy { - public: - AlteracStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + AlteracStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "alterac"; } + uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "alterac"; } }; class ArathiStrategy : public Strategy { - public: - ArathiStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + ArathiStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "arathi"; } + uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "arathi"; } }; class EyeStrategy : public Strategy { - public: - EyeStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + EyeStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "eye"; } + uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "eye"; } }; class IsleStrategy : public Strategy { - public: - IsleStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + IsleStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "isle"; } + uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "isle"; } }; class ArenaStrategy : public Strategy { - public: - ArenaStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + ArenaStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "arena"; } + uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "arena"; } }; #endif diff --git a/src/strategy/generic/CastTimeStrategy.cpp b/src/strategy/generic/CastTimeStrategy.cpp index 23e14ca7..7d1b4545 100644 --- a/src/strategy/generic/CastTimeStrategy.cpp +++ b/src/strategy/generic/CastTimeStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CastTimeStrategy.h" + #include "GenericSpellActions.h" #include "Playerbots.h" @@ -17,16 +19,17 @@ float CastTimeMultiplier::GetValue(Action* action) if (!action->GetTarget() || action->GetTarget() != AI_VALUE(Unit*, "current target")) return 1.0f; - if (/*targetHealth < sPlayerbotAIConfig->criticalHealth && */dynamic_cast(action)) + if (/*targetHealth < sPlayerbotAIConfig->criticalHealth && */ dynamic_cast(action)) { uint32 spellId = AI_VALUE2(uint32, "spell id", name); SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) return 1.0f; - if ((spellInfo->Targets & TARGET_FLAG_DEST_LOCATION) != 0 || (spellInfo->Targets & TARGET_FLAG_SOURCE_LOCATION) != 0) + if ((spellInfo->Targets & TARGET_FLAG_DEST_LOCATION) != 0 || + (spellInfo->Targets & TARGET_FLAG_SOURCE_LOCATION) != 0) return 1.0f; - + uint32 castTime = spellInfo->CalcCastTime(bot); if (spellInfo->IsChanneled()) @@ -39,11 +42,13 @@ float CastTimeMultiplier::GetValue(Action* action) } Unit* target = action->GetTarget(); - if (!target || !target->IsAlive() || !target->IsInWorld()) { + if (!target || !target->IsAlive() || !target->IsInWorld()) + { return 1.0f; } - if (castTime > (1000 * target->GetHealth() / AI_VALUE(float, "expected group dps"))) { + if (castTime > (1000 * target->GetHealth() / AI_VALUE(float, "expected group dps"))) + { return 0.1f; } } @@ -60,7 +65,7 @@ float CastTimeMultiplier::GetValue(Action* action) return 1.0f; } -void CastTimeStrategy::InitMultipliers(std::vector &multipliers) +void CastTimeStrategy::InitMultipliers(std::vector& multipliers) { multipliers.push_back(new CastTimeMultiplier(botAI)); } diff --git a/src/strategy/generic/CastTimeStrategy.h b/src/strategy/generic/CastTimeStrategy.h index 0f8ce525..07100249 100644 --- a/src/strategy/generic/CastTimeStrategy.h +++ b/src/strategy/generic/CastTimeStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CASTTIMESTRATEGY_H @@ -11,19 +12,19 @@ class PlayerbotAI; class CastTimeMultiplier : public Multiplier { - public: - CastTimeMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "cast time") { } +public: + CastTimeMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "cast time") {} - float GetValue(Action* action) override; + float GetValue(Action* action) override; }; class CastTimeStrategy : public Strategy { - public: - CastTimeStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + CastTimeStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitMultipliers(std::vector& multipliers) override; - std::string const getName() override { return "cast time"; } + void InitMultipliers(std::vector& multipliers) override; + std::string const getName() override { return "cast time"; } }; #endif diff --git a/src/strategy/generic/ChatCommandHandlerStrategy.cpp b/src/strategy/generic/ChatCommandHandlerStrategy.cpp index 0f149960..09a08fca 100644 --- a/src/strategy/generic/ChatCommandHandlerStrategy.cpp +++ b/src/strategy/generic/ChatCommandHandlerStrategy.cpp @@ -1,26 +1,25 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ChatCommandHandlerStrategy.h" + #include "Playerbots.h" class ChatCommandActionNodeFactoryInternal : public NamedObjectFactory { - public: - ChatCommandActionNodeFactoryInternal() - { - creators["tank attack chat shortcut"] = &tank_attack_chat_shortcut; - } +public: + ChatCommandActionNodeFactoryInternal() { creators["tank attack chat shortcut"] = &tank_attack_chat_shortcut; } - private: - static ActionNode* tank_attack_chat_shortcut(PlayerbotAI* botAI) - { - return new ActionNode ("tank attack chat shortcut", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ NextAction::array(0, new NextAction("attack my target", 100.0f), nullptr)); - } +private: + static ActionNode* tank_attack_chat_shortcut(PlayerbotAI* botAI) + { + return new ActionNode("tank attack chat shortcut", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ NextAction::array(0, new NextAction("attack my target", 100.0f), nullptr)); + } }; void ChatCommandHandlerStrategy::InitTriggers(std::vector& triggers) @@ -28,11 +27,14 @@ void ChatCommandHandlerStrategy::InitTriggers(std::vector& trigger PassTroughStrategy::InitTriggers(triggers); triggers.push_back(new TriggerNode("rep", NextAction::array(0, new NextAction("reputation", relevance), nullptr))); - triggers.push_back(new TriggerNode("q", NextAction::array(0, new NextAction("query quest", relevance), new NextAction("query item usage", relevance), nullptr))); - triggers.push_back(new TriggerNode("add all loot", NextAction::array(0, new NextAction("add all loot", relevance), new NextAction("loot", relevance), nullptr))); + triggers.push_back(new TriggerNode("q", NextAction::array(0, new NextAction("query quest", relevance), + new NextAction("query item usage", relevance), nullptr))); + triggers.push_back(new TriggerNode("add all loot", NextAction::array(0, new NextAction("add all loot", relevance), + new NextAction("loot", relevance), nullptr))); triggers.push_back(new TriggerNode("u", NextAction::array(0, new NextAction("use", relevance), nullptr))); triggers.push_back(new TriggerNode("c", NextAction::array(0, new NextAction("item count", relevance), nullptr))); - triggers.push_back(new TriggerNode("items", NextAction::array(0, new NextAction("item count", relevance), nullptr))); + triggers.push_back( + new TriggerNode("items", NextAction::array(0, new NextAction("item count", relevance), nullptr))); triggers.push_back(new TriggerNode("inv", NextAction::array(0, new NextAction("item count", relevance), nullptr))); triggers.push_back(new TriggerNode("e", NextAction::array(0, new NextAction("equip", relevance), nullptr))); triggers.push_back(new TriggerNode("ue", NextAction::array(0, new NextAction("unequip", relevance), nullptr))); @@ -41,27 +43,49 @@ void ChatCommandHandlerStrategy::InitTriggers(std::vector& trigger triggers.push_back(new TriggerNode("s", NextAction::array(0, new NextAction("sell", relevance), nullptr))); triggers.push_back(new TriggerNode("b", NextAction::array(0, new NextAction("buy", relevance), nullptr))); triggers.push_back(new TriggerNode("r", NextAction::array(0, new NextAction("reward", relevance), nullptr))); - triggers.push_back(new TriggerNode("attack", NextAction::array(0, new NextAction("attack my target", relevance), nullptr))); - triggers.push_back(new TriggerNode("accept", NextAction::array(0, new NextAction("accept quest", relevance), nullptr))); - triggers.push_back(new TriggerNode("follow", NextAction::array(0, new NextAction("follow chat shortcut", relevance), nullptr))); - triggers.push_back(new TriggerNode("stay", NextAction::array(0, new NextAction("stay chat shortcut", relevance), nullptr))); - triggers.push_back(new TriggerNode("flee", NextAction::array(0, new NextAction("flee chat shortcut", relevance), nullptr))); - triggers.push_back(new TriggerNode("tank attack", NextAction::array(0, new NextAction("tank attack chat shortcut", relevance), nullptr))); - triggers.push_back(new TriggerNode("grind", NextAction::array(0, new NextAction("grind chat shortcut", relevance), nullptr))); - triggers.push_back(new TriggerNode("talk", NextAction::array(0, new NextAction("gossip hello", relevance), new NextAction("talk to quest giver", relevance), nullptr))); - triggers.push_back(new TriggerNode("cast", NextAction::array(0, new NextAction("cast custom spell", relevance), nullptr))); - triggers.push_back(new TriggerNode("castnc", NextAction::array(0, new NextAction("cast custom nc spell", relevance), nullptr))); - triggers.push_back(new TriggerNode("revive", NextAction::array(0, new NextAction("spirit healer", relevance), nullptr))); - triggers.push_back(new TriggerNode("runaway", NextAction::array(0, new NextAction("runaway chat shortcut", relevance), nullptr))); - triggers.push_back(new TriggerNode("warning", NextAction::array(0, new NextAction("runaway chat shortcut", relevance), nullptr))); - triggers.push_back(new TriggerNode("max dps", NextAction::array(0, new NextAction("max dps chat shortcut", relevance), nullptr))); - triggers.push_back(new TriggerNode("attackers", NextAction::array(0, new NextAction("tell attackers", relevance), nullptr))); - triggers.push_back(new TriggerNode("target", NextAction::array(0, new NextAction("tell target", relevance), nullptr))); - triggers.push_back(new TriggerNode("ready", NextAction::array(0, new NextAction("ready check", relevance), nullptr))); - triggers.push_back(new TriggerNode("naxx", NextAction::array(0, new NextAction("naxx chat shortcut", relevance), NULL))); - triggers.push_back(new TriggerNode("bwl", NextAction::array(0, new NextAction("bwl chat shortcut", relevance), NULL))); - triggers.push_back(new TriggerNode("dps", NextAction::array(0, new NextAction("tell expected dps", relevance), NULL))); - triggers.push_back(new TriggerNode("disperse", NextAction::array(0, new NextAction("disperse set", relevance), NULL))); + triggers.push_back( + new TriggerNode("attack", NextAction::array(0, new NextAction("attack my target", relevance), nullptr))); + triggers.push_back( + new TriggerNode("accept", NextAction::array(0, new NextAction("accept quest", relevance), nullptr))); + triggers.push_back( + new TriggerNode("follow", NextAction::array(0, new NextAction("follow chat shortcut", relevance), nullptr))); + triggers.push_back( + new TriggerNode("stay", NextAction::array(0, new NextAction("stay chat shortcut", relevance), nullptr))); + triggers.push_back( + new TriggerNode("flee", NextAction::array(0, new NextAction("flee chat shortcut", relevance), nullptr))); + triggers.push_back(new TriggerNode( + "tank attack", NextAction::array(0, new NextAction("tank attack chat shortcut", relevance), nullptr))); + triggers.push_back( + new TriggerNode("grind", NextAction::array(0, new NextAction("grind chat shortcut", relevance), nullptr))); + triggers.push_back( + new TriggerNode("talk", NextAction::array(0, new NextAction("gossip hello", relevance), + new NextAction("talk to quest giver", relevance), nullptr))); + triggers.push_back( + new TriggerNode("cast", NextAction::array(0, new NextAction("cast custom spell", relevance), nullptr))); + triggers.push_back( + new TriggerNode("castnc", NextAction::array(0, new NextAction("cast custom nc spell", relevance), nullptr))); + triggers.push_back( + new TriggerNode("revive", NextAction::array(0, new NextAction("spirit healer", relevance), nullptr))); + triggers.push_back( + new TriggerNode("runaway", NextAction::array(0, new NextAction("runaway chat shortcut", relevance), nullptr))); + triggers.push_back( + new TriggerNode("warning", NextAction::array(0, new NextAction("runaway chat shortcut", relevance), nullptr))); + triggers.push_back( + new TriggerNode("max dps", NextAction::array(0, new NextAction("max dps chat shortcut", relevance), nullptr))); + triggers.push_back( + new TriggerNode("attackers", NextAction::array(0, new NextAction("tell attackers", relevance), nullptr))); + triggers.push_back( + new TriggerNode("target", NextAction::array(0, new NextAction("tell target", relevance), nullptr))); + triggers.push_back( + new TriggerNode("ready", NextAction::array(0, new NextAction("ready check", relevance), nullptr))); + triggers.push_back( + new TriggerNode("naxx", NextAction::array(0, new NextAction("naxx chat shortcut", relevance), NULL))); + triggers.push_back( + new TriggerNode("bwl", NextAction::array(0, new NextAction("bwl chat shortcut", relevance), NULL))); + triggers.push_back( + new TriggerNode("dps", NextAction::array(0, new NextAction("tell expected dps", relevance), NULL))); + triggers.push_back( + new TriggerNode("disperse", NextAction::array(0, new NextAction("disperse set", relevance), NULL))); } ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) diff --git a/src/strategy/generic/ChatCommandHandlerStrategy.h b/src/strategy/generic/ChatCommandHandlerStrategy.h index 4aa101f8..cf69a7b0 100644 --- a/src/strategy/generic/ChatCommandHandlerStrategy.h +++ b/src/strategy/generic/ChatCommandHandlerStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHATCOMMANDHANDLERSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class ChatCommandHandlerStrategy : public PassTroughStrategy { - public: - ChatCommandHandlerStrategy(PlayerbotAI* botAI); +public: + ChatCommandHandlerStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "chat"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "chat"; } }; #endif diff --git a/src/strategy/generic/CombatStrategy.cpp b/src/strategy/generic/CombatStrategy.cpp index b77277fd..92bb27f8 100644 --- a/src/strategy/generic/CombatStrategy.cpp +++ b/src/strategy/generic/CombatStrategy.cpp @@ -1,28 +1,33 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CombatStrategy.h" + #include "Playerbots.h" #include "Strategy.h" -void CombatStrategy::InitTriggers(std::vector &triggers) +void CombatStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("invalid target", NextAction::array(0, new NextAction("drop target", 100), nullptr))); - triggers.push_back(new TriggerNode("mounted", NextAction::array(0, new NextAction("check mount state", 54), nullptr))); - // triggers.push_back(new TriggerNode("out of react range", NextAction::array(0, new NextAction("flee to master", 55), nullptr))); + triggers.push_back(new TriggerNode("enemy out of spell", + NextAction::array(0, new NextAction("reach spell", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("invalid target", NextAction::array(0, new NextAction("drop target", 100), nullptr))); + triggers.push_back( + new TriggerNode("mounted", NextAction::array(0, new NextAction("check mount state", 54), nullptr))); + // triggers.push_back(new TriggerNode("out of react range", NextAction::array(0, new NextAction("flee to master", + // 55), nullptr))); triggers.push_back(new TriggerNode("combat stuck", NextAction::array(0, new NextAction("reset", 1.0f), nullptr))); - triggers.push_back(new TriggerNode("not facing target", NextAction::array(0, new NextAction("set facing", ACTION_MOVE + 7), nullptr))); - triggers.push_back(new TriggerNode("pet attack", NextAction::array(0, new NextAction("pet attack", ACTION_NORMAL), nullptr))); - // triggers.push_back(new TriggerNode("combat long stuck", NextAction::array(0, new NextAction("hearthstone", 0.9f), new NextAction("repop", 0.8f), nullptr))); -} - - -AvoidAoeStrategy::AvoidAoeStrategy(PlayerbotAI* botAI) : Strategy(botAI) -{ + triggers.push_back(new TriggerNode("not facing target", + NextAction::array(0, new NextAction("set facing", ACTION_MOVE + 7), nullptr))); + triggers.push_back( + new TriggerNode("pet attack", NextAction::array(0, new NextAction("pet attack", ACTION_NORMAL), nullptr))); + // triggers.push_back(new TriggerNode("combat long stuck", NextAction::array(0, new NextAction("hearthstone", 0.9f), + // new NextAction("repop", 0.8f), nullptr))); } +AvoidAoeStrategy::AvoidAoeStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} // class AvoidAoeStrategyMultiplier : public Multiplier // { @@ -65,12 +70,9 @@ AvoidAoeStrategy::AvoidAoeStrategy(PlayerbotAI* botAI) : Strategy(botAI) NextAction** AvoidAoeStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("avoid aoe", ACTION_EMERGENCY), - nullptr); + return NextAction::array(0, new NextAction("avoid aoe", ACTION_EMERGENCY), nullptr); } - void AvoidAoeStrategy::InitTriggers(std::vector& triggers) { // triggers.push_back(new TriggerNode( @@ -85,7 +87,5 @@ void AvoidAoeStrategy::InitMultipliers(std::vector& multipliers) NextAction** CombatFormationStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("combat formation move", ACTION_NORMAL), - nullptr); + return NextAction::array(0, new NextAction("combat formation move", ACTION_NORMAL), nullptr); } diff --git a/src/strategy/generic/CombatStrategy.h b/src/strategy/generic/CombatStrategy.h index 7f618064..422b4b22 100644 --- a/src/strategy/generic/CombatStrategy.h +++ b/src/strategy/generic/CombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_COMBATSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class CombatStrategy : public Strategy { - public: - CombatStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + CombatStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - uint32 GetType() const override { return STRATEGY_TYPE_COMBAT; } + void InitTriggers(std::vector& triggers) override; + uint32 GetType() const override { return STRATEGY_TYPE_COMBAT; } }; class AvoidAoeStrategy : public Strategy @@ -31,7 +32,7 @@ public: class CombatFormationStrategy : public Strategy { public: - CombatFormationStrategy(PlayerbotAI* ai): Strategy(ai) {} + CombatFormationStrategy(PlayerbotAI* ai) : Strategy(ai) {} const std::string getName() override { return "combat formation"; } NextAction** getDefaultActions() override; }; diff --git a/src/strategy/generic/ConserveManaStrategy.cpp b/src/strategy/generic/ConserveManaStrategy.cpp index c7a61ee0..48ebabab 100644 --- a/src/strategy/generic/ConserveManaStrategy.cpp +++ b/src/strategy/generic/ConserveManaStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ConserveManaStrategy.h" + #include "GenericSpellActions.h" #include "LastSpellCastValue.h" #include "PlayerbotAIConfig.h" @@ -96,7 +98,7 @@ float HealerAutoSaveManaMultiplier::GetValue(Action* action) if (!healingAction) return 1.0f; - + Unit* target = healingAction->GetTarget(); if (!target) return 1.0f; @@ -105,14 +107,20 @@ float HealerAutoSaveManaMultiplier::GetValue(Action* action) HealingManaEfficiency manaEfficiency = healingAction->manaEfficiency; uint8 estAmount = healingAction->estAmount; uint8 lossAmount = 100 - health; - if (isTank) { - estAmount /= 1.5; // tanks have more health - if (health >= sPlayerbotAIConfig->mediumHealth && (lossAmount < estAmount || manaEfficiency <= HealingManaEfficiency::MEDIUM)) + if (isTank) + { + estAmount /= 1.5; // tanks have more health + if (health >= sPlayerbotAIConfig->mediumHealth && + (lossAmount < estAmount || manaEfficiency <= HealingManaEfficiency::MEDIUM)) return 0.0f; - if (health >= sPlayerbotAIConfig->lowHealth && (lossAmount < estAmount || manaEfficiency <= HealingManaEfficiency::LOW)) + if (health >= sPlayerbotAIConfig->lowHealth && + (lossAmount < estAmount || manaEfficiency <= HealingManaEfficiency::LOW)) return 0.0f; - } else { - if (health >= sPlayerbotAIConfig->mediumHealth && (lossAmount < estAmount || manaEfficiency <= HealingManaEfficiency::MEDIUM)) + } + else + { + if (health >= sPlayerbotAIConfig->mediumHealth && + (lossAmount < estAmount || manaEfficiency <= HealingManaEfficiency::MEDIUM)) return 0.0f; if (lossAmount < estAmount || manaEfficiency <= HealingManaEfficiency::LOW) return 0.0f; diff --git a/src/strategy/generic/ConserveManaStrategy.h b/src/strategy/generic/ConserveManaStrategy.h index 9ad9a277..4af44222 100644 --- a/src/strategy/generic/ConserveManaStrategy.h +++ b/src/strategy/generic/ConserveManaStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CONSERVEMANASTRATEGY_H @@ -47,19 +48,19 @@ class PlayerbotAI; class HealerAutoSaveManaMultiplier : public Multiplier { - public: - HealerAutoSaveManaMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "auto save mana") { } +public: + HealerAutoSaveManaMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "auto save mana") {} - float GetValue(Action* action) override; + float GetValue(Action* action) override; }; class HealerAutoSaveManaStrategy : public Strategy { - public: - HealerAutoSaveManaStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + HealerAutoSaveManaStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitMultipliers(std::vector& multipliers) override; - std::string const getName() override { return "auto save mana"; } + void InitMultipliers(std::vector& multipliers) override; + std::string const getName() override { return "auto save mana"; } }; #endif diff --git a/src/strategy/generic/DeadStrategy.cpp b/src/strategy/generic/DeadStrategy.cpp index 9da37ece..c3bc59c7 100644 --- a/src/strategy/generic/DeadStrategy.cpp +++ b/src/strategy/generic/DeadStrategy.cpp @@ -1,23 +1,30 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DeadStrategy.h" + #include "Playerbots.h" void DeadStrategy::InitTriggers(std::vector& triggers) { PassTroughStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("auto release", relevance), nullptr))); - triggers.push_back(new TriggerNode("bg active", NextAction::array(0, new NextAction("auto release", relevance), nullptr))); - triggers.push_back(new TriggerNode("dead", NextAction::array(0, new NextAction("find corpse", relevance), nullptr))); - triggers.push_back(new TriggerNode("corpse near", NextAction::array(0, new NextAction("revive from corpse", relevance - 1.0f), nullptr))); - triggers.push_back(new TriggerNode("resurrect request", NextAction::array(0, new NextAction("accept resurrect", relevance), nullptr))); - triggers.push_back(new TriggerNode("falling far", NextAction::array(0, new NextAction("repop", relevance + 1.f), nullptr))); - triggers.push_back(new TriggerNode("location stuck", NextAction::array(0, new NextAction("repop", relevance + 1), nullptr))); + triggers.push_back( + new TriggerNode("often", NextAction::array(0, new NextAction("auto release", relevance), nullptr))); + triggers.push_back( + new TriggerNode("bg active", NextAction::array(0, new NextAction("auto release", relevance), nullptr))); + triggers.push_back( + new TriggerNode("dead", NextAction::array(0, new NextAction("find corpse", relevance), nullptr))); + triggers.push_back(new TriggerNode( + "corpse near", NextAction::array(0, new NextAction("revive from corpse", relevance - 1.0f), nullptr))); + triggers.push_back(new TriggerNode("resurrect request", + NextAction::array(0, new NextAction("accept resurrect", relevance), nullptr))); + triggers.push_back( + new TriggerNode("falling far", NextAction::array(0, new NextAction("repop", relevance + 1.f), nullptr))); + triggers.push_back( + new TriggerNode("location stuck", NextAction::array(0, new NextAction("repop", relevance + 1), nullptr))); } -DeadStrategy::DeadStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) -{ -} +DeadStrategy::DeadStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) {} diff --git a/src/strategy/generic/DeadStrategy.h b/src/strategy/generic/DeadStrategy.h index da716532..67addaa6 100644 --- a/src/strategy/generic/DeadStrategy.h +++ b/src/strategy/generic/DeadStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DEADSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class DeadStrategy : public PassTroughStrategy { - public: - DeadStrategy(PlayerbotAI* botAI); +public: + DeadStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "dead"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "dead"; } }; #endif diff --git a/src/strategy/generic/DebugStrategy.cpp b/src/strategy/generic/DebugStrategy.cpp index 1feed0d5..2840e2f6 100644 --- a/src/strategy/generic/DebugStrategy.cpp +++ b/src/strategy/generic/DebugStrategy.cpp @@ -1,6 +1,8 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DebugStrategy.h" + #include "Playerbots.h" diff --git a/src/strategy/generic/DebugStrategy.h b/src/strategy/generic/DebugStrategy.h index 55d59408..2b53b8ba 100644 --- a/src/strategy/generic/DebugStrategy.h +++ b/src/strategy/generic/DebugStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DEBUGSTRATEGY_H @@ -9,38 +10,38 @@ class DebugStrategy : public Strategy { - public: - DebugStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + DebugStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } - std::string const getName() override { return "debug"; } + uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } + std::string const getName() override { return "debug"; } }; class DebugMoveStrategy : public Strategy { - public: - DebugMoveStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + DebugMoveStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } - std::string const getName() override { return "debug move"; } + uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } + std::string const getName() override { return "debug move"; } }; class DebugRpgStrategy : public Strategy { - public: - DebugRpgStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + DebugRpgStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } - std::string const getName() override { return "debug rpg"; } + uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } + std::string const getName() override { return "debug rpg"; } }; class DebugSpellStrategy : public Strategy { - public: - DebugSpellStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + DebugSpellStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } - std::string const getName() override { return "debug spell"; } + uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } + std::string const getName() override { return "debug spell"; } }; #endif diff --git a/src/strategy/generic/DpsAssistStrategy.cpp b/src/strategy/generic/DpsAssistStrategy.cpp index 83d0b80b..11047e26 100644 --- a/src/strategy/generic/DpsAssistStrategy.cpp +++ b/src/strategy/generic/DpsAssistStrategy.cpp @@ -1,19 +1,20 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DpsAssistStrategy.h" + #include "Playerbots.h" void DpsAssistStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("not dps target active", NextAction::array(0, new NextAction("dps assist", 50.0f), nullptr))); + triggers.push_back( + new TriggerNode("not dps target active", NextAction::array(0, new NextAction("dps assist", 50.0f), nullptr))); } void DpsAoeStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("not dps aoe target active", NextAction::array(0, new NextAction("dps aoe", 50.0f), nullptr))); + triggers.push_back( + new TriggerNode("not dps aoe target active", NextAction::array(0, new NextAction("dps aoe", 50.0f), nullptr))); } - - - diff --git a/src/strategy/generic/DpsAssistStrategy.h b/src/strategy/generic/DpsAssistStrategy.h index 80c067f3..6d70d279 100644 --- a/src/strategy/generic/DpsAssistStrategy.h +++ b/src/strategy/generic/DpsAssistStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DPSASSISTSTRATEGY_H @@ -11,22 +12,22 @@ class PlayerbotAI; class DpsAssistStrategy : public NonCombatStrategy { - public: - DpsAssistStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + DpsAssistStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "dps assist"; } - // uint32 GetType() const override { return STRATEGY_TYPE_DPS; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "dps assist"; } + // uint32 GetType() const override { return STRATEGY_TYPE_DPS; } + void InitTriggers(std::vector& triggers) override; }; class DpsAoeStrategy : public NonCombatStrategy { - public: - DpsAoeStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + DpsAoeStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "dps aoe"; } - uint32 GetType() const override { return STRATEGY_TYPE_DPS; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "dps aoe"; } + uint32 GetType() const override { return STRATEGY_TYPE_DPS; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/DuelStrategy.cpp b/src/strategy/generic/DuelStrategy.cpp index c9e93989..cf7b836b 100644 --- a/src/strategy/generic/DuelStrategy.cpp +++ b/src/strategy/generic/DuelStrategy.cpp @@ -1,26 +1,24 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DuelStrategy.h" + #include "Playerbots.h" void DuelStrategy::InitTriggers(std::vector& triggers) { PassTroughStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("duel requested", NextAction::array(0, new NextAction("accept duel", relevance), nullptr))); - triggers.push_back(new TriggerNode("no attackers", NextAction::array(0, new NextAction("attack duel opponent", 70.0f), nullptr))); + triggers.push_back( + new TriggerNode("duel requested", NextAction::array(0, new NextAction("accept duel", relevance), nullptr))); + triggers.push_back( + new TriggerNode("no attackers", NextAction::array(0, new NextAction("attack duel opponent", 70.0f), nullptr))); } -DuelStrategy::DuelStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) -{ -} +DuelStrategy::DuelStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) {} -void StartDuelStrategy::InitTriggers(std::vector& triggers) -{ -} +void StartDuelStrategy::InitTriggers(std::vector& triggers) {} -StartDuelStrategy::StartDuelStrategy(PlayerbotAI* botAI) : Strategy(botAI) -{ -} +StartDuelStrategy::StartDuelStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} diff --git a/src/strategy/generic/DuelStrategy.h b/src/strategy/generic/DuelStrategy.h index 07a7b35d..db703c91 100644 --- a/src/strategy/generic/DuelStrategy.h +++ b/src/strategy/generic/DuelStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DUELSTRATEGY_H @@ -11,20 +12,20 @@ class PlayerbotAI; class DuelStrategy : public PassTroughStrategy { - public: - DuelStrategy(PlayerbotAI* botAI); +public: + DuelStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "duel"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "duel"; } }; class StartDuelStrategy : public Strategy { - public: - StartDuelStrategy(PlayerbotAI* botAI); +public: + StartDuelStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "start duel"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "start duel"; } }; #endif diff --git a/src/strategy/generic/EmoteStrategy.cpp b/src/strategy/generic/EmoteStrategy.cpp index d3b72fa3..373bc747 100644 --- a/src/strategy/generic/EmoteStrategy.cpp +++ b/src/strategy/generic/EmoteStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "EmoteStrategy.h" + #include "Playerbots.h" void EmoteStrategy::InitTriggers(std::vector& triggers) @@ -10,21 +12,23 @@ void EmoteStrategy::InitTriggers(std::vector& triggers) if (sPlayerbotAIConfig->randomBotEmote) { triggers.push_back(new TriggerNode("seldom", NextAction::array(0, new NextAction("emote", 1.0f), nullptr))); - triggers.push_back(new TriggerNode("receive text emote", NextAction::array(0, new NextAction("emote", 10.0f), nullptr))); - triggers.push_back(new TriggerNode("receive emote", NextAction::array(0, new NextAction("emote", 10.0f), nullptr))); + triggers.push_back( + new TriggerNode("receive text emote", NextAction::array(0, new NextAction("emote", 10.0f), nullptr))); + triggers.push_back( + new TriggerNode("receive emote", NextAction::array(0, new NextAction("emote", 10.0f), nullptr))); } if (sPlayerbotAIConfig->randomBotTalk) { - triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("suggest what to do", 10.0f), - new NextAction("suggest dungeon", 3.0f), - new NextAction("suggest trade", 3.0f), - new NextAction("talk", 1.0f), - nullptr))); + triggers.push_back(new TriggerNode( + "often", + NextAction::array(0, new NextAction("suggest what to do", 10.0f), new NextAction("suggest dungeon", 3.0f), + new NextAction("suggest trade", 3.0f), new NextAction("talk", 1.0f), nullptr))); } if (sPlayerbotAIConfig->enableGreet) - triggers.push_back(new TriggerNode("new player nearby", NextAction::array(0, new NextAction("greet", 1.0f), nullptr))); + triggers.push_back( + new TriggerNode("new player nearby", NextAction::array(0, new NextAction("greet", 1.0f), nullptr))); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("rpg mount anim", 1.0f), nullptr))); } diff --git a/src/strategy/generic/EmoteStrategy.h b/src/strategy/generic/EmoteStrategy.h index 74ff871d..9f4fdd98 100644 --- a/src/strategy/generic/EmoteStrategy.h +++ b/src/strategy/generic/EmoteStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_EMOTESTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class EmoteStrategy : public Strategy { - public: - EmoteStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + EmoteStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "emote"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "emote"; } }; #endif diff --git a/src/strategy/generic/FleeStrategy.cpp b/src/strategy/generic/FleeStrategy.cpp index 50abf3b9..36d49988 100644 --- a/src/strategy/generic/FleeStrategy.cpp +++ b/src/strategy/generic/FleeStrategy.cpp @@ -1,18 +1,24 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "FleeStrategy.h" + #include "Playerbots.h" -void FleeStrategy::InitTriggers(std::vector &triggers) +void FleeStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("panic", NextAction::array(0, new NextAction("flee", ACTION_EMERGENCY + 9), nullptr))); - triggers.push_back(new TriggerNode("outnumbered", NextAction::array(0, new NextAction("flee", ACTION_EMERGENCY + 9), nullptr))); - triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("flee", ACTION_MEDIUM_HEAL), nullptr))); + triggers.push_back( + new TriggerNode("panic", NextAction::array(0, new NextAction("flee", ACTION_EMERGENCY + 9), nullptr))); + triggers.push_back( + new TriggerNode("outnumbered", NextAction::array(0, new NextAction("flee", ACTION_EMERGENCY + 9), nullptr))); + triggers.push_back( + new TriggerNode("critical health", NextAction::array(0, new NextAction("flee", ACTION_MEDIUM_HEAL), nullptr))); } -void FleeFromAddsStrategy::InitTriggers(std::vector &triggers) +void FleeFromAddsStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("has nearest adds", NextAction::array(0, new NextAction("runaway", 50.0f), nullptr))); + triggers.push_back( + new TriggerNode("has nearest adds", NextAction::array(0, new NextAction("runaway", 50.0f), nullptr))); } diff --git a/src/strategy/generic/FleeStrategy.h b/src/strategy/generic/FleeStrategy.h index 32ce2da1..793e79b0 100644 --- a/src/strategy/generic/FleeStrategy.h +++ b/src/strategy/generic/FleeStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_FLEESTRATEGY_H @@ -11,20 +12,20 @@ class PlayerbotAI; class FleeStrategy : public Strategy { - public: - FleeStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + FleeStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "flee"; }; + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "flee"; }; }; class FleeFromAddsStrategy : public Strategy { - public: - FleeFromAddsStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + FleeFromAddsStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "flee from adds"; }; + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "flee from adds"; }; }; #endif diff --git a/src/strategy/generic/FollowMasterStrategy.cpp b/src/strategy/generic/FollowMasterStrategy.cpp index 4b4651e1..4e5984f0 100644 --- a/src/strategy/generic/FollowMasterStrategy.cpp +++ b/src/strategy/generic/FollowMasterStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "FollowMasterStrategy.h" + #include "Playerbots.h" NextAction** FollowMasterStrategy::getDefaultActions() @@ -12,5 +14,6 @@ NextAction** FollowMasterStrategy::getDefaultActions() void FollowMasterStrategy::InitTriggers(std::vector& triggers) { - // triggers.push_back(new TriggerNode("out of react range", NextAction::array(0, new NextAction("flee to master", ACTION_HIGH), nullptr))); + // triggers.push_back(new TriggerNode("out of react range", NextAction::array(0, new NextAction("flee to master", + // ACTION_HIGH), nullptr))); } diff --git a/src/strategy/generic/FollowMasterStrategy.h b/src/strategy/generic/FollowMasterStrategy.h index 13b82dc5..ef31c537 100644 --- a/src/strategy/generic/FollowMasterStrategy.h +++ b/src/strategy/generic/FollowMasterStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_FOLLOWMASTERSTRATEGY_H @@ -11,13 +12,12 @@ class PlayerbotAI; class FollowMasterStrategy : public NonCombatStrategy { - public: - FollowMasterStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } - - std::string const getName() override { return "follow"; } - NextAction** getDefaultActions() override; - void InitTriggers(std::vector& triggers) override; +public: + FollowMasterStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} + std::string const getName() override { return "follow"; } + NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/GrindingStrategy.cpp b/src/strategy/generic/GrindingStrategy.cpp index ffbe8300..c8638e45 100644 --- a/src/strategy/generic/GrindingStrategy.cpp +++ b/src/strategy/generic/GrindingStrategy.cpp @@ -1,25 +1,23 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GrindingStrategy.h" + #include "Playerbots.h" -NextAction** GrindingStrategy::getDefaultActions() -{ - return nullptr; -} +NextAction** GrindingStrategy::getDefaultActions() { return nullptr; } void GrindingStrategy::InitTriggers(std::vector& triggers) { triggers.push_back(new TriggerNode("timer", NextAction::array(0, new NextAction("drink", 4.2f), nullptr))); triggers.push_back(new TriggerNode("timer", NextAction::array(0, new NextAction("food", 4.1f), nullptr))); - triggers.push_back(new TriggerNode("no target", NextAction::array(0, new NextAction("attack anything", 4.0f), nullptr))); + triggers.push_back( + new TriggerNode("no target", NextAction::array(0, new NextAction("attack anything", 4.0f), nullptr))); } void MoveRandomStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode( - "often", - NextAction::array(0, new NextAction("move random", 1.5f), NULL))); + triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("move random", 1.5f), NULL))); } \ No newline at end of file diff --git a/src/strategy/generic/GrindingStrategy.h b/src/strategy/generic/GrindingStrategy.h index 9821f84b..6ab11904 100644 --- a/src/strategy/generic/GrindingStrategy.h +++ b/src/strategy/generic/GrindingStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GRINDINGSTRATEGY_H @@ -11,13 +12,13 @@ class PlayerbotAI; class GrindingStrategy : public NonCombatStrategy { - public: - GrindingStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + GrindingStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "grind"; } - uint32 GetType() const override { return STRATEGY_TYPE_DPS; } - NextAction** getDefaultActions() override; - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "grind"; } + uint32 GetType() const override { return STRATEGY_TYPE_DPS; } + NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; }; class MoveRandomStrategy : public NonCombatStrategy diff --git a/src/strategy/generic/GroupStrategy.cpp b/src/strategy/generic/GroupStrategy.cpp index 7f87e2e6..b17b46e1 100644 --- a/src/strategy/generic/GroupStrategy.cpp +++ b/src/strategy/generic/GroupStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GroupStrategy.h" + #include "Playerbots.h" void GroupStrategy::InitTriggers(std::vector& triggers) @@ -10,6 +12,6 @@ void GroupStrategy::InitTriggers(std::vector& triggers) triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("invite nearby", 4.0f), nullptr))); triggers.push_back(new TriggerNode("random", NextAction::array(0, new NextAction("invite guild", 4.0f), nullptr))); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("leave far away", 4.0f), nullptr))); - triggers.push_back(new TriggerNode("seldom", NextAction::array(0, new NextAction("reset instances", 1.0f), nullptr))); + triggers.push_back( + new TriggerNode("seldom", NextAction::array(0, new NextAction("reset instances", 1.0f), nullptr))); } - diff --git a/src/strategy/generic/GroupStrategy.h b/src/strategy/generic/GroupStrategy.h index 69cdc0fc..9f5fc71d 100644 --- a/src/strategy/generic/GroupStrategy.h +++ b/src/strategy/generic/GroupStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GROUPSTRATEGY_H @@ -11,12 +12,12 @@ class PlayerbotAI; class GroupStrategy : public NonCombatStrategy { - public: - GroupStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + GroupStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "group"; } - uint32 GetType()const override { return STRATEGY_TYPE_GENERIC; } - void InitTriggers(std::vector &triggers) override; + std::string const getName() override { return "group"; } + uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/GuardStrategy.cpp b/src/strategy/generic/GuardStrategy.cpp index af682652..7022c96a 100644 --- a/src/strategy/generic/GuardStrategy.cpp +++ b/src/strategy/generic/GuardStrategy.cpp @@ -1,16 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GuardStrategy.h" + #include "Playerbots.h" -NextAction** GuardStrategy::getDefaultActions() -{ - return NextAction::array(0, new NextAction("guard", 4.0f), nullptr); -} - -void GuardStrategy::InitTriggers(std::vector& triggers) -{ -} +NextAction** GuardStrategy::getDefaultActions() { return NextAction::array(0, new NextAction("guard", 4.0f), nullptr); } +void GuardStrategy::InitTriggers(std::vector& triggers) {} diff --git a/src/strategy/generic/GuardStrategy.h b/src/strategy/generic/GuardStrategy.h index 923dc4ea..c6c21938 100644 --- a/src/strategy/generic/GuardStrategy.h +++ b/src/strategy/generic/GuardStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GUARDSTRATEGY_H @@ -11,12 +12,12 @@ class PlayerbotAI; class GuardStrategy : public NonCombatStrategy { - public: - GuardStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + GuardStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "guard"; } - NextAction** getDefaultActions() override; - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "guard"; } + NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/GuildStrategy.cpp b/src/strategy/generic/GuildStrategy.cpp index ba36a736..f2249db5 100644 --- a/src/strategy/generic/GuildStrategy.cpp +++ b/src/strategy/generic/GuildStrategy.cpp @@ -1,16 +1,22 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GuildStrategy.h" + #include "Playerbots.h" -void GuildStrategy::InitTriggers(std::vector &triggers) +void GuildStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("offer petition nearby", 4.0f), nullptr))); - triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("guild manage nearby", 4.0f), nullptr))); - triggers.push_back(new TriggerNode("petition signed", NextAction::array(0, new NextAction("turn in petition", 10.0f), nullptr))); - triggers.push_back(new TriggerNode("buy tabard", NextAction::array(0, new NextAction("buy tabard", 10.0f), nullptr))); - triggers.push_back(new TriggerNode("leave large guild", NextAction::array(0, new NextAction("guild leave", 4.0f), nullptr))); + triggers.push_back( + new TriggerNode("often", NextAction::array(0, new NextAction("offer petition nearby", 4.0f), nullptr))); + triggers.push_back( + new TriggerNode("often", NextAction::array(0, new NextAction("guild manage nearby", 4.0f), nullptr))); + triggers.push_back( + new TriggerNode("petition signed", NextAction::array(0, new NextAction("turn in petition", 10.0f), nullptr))); + triggers.push_back( + new TriggerNode("buy tabard", NextAction::array(0, new NextAction("buy tabard", 10.0f), nullptr))); + triggers.push_back( + new TriggerNode("leave large guild", NextAction::array(0, new NextAction("guild leave", 4.0f), nullptr))); } - diff --git a/src/strategy/generic/GuildStrategy.h b/src/strategy/generic/GuildStrategy.h index 8c51396a..2a06ca2e 100644 --- a/src/strategy/generic/GuildStrategy.h +++ b/src/strategy/generic/GuildStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GUILDSTRATEGY_H @@ -11,12 +12,12 @@ class PlayerbotAI; class GuildStrategy : public NonCombatStrategy { - public: - GuildStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + GuildStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "guild"; } - uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } - void InitTriggers(std::vector &triggers) override; + std::string const getName() override { return "guild"; } + uint32 GetType() const override { return STRATEGY_TYPE_GENERIC; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/KiteStrategy.cpp b/src/strategy/generic/KiteStrategy.cpp index 6b5fda05..a369baa0 100644 --- a/src/strategy/generic/KiteStrategy.cpp +++ b/src/strategy/generic/KiteStrategy.cpp @@ -1,13 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "KiteStrategy.h" + #include "Playerbots.h" -KiteStrategy::KiteStrategy(PlayerbotAI* botAI) : Strategy(botAI) -{ -} +KiteStrategy::KiteStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} void KiteStrategy::InitTriggers(std::vector& triggers) { diff --git a/src/strategy/generic/KiteStrategy.h b/src/strategy/generic/KiteStrategy.h index a1d70e27..c8eb226b 100644 --- a/src/strategy/generic/KiteStrategy.h +++ b/src/strategy/generic/KiteStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_KITESTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class KiteStrategy : public Strategy { - public: - KiteStrategy(PlayerbotAI* botAI); +public: + KiteStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "kite"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "kite"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/LfgStrategy.cpp b/src/strategy/generic/LfgStrategy.cpp index fe878bee..59f95f4d 100644 --- a/src/strategy/generic/LfgStrategy.cpp +++ b/src/strategy/generic/LfgStrategy.cpp @@ -1,17 +1,19 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LfgStrategy.h" + #include "Playerbots.h" -void LfgStrategy::InitTriggers(std::vector &triggers) +void LfgStrategy::InitTriggers(std::vector& triggers) { triggers.push_back(new TriggerNode("random", NextAction::array(0, new NextAction("lfg join", relevance), nullptr))); - triggers.push_back(new TriggerNode("seldom", NextAction::array(0, new NextAction("lfg leave", relevance), nullptr))); - triggers.push_back(new TriggerNode("unknown dungeon", NextAction::array(0, new NextAction("give leader in dungeon", relevance), nullptr))); + triggers.push_back( + new TriggerNode("seldom", NextAction::array(0, new NextAction("lfg leave", relevance), nullptr))); + triggers.push_back(new TriggerNode( + "unknown dungeon", NextAction::array(0, new NextAction("give leader in dungeon", relevance), nullptr))); } -LfgStrategy::LfgStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) -{ -} +LfgStrategy::LfgStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) {} diff --git a/src/strategy/generic/LfgStrategy.h b/src/strategy/generic/LfgStrategy.h index f55d24cf..88324234 100644 --- a/src/strategy/generic/LfgStrategy.h +++ b/src/strategy/generic/LfgStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LFGSTRATEGY_H @@ -9,12 +10,12 @@ class LfgStrategy : public PassTroughStrategy { - public: - LfgStrategy(PlayerbotAI* botAI); +public: + LfgStrategy(PlayerbotAI* botAI); - uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } - void InitTriggers(std::vector &triggers) override; - std::string const getName() override { return "lfg"; } + uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "lfg"; } }; #endif diff --git a/src/strategy/generic/LootNonCombatStrategy.cpp b/src/strategy/generic/LootNonCombatStrategy.cpp index d939ef45..57cc296a 100644 --- a/src/strategy/generic/LootNonCombatStrategy.cpp +++ b/src/strategy/generic/LootNonCombatStrategy.cpp @@ -1,26 +1,29 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LootNonCombatStrategy.h" + #include "Playerbots.h" void LootNonCombatStrategy::InitTriggers(std::vector& triggers) { triggers.push_back(new TriggerNode("loot available", NextAction::array(0, new NextAction("loot", 6.0f), nullptr))); - triggers.push_back(new TriggerNode("far from loot target", NextAction::array(0, new NextAction("move to loot", 7.0f), nullptr))); + triggers.push_back( + new TriggerNode("far from loot target", NextAction::array(0, new NextAction("move to loot", 7.0f), nullptr))); triggers.push_back(new TriggerNode("can loot", NextAction::array(0, new NextAction("open loot", 8.0f), nullptr))); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("add all loot", 1.0f), nullptr))); } void GatherStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("timer", NextAction::array(0, new NextAction("add gathering loot", 2.0f), nullptr))); + triggers.push_back( + new TriggerNode("timer", NextAction::array(0, new NextAction("add gathering loot", 2.0f), nullptr))); } void RevealStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("reveal gathering item", 50.0f), nullptr))); + triggers.push_back( + new TriggerNode("often", NextAction::array(0, new NextAction("reveal gathering item", 50.0f), nullptr))); } - - diff --git a/src/strategy/generic/LootNonCombatStrategy.h b/src/strategy/generic/LootNonCombatStrategy.h index ddb40e8d..e9b59e97 100644 --- a/src/strategy/generic/LootNonCombatStrategy.h +++ b/src/strategy/generic/LootNonCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LOOTNONCOMBATSTRATEGY_H @@ -11,29 +12,29 @@ class PlayerbotAI; class LootNonCombatStrategy : public Strategy { - public: - LootNonCombatStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + LootNonCombatStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "loot"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "loot"; } }; class GatherStrategy : public Strategy { - public: - GatherStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + GatherStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "gather"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "gather"; } }; class RevealStrategy : public Strategy { - public: - RevealStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + RevealStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "reveal"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "reveal"; } }; #endif diff --git a/src/strategy/generic/MaintenanceStrategy.cpp b/src/strategy/generic/MaintenanceStrategy.cpp index 46b1f044..bb3707b9 100644 --- a/src/strategy/generic/MaintenanceStrategy.cpp +++ b/src/strategy/generic/MaintenanceStrategy.cpp @@ -1,24 +1,29 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "MaintenanceStrategy.h" + #include "Playerbots.h" -NextAction** MaintenanceStrategy::getDefaultActions() -{ - return nullptr; -} +NextAction** MaintenanceStrategy::getDefaultActions() { return nullptr; } void MaintenanceStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("random", NextAction::array(0, new NextAction("clean quest log", 6.0f), nullptr))); - triggers.push_back(new TriggerNode("random", NextAction::array(0, new NextAction("use random recipe", 1.0f), nullptr))); - triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("use random quest item", 10.0f), nullptr))); - triggers.push_back(new TriggerNode("random", NextAction::array(0, new NextAction("disenchant random item", 1.0f), nullptr))); - triggers.push_back(new TriggerNode("random", NextAction::array(0, new NextAction("enchant random item", 1.0f), nullptr))); - triggers.push_back(new TriggerNode("random", NextAction::array(0, new NextAction("smart destroy item", 1.0f), nullptr))); + triggers.push_back( + new TriggerNode("random", NextAction::array(0, new NextAction("clean quest log", 6.0f), nullptr))); + triggers.push_back( + new TriggerNode("random", NextAction::array(0, new NextAction("use random recipe", 1.0f), nullptr))); + triggers.push_back( + new TriggerNode("often", NextAction::array(0, new NextAction("use random quest item", 10.0f), nullptr))); + triggers.push_back( + new TriggerNode("random", NextAction::array(0, new NextAction("disenchant random item", 1.0f), nullptr))); + triggers.push_back( + new TriggerNode("random", NextAction::array(0, new NextAction("enchant random item", 1.0f), nullptr))); + triggers.push_back( + new TriggerNode("random", NextAction::array(0, new NextAction("smart destroy item", 1.0f), nullptr))); triggers.push_back(new TriggerNode("move stuck", NextAction::array(0, new NextAction("reset", 1.0f), nullptr))); - // triggers.push_back(new TriggerNode("move long stuck", NextAction::array(0, new NextAction("hearthstone", 0.9f), new NextAction("repop", 0.8f), nullptr))); + // triggers.push_back(new TriggerNode("move long stuck", NextAction::array(0, new NextAction("hearthstone", 0.9f), + // new NextAction("repop", 0.8f), nullptr))); } - diff --git a/src/strategy/generic/MaintenanceStrategy.h b/src/strategy/generic/MaintenanceStrategy.h index 593992da..a879e3fa 100644 --- a/src/strategy/generic/MaintenanceStrategy.h +++ b/src/strategy/generic/MaintenanceStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MAINTANCESTRATEGY_H @@ -11,13 +12,13 @@ class PlayerbotAI; class MaintenanceStrategy : public NonCombatStrategy { - public: - MaintenanceStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + MaintenanceStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "maintenance"; } - uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } - NextAction** getDefaultActions() override; - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "maintenance"; } + uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } + NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/MarkRtiStrategy.cpp b/src/strategy/generic/MarkRtiStrategy.cpp index 1e42c922..dea739ce 100644 --- a/src/strategy/generic/MarkRtiStrategy.cpp +++ b/src/strategy/generic/MarkRtiStrategy.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "MarkRtiStrategy.h" + #include "Playerbots.h" void MarkRtiStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("no rti target", NextAction::array(0, new NextAction("mark rti", ACTION_NORMAL), nullptr))); + triggers.push_back( + new TriggerNode("no rti target", NextAction::array(0, new NextAction("mark rti", ACTION_NORMAL), nullptr))); } - diff --git a/src/strategy/generic/MarkRtiStrategy.h b/src/strategy/generic/MarkRtiStrategy.h index 2adf4dc9..dbb2c495 100644 --- a/src/strategy/generic/MarkRtiStrategy.h +++ b/src/strategy/generic/MarkRtiStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MARKRTISTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class MarkRtiStrategy : public Strategy { - public: - MarkRtiStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + MarkRtiStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - std::string const getName() override { return "mark rti"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "mark rti"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/MeleeCombatStrategy.cpp b/src/strategy/generic/MeleeCombatStrategy.cpp index 179d3621..178bd418 100644 --- a/src/strategy/generic/MeleeCombatStrategy.cpp +++ b/src/strategy/generic/MeleeCombatStrategy.cpp @@ -1,22 +1,28 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "MeleeCombatStrategy.h" + #include "Playerbots.h" -void MeleeCombatStrategy::InitTriggers(std::vector &triggers) +void MeleeCombatStrategy::InitTriggers(std::vector& triggers) { CombatStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("not facing target", NextAction::array(0, new NextAction("set facing", ACTION_MOVE + 7), nullptr))); - triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("reach melee", ACTION_NORMAL + 8), nullptr))); - // triggers.push_back(new TriggerNode("enemy too close for melee", NextAction::array(0, new NextAction("move out of enemy contact", ACTION_NORMAL + 8), nullptr))); + // triggers.push_back(new TriggerNode("not facing target", NextAction::array(0, new NextAction("set facing", + // ACTION_MOVE + 7), nullptr))); + triggers.push_back(new TriggerNode( + "enemy out of melee", NextAction::array(0, new NextAction("reach melee", ACTION_NORMAL + 8), nullptr))); + // triggers.push_back(new TriggerNode("enemy too close for melee", NextAction::array(0, new NextAction("move out of + // enemy contact", ACTION_NORMAL + 8), nullptr))); } -void SetBehindCombatStrategy::InitTriggers(std::vector &triggers) +void SetBehindCombatStrategy::InitTriggers(std::vector& triggers) { CombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("not behind target", NextAction::array(0, new NextAction("set behind", ACTION_MOVE + 7), nullptr))); + triggers.push_back(new TriggerNode("not behind target", + NextAction::array(0, new NextAction("set behind", ACTION_MOVE + 7), nullptr))); } diff --git a/src/strategy/generic/MeleeCombatStrategy.h b/src/strategy/generic/MeleeCombatStrategy.h index 0f7d284d..c5adc269 100644 --- a/src/strategy/generic/MeleeCombatStrategy.h +++ b/src/strategy/generic/MeleeCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MELEECOMBATSTRATEGY_H @@ -11,21 +12,21 @@ class PlayerbotAI; class MeleeCombatStrategy : public CombatStrategy { - public: - MeleeCombatStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + MeleeCombatStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_MELEE; } - std::string const getName() override { return "close"; } + void InitTriggers(std::vector& triggers) override; + uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_MELEE; } + std::string const getName() override { return "close"; } }; class SetBehindCombatStrategy : public CombatStrategy { - public: - SetBehindCombatStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + SetBehindCombatStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "behind"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "behind"; } }; #endif diff --git a/src/strategy/generic/NonCombatStrategy.cpp b/src/strategy/generic/NonCombatStrategy.cpp index 41874d59..cc673fae 100644 --- a/src/strategy/generic/NonCombatStrategy.cpp +++ b/src/strategy/generic/NonCombatStrategy.cpp @@ -1,30 +1,36 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "NonCombatStrategy.h" + #include "Playerbots.h" void NonCombatStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("timer", NextAction::array(0, new NextAction("check mount state", 1.0f), - // new NextAction("check values", 1.0f), - nullptr))); - // triggers.push_back(new TriggerNode("near dark portal", NextAction::array(0, new NextAction("move to dark portal", 1.0f), nullptr))); - // triggers.push_back(new TriggerNode("at dark portal azeroth", NextAction::array(0, new NextAction("use dark portal azeroth", 1.0f), nullptr))); - // triggers.push_back(new TriggerNode("at dark portal outland", NextAction::array(0, new NextAction("move from dark portal", 1.0f), nullptr))); - // triggers.push_back(new TriggerNode("need world buff", NextAction::array(0, new NextAction("world buff", 1.0f), nullptr))); - // triggers.push_back(new TriggerNode("vehicle near", NextAction::array(0, new NextAction("enter vehicle", 10.0f), nullptr))); + triggers.push_back(new TriggerNode("timer", NextAction::array(0, new NextAction("check mount state", 1.0f), + // new NextAction("check values", 1.0f), + nullptr))); + // triggers.push_back(new TriggerNode("near dark portal", NextAction::array(0, new NextAction("move to dark + // portal", 1.0f), nullptr))); triggers.push_back(new TriggerNode("at dark portal azeroth", NextAction::array(0, new + // NextAction("use dark portal azeroth", 1.0f), nullptr))); triggers.push_back(new TriggerNode("at dark portal + // outland", NextAction::array(0, new NextAction("move from dark portal", 1.0f), nullptr))); triggers.push_back(new + // TriggerNode("need world buff", NextAction::array(0, new NextAction("world buff", 1.0f), nullptr))); + // triggers.push_back(new TriggerNode("vehicle near", NextAction::array(0, new NextAction("enter vehicle", 10.0f), + // nullptr))); } void CollisionStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("collision", NextAction::array(0, new NextAction("move out of collision", 2.0f), nullptr))); + triggers.push_back( + new TriggerNode("collision", NextAction::array(0, new NextAction("move out of collision", 2.0f), nullptr))); } void MountStrategy::InitTriggers(std::vector& triggers) { - /*triggers.push_back(new TriggerNode("no possible targets", NextAction::array(0, new NextAction("mount", 1.0f), nullptr))); - triggers.push_back(new TriggerNode("no rpg target", NextAction::array(0, new NextAction("mount", 1.0f), nullptr)));*/ + /*triggers.push_back(new TriggerNode("no possible targets", NextAction::array(0, new NextAction("mount", 1.0f), + nullptr))); triggers.push_back(new TriggerNode("no rpg target", NextAction::array(0, new NextAction("mount", 1.0f), + nullptr)));*/ /*triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("mount", 4.0f), nullptr)));*/ } diff --git a/src/strategy/generic/NonCombatStrategy.h b/src/strategy/generic/NonCombatStrategy.h index 2a39427f..d032dcf4 100644 --- a/src/strategy/generic/NonCombatStrategy.h +++ b/src/strategy/generic/NonCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_NONCOMBATSTRATEGY_H @@ -11,40 +12,40 @@ class PlayerbotAI; class NonCombatStrategy : public Strategy { - public: - NonCombatStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + NonCombatStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } - void InitTriggers(std::vector& triggers) override; + uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } + void InitTriggers(std::vector& triggers) override; }; class CollisionStrategy : public Strategy { - public: - CollisionStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + CollisionStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "collision"; } + uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "collision"; } }; class MountStrategy : public Strategy { - public: - MountStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + MountStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "mount"; } + uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "mount"; } }; class AttackTaggedStrategy : public Strategy { - public: - AttackTaggedStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + AttackTaggedStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } - std::string const getName() override { return "attack tagged"; } + uint32 GetType() const override { return STRATEGY_TYPE_NONCOMBAT; } + std::string const getName() override { return "attack tagged"; } }; #endif diff --git a/src/strategy/generic/PassTroughStrategy.cpp b/src/strategy/generic/PassTroughStrategy.cpp index b5b34000..d66af024 100644 --- a/src/strategy/generic/PassTroughStrategy.cpp +++ b/src/strategy/generic/PassTroughStrategy.cpp @@ -1,13 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PassTroughStrategy.h" + #include "Playerbots.h" void PassTroughStrategy::InitTriggers(std::vector& triggers) { for (std::vector::iterator i = supported.begin(); i != supported.end(); i++) - triggers.push_back(new TriggerNode(i->c_str(), NextAction::array(0, new NextAction(i->c_str(), relevance), nullptr))); + triggers.push_back( + new TriggerNode(i->c_str(), NextAction::array(0, new NextAction(i->c_str(), relevance), nullptr))); } - diff --git a/src/strategy/generic/PassTroughStrategy.h b/src/strategy/generic/PassTroughStrategy.h index 10e8a5df..b5784fd7 100644 --- a/src/strategy/generic/PassTroughStrategy.h +++ b/src/strategy/generic/PassTroughStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PASSTHROUGHSTRATEGY_H @@ -11,14 +12,14 @@ class PlayerbotAI; class PassTroughStrategy : public Strategy { - public: - PassTroughStrategy(PlayerbotAI* botAI, float relevance = 100.0f) : Strategy(botAI), relevance(relevance) { } +public: + PassTroughStrategy(PlayerbotAI* botAI, float relevance = 100.0f) : Strategy(botAI), relevance(relevance) {} - void InitTriggers(std::vector& triggers) override; + void InitTriggers(std::vector& triggers) override; - protected: - std::vector supported; - float relevance; +protected: + std::vector supported; + float relevance; }; #endif diff --git a/src/strategy/generic/PassiveStrategy.cpp b/src/strategy/generic/PassiveStrategy.cpp index 4f87363c..d716c0dd 100644 --- a/src/strategy/generic/PassiveStrategy.cpp +++ b/src/strategy/generic/PassiveStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PassiveStrategy.h" + #include "PassiveMultiplier.h" #include "Playerbots.h" @@ -10,4 +12,3 @@ void PassiveStrategy::InitMultipliers(std::vector& multipliers) { multipliers.push_back(new PassiveMultiplier(botAI)); } - diff --git a/src/strategy/generic/PassiveStrategy.h b/src/strategy/generic/PassiveStrategy.h index b30ba1cc..86bbef97 100644 --- a/src/strategy/generic/PassiveStrategy.h +++ b/src/strategy/generic/PassiveStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PASSIVESTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class PassiveStrategy : public Strategy { - public: - PassiveStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PassiveStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitMultipliers(std::vector& multipliers) override; - std::string const getName() override { return "passive"; } + void InitMultipliers(std::vector& multipliers) override; + std::string const getName() override { return "passive"; } }; #endif diff --git a/src/strategy/generic/PullStrategy.cpp b/src/strategy/generic/PullStrategy.cpp index a00c18e5..557ac729 100644 --- a/src/strategy/generic/PullStrategy.cpp +++ b/src/strategy/generic/PullStrategy.cpp @@ -1,20 +1,22 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PullStrategy.h" + #include "PassiveMultiplier.h" #include "Playerbots.h" class MagePullMultiplier : public PassiveMultiplier { - public: - MagePullMultiplier(PlayerbotAI* botAI, std::string const action) : PassiveMultiplier(botAI), actionName(action) { } +public: + MagePullMultiplier(PlayerbotAI* botAI, std::string const action) : PassiveMultiplier(botAI), actionName(action) {} - float GetValue(Action* action) override; + float GetValue(Action* action) override; - private: - std::string const actionName; +private: + std::string const actionName; }; float MagePullMultiplier::GetValue(Action* action) @@ -31,13 +33,11 @@ float MagePullMultiplier::GetValue(Action* action) NextAction** PullStrategy::getDefaultActions() { - return NextAction::array(0, new NextAction(action, 105.0f), new NextAction("follow", 104.0f), new NextAction("end pull", 103.0f), nullptr); + return NextAction::array(0, new NextAction(action, 105.0f), new NextAction("follow", 104.0f), + new NextAction("end pull", 103.0f), nullptr); } -void PullStrategy::InitTriggers(std::vector& triggers) -{ - CombatStrategy::InitTriggers(triggers); -} +void PullStrategy::InitTriggers(std::vector& triggers) { CombatStrategy::InitTriggers(triggers); } void PullStrategy::InitMultipliers(std::vector& multipliers) { @@ -49,5 +49,6 @@ void PossibleAddsStrategy::InitTriggers(std::vector& triggers) { Strategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("possible adds", NextAction::array(0, new NextAction("flee with pet", 60), nullptr))); + triggers.push_back( + new TriggerNode("possible adds", NextAction::array(0, new NextAction("flee with pet", 60), nullptr))); } diff --git a/src/strategy/generic/PullStrategy.h b/src/strategy/generic/PullStrategy.h index 6a91ed73..f8489d3d 100644 --- a/src/strategy/generic/PullStrategy.h +++ b/src/strategy/generic/PullStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PULLSTRATEGY_H @@ -11,25 +12,25 @@ class PlayerbotAI; class PullStrategy : public CombatStrategy { - public: - PullStrategy(PlayerbotAI* botAI, std::string const action) : CombatStrategy(botAI), action(action) { } +public: + PullStrategy(PlayerbotAI* botAI, std::string const action) : CombatStrategy(botAI), action(action) {} - void InitTriggers(std::vector& triggers) override; - void InitMultipliers(std::vector& multipliers) override; - std::string const getName() override { return "pull"; } - NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; + void InitMultipliers(std::vector& multipliers) override; + std::string const getName() override { return "pull"; } + NextAction** getDefaultActions() override; - private: - std::string const action; +private: + std::string const action; }; class PossibleAddsStrategy : public Strategy { - public: - PossibleAddsStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PossibleAddsStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "adds"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "adds"; } }; #endif diff --git a/src/strategy/generic/QuestStrategies.cpp b/src/strategy/generic/QuestStrategies.cpp index 7ea6c656..53a1eabf 100644 --- a/src/strategy/generic/QuestStrategies.cpp +++ b/src/strategy/generic/QuestStrategies.cpp @@ -1,44 +1,49 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "QuestStrategies.h" + #include "Playerbots.h" -QuestStrategy::QuestStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) -{ - supported.push_back("accept quest"); -} +QuestStrategy::QuestStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) { supported.push_back("accept quest"); } void QuestStrategy::InitTriggers(std::vector& triggers) { PassTroughStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("quest share", NextAction::array(0, new NextAction("accept quest share", relevance), nullptr))); + triggers.push_back( + new TriggerNode("quest share", NextAction::array(0, new NextAction("accept quest share", relevance), nullptr))); } void DefaultQuestStrategy::InitTriggers(std::vector& triggers) { QuestStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("use game object", NextAction::array(0, new NextAction("talk to quest giver", relevance), nullptr))); - triggers.push_back(new TriggerNode("gossip hello", NextAction::array(0, new NextAction("talk to quest giver", relevance), nullptr))); - triggers.push_back(new TriggerNode("complete quest", NextAction::array(0, new NextAction("talk to quest giver", relevance), nullptr))); + triggers.push_back(new TriggerNode( + "use game object", NextAction::array(0, new NextAction("talk to quest giver", relevance), nullptr))); + triggers.push_back(new TriggerNode( + "gossip hello", NextAction::array(0, new NextAction("talk to quest giver", relevance), nullptr))); + triggers.push_back(new TriggerNode( + "complete quest", NextAction::array(0, new NextAction("talk to quest giver", relevance), nullptr))); } -DefaultQuestStrategy::DefaultQuestStrategy(PlayerbotAI* botAI) : QuestStrategy(botAI) -{ -} +DefaultQuestStrategy::DefaultQuestStrategy(PlayerbotAI* botAI) : QuestStrategy(botAI) {} void AcceptAllQuestsStrategy::InitTriggers(std::vector& triggers) { QuestStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("use game object", NextAction::array(0, new NextAction("talk to quest giver", relevance), new NextAction("accept all quests", relevance), nullptr))); - triggers.push_back(new TriggerNode("gossip hello", NextAction::array(0, new NextAction("talk to quest giver", relevance), new NextAction("accept all quests", relevance), nullptr))); - triggers.push_back(new TriggerNode("complete quest", NextAction::array(0, new NextAction("talk to quest giver", relevance), new NextAction("accept all quests", relevance), nullptr))); + triggers.push_back( + new TriggerNode("use game object", NextAction::array(0, new NextAction("talk to quest giver", relevance), + new NextAction("accept all quests", relevance), nullptr))); + triggers.push_back( + new TriggerNode("gossip hello", NextAction::array(0, new NextAction("talk to quest giver", relevance), + new NextAction("accept all quests", relevance), nullptr))); + triggers.push_back( + new TriggerNode("complete quest", NextAction::array(0, new NextAction("talk to quest giver", relevance), + new NextAction("accept all quests", relevance), nullptr))); } -AcceptAllQuestsStrategy::AcceptAllQuestsStrategy(PlayerbotAI* botAI) : QuestStrategy(botAI) -{ -} +AcceptAllQuestsStrategy::AcceptAllQuestsStrategy(PlayerbotAI* botAI) : QuestStrategy(botAI) {} diff --git a/src/strategy/generic/QuestStrategies.h b/src/strategy/generic/QuestStrategies.h index 13137782..55a36e24 100644 --- a/src/strategy/generic/QuestStrategies.h +++ b/src/strategy/generic/QuestStrategies.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_QUESTSTRATEGIES_H @@ -11,28 +12,28 @@ class PlayerbotAI; class QuestStrategy : public PassTroughStrategy { - public: - QuestStrategy(PlayerbotAI* botAI); +public: + QuestStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; + void InitTriggers(std::vector& triggers) override; }; class DefaultQuestStrategy : public QuestStrategy { - public: - DefaultQuestStrategy(PlayerbotAI* botAI); +public: + DefaultQuestStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "quest"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "quest"; } }; class AcceptAllQuestsStrategy : public QuestStrategy { - public: - AcceptAllQuestsStrategy(PlayerbotAI* botAI); +public: + AcceptAllQuestsStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "accept all quests"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "accept all quests"; } }; #endif diff --git a/src/strategy/generic/RTSCStrategy.cpp b/src/strategy/generic/RTSCStrategy.cpp index 41af5cec..820a837b 100644 --- a/src/strategy/generic/RTSCStrategy.cpp +++ b/src/strategy/generic/RTSCStrategy.cpp @@ -1,14 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RTSCStrategy.h" + #include "Playerbots.h" -RTSCStrategy::RTSCStrategy(PlayerbotAI* botAI) : Strategy(botAI) -{ -} +RTSCStrategy::RTSCStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} -void RTSCStrategy::InitTriggers(std::vector& triggers) -{ -} +void RTSCStrategy::InitTriggers(std::vector& triggers) {} diff --git a/src/strategy/generic/RTSCStrategy.h b/src/strategy/generic/RTSCStrategy.h index 4e5aa6f3..46465fd8 100644 --- a/src/strategy/generic/RTSCStrategy.h +++ b/src/strategy/generic/RTSCStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RTSCSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class RTSCStrategy : public Strategy { - public: - RTSCStrategy(PlayerbotAI* botAI); +public: + RTSCStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "RTSC"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "RTSC"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/RacialsStrategy.cpp b/src/strategy/generic/RacialsStrategy.cpp index cb3b8938..4b17bdf9 100644 --- a/src/strategy/generic/RacialsStrategy.cpp +++ b/src/strategy/generic/RacialsStrategy.cpp @@ -1,35 +1,38 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RacialsStrategy.h" + #include "Playerbots.h" class RacialsStrategyActionNodeFactory : public NamedObjectFactory { - public: - RacialsStrategyActionNodeFactory() - { - creators["lifeblood"] = &lifeblood; - } +public: + RacialsStrategyActionNodeFactory() { creators["lifeblood"] = &lifeblood; } - private: - static ActionNode* lifeblood(PlayerbotAI* botAI) - { - return new ActionNode ("lifeblood", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("gift of the naaru"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* lifeblood(PlayerbotAI* botAI) + { + return new ActionNode("lifeblood", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("gift of the naaru"), nullptr), + /*C*/ nullptr); + } }; void RacialsStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("lifeblood", 71.0f), nullptr))); - // triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("war stomp", 71.0f), nullptr))); - /*triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("war stomp", 71.0f), nullptr)));*/ - /*triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("arcane torrent", ACTION_EMERGENCY + 6), nullptr))); - triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new NextAction("mana tap", ACTION_EMERGENCY + 6), nullptr)));*/ + triggers.push_back( + new TriggerNode("low health", NextAction::array(0, new NextAction("lifeblood", 71.0f), nullptr))); + // triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("war stomp", 71.0f), + // nullptr))); + /*triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("war stomp", 71.0f), + * nullptr)));*/ + /*triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("arcane torrent", + ACTION_EMERGENCY + 6), nullptr))); triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new + NextAction("mana tap", ACTION_EMERGENCY + 6), nullptr)));*/ } RacialsStrategy::RacialsStrategy(PlayerbotAI* botAI) : Strategy(botAI) diff --git a/src/strategy/generic/RacialsStrategy.h b/src/strategy/generic/RacialsStrategy.h index 7cfac4d2..ca42f3ac 100644 --- a/src/strategy/generic/RacialsStrategy.h +++ b/src/strategy/generic/RacialsStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RACIALSSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class RacialsStrategy : public Strategy { - public: - RacialsStrategy(PlayerbotAI* botAI); +public: + RacialsStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "racials"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "racials"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/RangedCombatStrategy.cpp b/src/strategy/generic/RangedCombatStrategy.cpp index df9377a7..f4aefb0e 100644 --- a/src/strategy/generic/RangedCombatStrategy.cpp +++ b/src/strategy/generic/RangedCombatStrategy.cpp @@ -1,14 +1,18 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RangedCombatStrategy.h" + #include "Playerbots.h" -void RangedCombatStrategy::InitTriggers(std::vector &triggers) +void RangedCombatStrategy::InitTriggers(std::vector& triggers) { CombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("enemy too close for spell", NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); - // triggers.push_back(new TriggerNode("not facing target", NextAction::array(0, new NextAction("set facing", ACTION_MOVE + 7), nullptr))); + triggers.push_back(new TriggerNode("enemy too close for spell", + NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); + // triggers.push_back(new TriggerNode("not facing target", NextAction::array(0, new NextAction("set facing", + // ACTION_MOVE + 7), nullptr))); } diff --git a/src/strategy/generic/RangedCombatStrategy.h b/src/strategy/generic/RangedCombatStrategy.h index ee4f4e8e..04d9150f 100644 --- a/src/strategy/generic/RangedCombatStrategy.h +++ b/src/strategy/generic/RangedCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RANGEDCOMBATSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class RangedCombatStrategy : public CombatStrategy { - public: - RangedCombatStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } - void InitTriggers(std::vector& triggers) override; - uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_RANGED; } - std::string const getName() override { return "ranged"; } +public: + RangedCombatStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} + void InitTriggers(std::vector& triggers) override; + uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_RANGED; } + std::string const getName() override { return "ranged"; } }; #endif diff --git a/src/strategy/generic/ReturnStrategy.cpp b/src/strategy/generic/ReturnStrategy.cpp index dbdc72c5..cf70a86a 100644 --- a/src/strategy/generic/ReturnStrategy.cpp +++ b/src/strategy/generic/ReturnStrategy.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ReturnStrategy.h" + #include "Playerbots.h" void ReturnStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("return", NextAction::array(0, new NextAction("set return position", 1.5f), new NextAction("return", 1.0f), nullptr))); + triggers.push_back(new TriggerNode("return", NextAction::array(0, new NextAction("set return position", 1.5f), + new NextAction("return", 1.0f), nullptr))); } - diff --git a/src/strategy/generic/ReturnStrategy.h b/src/strategy/generic/ReturnStrategy.h index 417b68bd..739f0bcb 100644 --- a/src/strategy/generic/ReturnStrategy.h +++ b/src/strategy/generic/ReturnStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RETURNSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class ReturnStrategy : public NonCombatStrategy { - public: - ReturnStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + ReturnStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "return"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "return"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/RpgStrategy.cpp b/src/strategy/generic/RpgStrategy.cpp index 058e32c8..67e43c38 100644 --- a/src/strategy/generic/RpgStrategy.cpp +++ b/src/strategy/generic/RpgStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RpgStrategy.h" + #include "Playerbots.h" #include "RpgSubActions.h" @@ -20,43 +22,53 @@ float RpgActionMultiplier::GetValue(Action* action) return 1.0f; } -RpgStrategy::RpgStrategy(PlayerbotAI* botAI) : Strategy(botAI) -{ -} +RpgStrategy::RpgStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} -NextAction** RpgStrategy::getDefaultActions() -{ - return NextAction::array(0, new NextAction("rpg", 1.0f), nullptr); -} +NextAction** RpgStrategy::getDefaultActions() { return NextAction::array(0, new NextAction("rpg", 1.0f), nullptr); } void RpgStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("no rpg target", NextAction::array(0, new NextAction("choose rpg target", 5.0f), nullptr))); + triggers.push_back( + new TriggerNode("no rpg target", NextAction::array(0, new NextAction("choose rpg target", 5.0f), nullptr))); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("move random", 1.10f), NULL))); - triggers.push_back(new TriggerNode("far from rpg target", NextAction::array(0, new NextAction("move to rpg target", 5.0f), nullptr))); + triggers.push_back(new TriggerNode("far from rpg target", + NextAction::array(0, new NextAction("move to rpg target", 5.0f), nullptr))); - //Sub actions + // Sub actions triggers.push_back(new TriggerNode("rpg", NextAction::array(0, new NextAction("rpg stay", 1.101f), nullptr))); triggers.push_back(new TriggerNode("rpg", NextAction::array(0, new NextAction("rpg work", 1.101f), nullptr))); triggers.push_back(new TriggerNode("rpg", NextAction::array(0, new NextAction("rpg emote", 1.101f), nullptr))); - triggers.push_back(new TriggerNode("has rpg target", NextAction::array(0, new NextAction("rpg cancel", 1.101f), nullptr))); - // triggers.push_back(new TriggerNode("rpg taxi", NextAction::array(0, new NextAction("rpg taxi", 1.005f), nullptr))); - triggers.push_back(new TriggerNode("rpg discover", NextAction::array(0, new NextAction("rpg discover", 1.210f), nullptr))); - triggers.push_back(new TriggerNode("rpg start quest", NextAction::array(0, new NextAction("rpg start quest", 1.180f), nullptr))); - triggers.push_back(new TriggerNode("rpg end quest", NextAction::array(0, new NextAction("rpg end quest", 1.190f), nullptr))); + triggers.push_back( + new TriggerNode("has rpg target", NextAction::array(0, new NextAction("rpg cancel", 1.101f), nullptr))); + // triggers.push_back(new TriggerNode("rpg taxi", NextAction::array(0, new NextAction("rpg taxi", 1.005f), + // nullptr))); + triggers.push_back( + new TriggerNode("rpg discover", NextAction::array(0, new NextAction("rpg discover", 1.210f), nullptr))); + triggers.push_back( + new TriggerNode("rpg start quest", NextAction::array(0, new NextAction("rpg start quest", 1.180f), nullptr))); + triggers.push_back( + new TriggerNode("rpg end quest", NextAction::array(0, new NextAction("rpg end quest", 1.190f), nullptr))); triggers.push_back(new TriggerNode("rpg buy", NextAction::array(0, new NextAction("rpg buy", 1.130f), nullptr))); - // triggers.push_back(new TriggerNode("rpg sell", NextAction::array(0, new NextAction("rpg sell", 1.100f), nullptr))); - triggers.push_back(new TriggerNode("rpg repair", NextAction::array(0, new NextAction("rpg repair", 1.195f), nullptr))); - // triggers.push_back(new TriggerNode("rpg train", NextAction::array(0, new NextAction("rpg train", 1.080f), nullptr))); + // triggers.push_back(new TriggerNode("rpg sell", NextAction::array(0, new NextAction("rpg sell", 1.100f), + // nullptr))); + triggers.push_back( + new TriggerNode("rpg repair", NextAction::array(0, new NextAction("rpg repair", 1.195f), nullptr))); + // triggers.push_back(new TriggerNode("rpg train", NextAction::array(0, new NextAction("rpg train", 1.080f), + // nullptr))); triggers.push_back(new TriggerNode("rpg heal", NextAction::array(0, new NextAction("rpg heal", 1.125f), nullptr))); - triggers.push_back(new TriggerNode("rpg home bind", NextAction::array(0, new NextAction("rpg home bind", 1.160f), nullptr))); - // triggers.push_back(new TriggerNode("rpg queue bg", NextAction::array(0, new NextAction("rpg queue bg", 1.085f), nullptr))); - triggers.push_back(new TriggerNode("rpg buy petition", NextAction::array(0, new NextAction("rpg buy petition", 1.140f), nullptr))); + triggers.push_back( + new TriggerNode("rpg home bind", NextAction::array(0, new NextAction("rpg home bind", 1.160f), nullptr))); + // triggers.push_back(new TriggerNode("rpg queue bg", NextAction::array(0, new NextAction("rpg queue bg", 1.085f), + // nullptr))); + triggers.push_back( + new TriggerNode("rpg buy petition", NextAction::array(0, new NextAction("rpg buy petition", 1.140f), nullptr))); triggers.push_back(new TriggerNode("rpg use", NextAction::array(0, new NextAction("rpg use", 1.102f), nullptr))); - //triggers.push_back(new TriggerNode("rpg spell", NextAction::array(0, new NextAction("rpg spell", 1.001f), nullptr))); - //triggers.push_back(new TriggerNode("rpg craft", NextAction::array(0, new NextAction("rpg craft", 1.001f), nullptr))); - // triggers.push_back(new TriggerNode("rpg trade useful", NextAction::array(0, new NextAction("rpg trade useful", 1.030f), nullptr))); - // triggers.push_back(new TriggerNode("rpg duel", NextAction::array(0, new NextAction("rpg duel", 1.010f), nullptr))); + // triggers.push_back(new TriggerNode("rpg spell", NextAction::array(0, new NextAction("rpg spell", 1.001f), + // nullptr))); triggers.push_back(new TriggerNode("rpg craft", NextAction::array(0, new NextAction("rpg + // craft", 1.001f), nullptr))); + // triggers.push_back(new TriggerNode("rpg trade useful", NextAction::array(0, new NextAction("rpg trade + // useful", 1.030f), nullptr))); triggers.push_back(new TriggerNode("rpg duel", NextAction::array(0, new + // NextAction("rpg duel", 1.010f), nullptr))); } void RpgStrategy::InitMultipliers(std::vector& multipliers) diff --git a/src/strategy/generic/RpgStrategy.h b/src/strategy/generic/RpgStrategy.h index 15ec39c5..26a054e6 100644 --- a/src/strategy/generic/RpgStrategy.h +++ b/src/strategy/generic/RpgStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RPGSTRATEGY_H @@ -11,21 +12,21 @@ class PlayerbotAI; class RpgActionMultiplier : public Multiplier { - public: - RpgActionMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "rpg action") { } +public: + RpgActionMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "rpg action") {} - float GetValue(Action* action) override; + float GetValue(Action* action) override; }; class RpgStrategy : public Strategy { - public: - RpgStrategy(PlayerbotAI* botAI); +public: + RpgStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "rpg"; } - NextAction** getDefaultActions() override; - void InitTriggers(std::vector& triggers) override; - void InitMultipliers(std::vector& multipliers) override; + std::string const getName() override { return "rpg"; } + NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; + void InitMultipliers(std::vector& multipliers) override; }; #endif diff --git a/src/strategy/generic/RunawayStrategy.cpp b/src/strategy/generic/RunawayStrategy.cpp index ac104765..78db444b 100644 --- a/src/strategy/generic/RunawayStrategy.cpp +++ b/src/strategy/generic/RunawayStrategy.cpp @@ -1,11 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RunawayStrategy.h" + #include "Playerbots.h" void RunawayStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("enemy too close for spell", NextAction::array(0, new NextAction("runaway", 50.0f), nullptr))); + triggers.push_back( + new TriggerNode("enemy too close for spell", NextAction::array(0, new NextAction("runaway", 50.0f), nullptr))); } diff --git a/src/strategy/generic/RunawayStrategy.h b/src/strategy/generic/RunawayStrategy.h index 4e872dc2..8152af05 100644 --- a/src/strategy/generic/RunawayStrategy.h +++ b/src/strategy/generic/RunawayStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RUNAWAYSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class RunawayStrategy : public NonCombatStrategy { - public: - RunawayStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + RunawayStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "runaway"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "runaway"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/SayStrategy.cpp b/src/strategy/generic/SayStrategy.cpp index 7af0ab98..e6c1a51f 100644 --- a/src/strategy/generic/SayStrategy.cpp +++ b/src/strategy/generic/SayStrategy.cpp @@ -1,15 +1,20 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SayStrategy.h" + #include "Playerbots.h" void SayStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("say::critical health", 99.0f), nullptr))); - triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("say::low health", 99.0f), nullptr))); - triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("say::low mana", 99.0f), nullptr))); + triggers.push_back(new TriggerNode("critical health", + NextAction::array(0, new NextAction("say::critical health", 99.0f), nullptr))); + triggers.push_back( + new TriggerNode("low health", NextAction::array(0, new NextAction("say::low health", 99.0f), nullptr))); + triggers.push_back( + new TriggerNode("low mana", NextAction::array(0, new NextAction("say::low mana", 99.0f), nullptr))); triggers.push_back(new TriggerNode("tank aoe", NextAction::array(0, new NextAction("say::taunt", 99.0f), nullptr))); triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("say::aoe", 99.0f), nullptr))); } diff --git a/src/strategy/generic/SayStrategy.h b/src/strategy/generic/SayStrategy.h index 579c9444..63dad120 100644 --- a/src/strategy/generic/SayStrategy.h +++ b/src/strategy/generic/SayStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SAYSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class SayStrategy : public Strategy { - public: - SayStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + SayStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "say"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "say"; } }; #endif diff --git a/src/strategy/generic/StayStrategy.cpp b/src/strategy/generic/StayStrategy.cpp index e595d84d..8809971a 100644 --- a/src/strategy/generic/StayStrategy.cpp +++ b/src/strategy/generic/StayStrategy.cpp @@ -1,14 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "StayStrategy.h" + #include "Playerbots.h" -NextAction** StayStrategy::getDefaultActions() -{ - return NextAction::array(0, new NextAction("stay", 1.0f), nullptr); -} +NextAction** StayStrategy::getDefaultActions() { return NextAction::array(0, new NextAction("stay", 1.0f), nullptr); } void SitStrategy::InitTriggers(std::vector& triggers) { diff --git a/src/strategy/generic/StayStrategy.h b/src/strategy/generic/StayStrategy.h index c6a9fc50..0d9d6385 100644 --- a/src/strategy/generic/StayStrategy.h +++ b/src/strategy/generic/StayStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_STAYSTRATEGY_H @@ -11,20 +12,20 @@ class PlayerbotAI; class StayStrategy : public NonCombatStrategy { - public: - StayStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + StayStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "stay"; } - NextAction** getDefaultActions() override; + std::string const getName() override { return "stay"; } + NextAction** getDefaultActions() override; }; class SitStrategy : public NonCombatStrategy { - public: - SitStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + SitStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "sit"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "sit"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/TankAssistStrategy.cpp b/src/strategy/generic/TankAssistStrategy.cpp index 83c9c007..46ad4d96 100644 --- a/src/strategy/generic/TankAssistStrategy.cpp +++ b/src/strategy/generic/TankAssistStrategy.cpp @@ -1,11 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TankAssistStrategy.h" + #include "Playerbots.h" void TankAssistStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("tank assist", NextAction::array(0, new NextAction("tank assist", 50.0f), nullptr))); + triggers.push_back( + new TriggerNode("tank assist", NextAction::array(0, new NextAction("tank assist", 50.0f), nullptr))); } diff --git a/src/strategy/generic/TankAssistStrategy.h b/src/strategy/generic/TankAssistStrategy.h index dc3e6ff3..924773ad 100644 --- a/src/strategy/generic/TankAssistStrategy.h +++ b/src/strategy/generic/TankAssistStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TANKASSISTSTRATEGY_H @@ -11,12 +12,12 @@ class PlayerbotAI; class TankAssistStrategy : public Strategy { - public: - TankAssistStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + TankAssistStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - std::string const getName() override { return "tank assist"; } - uint32 GetType() const override { return STRATEGY_TYPE_TANK; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "tank assist"; } + uint32 GetType() const override { return STRATEGY_TYPE_TANK; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/generic/TellTargetStrategy.cpp b/src/strategy/generic/TellTargetStrategy.cpp index 49855cd4..522accb3 100644 --- a/src/strategy/generic/TellTargetStrategy.cpp +++ b/src/strategy/generic/TellTargetStrategy.cpp @@ -1,11 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TellTargetStrategy.h" + #include "Playerbots.h" void TellTargetStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("target changed", NextAction::array(0, new NextAction("tell target", 51.0f), nullptr))); + triggers.push_back( + new TriggerNode("target changed", NextAction::array(0, new NextAction("tell target", 51.0f), nullptr))); } diff --git a/src/strategy/generic/TellTargetStrategy.h b/src/strategy/generic/TellTargetStrategy.h index 5e477335..b87f44f5 100644 --- a/src/strategy/generic/TellTargetStrategy.h +++ b/src/strategy/generic/TellTargetStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TELLTARGETSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class TellTargetStrategy : public Strategy { - public: - TellTargetStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + TellTargetStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "TellTarget"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "TellTarget"; } }; #endif diff --git a/src/strategy/generic/ThreatStrategy.cpp b/src/strategy/generic/ThreatStrategy.cpp index ba1cbf4c..1e73e89e 100644 --- a/src/strategy/generic/ThreatStrategy.cpp +++ b/src/strategy/generic/ThreatStrategy.cpp @@ -1,18 +1,21 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ThreatStrategy.h" + #include "GenericSpellActions.h" #include "Map.h" #include "Playerbots.h" float ThreatMultiplier::GetValue(Action* action) { - if (AI_VALUE(bool, "neglect threat")) { + if (AI_VALUE(bool, "neglect threat")) + { return 1.0f; } - + if (!action || action->getThreatType() == Action::ActionThreatType::None) return 1.0f; @@ -40,13 +43,16 @@ void ThreatStrategy::InitMultipliers(std::vector& multipliers) float FocusMultiplier::GetValue(Action* action) { - if (!action) { + if (!action) + { return 1.0f; } - if (action->getThreatType() == Action::ActionThreatType::Aoe && !dynamic_cast(action)) { + if (action->getThreatType() == Action::ActionThreatType::Aoe && !dynamic_cast(action)) + { return 0.0f; } - if (dynamic_cast(action)) { + if (dynamic_cast(action)) + { return 0.0f; } return 1.0f; diff --git a/src/strategy/generic/ThreatStrategy.h b/src/strategy/generic/ThreatStrategy.h index 521233c9..61e347d7 100644 --- a/src/strategy/generic/ThreatStrategy.h +++ b/src/strategy/generic/ThreatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_THREATSTRATEGY_H @@ -11,36 +12,36 @@ class PlayerbotAI; class ThreatMultiplier : public Multiplier { - public: - ThreatMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "threat") { } +public: + ThreatMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "threat") {} - float GetValue(Action* action) override; + float GetValue(Action* action) override; }; class ThreatStrategy : public Strategy { - public: - ThreatStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + ThreatStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitMultipliers(std::vector& multipliers) override; - std::string const getName() override { return "threat"; } + void InitMultipliers(std::vector& multipliers) override; + std::string const getName() override { return "threat"; } }; class FocusMultiplier : public Multiplier { - public: - FocusMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "focus") { } +public: + FocusMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "focus") {} - float GetValue(Action* action) override; + float GetValue(Action* action) override; }; class FocusStrategy : public Strategy { - public: - FocusStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + FocusStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitMultipliers(std::vector& multipliers) override; - std::string const getName() override { return "focus"; } + void InitMultipliers(std::vector& multipliers) override; + std::string const getName() override { return "focus"; } }; #endif diff --git a/src/strategy/generic/TravelStrategy.cpp b/src/strategy/generic/TravelStrategy.cpp index 84877f66..978666eb 100644 --- a/src/strategy/generic/TravelStrategy.cpp +++ b/src/strategy/generic/TravelStrategy.cpp @@ -1,21 +1,23 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TravelStrategy.h" + #include "Playerbots.h" -TravelStrategy::TravelStrategy(PlayerbotAI* botAI) : Strategy(botAI) -{ -} +TravelStrategy::TravelStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} NextAction** TravelStrategy::getDefaultActions() { return NextAction::array(0, new NextAction("travel", 1.0f), nullptr); } -void TravelStrategy::InitTriggers(std::vector &triggers) +void TravelStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("no travel target", NextAction::array(0, new NextAction("choose travel target", 6.f), nullptr))); - triggers.push_back(new TriggerNode("far from travel target", NextAction::array(0, new NextAction("move to travel target", 1), nullptr))); + triggers.push_back(new TriggerNode("no travel target", + NextAction::array(0, new NextAction("choose travel target", 6.f), nullptr))); + triggers.push_back(new TriggerNode("far from travel target", + NextAction::array(0, new NextAction("move to travel target", 1), nullptr))); } diff --git a/src/strategy/generic/TravelStrategy.h b/src/strategy/generic/TravelStrategy.h index 302ce19b..50782ba3 100644 --- a/src/strategy/generic/TravelStrategy.h +++ b/src/strategy/generic/TravelStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TRAVELSTRATEGY_H @@ -11,37 +12,37 @@ class PlayerbotAI; class TravelStrategy : public Strategy { - public: - TravelStrategy(PlayerbotAI* botAI); +public: + TravelStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "travel"; } + std::string const getName() override { return "travel"; } - NextAction** getDefaultActions() override; - void InitTriggers(std::vector &triggers) override; + NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; }; class ExploreStrategy : public Strategy { - public: - ExploreStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + ExploreStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - std::string const getName() override { return "explore"; } + std::string const getName() override { return "explore"; } }; class MapStrategy : public Strategy { - public: - MapStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + MapStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - std::string const getName() override { return "map"; } + std::string const getName() override { return "map"; } }; class MapFullStrategy : public Strategy { - public: - MapFullStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + MapFullStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - std::string const getName() override { return "map full"; } + std::string const getName() override { return "map full"; } }; #endif diff --git a/src/strategy/generic/UseFoodStrategy.cpp b/src/strategy/generic/UseFoodStrategy.cpp index f97a70f8..c0c29b51 100644 --- a/src/strategy/generic/UseFoodStrategy.cpp +++ b/src/strategy/generic/UseFoodStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "UseFoodStrategy.h" + #include "Playerbots.h" void UseFoodStrategy::InitTriggers(std::vector& triggers) diff --git a/src/strategy/generic/UseFoodStrategy.h b/src/strategy/generic/UseFoodStrategy.h index dd039955..33db69e0 100644 --- a/src/strategy/generic/UseFoodStrategy.h +++ b/src/strategy/generic/UseFoodStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_USEFOODSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class UseFoodStrategy : public Strategy { - public: - UseFoodStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + UseFoodStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "food"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "food"; } }; #endif diff --git a/src/strategy/generic/UsePotionsStrategy.cpp b/src/strategy/generic/UsePotionsStrategy.cpp index 3917b6b8..71908a97 100644 --- a/src/strategy/generic/UsePotionsStrategy.cpp +++ b/src/strategy/generic/UsePotionsStrategy.cpp @@ -1,25 +1,25 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "UsePotionsStrategy.h" + #include "Playerbots.h" class UsePotionsStrategyActionNodeFactory : public NamedObjectFactory { - public: - UsePotionsStrategyActionNodeFactory() - { - creators["healthstone"] = &healthstone; - } - private: - static ActionNode* healthstone(PlayerbotAI* botAI) - { - return new ActionNode("healthstone", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("healing potion"), nullptr), - /*C*/ nullptr); - } +public: + UsePotionsStrategyActionNodeFactory() { creators["healthstone"] = &healthstone; } + +private: + static ActionNode* healthstone(PlayerbotAI* botAI) + { + return new ActionNode("healthstone", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("healing potion"), nullptr), + /*C*/ nullptr); + } }; UsePotionsStrategy::UsePotionsStrategy(PlayerbotAI* botAI) : Strategy(botAI) @@ -31,6 +31,8 @@ void UsePotionsStrategy::InitTriggers(std::vector& triggers) { Strategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("healthstone", ACTION_MEDIUM_HEAL + 1), nullptr))); - triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("mana potion", ACTION_EMERGENCY), nullptr))); + triggers.push_back(new TriggerNode( + "critical health", NextAction::array(0, new NextAction("healthstone", ACTION_MEDIUM_HEAL + 1), nullptr))); + triggers.push_back( + new TriggerNode("low mana", NextAction::array(0, new NextAction("mana potion", ACTION_EMERGENCY), nullptr))); } diff --git a/src/strategy/generic/UsePotionsStrategy.h b/src/strategy/generic/UsePotionsStrategy.h index be640c4b..b6042cd7 100644 --- a/src/strategy/generic/UsePotionsStrategy.h +++ b/src/strategy/generic/UsePotionsStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_USEPOTIONSSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class UsePotionsStrategy : public Strategy { - public: - UsePotionsStrategy(PlayerbotAI* botAI); +public: + UsePotionsStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "potions"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "potions"; } }; #endif diff --git a/src/strategy/generic/WorldPacketHandlerStrategy.cpp b/src/strategy/generic/WorldPacketHandlerStrategy.cpp index 2db5ed84..4b37d3d8 100644 --- a/src/strategy/generic/WorldPacketHandlerStrategy.cpp +++ b/src/strategy/generic/WorldPacketHandlerStrategy.cpp @@ -1,55 +1,92 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "WorldPacketHandlerStrategy.h" + #include "Playerbots.h" void WorldPacketHandlerStrategy::InitTriggers(std::vector& triggers) { PassTroughStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("group invite", NextAction::array(0, new NextAction("accept invitation", relevance), nullptr))); - triggers.push_back(new TriggerNode("uninvite", NextAction::array(0, new NextAction("uninvite", relevance), nullptr))); - triggers.push_back(new TriggerNode("uninvite guid", NextAction::array(0, new NextAction("uninvite", relevance), nullptr))); - triggers.push_back(new TriggerNode("group set leader", NextAction::array(0, /*new NextAction("leader", relevance),*/ nullptr))); - triggers.push_back(new TriggerNode("not enough money", NextAction::array(0, new NextAction("tell not enough money", relevance), nullptr))); - triggers.push_back(new TriggerNode("not enough reputation", NextAction::array(0, new NextAction("tell not enough reputation", relevance), nullptr))); - triggers.push_back(new TriggerNode("cannot equip", NextAction::array(0, new NextAction("tell cannot equip", relevance), nullptr))); - triggers.push_back(new TriggerNode("use game object", NextAction::array(0, new NextAction("add loot", relevance), new NextAction("use meeting stone", relevance), nullptr))); - triggers.push_back(new TriggerNode("gossip hello", NextAction::array(0, new NextAction("trainer", relevance), nullptr))); - triggers.push_back(new TriggerNode("activate taxi", NextAction::array(0, new NextAction("remember taxi", relevance), new NextAction("taxi", relevance), nullptr))); + triggers.push_back( + new TriggerNode("group invite", NextAction::array(0, new NextAction("accept invitation", relevance), nullptr))); + triggers.push_back( + new TriggerNode("uninvite", NextAction::array(0, new NextAction("uninvite", relevance), nullptr))); + triggers.push_back( + new TriggerNode("uninvite guid", NextAction::array(0, new NextAction("uninvite", relevance), nullptr))); + triggers.push_back( + new TriggerNode("group set leader", NextAction::array(0, /*new NextAction("leader", relevance),*/ nullptr))); + triggers.push_back(new TriggerNode( + "not enough money", NextAction::array(0, new NextAction("tell not enough money", relevance), nullptr))); + triggers.push_back( + new TriggerNode("not enough reputation", + NextAction::array(0, new NextAction("tell not enough reputation", relevance), nullptr))); + triggers.push_back( + new TriggerNode("cannot equip", NextAction::array(0, new NextAction("tell cannot equip", relevance), nullptr))); + triggers.push_back( + new TriggerNode("use game object", NextAction::array(0, new NextAction("add loot", relevance), + new NextAction("use meeting stone", relevance), nullptr))); + triggers.push_back( + new TriggerNode("gossip hello", NextAction::array(0, new NextAction("trainer", relevance), nullptr))); + triggers.push_back(new TriggerNode("activate taxi", NextAction::array(0, new NextAction("remember taxi", relevance), + new NextAction("taxi", relevance), nullptr))); triggers.push_back(new TriggerNode("taxi done", NextAction::array(0, new NextAction("taxi", relevance), nullptr))); - triggers.push_back(new TriggerNode("trade status", NextAction::array(0, new NextAction("accept trade", relevance), new NextAction("equip upgrades", relevance), nullptr))); - triggers.push_back(new TriggerNode("area trigger", NextAction::array(0, new NextAction("reach area trigger", relevance), nullptr))); - triggers.push_back(new TriggerNode("within area trigger", NextAction::array(0, new NextAction("area trigger", relevance), nullptr))); - triggers.push_back(new TriggerNode("loot response", NextAction::array(0, new NextAction("store loot", relevance), nullptr))); - triggers.push_back(new TriggerNode("item push result", NextAction::array(0, new NextAction("query item usage", relevance), new NextAction("equip upgrades", relevance), nullptr))); - triggers.push_back(new TriggerNode("ready check finished", NextAction::array(0, new NextAction("finish ready check", relevance), nullptr))); - // triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("security check", relevance), new NextAction("check mail", relevance), nullptr))); - triggers.push_back(new TriggerNode("guild invite", NextAction::array(0, new NextAction("guild accept", relevance), nullptr))); - triggers.push_back(new TriggerNode("petition offer", NextAction::array(0, new NextAction("petition sign", relevance), nullptr))); - triggers.push_back(new TriggerNode("lfg proposal", NextAction::array(0, new NextAction("lfg accept", relevance), nullptr))); - triggers.push_back(new TriggerNode("lfg proposal active", NextAction::array(0, new NextAction("lfg accept", relevance), nullptr))); - triggers.push_back(new TriggerNode("arena team invite", NextAction::array(0, new NextAction("arena team accept", relevance), nullptr))); - triggers.push_back(new TriggerNode("quest confirm accept", NextAction::array(0, new NextAction("quest confirm accept", relevance), nullptr))); - //triggers.push_back(new TriggerNode("no non bot players around", NextAction::array(0, new NextAction("delay", relevance), nullptr))); - triggers.push_back(new TriggerNode("bg status", NextAction::array(0, new NextAction("bg status", relevance), nullptr))); + triggers.push_back( + new TriggerNode("trade status", NextAction::array(0, new NextAction("accept trade", relevance), + new NextAction("equip upgrades", relevance), nullptr))); + triggers.push_back(new TriggerNode("area trigger", + NextAction::array(0, new NextAction("reach area trigger", relevance), nullptr))); + triggers.push_back(new TriggerNode("within area trigger", + NextAction::array(0, new NextAction("area trigger", relevance), nullptr))); + triggers.push_back( + new TriggerNode("loot response", NextAction::array(0, new NextAction("store loot", relevance), nullptr))); + triggers.push_back( + new TriggerNode("item push result", NextAction::array(0, new NextAction("query item usage", relevance), + new NextAction("equip upgrades", relevance), nullptr))); + triggers.push_back(new TriggerNode("ready check finished", + NextAction::array(0, new NextAction("finish ready check", relevance), nullptr))); + // triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("security check", relevance), new + // NextAction("check mail", relevance), nullptr))); + triggers.push_back( + new TriggerNode("guild invite", NextAction::array(0, new NextAction("guild accept", relevance), nullptr))); + triggers.push_back( + new TriggerNode("petition offer", NextAction::array(0, new NextAction("petition sign", relevance), nullptr))); + triggers.push_back( + new TriggerNode("lfg proposal", NextAction::array(0, new NextAction("lfg accept", relevance), nullptr))); + triggers.push_back( + new TriggerNode("lfg proposal active", NextAction::array(0, new NextAction("lfg accept", relevance), nullptr))); + triggers.push_back(new TriggerNode("arena team invite", + NextAction::array(0, new NextAction("arena team accept", relevance), nullptr))); + triggers.push_back(new TriggerNode( + "quest confirm accept", NextAction::array(0, new NextAction("quest confirm accept", relevance), nullptr))); + // triggers.push_back(new TriggerNode("no non bot players around", NextAction::array(0, new NextAction("delay", + // relevance), nullptr))); + triggers.push_back( + new TriggerNode("bg status", NextAction::array(0, new NextAction("bg status", relevance), nullptr))); triggers.push_back(new TriggerNode("xpgain", NextAction::array(0, new NextAction("xp gain", relevance), nullptr))); - triggers.push_back(new TriggerNode("levelup", NextAction::array(0, - new NextAction("auto teleport for level", relevance + 3), - new NextAction("auto talents", relevance + 2), - new NextAction("auto learn spell", relevance + 1), - new NextAction("auto upgrade equip", relevance), - nullptr))); - // triggers.push_back(new TriggerNode("group destroyed", NextAction::array(0, new NextAction("reset botAI", relevance), nullptr))); - triggers.push_back(new TriggerNode("questgiver quest details", NextAction::array(0, new NextAction("turn in query quest", relevance), nullptr))); - - triggers.push_back(new TriggerNode("group list", NextAction::array(0, new NextAction("reset botAI", relevance), nullptr))); - triggers.push_back(new TriggerNode("see spell", NextAction::array(0, new NextAction("see spell", relevance), nullptr))); - triggers.push_back(new TriggerNode("release spirit", NextAction::array(0, new NextAction("release", relevance), nullptr))); - triggers.push_back(new TriggerNode("revive from corpse", NextAction::array(0, new NextAction("revive from corpse", relevance), nullptr))); - triggers.push_back(new TriggerNode("master loot roll", NextAction::array(0, new NextAction("master loot roll", relevance), nullptr))); + triggers.push_back( + new TriggerNode("levelup", NextAction::array(0, new NextAction("auto teleport for level", relevance + 3), + new NextAction("auto talents", relevance + 2), + new NextAction("auto learn spell", relevance + 1), + new NextAction("auto upgrade equip", relevance), nullptr))); + // triggers.push_back(new TriggerNode("group destroyed", NextAction::array(0, new NextAction("reset botAI", + // relevance), nullptr))); + triggers.push_back(new TriggerNode( + "questgiver quest details", NextAction::array(0, new NextAction("turn in query quest", relevance), nullptr))); + + triggers.push_back( + new TriggerNode("group list", NextAction::array(0, new NextAction("reset botAI", relevance), nullptr))); + triggers.push_back( + new TriggerNode("see spell", NextAction::array(0, new NextAction("see spell", relevance), nullptr))); + triggers.push_back( + new TriggerNode("release spirit", NextAction::array(0, new NextAction("release", relevance), nullptr))); + triggers.push_back(new TriggerNode("revive from corpse", + NextAction::array(0, new NextAction("revive from corpse", relevance), nullptr))); + triggers.push_back(new TriggerNode("master loot roll", + NextAction::array(0, new NextAction("master loot roll", relevance), nullptr))); } WorldPacketHandlerStrategy::WorldPacketHandlerStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) @@ -69,5 +106,6 @@ WorldPacketHandlerStrategy::WorldPacketHandlerStrategy(PlayerbotAI* botAI) : Pas void ReadyCheckStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("timer", NextAction::array(0, new NextAction("ready check", relevance), nullptr))); + triggers.push_back( + new TriggerNode("timer", NextAction::array(0, new NextAction("ready check", relevance), nullptr))); } diff --git a/src/strategy/generic/WorldPacketHandlerStrategy.h b/src/strategy/generic/WorldPacketHandlerStrategy.h index 2333877f..0decfed8 100644 --- a/src/strategy/generic/WorldPacketHandlerStrategy.h +++ b/src/strategy/generic/WorldPacketHandlerStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WORLDPACKETHANDLERSTRATEGY_H @@ -11,20 +12,20 @@ class PlayerbotAI; class WorldPacketHandlerStrategy : public PassTroughStrategy { - public: - WorldPacketHandlerStrategy(PlayerbotAI* botAI); +public: + WorldPacketHandlerStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "default"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "default"; } }; class ReadyCheckStrategy : public PassTroughStrategy { - public: - ReadyCheckStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) { } +public: + ReadyCheckStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "ready check"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "ready check"; } }; #endif diff --git a/src/strategy/hunter/DpsHunterStrategy.cpp b/src/strategy/hunter/DpsHunterStrategy.cpp index 881c5263..684622a3 100644 --- a/src/strategy/hunter/DpsHunterStrategy.cpp +++ b/src/strategy/hunter/DpsHunterStrategy.cpp @@ -1,26 +1,25 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DpsHunterStrategy.h" + #include "Playerbots.h" class DpsHunterStrategyActionNodeFactory : public NamedObjectFactory { - public: - DpsHunterStrategyActionNodeFactory() - { - creators["aimed shot"] = &aimed_shot; - } +public: + DpsHunterStrategyActionNodeFactory() { creators["aimed shot"] = &aimed_shot; } - private: - static ActionNode* aimed_shot([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("aimed shot", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("multi-shot"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* aimed_shot([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("aimed shot", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("multi-shot"), nullptr), + /*C*/ nullptr); + } }; DpsHunterStrategy::DpsHunterStrategy(PlayerbotAI* botAI) : GenericHunterStrategy(botAI) @@ -30,39 +29,46 @@ DpsHunterStrategy::DpsHunterStrategy(PlayerbotAI* botAI) : GenericHunterStrategy NextAction** DpsHunterStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("kill shot", ACTION_DEFAULT + 0.6f), - new NextAction("chimera shot", ACTION_DEFAULT + 0.5f), - new NextAction("explosive shot", ACTION_DEFAULT + 0.4f), - new NextAction("aimed shot", ACTION_DEFAULT + 0.3f), - new NextAction("arcane shot", ACTION_DEFAULT + 0.2f), - new NextAction("steady shot", ACTION_DEFAULT + 0.1f), - new NextAction("auto shot", ACTION_DEFAULT), - nullptr); - // return NextAction::array(0, new NextAction("explosive shot", 11.0f), new NextAction("auto shot", 10.0f), new NextAction("auto attack", 9.0f), nullptr); + return NextAction::array( + 0, new NextAction("kill shot", ACTION_DEFAULT + 0.6f), new NextAction("chimera shot", ACTION_DEFAULT + 0.5f), + new NextAction("explosive shot", ACTION_DEFAULT + 0.4f), new NextAction("aimed shot", ACTION_DEFAULT + 0.3f), + new NextAction("arcane shot", ACTION_DEFAULT + 0.2f), new NextAction("steady shot", ACTION_DEFAULT + 0.1f), + new NextAction("auto shot", ACTION_DEFAULT), nullptr); + // return NextAction::array(0, new NextAction("explosive shot", 11.0f), new NextAction("auto shot", 10.0f), new + // NextAction("auto attack", 9.0f), nullptr); } void DpsHunterStrategy::InitTriggers(std::vector& triggers) { GenericHunterStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("black arrow", NextAction::array(0, new NextAction("black arrow", 15.0f), nullptr))); - triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("viper sting", 23.0f), nullptr))); - triggers.push_back(new TriggerNode("hunter's mark", NextAction::array(0, new NextAction("hunter's mark", 31.0f), nullptr))); - triggers.push_back(new TriggerNode("concussive shot on snare target", NextAction::array(0, new NextAction("concussive shot", 20.0f), nullptr))); + triggers.push_back( + new TriggerNode("black arrow", NextAction::array(0, new NextAction("black arrow", 15.0f), nullptr))); + triggers.push_back( + new TriggerNode("low mana", NextAction::array(0, new NextAction("viper sting", 23.0f), nullptr))); + triggers.push_back( + new TriggerNode("hunter's mark", NextAction::array(0, new NextAction("hunter's mark", 31.0f), nullptr))); + triggers.push_back(new TriggerNode("concussive shot on snare target", + NextAction::array(0, new NextAction("concussive shot", 20.0f), nullptr))); // triggers.push_back(new TriggerNode("no pet", NextAction::array(0, new NextAction("call pet", 21.0f), NULL))); - // triggers.push_back(new TriggerNode("hunters pet low health", NextAction::array(0, new NextAction("mend pet", 21.0f), NULL))); - triggers.push_back(new TriggerNode("has aggro", NextAction::array(0, new NextAction("concussive shot", 20.0f), nullptr))); + // triggers.push_back(new TriggerNode("hunters pet low health", NextAction::array(0, new NextAction("mend + // pet", 21.0f), NULL))); + triggers.push_back( + new TriggerNode("has aggro", NextAction::array(0, new NextAction("concussive shot", 20.0f), nullptr))); } void DpsAoeHunterStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("light aoe", NextAction::array(0, new NextAction("multi-shot", 20.0f), nullptr))); - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("volley", 21.0f), nullptr))); - triggers.push_back(new TriggerNode("serpent sting on attacker", NextAction::array(0, new NextAction("serpent sting on attacker", 17.0f), nullptr))); + triggers.push_back( + new TriggerNode("light aoe", NextAction::array(0, new NextAction("multi-shot", 20.0f), nullptr))); + triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("volley", 21.0f), nullptr))); + triggers.push_back( + new TriggerNode("serpent sting on attacker", + NextAction::array(0, new NextAction("serpent sting on attacker", 17.0f), nullptr))); } void DpsHunterDebuffStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("no stings", NextAction::array(0, new NextAction("serpent sting", 18.0f), nullptr))); + triggers.push_back( + new TriggerNode("no stings", NextAction::array(0, new NextAction("serpent sting", 18.0f), nullptr))); } diff --git a/src/strategy/hunter/DpsHunterStrategy.h b/src/strategy/hunter/DpsHunterStrategy.h index 7a122672..2cf8707c 100644 --- a/src/strategy/hunter/DpsHunterStrategy.h +++ b/src/strategy/hunter/DpsHunterStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DPSHUNTERSTRATEGY_H @@ -11,30 +12,30 @@ class PlayerbotAI; class DpsHunterStrategy : public GenericHunterStrategy { - public: - DpsHunterStrategy(PlayerbotAI* botAI); +public: + DpsHunterStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "dps"; } - NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "dps"; } + NextAction** getDefaultActions() override; }; class DpsAoeHunterStrategy : public CombatStrategy { - public: - DpsAoeHunterStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + DpsAoeHunterStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "aoe"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "aoe"; } }; class DpsHunterDebuffStrategy : public CombatStrategy { - public: - DpsHunterDebuffStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + DpsHunterDebuffStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "dps debuff"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "dps debuff"; } }; #endif diff --git a/src/strategy/hunter/GenericHunterNonCombatStrategy.cpp b/src/strategy/hunter/GenericHunterNonCombatStrategy.cpp index 4a42bcff..ca7debfa 100644 --- a/src/strategy/hunter/GenericHunterNonCombatStrategy.cpp +++ b/src/strategy/hunter/GenericHunterNonCombatStrategy.cpp @@ -1,36 +1,38 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericHunterNonCombatStrategy.h" + #include "Playerbots.h" class GenericHunterNonCombatStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericHunterNonCombatStrategyActionNodeFactory() - { - creators["rapid fire"] = &rapid_fire; - creators["boost"] = &rapid_fire; - creators["aspect of the pack"] = &aspect_of_the_pack; - } +public: + GenericHunterNonCombatStrategyActionNodeFactory() + { + creators["rapid fire"] = &rapid_fire; + creators["boost"] = &rapid_fire; + creators["aspect of the pack"] = &aspect_of_the_pack; + } - private: - static ActionNode* rapid_fire([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("rapid fire", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("readiness"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* rapid_fire([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("rapid fire", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("readiness"), nullptr), + /*C*/ nullptr); + } - static ActionNode* aspect_of_the_pack([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("aspect of the pack", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("aspect of the cheetah"), nullptr), - /*C*/ nullptr); - } + static ActionNode* aspect_of_the_pack([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("aspect of the pack", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("aspect of the cheetah"), nullptr), + /*C*/ nullptr); + } }; GenericHunterNonCombatStrategy::GenericHunterNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) @@ -42,18 +44,25 @@ void GenericHunterNonCombatStrategy::InitTriggers(std::vector& tri { NonCombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("trueshot aura", NextAction::array(0, new NextAction("trueshot aura", 2.0f), nullptr))); + triggers.push_back( + new TriggerNode("trueshot aura", NextAction::array(0, new NextAction("trueshot aura", 2.0f), nullptr))); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("apply oil", 1.0f), nullptr))); - triggers.push_back(new TriggerNode("low ammo", NextAction::array(0, new NextAction("say::low ammo", ACTION_NORMAL), nullptr))); - // triggers.push_back(new TriggerNode("no ammo", NextAction::array(0, new NextAction("switch to melee", ACTION_NORMAL + 1), new NextAction("say::no ammo", ACTION_NORMAL), nullptr))); - // triggers.push_back(new TriggerNode("has ammo", NextAction::array(0, new NextAction("switch to ranged", ACTION_NORMAL), nullptr))); + triggers.push_back( + new TriggerNode("low ammo", NextAction::array(0, new NextAction("say::low ammo", ACTION_NORMAL), nullptr))); + // triggers.push_back(new TriggerNode("no ammo", NextAction::array(0, new NextAction("switch to melee", + // ACTION_NORMAL + 1), new NextAction("say::no ammo", ACTION_NORMAL), nullptr))); triggers.push_back(new + // TriggerNode("has ammo", NextAction::array(0, new NextAction("switch to ranged", ACTION_NORMAL), nullptr))); } void HunterPetStrategy::InitTriggers(std::vector& triggers) { triggers.push_back(new TriggerNode("no pet", NextAction::array(0, new NextAction("call pet", 60.0f), nullptr))); - triggers.push_back(new TriggerNode("has pet", NextAction::array(0, new NextAction("toggle pet spell", 60.0f), nullptr))); - triggers.push_back(new TriggerNode("pet not happy", NextAction::array(0, new NextAction("feed pet", 60.0f), nullptr))); - triggers.push_back(new TriggerNode("hunters pet medium health", NextAction::array(0, new NextAction("mend pet", 60.0f), nullptr))); - triggers.push_back(new TriggerNode("hunters pet dead", NextAction::array(0, new NextAction("revive pet", 60.0f), nullptr))); + triggers.push_back( + new TriggerNode("has pet", NextAction::array(0, new NextAction("toggle pet spell", 60.0f), nullptr))); + triggers.push_back( + new TriggerNode("pet not happy", NextAction::array(0, new NextAction("feed pet", 60.0f), nullptr))); + triggers.push_back( + new TriggerNode("hunters pet medium health", NextAction::array(0, new NextAction("mend pet", 60.0f), nullptr))); + triggers.push_back( + new TriggerNode("hunters pet dead", NextAction::array(0, new NextAction("revive pet", 60.0f), nullptr))); } diff --git a/src/strategy/hunter/GenericHunterNonCombatStrategy.h b/src/strategy/hunter/GenericHunterNonCombatStrategy.h index 3b6b8ec3..719b7756 100644 --- a/src/strategy/hunter/GenericHunterNonCombatStrategy.h +++ b/src/strategy/hunter/GenericHunterNonCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICHUNTERNONCOMBATSTRATEGY_H @@ -11,20 +12,20 @@ class PlayerbotAI; class GenericHunterNonCombatStrategy : public NonCombatStrategy { - public: - GenericHunterNonCombatStrategy(PlayerbotAI* botAI); +public: + GenericHunterNonCombatStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "nc"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "nc"; } + void InitTriggers(std::vector& triggers) override; }; class HunterPetStrategy : public Strategy { - public: - HunterPetStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + HunterPetStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - std::string const getName() override { return "pet"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "pet"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/hunter/GenericHunterStrategy.cpp b/src/strategy/hunter/GenericHunterStrategy.cpp index f59db30e..d245400a 100644 --- a/src/strategy/hunter/GenericHunterStrategy.cpp +++ b/src/strategy/hunter/GenericHunterStrategy.cpp @@ -1,73 +1,75 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericHunterStrategy.h" + #include "Playerbots.h" class GenericHunterStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericHunterStrategyActionNodeFactory() - { - creators["rapid fire"] = &rapid_fire; - creators["boost"] = &rapid_fire; - creators["aspect of the pack"] = &aspect_of_the_pack; - creators["feign death"] = &feign_death; - creators["wing clip"] = &wing_clip; - creators["mongoose bite"] = &mongoose_bite; - creators["raptor strike"] = &raptor_strike; - } +public: + GenericHunterStrategyActionNodeFactory() + { + creators["rapid fire"] = &rapid_fire; + creators["boost"] = &rapid_fire; + creators["aspect of the pack"] = &aspect_of_the_pack; + creators["feign death"] = &feign_death; + creators["wing clip"] = &wing_clip; + creators["mongoose bite"] = &mongoose_bite; + creators["raptor strike"] = &raptor_strike; + } - private: - static ActionNode* rapid_fire([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("rapid fire", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("readiness"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* rapid_fire([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("rapid fire", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("readiness"), nullptr), + /*C*/ nullptr); + } - static ActionNode* aspect_of_the_pack([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("aspect of the pack", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("aspect of the cheetah"), nullptr), - /*C*/ nullptr); - } + static ActionNode* aspect_of_the_pack([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("aspect of the pack", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("aspect of the cheetah"), nullptr), + /*C*/ nullptr); + } - static ActionNode* feign_death([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("feign death", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* feign_death([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("feign death", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* wing_clip([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("wing clip", - /*P*/ nullptr, - // /*A*/ NextAction::array(0, new NextAction("mongoose bite"), nullptr), - nullptr, - /*C*/ nullptr); - } + static ActionNode* wing_clip([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("wing clip", + /*P*/ nullptr, + // /*A*/ NextAction::array(0, new NextAction("mongoose bite"), nullptr), + nullptr, + /*C*/ nullptr); + } - static ActionNode* mongoose_bite([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("mongoose bite", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("raptor strike"), nullptr), - /*C*/ nullptr); - } + static ActionNode* mongoose_bite([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("mongoose bite", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("raptor strike"), nullptr), + /*C*/ nullptr); + } - static ActionNode* raptor_strike([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("raptor strike", - /*P*/ NextAction::array(0, new NextAction("melee"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* raptor_strike([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("raptor strike", + /*P*/ NextAction::array(0, new NextAction("melee"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } }; GenericHunterStrategy::GenericHunterStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) @@ -79,19 +81,24 @@ void GenericHunterStrategy::InitTriggers(std::vector& triggers) { CombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("enemy within melee", - NextAction::array(0, - new NextAction("wing clip", ACTION_HIGH + 1), - new NextAction("mongoose bite", ACTION_HIGH), - nullptr))); - triggers.push_back(new TriggerNode("medium threat", NextAction::array(0, new NextAction("feign death", 35.0f), nullptr))); - triggers.push_back(new TriggerNode("hunters pet medium health", NextAction::array(0, new NextAction("mend pet", ACTION_HIGH + 2), nullptr))); - // triggers.push_back(new TriggerNode("no ammo", NextAction::array(0, new NextAction("switch to melee", ACTION_HIGH + 1), new NextAction("say::no ammo", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("aspect of the viper", NextAction::array(0, new NextAction("aspect of the viper", ACTION_HIGH), NULL))); - triggers.push_back(new TriggerNode("enemy too close for auto shot", NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); - triggers.push_back(new TriggerNode("misdirection on main tank", NextAction::array(0, new NextAction("misdirection on main tank", ACTION_HIGH + 7), NULL))); - triggers.push_back(new TriggerNode("tranquilizing shot", NextAction::array(0, new NextAction("tranquilizing shot", 61.0f), NULL))); - + triggers.push_back(new TriggerNode("enemy within melee", + NextAction::array(0, new NextAction("wing clip", ACTION_HIGH + 1), + new NextAction("mongoose bite", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("medium threat", NextAction::array(0, new NextAction("feign death", 35.0f), nullptr))); + triggers.push_back(new TriggerNode("hunters pet medium health", + NextAction::array(0, new NextAction("mend pet", ACTION_HIGH + 2), nullptr))); + // triggers.push_back(new TriggerNode("no ammo", NextAction::array(0, new NextAction("switch to melee", ACTION_HIGH + // + 1), new NextAction("say::no ammo", ACTION_HIGH), nullptr))); + triggers.push_back(new TriggerNode("aspect of the viper", + NextAction::array(0, new NextAction("aspect of the viper", ACTION_HIGH), NULL))); + triggers.push_back(new TriggerNode("enemy too close for auto shot", + NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); + triggers.push_back( + new TriggerNode("misdirection on main tank", + NextAction::array(0, new NextAction("misdirection on main tank", ACTION_HIGH + 7), NULL))); + triggers.push_back( + new TriggerNode("tranquilizing shot", NextAction::array(0, new NextAction("tranquilizing shot", 61.0f), NULL))); } NextAction** HunterBoostStrategy::getDefaultActions() @@ -101,11 +108,14 @@ NextAction** HunterBoostStrategy::getDefaultActions() void HunterBoostStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("rapid fire", NextAction::array(0, new NextAction("rapid fire", 16.0f), nullptr))); + triggers.push_back( + new TriggerNode("rapid fire", NextAction::array(0, new NextAction("rapid fire", 16.0f), nullptr))); } void HunterCcStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("scare beast", NextAction::array(0, new NextAction("scare beast on cc", ACTION_HIGH + 3), nullptr))); - triggers.push_back(new TriggerNode("freezing trap", NextAction::array(0, new NextAction("freezing trap on cc", ACTION_HIGH + 3), nullptr))); + triggers.push_back(new TriggerNode( + "scare beast", NextAction::array(0, new NextAction("scare beast on cc", ACTION_HIGH + 3), nullptr))); + triggers.push_back(new TriggerNode( + "freezing trap", NextAction::array(0, new NextAction("freezing trap on cc", ACTION_HIGH + 3), nullptr))); } diff --git a/src/strategy/hunter/GenericHunterStrategy.h b/src/strategy/hunter/GenericHunterStrategy.h index 23e47ddc..9ee16ba1 100644 --- a/src/strategy/hunter/GenericHunterStrategy.h +++ b/src/strategy/hunter/GenericHunterStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICHUNTERSTRATEGY_H @@ -12,31 +13,31 @@ class PlayerbotAI; class GenericHunterStrategy : public CombatStrategy { - public: - GenericHunterStrategy(PlayerbotAI* botAI); +public: + GenericHunterStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "hunter"; } - uint32 GetType() const override { return CombatStrategy::GetType() | STRATEGY_TYPE_RANGED | STRATEGY_TYPE_DPS; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "hunter"; } + uint32 GetType() const override { return CombatStrategy::GetType() | STRATEGY_TYPE_RANGED | STRATEGY_TYPE_DPS; } }; class HunterBoostStrategy : public Strategy { - public: - HunterBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + HunterBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - std::string const getName() override { return "boost"; } - NextAction** getDefaultActions() override; - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "boost"; } + NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; }; class HunterCcStrategy : public Strategy { - public: - HunterCcStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + HunterCcStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "cc"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cc"; } }; #endif diff --git a/src/strategy/hunter/HunterActions.cpp b/src/strategy/hunter/HunterActions.cpp index f863e861..eb3572f0 100644 --- a/src/strategy/hunter/HunterActions.cpp +++ b/src/strategy/hunter/HunterActions.cpp @@ -1,16 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HunterActions.h" + #include "Event.h" #include "GenericSpellActions.h" #include "Playerbots.h" -bool CastHuntersMarkAction::isUseful() -{ - return CastDebuffSpellAction::isUseful(); -} +bool CastHuntersMarkAction::isUseful() { return CastDebuffSpellAction::isUseful(); } bool CastViperStingAction::isUseful() { @@ -22,10 +21,7 @@ bool CastAspectOfTheCheetahAction::isUseful() return !botAI->HasAnyAuraOf(GetTarget(), "aspect of the cheetah", "aspect of the pack", nullptr); } -Value* CastFreezingTrap::GetTargetValue() -{ - return context->GetValue("cc target", "freezing trap"); -} +Value* CastFreezingTrap::GetTargetValue() { return context->GetValue("cc target", "freezing trap"); } bool FeedPetAction::Execute(Event event) { @@ -40,32 +36,23 @@ bool CastAutoShotAction::isUseful() { if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true)) return false; - - if (AI_VALUE(Unit*, "current target") && bot->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL) && bot->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)->m_targets.GetUnitTargetGUID() == AI_VALUE(Unit*, "current target")->GetGUID()) { + + if (AI_VALUE(Unit*, "current target") && bot->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL) && + bot->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)->m_targets.GetUnitTargetGUID() == + AI_VALUE(Unit*, "current target")->GetGUID()) + { return false; } return AI_VALUE(uint32, "active spell") != AI_VALUE2(uint32, "spell id", getName()); } -Value* CastScareBeastCcAction::GetTargetValue() -{ - return context->GetValue("cc target", "scare beast"); -} +Value* CastScareBeastCcAction::GetTargetValue() { return context->GetValue("cc target", "scare beast"); } -bool CastScareBeastCcAction::Execute(Event event) -{ - return botAI->CastSpell("scare beast", GetTarget()); -} +bool CastScareBeastCcAction::Execute(Event event) { return botAI->CastSpell("scare beast", GetTarget()); } -bool CastWingClipAction::isUseful() -{ - return CastSpellAction::isUseful() && !botAI->HasAura(spell, GetTarget()); -} +bool CastWingClipAction::isUseful() { return CastSpellAction::isUseful() && !botAI->HasAura(spell, GetTarget()); } -NextAction** CastWingClipAction::getPrerequisites() -{ - return nullptr; -} +NextAction** CastWingClipAction::getPrerequisites() { return nullptr; } // bool CastRaptorStrikeAction::isUseful() // { diff --git a/src/strategy/hunter/HunterActions.h b/src/strategy/hunter/HunterActions.h index 3f06d0f1..ef95eb15 100644 --- a/src/strategy/hunter/HunterActions.h +++ b/src/strategy/hunter/HunterActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HUNTERACTIONS_H @@ -16,16 +17,16 @@ class Unit; class CastHuntersMarkAction : public CastDebuffSpellAction { - public: - CastHuntersMarkAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "hunter's mark") { } - bool isUseful() override; +public: + CastHuntersMarkAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "hunter's mark") {} + bool isUseful() override; }; class CastAutoShotAction : public CastSpellAction { - public: - CastAutoShotAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "auto shot") { } - ActionThreatType getThreatType() override { return ActionThreatType::None; } - bool isUseful() override; +public: + CastAutoShotAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "auto shot") {} + ActionThreatType getThreatType() override { return ActionThreatType::None; } + bool isUseful() override; }; BEGIN_RANGED_SPELL_ACTION(CastArcaneShotAction, "arcane shot") @@ -42,8 +43,8 @@ END_SPELL_ACTION() class CastConcussiveShotAction : public CastSnareSpellAction { - public: - CastConcussiveShotAction(PlayerbotAI* botAI) : CastSnareSpellAction(botAI, "concussive shot") { } +public: + CastConcussiveShotAction(PlayerbotAI* botAI) : CastSnareSpellAction(botAI, "concussive shot") {} }; BEGIN_RANGED_SPELL_ACTION(CastDistractingShotAction, "distracting shot") @@ -53,7 +54,7 @@ BEGIN_RANGED_SPELL_ACTION(CastMultiShotAction, "multi-shot") END_SPELL_ACTION() BEGIN_RANGED_SPELL_ACTION(CastVolleyAction, "volley") - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } +ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } END_SPELL_ACTION() DEBUFF_CHECKISOWNER_ACTION(CastSerpentStingAction, "serpent sting"); @@ -79,14 +80,14 @@ END_SPELL_ACTION() class CastAspectOfTheHawkAction : public CastBuffSpellAction { - public: - CastAspectOfTheHawkAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aspect of the hawk") { } +public: + CastAspectOfTheHawkAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aspect of the hawk") {} }; class CastAspectOfTheMonkeyAction : public CastBuffSpellAction { - public: - CastAspectOfTheMonkeyAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aspect of the monkey") { } +public: + CastAspectOfTheMonkeyAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aspect of the monkey") {} }; class CastAspectOfTheDragonhawkAction : public CastBuffSpellAction @@ -97,148 +98,150 @@ public: class CastAspectOfTheWildAction : public CastBuffSpellAction { - public: - CastAspectOfTheWildAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aspect of the wild") { } +public: + CastAspectOfTheWildAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aspect of the wild") {} }; class CastAspectOfTheCheetahAction : public CastBuffSpellAction { - public: - CastAspectOfTheCheetahAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aspect of the cheetah") { } +public: + CastAspectOfTheCheetahAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aspect of the cheetah") {} - bool isUseful() override; + bool isUseful() override; }; class CastAspectOfThePackAction : public CastBuffSpellAction { - public: - CastAspectOfThePackAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aspect of the pack") { } +public: + CastAspectOfThePackAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aspect of the pack") {} }; class CastAspectOfTheViperAction : public CastBuffSpellAction { - public: - CastAspectOfTheViperAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aspect of the viper") { } +public: + CastAspectOfTheViperAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "aspect of the viper") {} }; class CastCallPetAction : public CastBuffSpellAction { - public: - CastCallPetAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "call pet") { } +public: + CastCallPetAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "call pet") {} }; class CastMendPetAction : public CastAuraSpellAction { - public: - CastMendPetAction(PlayerbotAI* botAI) : CastAuraSpellAction(botAI, "mend pet") { } +public: + CastMendPetAction(PlayerbotAI* botAI) : CastAuraSpellAction(botAI, "mend pet") {} - std::string const GetTargetName() override { return "pet target"; } + std::string const GetTargetName() override { return "pet target"; } }; class CastRevivePetAction : public CastBuffSpellAction { - public: - CastRevivePetAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "revive pet") { } +public: + CastRevivePetAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "revive pet") {} }; class CastTrueshotAuraAction : public CastBuffSpellAction { - public: - CastTrueshotAuraAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "trueshot aura") { } +public: + CastTrueshotAuraAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "trueshot aura") {} }; class CastFeignDeathAction : public CastBuffSpellAction { - public: - CastFeignDeathAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "feign death") { } +public: + CastFeignDeathAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "feign death") {} }; class CastRapidFireAction : public CastBuffSpellAction { - public: - CastRapidFireAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "rapid fire") { } +public: + CastRapidFireAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "rapid fire") {} }; class CastReadinessAction : public CastBuffSpellAction { - public: - CastReadinessAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "readiness") { } +public: + CastReadinessAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "readiness") {} }; class CastBlackArrow : public CastDebuffSpellAction { - public: - CastBlackArrow(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "black arrow", true) { } +public: + CastBlackArrow(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "black arrow", true) {} }; class CastFreezingTrap : public CastDebuffSpellAction { - public: - CastFreezingTrap(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "freezing trap") { } +public: + CastFreezingTrap(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "freezing trap") {} - Value* GetTargetValue() override; + Value* GetTargetValue() override; }; class CastWingClipAction : public CastSpellAction { - public: - CastWingClipAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "wing clip") { } +public: + CastWingClipAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "wing clip") {} - bool isUseful() override; - NextAction** getPrerequisites() override; + bool isUseful() override; + NextAction** getPrerequisites() override; }; class CastRaptorStrikeAction : public CastSpellAction { - public: - CastRaptorStrikeAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "raptor strike") { } +public: + CastRaptorStrikeAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "raptor strike") {} }; class CastMongooseBiteAction : public CastSpellAction { - public: - CastMongooseBiteAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "mongoose bite") { } +public: + CastMongooseBiteAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "mongoose bite") {} }; class CastSerpentStingOnAttackerAction : public CastDebuffSpellOnAttackerAction { - public: - CastSerpentStingOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "serpent sting", true) { } +public: + CastSerpentStingOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "serpent sting", true) + { + } }; class FeedPetAction : public Action { - public: - FeedPetAction(PlayerbotAI* botAI) : Action(botAI, "feed pet") { } +public: + FeedPetAction(PlayerbotAI* botAI) : Action(botAI, "feed pet") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class CastBestialWrathAction : public CastBuffSpellAction { - public: - CastBestialWrathAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "bestial wrath") { } - std::string const GetTargetName() override { return "pet target"; } +public: + CastBestialWrathAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "bestial wrath") {} + std::string const GetTargetName() override { return "pet target"; } }; class CastScareBeastAction : public CastSpellAction { - public: - CastScareBeastAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "scare beast") { } +public: + CastScareBeastAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "scare beast") {} }; class CastScareBeastCcAction : public CastSpellAction { - public: - CastScareBeastCcAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "scare beast on cc") { } +public: + CastScareBeastCcAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "scare beast on cc") {} - Value* GetTargetValue() override; - bool Execute(Event event) override; + Value* GetTargetValue() override; + bool Execute(Event event) override; }; class CastMisdirectionOnMainTankAction : public BuffOnMainTankAction { - public: - CastMisdirectionOnMainTankAction(PlayerbotAI* ai) : BuffOnMainTankAction(ai, "misdirection", true) {} +public: + CastMisdirectionOnMainTankAction(PlayerbotAI* ai) : BuffOnMainTankAction(ai, "misdirection", true) {} }; #endif diff --git a/src/strategy/hunter/HunterAiObjectContext.cpp b/src/strategy/hunter/HunterAiObjectContext.cpp index 94677212..1a4e855f 100644 --- a/src/strategy/hunter/HunterAiObjectContext.cpp +++ b/src/strategy/hunter/HunterAiObjectContext.cpp @@ -1,213 +1,218 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HunterAiObjectContext.h" + #include "DpsHunterStrategy.h" +#include "GenericHunterNonCombatStrategy.h" #include "HunterActions.h" #include "HunterBuffStrategies.h" #include "HunterTriggers.h" -#include "GenericHunterNonCombatStrategy.h" #include "NamedObjectContext.h" #include "Playerbots.h" class HunterStrategyFactoryInternal : public NamedObjectContext { - public: - HunterStrategyFactoryInternal() - { - creators["dps"] = &HunterStrategyFactoryInternal::dps; - creators["nc"] = &HunterStrategyFactoryInternal::nc; - creators["aoe"] = &HunterStrategyFactoryInternal::aoe; - creators["dps debuff"] = &HunterStrategyFactoryInternal::dps_debuff; - creators["boost"] = &HunterStrategyFactoryInternal::boost; - creators["pet"] = &HunterStrategyFactoryInternal::pet; - creators["cc"] = &HunterStrategyFactoryInternal::cc; - } +public: + HunterStrategyFactoryInternal() + { + creators["dps"] = &HunterStrategyFactoryInternal::dps; + creators["nc"] = &HunterStrategyFactoryInternal::nc; + creators["aoe"] = &HunterStrategyFactoryInternal::aoe; + creators["dps debuff"] = &HunterStrategyFactoryInternal::dps_debuff; + creators["boost"] = &HunterStrategyFactoryInternal::boost; + creators["pet"] = &HunterStrategyFactoryInternal::pet; + creators["cc"] = &HunterStrategyFactoryInternal::cc; + } - private: - static Strategy* aoe(PlayerbotAI* botAI) { return new DpsAoeHunterStrategy(botAI); } - static Strategy* dps(PlayerbotAI* botAI) { return new DpsHunterStrategy(botAI); } - static Strategy* nc(PlayerbotAI* botAI) { return new GenericHunterNonCombatStrategy(botAI); } - static Strategy* dps_debuff(PlayerbotAI* botAI) { return new DpsHunterDebuffStrategy(botAI); } - static Strategy* boost(PlayerbotAI* botAI) { return new HunterBoostStrategy(botAI); } - static Strategy* pet(PlayerbotAI* botAI) { return new HunterPetStrategy(botAI); } - static Strategy* cc(PlayerbotAI* botAI) { return new HunterCcStrategy(botAI); } +private: + static Strategy* aoe(PlayerbotAI* botAI) { return new DpsAoeHunterStrategy(botAI); } + static Strategy* dps(PlayerbotAI* botAI) { return new DpsHunterStrategy(botAI); } + static Strategy* nc(PlayerbotAI* botAI) { return new GenericHunterNonCombatStrategy(botAI); } + static Strategy* dps_debuff(PlayerbotAI* botAI) { return new DpsHunterDebuffStrategy(botAI); } + static Strategy* boost(PlayerbotAI* botAI) { return new HunterBoostStrategy(botAI); } + static Strategy* pet(PlayerbotAI* botAI) { return new HunterPetStrategy(botAI); } + static Strategy* cc(PlayerbotAI* botAI) { return new HunterCcStrategy(botAI); } }; class HunterBuffStrategyFactoryInternal : public NamedObjectContext { - public: - HunterBuffStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["bspeed"] = &HunterBuffStrategyFactoryInternal::bspeed; - creators["bdps"] = &HunterBuffStrategyFactoryInternal::bdps; - creators["bmana"] = &HunterBuffStrategyFactoryInternal::bmana; - creators["rnature"] = &HunterBuffStrategyFactoryInternal::rnature; - } +public: + HunterBuffStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["bspeed"] = &HunterBuffStrategyFactoryInternal::bspeed; + creators["bdps"] = &HunterBuffStrategyFactoryInternal::bdps; + creators["bmana"] = &HunterBuffStrategyFactoryInternal::bmana; + creators["rnature"] = &HunterBuffStrategyFactoryInternal::rnature; + } - private: - static Strategy* bspeed(PlayerbotAI* botAI) { return new HunterBuffSpeedStrategy(botAI); } - static Strategy* bdps(PlayerbotAI* botAI) { return new HunterBuffDpsStrategy(botAI); } - static Strategy* bmana(PlayerbotAI* botAI) { return new HunterBuffManaStrategy(botAI); } - static Strategy* rnature(PlayerbotAI* botAI) { return new HunterNatureResistanceStrategy(botAI); } +private: + static Strategy* bspeed(PlayerbotAI* botAI) { return new HunterBuffSpeedStrategy(botAI); } + static Strategy* bdps(PlayerbotAI* botAI) { return new HunterBuffDpsStrategy(botAI); } + static Strategy* bmana(PlayerbotAI* botAI) { return new HunterBuffManaStrategy(botAI); } + static Strategy* rnature(PlayerbotAI* botAI) { return new HunterNatureResistanceStrategy(botAI); } }; class HunterTriggerFactoryInternal : public NamedObjectContext { - public: - HunterTriggerFactoryInternal() - { - creators["aspect of the viper"] = &HunterTriggerFactoryInternal::aspect_of_the_viper; - creators["black arrow"] = &HunterTriggerFactoryInternal::black_arrow; - creators["no stings"] = &HunterTriggerFactoryInternal::NoStings; - creators["hunters pet dead"] = &HunterTriggerFactoryInternal::hunters_pet_dead; - creators["hunters pet low health"] = &HunterTriggerFactoryInternal::hunters_pet_low_health; - creators["hunters pet medium health"] = &HunterTriggerFactoryInternal::hunters_pet_medium_health; - creators["hunter's mark"] = &HunterTriggerFactoryInternal::hunters_mark; - creators["freezing trap"] = &HunterTriggerFactoryInternal::freezing_trap; - creators["aspect of the pack"] = &HunterTriggerFactoryInternal::aspect_of_the_pack; - creators["rapid fire"] = &HunterTriggerFactoryInternal::rapid_fire; - creators["aspect of the hawk"] = &HunterTriggerFactoryInternal::aspect_of_the_hawk; - creators["aspect of the monkey"] = &HunterTriggerFactoryInternal::aspect_of_the_monkey; - creators["aspect of the wild"] = &HunterTriggerFactoryInternal::aspect_of_the_wild; - creators["aspect of the viper"] = &HunterTriggerFactoryInternal::aspect_of_the_viper; - creators["trueshot aura"] = &HunterTriggerFactoryInternal::trueshot_aura; - creators["serpent sting on attacker"] = &HunterTriggerFactoryInternal::serpent_sting_on_attacker; - creators["pet not happy"] = &HunterTriggerFactoryInternal::pet_not_happy; - creators["concussive shot on snare target"] = &HunterTriggerFactoryInternal::concussive_shot_on_snare_target; - creators["scare beast"] = &HunterTriggerFactoryInternal::scare_beast; - creators["low ammo"] = &HunterTriggerFactoryInternal::low_ammo; - creators["no ammo"] = &HunterTriggerFactoryInternal::no_ammo; - creators["has ammo"] = &HunterTriggerFactoryInternal::has_ammo; - creators["switch to melee"] = &HunterTriggerFactoryInternal::switch_to_melee; - creators["switch to ranged"] = &HunterTriggerFactoryInternal::switch_to_ranged; - creators["misdirection on main tank"] = &HunterTriggerFactoryInternal::misdirection_on_main_tank; - creators["tranquilizing shot"] = &HunterTriggerFactoryInternal::remove_enrage; - } +public: + HunterTriggerFactoryInternal() + { + creators["aspect of the viper"] = &HunterTriggerFactoryInternal::aspect_of_the_viper; + creators["black arrow"] = &HunterTriggerFactoryInternal::black_arrow; + creators["no stings"] = &HunterTriggerFactoryInternal::NoStings; + creators["hunters pet dead"] = &HunterTriggerFactoryInternal::hunters_pet_dead; + creators["hunters pet low health"] = &HunterTriggerFactoryInternal::hunters_pet_low_health; + creators["hunters pet medium health"] = &HunterTriggerFactoryInternal::hunters_pet_medium_health; + creators["hunter's mark"] = &HunterTriggerFactoryInternal::hunters_mark; + creators["freezing trap"] = &HunterTriggerFactoryInternal::freezing_trap; + creators["aspect of the pack"] = &HunterTriggerFactoryInternal::aspect_of_the_pack; + creators["rapid fire"] = &HunterTriggerFactoryInternal::rapid_fire; + creators["aspect of the hawk"] = &HunterTriggerFactoryInternal::aspect_of_the_hawk; + creators["aspect of the monkey"] = &HunterTriggerFactoryInternal::aspect_of_the_monkey; + creators["aspect of the wild"] = &HunterTriggerFactoryInternal::aspect_of_the_wild; + creators["aspect of the viper"] = &HunterTriggerFactoryInternal::aspect_of_the_viper; + creators["trueshot aura"] = &HunterTriggerFactoryInternal::trueshot_aura; + creators["serpent sting on attacker"] = &HunterTriggerFactoryInternal::serpent_sting_on_attacker; + creators["pet not happy"] = &HunterTriggerFactoryInternal::pet_not_happy; + creators["concussive shot on snare target"] = &HunterTriggerFactoryInternal::concussive_shot_on_snare_target; + creators["scare beast"] = &HunterTriggerFactoryInternal::scare_beast; + creators["low ammo"] = &HunterTriggerFactoryInternal::low_ammo; + creators["no ammo"] = &HunterTriggerFactoryInternal::no_ammo; + creators["has ammo"] = &HunterTriggerFactoryInternal::has_ammo; + creators["switch to melee"] = &HunterTriggerFactoryInternal::switch_to_melee; + creators["switch to ranged"] = &HunterTriggerFactoryInternal::switch_to_ranged; + creators["misdirection on main tank"] = &HunterTriggerFactoryInternal::misdirection_on_main_tank; + creators["tranquilizing shot"] = &HunterTriggerFactoryInternal::remove_enrage; + } - private: - static Trigger* auto_shot(PlayerbotAI* botAI) { return new AutoShotTrigger(botAI); } - static Trigger* scare_beast(PlayerbotAI* botAI) { return new ScareBeastTrigger(botAI); } - static Trigger* concussive_shot_on_snare_target(PlayerbotAI* botAI) { return new ConsussiveShotSnareTrigger(botAI); } - static Trigger* pet_not_happy(PlayerbotAI* botAI) { return new HunterPetNotHappy(botAI); } - static Trigger* serpent_sting_on_attacker(PlayerbotAI* botAI) { return new SerpentStingOnAttackerTrigger(botAI); } - static Trigger* trueshot_aura(PlayerbotAI* botAI) { return new TrueshotAuraTrigger(botAI); } - static Trigger* aspect_of_the_viper(PlayerbotAI* botAI) { return new HunterAspectOfTheViperTrigger(botAI); } - static Trigger* black_arrow(PlayerbotAI* botAI) { return new BlackArrowTrigger(botAI); } - static Trigger* NoStings(PlayerbotAI* botAI) { return new HunterNoStingsActiveTrigger(botAI); } - static Trigger* hunters_pet_dead(PlayerbotAI* botAI) { return new HuntersPetDeadTrigger(botAI); } - static Trigger* hunters_pet_low_health(PlayerbotAI* botAI) { return new HuntersPetLowHealthTrigger(botAI); } - static Trigger* hunters_pet_medium_health(PlayerbotAI* botAI) { return new HuntersPetMediumHealthTrigger(botAI); } - static Trigger* hunters_mark(PlayerbotAI* botAI) { return new HuntersMarkTrigger(botAI); } - static Trigger* freezing_trap(PlayerbotAI* botAI) { return new FreezingTrapTrigger(botAI); } - static Trigger* aspect_of_the_pack(PlayerbotAI* botAI) { return new HunterAspectOfThePackTrigger(botAI); } - static Trigger* rapid_fire(PlayerbotAI* botAI) { return new RapidFireTrigger(botAI); } - static Trigger* aspect_of_the_hawk(PlayerbotAI* botAI) { return new HunterAspectOfTheHawkTrigger(botAI); } - static Trigger* aspect_of_the_monkey(PlayerbotAI* botAI) { return new HunterAspectOfTheMonkeyTrigger(botAI); } - static Trigger* aspect_of_the_wild(PlayerbotAI* botAI) { return new HunterAspectOfTheWildTrigger(botAI); } - static Trigger* low_ammo(PlayerbotAI* botAI) { return new HunterLowAmmoTrigger(botAI); } - static Trigger* no_ammo(PlayerbotAI* botAI) { return new HunterNoAmmoTrigger(botAI); } - static Trigger* has_ammo(PlayerbotAI* botAI) { return new HunterHasAmmoTrigger(botAI); } - static Trigger* switch_to_melee(PlayerbotAI* botAI) { return new SwitchToMeleeTrigger(botAI); } - static Trigger* switch_to_ranged(PlayerbotAI* botAI) { return new SwitchToRangedTrigger(botAI); } - static Trigger* misdirection_on_main_tank(PlayerbotAI* ai) { return new MisdirectionOnMainTankTrigger(ai); } - static Trigger* remove_enrage(PlayerbotAI* ai) { return new TargetRemoveEnrageTrigger(ai); } +private: + static Trigger* auto_shot(PlayerbotAI* botAI) { return new AutoShotTrigger(botAI); } + static Trigger* scare_beast(PlayerbotAI* botAI) { return new ScareBeastTrigger(botAI); } + static Trigger* concussive_shot_on_snare_target(PlayerbotAI* botAI) + { + return new ConsussiveShotSnareTrigger(botAI); + } + static Trigger* pet_not_happy(PlayerbotAI* botAI) { return new HunterPetNotHappy(botAI); } + static Trigger* serpent_sting_on_attacker(PlayerbotAI* botAI) { return new SerpentStingOnAttackerTrigger(botAI); } + static Trigger* trueshot_aura(PlayerbotAI* botAI) { return new TrueshotAuraTrigger(botAI); } + static Trigger* aspect_of_the_viper(PlayerbotAI* botAI) { return new HunterAspectOfTheViperTrigger(botAI); } + static Trigger* black_arrow(PlayerbotAI* botAI) { return new BlackArrowTrigger(botAI); } + static Trigger* NoStings(PlayerbotAI* botAI) { return new HunterNoStingsActiveTrigger(botAI); } + static Trigger* hunters_pet_dead(PlayerbotAI* botAI) { return new HuntersPetDeadTrigger(botAI); } + static Trigger* hunters_pet_low_health(PlayerbotAI* botAI) { return new HuntersPetLowHealthTrigger(botAI); } + static Trigger* hunters_pet_medium_health(PlayerbotAI* botAI) { return new HuntersPetMediumHealthTrigger(botAI); } + static Trigger* hunters_mark(PlayerbotAI* botAI) { return new HuntersMarkTrigger(botAI); } + static Trigger* freezing_trap(PlayerbotAI* botAI) { return new FreezingTrapTrigger(botAI); } + static Trigger* aspect_of_the_pack(PlayerbotAI* botAI) { return new HunterAspectOfThePackTrigger(botAI); } + static Trigger* rapid_fire(PlayerbotAI* botAI) { return new RapidFireTrigger(botAI); } + static Trigger* aspect_of_the_hawk(PlayerbotAI* botAI) { return new HunterAspectOfTheHawkTrigger(botAI); } + static Trigger* aspect_of_the_monkey(PlayerbotAI* botAI) { return new HunterAspectOfTheMonkeyTrigger(botAI); } + static Trigger* aspect_of_the_wild(PlayerbotAI* botAI) { return new HunterAspectOfTheWildTrigger(botAI); } + static Trigger* low_ammo(PlayerbotAI* botAI) { return new HunterLowAmmoTrigger(botAI); } + static Trigger* no_ammo(PlayerbotAI* botAI) { return new HunterNoAmmoTrigger(botAI); } + static Trigger* has_ammo(PlayerbotAI* botAI) { return new HunterHasAmmoTrigger(botAI); } + static Trigger* switch_to_melee(PlayerbotAI* botAI) { return new SwitchToMeleeTrigger(botAI); } + static Trigger* switch_to_ranged(PlayerbotAI* botAI) { return new SwitchToRangedTrigger(botAI); } + static Trigger* misdirection_on_main_tank(PlayerbotAI* ai) { return new MisdirectionOnMainTankTrigger(ai); } + static Trigger* remove_enrage(PlayerbotAI* ai) { return new TargetRemoveEnrageTrigger(ai); } }; class HunterAiObjectContextInternal : public NamedObjectContext { - public: - HunterAiObjectContextInternal() - { - creators["auto shot"] = &HunterAiObjectContextInternal::auto_shot; - creators["aimed shot"] = &HunterAiObjectContextInternal::aimed_shot; - creators["chimera shot"] = &HunterAiObjectContextInternal::chimera_shot; - creators["explosive shot"] = &HunterAiObjectContextInternal::explosive_shot; - creators["arcane shot"] = &HunterAiObjectContextInternal::arcane_shot; - creators["concussive shot"] = &HunterAiObjectContextInternal::concussive_shot; - creators["distracting shot"] = &HunterAiObjectContextInternal::distracting_shot; - creators["multi-shot"] = &HunterAiObjectContextInternal::multi_shot; - creators["volley"] = &HunterAiObjectContextInternal::volley; - creators["serpent sting"] = &HunterAiObjectContextInternal::serpent_sting; - creators["serpent sting on attacker"] = &HunterAiObjectContextInternal::serpent_sting_on_attacker; - creators["wyvern sting"] = &HunterAiObjectContextInternal::wyvern_sting; - creators["viper sting"] = &HunterAiObjectContextInternal::viper_sting; - creators["scorpid sting"] = &HunterAiObjectContextInternal::scorpid_sting; - creators["hunter's mark"] = &HunterAiObjectContextInternal::hunters_mark; - creators["mend pet"] = &HunterAiObjectContextInternal::mend_pet; - creators["revive pet"] = &HunterAiObjectContextInternal::revive_pet; - creators["call pet"] = &HunterAiObjectContextInternal::call_pet; - creators["black arrow"] = &HunterAiObjectContextInternal::black_arrow; - creators["freezing trap"] = &HunterAiObjectContextInternal::freezing_trap; - creators["rapid fire"] = &HunterAiObjectContextInternal::rapid_fire; - creators["boost"] = &HunterAiObjectContextInternal::rapid_fire; - creators["readiness"] = &HunterAiObjectContextInternal::readiness; - creators["aspect of the hawk"] = &HunterAiObjectContextInternal::aspect_of_the_hawk; - creators["aspect of the monkey"] = &HunterAiObjectContextInternal::aspect_of_the_monkey; - creators["aspect of the wild"] = &HunterAiObjectContextInternal::aspect_of_the_wild; - creators["aspect of the viper"] = &HunterAiObjectContextInternal::aspect_of_the_viper; - creators["aspect of the pack"] = &HunterAiObjectContextInternal::aspect_of_the_pack; - creators["aspect of the cheetah"] = &HunterAiObjectContextInternal::aspect_of_the_cheetah; - creators["trueshot aura"] = &HunterAiObjectContextInternal::trueshot_aura; - creators["feign death"] = &HunterAiObjectContextInternal::feign_death; - creators["wing clip"] = &HunterAiObjectContextInternal::wing_clip; - creators["raptor strike"] = &HunterAiObjectContextInternal::raptor_strike; - creators["mongoose bite"] = &HunterAiObjectContextInternal::mongoose_bite; - creators["feed pet"] = &HunterAiObjectContextInternal::feed_pet; - creators["bestial wrath"] = &HunterAiObjectContextInternal::bestial_wrath; - creators["scare beast"] = &HunterAiObjectContextInternal::scare_beast; - creators["scare beast on cc"] = &HunterAiObjectContextInternal::scare_beast_on_cc; - creators["aspect of the dragonhawk"] = &HunterAiObjectContextInternal::aspect_of_the_dragonhawk; - creators["tranquilizing shot"] = &HunterAiObjectContextInternal::tranquilizing_shot; - creators["steady shot"] = &HunterAiObjectContextInternal::steady_shot; - creators["kill shot"] = &HunterAiObjectContextInternal::kill_shot; - creators["misdirection on main tank"] = &HunterAiObjectContextInternal::misdirection_on_main_tank; - } +public: + HunterAiObjectContextInternal() + { + creators["auto shot"] = &HunterAiObjectContextInternal::auto_shot; + creators["aimed shot"] = &HunterAiObjectContextInternal::aimed_shot; + creators["chimera shot"] = &HunterAiObjectContextInternal::chimera_shot; + creators["explosive shot"] = &HunterAiObjectContextInternal::explosive_shot; + creators["arcane shot"] = &HunterAiObjectContextInternal::arcane_shot; + creators["concussive shot"] = &HunterAiObjectContextInternal::concussive_shot; + creators["distracting shot"] = &HunterAiObjectContextInternal::distracting_shot; + creators["multi-shot"] = &HunterAiObjectContextInternal::multi_shot; + creators["volley"] = &HunterAiObjectContextInternal::volley; + creators["serpent sting"] = &HunterAiObjectContextInternal::serpent_sting; + creators["serpent sting on attacker"] = &HunterAiObjectContextInternal::serpent_sting_on_attacker; + creators["wyvern sting"] = &HunterAiObjectContextInternal::wyvern_sting; + creators["viper sting"] = &HunterAiObjectContextInternal::viper_sting; + creators["scorpid sting"] = &HunterAiObjectContextInternal::scorpid_sting; + creators["hunter's mark"] = &HunterAiObjectContextInternal::hunters_mark; + creators["mend pet"] = &HunterAiObjectContextInternal::mend_pet; + creators["revive pet"] = &HunterAiObjectContextInternal::revive_pet; + creators["call pet"] = &HunterAiObjectContextInternal::call_pet; + creators["black arrow"] = &HunterAiObjectContextInternal::black_arrow; + creators["freezing trap"] = &HunterAiObjectContextInternal::freezing_trap; + creators["rapid fire"] = &HunterAiObjectContextInternal::rapid_fire; + creators["boost"] = &HunterAiObjectContextInternal::rapid_fire; + creators["readiness"] = &HunterAiObjectContextInternal::readiness; + creators["aspect of the hawk"] = &HunterAiObjectContextInternal::aspect_of_the_hawk; + creators["aspect of the monkey"] = &HunterAiObjectContextInternal::aspect_of_the_monkey; + creators["aspect of the wild"] = &HunterAiObjectContextInternal::aspect_of_the_wild; + creators["aspect of the viper"] = &HunterAiObjectContextInternal::aspect_of_the_viper; + creators["aspect of the pack"] = &HunterAiObjectContextInternal::aspect_of_the_pack; + creators["aspect of the cheetah"] = &HunterAiObjectContextInternal::aspect_of_the_cheetah; + creators["trueshot aura"] = &HunterAiObjectContextInternal::trueshot_aura; + creators["feign death"] = &HunterAiObjectContextInternal::feign_death; + creators["wing clip"] = &HunterAiObjectContextInternal::wing_clip; + creators["raptor strike"] = &HunterAiObjectContextInternal::raptor_strike; + creators["mongoose bite"] = &HunterAiObjectContextInternal::mongoose_bite; + creators["feed pet"] = &HunterAiObjectContextInternal::feed_pet; + creators["bestial wrath"] = &HunterAiObjectContextInternal::bestial_wrath; + creators["scare beast"] = &HunterAiObjectContextInternal::scare_beast; + creators["scare beast on cc"] = &HunterAiObjectContextInternal::scare_beast_on_cc; + creators["aspect of the dragonhawk"] = &HunterAiObjectContextInternal::aspect_of_the_dragonhawk; + creators["tranquilizing shot"] = &HunterAiObjectContextInternal::tranquilizing_shot; + creators["steady shot"] = &HunterAiObjectContextInternal::steady_shot; + creators["kill shot"] = &HunterAiObjectContextInternal::kill_shot; + creators["misdirection on main tank"] = &HunterAiObjectContextInternal::misdirection_on_main_tank; + } - private: - static Action* scare_beast(PlayerbotAI* botAI) { return new CastScareBeastAction(botAI); } - static Action* scare_beast_on_cc(PlayerbotAI* botAI) { return new CastScareBeastCcAction(botAI); } - static Action* bestial_wrath(PlayerbotAI* botAI) { return new CastBestialWrathAction(botAI); } - static Action* feed_pet(PlayerbotAI* botAI) { return new FeedPetAction(botAI); } - static Action* feign_death(PlayerbotAI* botAI) { return new CastFeignDeathAction(botAI); } - static Action* trueshot_aura(PlayerbotAI* botAI) { return new CastTrueshotAuraAction(botAI); } - static Action* auto_shot(PlayerbotAI* botAI) { return new CastAutoShotAction(botAI); } - static Action* aimed_shot(PlayerbotAI* botAI) { return new CastAimedShotAction(botAI); } - static Action* chimera_shot(PlayerbotAI* botAI) { return new CastChimeraShotAction(botAI); } - static Action* explosive_shot(PlayerbotAI* botAI) { return new CastExplosiveShotAction(botAI); } - static Action* arcane_shot(PlayerbotAI* botAI) { return new CastArcaneShotAction(botAI); } - static Action* concussive_shot(PlayerbotAI* botAI) { return new CastConcussiveShotAction(botAI); } - static Action* distracting_shot(PlayerbotAI* botAI) { return new CastDistractingShotAction(botAI); } - static Action* multi_shot(PlayerbotAI* botAI) { return new CastMultiShotAction(botAI); } - static Action* volley(PlayerbotAI* botAI) { return new CastVolleyAction(botAI); } - static Action* serpent_sting(PlayerbotAI* botAI) { return new CastSerpentStingAction(botAI); } - static Action* serpent_sting_on_attacker(PlayerbotAI* botAI) { return new CastSerpentStingOnAttackerAction(botAI); } - static Action* wyvern_sting(PlayerbotAI* botAI) { return new CastWyvernStingAction(botAI); } - static Action* viper_sting(PlayerbotAI* botAI) { return new CastViperStingAction(botAI); } - static Action* scorpid_sting(PlayerbotAI* botAI) { return new CastScorpidStingAction(botAI); } - static Action* hunters_mark(PlayerbotAI* botAI) { return new CastHuntersMarkAction(botAI); } - static Action* mend_pet(PlayerbotAI* botAI) { return new CastMendPetAction(botAI); } - static Action* revive_pet(PlayerbotAI* botAI) { return new CastRevivePetAction(botAI); } - static Action* call_pet(PlayerbotAI* botAI) { return new CastCallPetAction(botAI); } - static Action* black_arrow(PlayerbotAI* botAI) { return new CastBlackArrow(botAI); } - static Action* freezing_trap(PlayerbotAI* botAI) { return new CastFreezingTrap(botAI); } - static Action* rapid_fire(PlayerbotAI* botAI) { return new CastRapidFireAction(botAI); } - static Action* readiness(PlayerbotAI* botAI) { return new CastReadinessAction(botAI); } - static Action* aspect_of_the_hawk(PlayerbotAI* botAI) { return new CastAspectOfTheHawkAction(botAI); } - static Action* aspect_of_the_monkey(PlayerbotAI* botAI) { return new CastAspectOfTheMonkeyAction(botAI); } - static Action* aspect_of_the_wild(PlayerbotAI* botAI) { return new CastAspectOfTheWildAction(botAI); } - static Action* aspect_of_the_viper(PlayerbotAI* botAI) { return new CastAspectOfTheViperAction(botAI); } - static Action* aspect_of_the_pack(PlayerbotAI* botAI) { return new CastAspectOfThePackAction(botAI); } - static Action* aspect_of_the_cheetah(PlayerbotAI* botAI) { return new CastAspectOfTheCheetahAction(botAI); } - static Action* wing_clip(PlayerbotAI* botAI) { return new CastWingClipAction(botAI); } - static Action* raptor_strike(PlayerbotAI* botAI) { return new CastRaptorStrikeAction(botAI); } - static Action* mongoose_bite(PlayerbotAI* botAI) { return new CastMongooseBiteAction(botAI); } - static Action* aspect_of_the_dragonhawk(PlayerbotAI* ai) { return new CastAspectOfTheDragonhawkAction(ai); } - static Action* tranquilizing_shot(PlayerbotAI* ai) { return new CastTranquilizingShotAction(ai); } - static Action* steady_shot(PlayerbotAI* ai) { return new CastSteadyShotAction(ai); } - static Action* kill_shot(PlayerbotAI* ai) { return new CastKillShotAction(ai); } - static Action* misdirection_on_main_tank(PlayerbotAI* ai) { return new CastMisdirectionOnMainTankAction(ai); } +private: + static Action* scare_beast(PlayerbotAI* botAI) { return new CastScareBeastAction(botAI); } + static Action* scare_beast_on_cc(PlayerbotAI* botAI) { return new CastScareBeastCcAction(botAI); } + static Action* bestial_wrath(PlayerbotAI* botAI) { return new CastBestialWrathAction(botAI); } + static Action* feed_pet(PlayerbotAI* botAI) { return new FeedPetAction(botAI); } + static Action* feign_death(PlayerbotAI* botAI) { return new CastFeignDeathAction(botAI); } + static Action* trueshot_aura(PlayerbotAI* botAI) { return new CastTrueshotAuraAction(botAI); } + static Action* auto_shot(PlayerbotAI* botAI) { return new CastAutoShotAction(botAI); } + static Action* aimed_shot(PlayerbotAI* botAI) { return new CastAimedShotAction(botAI); } + static Action* chimera_shot(PlayerbotAI* botAI) { return new CastChimeraShotAction(botAI); } + static Action* explosive_shot(PlayerbotAI* botAI) { return new CastExplosiveShotAction(botAI); } + static Action* arcane_shot(PlayerbotAI* botAI) { return new CastArcaneShotAction(botAI); } + static Action* concussive_shot(PlayerbotAI* botAI) { return new CastConcussiveShotAction(botAI); } + static Action* distracting_shot(PlayerbotAI* botAI) { return new CastDistractingShotAction(botAI); } + static Action* multi_shot(PlayerbotAI* botAI) { return new CastMultiShotAction(botAI); } + static Action* volley(PlayerbotAI* botAI) { return new CastVolleyAction(botAI); } + static Action* serpent_sting(PlayerbotAI* botAI) { return new CastSerpentStingAction(botAI); } + static Action* serpent_sting_on_attacker(PlayerbotAI* botAI) { return new CastSerpentStingOnAttackerAction(botAI); } + static Action* wyvern_sting(PlayerbotAI* botAI) { return new CastWyvernStingAction(botAI); } + static Action* viper_sting(PlayerbotAI* botAI) { return new CastViperStingAction(botAI); } + static Action* scorpid_sting(PlayerbotAI* botAI) { return new CastScorpidStingAction(botAI); } + static Action* hunters_mark(PlayerbotAI* botAI) { return new CastHuntersMarkAction(botAI); } + static Action* mend_pet(PlayerbotAI* botAI) { return new CastMendPetAction(botAI); } + static Action* revive_pet(PlayerbotAI* botAI) { return new CastRevivePetAction(botAI); } + static Action* call_pet(PlayerbotAI* botAI) { return new CastCallPetAction(botAI); } + static Action* black_arrow(PlayerbotAI* botAI) { return new CastBlackArrow(botAI); } + static Action* freezing_trap(PlayerbotAI* botAI) { return new CastFreezingTrap(botAI); } + static Action* rapid_fire(PlayerbotAI* botAI) { return new CastRapidFireAction(botAI); } + static Action* readiness(PlayerbotAI* botAI) { return new CastReadinessAction(botAI); } + static Action* aspect_of_the_hawk(PlayerbotAI* botAI) { return new CastAspectOfTheHawkAction(botAI); } + static Action* aspect_of_the_monkey(PlayerbotAI* botAI) { return new CastAspectOfTheMonkeyAction(botAI); } + static Action* aspect_of_the_wild(PlayerbotAI* botAI) { return new CastAspectOfTheWildAction(botAI); } + static Action* aspect_of_the_viper(PlayerbotAI* botAI) { return new CastAspectOfTheViperAction(botAI); } + static Action* aspect_of_the_pack(PlayerbotAI* botAI) { return new CastAspectOfThePackAction(botAI); } + static Action* aspect_of_the_cheetah(PlayerbotAI* botAI) { return new CastAspectOfTheCheetahAction(botAI); } + static Action* wing_clip(PlayerbotAI* botAI) { return new CastWingClipAction(botAI); } + static Action* raptor_strike(PlayerbotAI* botAI) { return new CastRaptorStrikeAction(botAI); } + static Action* mongoose_bite(PlayerbotAI* botAI) { return new CastMongooseBiteAction(botAI); } + static Action* aspect_of_the_dragonhawk(PlayerbotAI* ai) { return new CastAspectOfTheDragonhawkAction(ai); } + static Action* tranquilizing_shot(PlayerbotAI* ai) { return new CastTranquilizingShotAction(ai); } + static Action* steady_shot(PlayerbotAI* ai) { return new CastSteadyShotAction(ai); } + static Action* kill_shot(PlayerbotAI* ai) { return new CastKillShotAction(ai); } + static Action* misdirection_on_main_tank(PlayerbotAI* ai) { return new CastMisdirectionOnMainTankAction(ai); } }; HunterAiObjectContext::HunterAiObjectContext(PlayerbotAI* botAI) : AiObjectContext(botAI) diff --git a/src/strategy/hunter/HunterAiObjectContext.h b/src/strategy/hunter/HunterAiObjectContext.h index 80c52602..e06e8f54 100644 --- a/src/strategy/hunter/HunterAiObjectContext.h +++ b/src/strategy/hunter/HunterAiObjectContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HUNTERAIOBJECTCONTEXT_H @@ -11,8 +12,8 @@ class PlayerbotAI; class HunterAiObjectContext : public AiObjectContext { - public: - HunterAiObjectContext(PlayerbotAI* botAI); +public: + HunterAiObjectContext(PlayerbotAI* botAI); }; #endif diff --git a/src/strategy/hunter/HunterBuffStrategies.cpp b/src/strategy/hunter/HunterBuffStrategies.cpp index 3eb7cad1..25c3577d 100644 --- a/src/strategy/hunter/HunterBuffStrategies.cpp +++ b/src/strategy/hunter/HunterBuffStrategies.cpp @@ -1,51 +1,53 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HunterBuffStrategies.h" + #include "Playerbots.h" class BuffHunterStrategyActionNodeFactory : public NamedObjectFactory { - public: - BuffHunterStrategyActionNodeFactory() - { - creators["aspect of the hawk"] = &aspect_of_the_hawk; - } +public: + BuffHunterStrategyActionNodeFactory() { creators["aspect of the hawk"] = &aspect_of_the_hawk; } - private: - static ActionNode* aspect_of_the_hawk([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("aspect of the hawk", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("aspect of the monkey"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* aspect_of_the_hawk([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("aspect of the hawk", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("aspect of the monkey"), nullptr), + /*C*/ nullptr); + } }; -HunterBuffDpsStrategy::HunterBuffDpsStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) -{ +HunterBuffDpsStrategy::HunterBuffDpsStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) +{ actionNodeFactories.Add(new BuffHunterStrategyActionNodeFactory()); } void HunterBuffDpsStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("aspect of the hawk", NextAction::array(0, - new NextAction("aspect of the dragonhawk", 20.1f), - new NextAction("aspect of the hawk", 20.0f),nullptr))); + triggers.push_back( + new TriggerNode("aspect of the hawk", NextAction::array(0, new NextAction("aspect of the dragonhawk", 20.1f), + new NextAction("aspect of the hawk", 20.0f), nullptr))); } void HunterNatureResistanceStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("aspect of the wild", NextAction::array(0, new NextAction("aspect of the wild", 20.0f), nullptr))); + triggers.push_back(new TriggerNode("aspect of the wild", + NextAction::array(0, new NextAction("aspect of the wild", 20.0f), nullptr))); } void HunterBuffSpeedStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("aspect of the pack", NextAction::array(0, new NextAction("aspect of the pack", 20.0f), nullptr))); + triggers.push_back(new TriggerNode("aspect of the pack", + NextAction::array(0, new NextAction("aspect of the pack", 20.0f), nullptr))); } void HunterBuffManaStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("aspect of the viper", NextAction::array(0, new NextAction("aspect of the viper", 20.0f), nullptr))); + triggers.push_back(new TriggerNode("aspect of the viper", + NextAction::array(0, new NextAction("aspect of the viper", 20.0f), nullptr))); } diff --git a/src/strategy/hunter/HunterBuffStrategies.h b/src/strategy/hunter/HunterBuffStrategies.h index c099a805..3bedd3a1 100644 --- a/src/strategy/hunter/HunterBuffStrategies.h +++ b/src/strategy/hunter/HunterBuffStrategies.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HUNTERBUFFSTRATEGIES_H @@ -11,38 +12,38 @@ class PlayerbotAI; class HunterBuffSpeedStrategy : public NonCombatStrategy { - public: - HunterBuffSpeedStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + HunterBuffSpeedStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "bspeed"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bspeed"; } + void InitTriggers(std::vector& triggers) override; }; class HunterBuffManaStrategy : public NonCombatStrategy { - public: - HunterBuffManaStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + HunterBuffManaStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "bmana"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bmana"; } + void InitTriggers(std::vector& triggers) override; }; class HunterBuffDpsStrategy : public NonCombatStrategy { - public: - HunterBuffDpsStrategy(PlayerbotAI* botAI); +public: + HunterBuffDpsStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "bdps"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bdps"; } + void InitTriggers(std::vector& triggers) override; }; class HunterNatureResistanceStrategy : public NonCombatStrategy { - public: - HunterNatureResistanceStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + HunterNatureResistanceStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "rnature"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "rnature"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/hunter/HunterTriggers.cpp b/src/strategy/hunter/HunterTriggers.cpp index a8dbaa70..d581955d 100644 --- a/src/strategy/hunter/HunterTriggers.cpp +++ b/src/strategy/hunter/HunterTriggers.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HunterTriggers.h" + #include "GenericTriggers.h" #include "HunterActions.h" #include "PlayerbotAIConfig.h" @@ -13,18 +15,16 @@ bool HunterAspectOfTheHawkTrigger::IsActive() { Unit* target = GetTarget(); - return SpellTrigger::IsActive() && - !botAI->HasAura("aspect of the hawk", target) && !botAI->HasAura("aspect of the dragonhawk", target) && - (!AI_VALUE2(bool, "has mana", "self target") || AI_VALUE2(uint8, "mana", "self target") > 70); + return SpellTrigger::IsActive() && !botAI->HasAura("aspect of the hawk", target) && + !botAI->HasAura("aspect of the dragonhawk", target) && + (!AI_VALUE2(bool, "has mana", "self target") || AI_VALUE2(uint8, "mana", "self target") > 70); } bool HunterNoStingsActiveTrigger::IsActive() { - Unit* target = AI_VALUE(Unit*, "current target"); - return DebuffTrigger::IsActive() && target && - !botAI->HasAura("serpent sting", target, false, true) && - !botAI->HasAura("scorpid sting", target, false, true) && - !botAI->HasAura("viper sting", target, false, true); + Unit* target = AI_VALUE(Unit*, "current target"); + return DebuffTrigger::IsActive() && target && !botAI->HasAura("serpent sting", target, false, true) && + !botAI->HasAura("scorpid sting", target, false, true) && !botAI->HasAura("viper sting", target, false, true); } bool HuntersPetDeadTrigger::IsActive() @@ -37,13 +37,15 @@ bool HuntersPetDeadTrigger::IsActive() bool HuntersPetLowHealthTrigger::IsActive() { Unit* pet = AI_VALUE(Unit*, "pet target"); - return pet && AI_VALUE2(uint8, "health", "pet target") < 40 && !AI_VALUE2(bool, "dead", "pet target") && !AI_VALUE2(bool, "mounted", "self target"); + return pet && AI_VALUE2(uint8, "health", "pet target") < 40 && !AI_VALUE2(bool, "dead", "pet target") && + !AI_VALUE2(bool, "mounted", "self target"); } bool HuntersPetMediumHealthTrigger::IsActive() { Unit* pet = AI_VALUE(Unit*, "pet target"); - return pet && AI_VALUE2(uint8, "health", "pet target") < sPlayerbotAIConfig->mediumHealth && !AI_VALUE2(bool, "dead", "pet target") && !AI_VALUE2(bool, "mounted", "self target"); + return pet && AI_VALUE2(uint8, "health", "pet target") < sPlayerbotAIConfig->mediumHealth && + !AI_VALUE2(bool, "dead", "pet target") && !AI_VALUE2(bool, "mounted", "self target"); } bool HunterPetNotHappy::IsActive() @@ -53,8 +55,9 @@ bool HunterPetNotHappy::IsActive() bool HunterAspectOfTheViperTrigger::IsActive() { - return SpellTrigger::IsActive() && !botAI->HasAura(spell, GetTarget()) && - AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->lowMana;; + return SpellTrigger::IsActive() && !botAI->HasAura(spell, GetTarget()) && + AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->lowMana; + ; } bool HunterAspectOfThePackTrigger::IsActive() @@ -64,30 +67,30 @@ bool HunterAspectOfThePackTrigger::IsActive() bool HunterLowAmmoTrigger::IsActive() { - return bot->GetGroup() && (AI_VALUE2(uint32, "item count", "ammo") < 100) && (AI_VALUE2(uint32, "item count", "ammo") > 0); + return bot->GetGroup() && (AI_VALUE2(uint32, "item count", "ammo") < 100) && + (AI_VALUE2(uint32, "item count", "ammo") > 0); } -bool HunterHasAmmoTrigger::IsActive() -{ - return !AmmoCountTrigger::IsActive(); -} +bool HunterHasAmmoTrigger::IsActive() { return !AmmoCountTrigger::IsActive(); } bool SwitchToRangedTrigger::IsActive() { Unit* target = AI_VALUE(Unit*, "current target"); - return botAI->HasStrategy("close", BOT_STATE_COMBAT) && target && (target->GetVictim() != bot && - sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "current target"), 8.0f)); + return botAI->HasStrategy("close", BOT_STATE_COMBAT) && target && + (target->GetVictim() != bot && + sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "current target"), 8.0f)); } bool SwitchToMeleeTrigger::IsActive() { Unit* target = AI_VALUE(Unit*, "current target"); - return botAI->HasStrategy("ranged", BOT_STATE_COMBAT) && target && (target->GetVictim() == bot && - sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "current target"), 8.0f)); + return botAI->HasStrategy("ranged", BOT_STATE_COMBAT) && target && + (target->GetVictim() == bot && + sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "current target"), 8.0f)); } bool TargetRemoveEnrageTrigger::IsActive() { - Unit* target = GetTarget(); - return target && (botAI->HasAuraToDispel(target, DISPEL_ENRAGE) || botAI->HasAuraToDispel(target, DISPEL_MAGIC)); + Unit* target = GetTarget(); + return target && (botAI->HasAuraToDispel(target, DISPEL_ENRAGE) || botAI->HasAuraToDispel(target, DISPEL_MAGIC)); } \ No newline at end of file diff --git a/src/strategy/hunter/HunterTriggers.h b/src/strategy/hunter/HunterTriggers.h index 6896fd32..4b5a7078 100644 --- a/src/strategy/hunter/HunterTriggers.h +++ b/src/strategy/hunter/HunterTriggers.h @@ -1,64 +1,65 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HUNTERTRIGGERS_H #define _PLAYERBOT_HUNTERTRIGGERS_H +#include "CureTriggers.h" #include "GenericTriggers.h" #include "Trigger.h" -#include "CureTriggers.h" class PlayerbotAI; class HunterNoStingsActiveTrigger : public DebuffTrigger { - public: - HunterNoStingsActiveTrigger(PlayerbotAI* botAI): DebuffTrigger(botAI, "no stings") {} - bool IsActive() override; +public: + HunterNoStingsActiveTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "no stings") {} + bool IsActive() override; }; class AutoShotTrigger : public Trigger { - public: - AutoShotTrigger(PlayerbotAI* botAI) : Trigger(botAI, "auto shot") { } +public: + AutoShotTrigger(PlayerbotAI* botAI) : Trigger(botAI, "auto shot") {} - bool IsActive() override; + bool IsActive() override; }; class HunterAspectOfTheMonkeyTrigger : public BuffTrigger { - public: - HunterAspectOfTheMonkeyTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "aspect of the monkey") { } +public: + HunterAspectOfTheMonkeyTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "aspect of the monkey") {} }; class HunterAspectOfTheHawkTrigger : public BuffTrigger { - public: - HunterAspectOfTheHawkTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "aspect of the hawk") { } - bool IsActive() override; +public: + HunterAspectOfTheHawkTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "aspect of the hawk") {} + bool IsActive() override; }; class HunterAspectOfTheWildTrigger : public BuffTrigger { - public: - HunterAspectOfTheWildTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "aspect of the wild") { } +public: + HunterAspectOfTheWildTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "aspect of the wild") {} }; class HunterAspectOfTheViperTrigger : public BuffTrigger { - public: - HunterAspectOfTheViperTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "aspect of the viper") { } +public: + HunterAspectOfTheViperTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "aspect of the viper") {} - bool IsActive() override; + bool IsActive() override; }; class HunterAspectOfThePackTrigger : public BuffTrigger { - public: - HunterAspectOfThePackTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "aspect of the pack") { } +public: + HunterAspectOfThePackTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "aspect of the pack") {} - bool IsActive() override; + bool IsActive() override; }; BEGIN_TRIGGER(HuntersPetDeadTrigger, Trigger) @@ -72,38 +73,38 @@ END_TRIGGER() class BlackArrowTrigger : public DebuffTrigger { - public: - BlackArrowTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "black arrow", 1, true) { } +public: + BlackArrowTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "black arrow", 1, true) {} }; class HuntersMarkTrigger : public DebuffTrigger { - public: - HuntersMarkTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "hunter's mark", 1, false, 25.0f) { } +public: + HuntersMarkTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "hunter's mark", 1, false, 25.0f) {} }; class FreezingTrapTrigger : public HasCcTargetTrigger { - public: - FreezingTrapTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "freezing trap") { } +public: + FreezingTrapTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "freezing trap") {} }; class RapidFireTrigger : public BoostTrigger { - public: - RapidFireTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "rapid fire") { } +public: + RapidFireTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "rapid fire") {} }; class TrueshotAuraTrigger : public BuffTrigger { - public: - TrueshotAuraTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "trueshot aura") { } +public: + TrueshotAuraTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "trueshot aura") {} }; class SerpentStingOnAttackerTrigger : public DebuffOnAttackerTrigger { - public: - SerpentStingOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "serpent sting", true) { } +public: + SerpentStingOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "serpent sting", true) {} }; BEGIN_TRIGGER(HunterPetNotHappy, Trigger) @@ -111,64 +112,64 @@ END_TRIGGER() class ConsussiveShotSnareTrigger : public SnareTargetTrigger { - public: - ConsussiveShotSnareTrigger(PlayerbotAI* botAI) : SnareTargetTrigger(botAI, "concussive shot") { } +public: + ConsussiveShotSnareTrigger(PlayerbotAI* botAI) : SnareTargetTrigger(botAI, "concussive shot") {} }; class ScareBeastTrigger : public HasCcTargetTrigger { - public: - ScareBeastTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "scare beast") { } +public: + ScareBeastTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "scare beast") {} }; class HunterLowAmmoTrigger : public AmmoCountTrigger { - public: - HunterLowAmmoTrigger(PlayerbotAI* botAI) : AmmoCountTrigger(botAI, "ammo", 1, 30) { } +public: + HunterLowAmmoTrigger(PlayerbotAI* botAI) : AmmoCountTrigger(botAI, "ammo", 1, 30) {} - bool IsActive() override; + bool IsActive() override; }; class HunterNoAmmoTrigger : public AmmoCountTrigger { - public: - HunterNoAmmoTrigger(PlayerbotAI* botAI) : AmmoCountTrigger(botAI, "ammo", 1, 10) { } +public: + HunterNoAmmoTrigger(PlayerbotAI* botAI) : AmmoCountTrigger(botAI, "ammo", 1, 10) {} }; class HunterHasAmmoTrigger : public AmmoCountTrigger { - public: - HunterHasAmmoTrigger(PlayerbotAI* botAI) : AmmoCountTrigger(botAI, "ammo", 1, 10) { } +public: + HunterHasAmmoTrigger(PlayerbotAI* botAI) : AmmoCountTrigger(botAI, "ammo", 1, 10) {} - bool IsActive() override; + bool IsActive() override; }; class SwitchToRangedTrigger : public Trigger { - public: - SwitchToRangedTrigger(PlayerbotAI* botAI) : Trigger(botAI, "switch to ranged") { } +public: + SwitchToRangedTrigger(PlayerbotAI* botAI) : Trigger(botAI, "switch to ranged") {} - bool IsActive() override; + bool IsActive() override; }; class SwitchToMeleeTrigger : public Trigger { - public: - SwitchToMeleeTrigger(PlayerbotAI* botAI) : Trigger(botAI, "switch to melee") { } +public: + SwitchToMeleeTrigger(PlayerbotAI* botAI) : Trigger(botAI, "switch to melee") {} - bool IsActive() override; + bool IsActive() override; }; class MisdirectionOnMainTankTrigger : public BuffOnMainTankTrigger { - public: - MisdirectionOnMainTankTrigger(PlayerbotAI* ai) : BuffOnMainTankTrigger(ai, "misdirection", true) {} +public: + MisdirectionOnMainTankTrigger(PlayerbotAI* ai) : BuffOnMainTankTrigger(ai, "misdirection", true) {} }; class TargetRemoveEnrageTrigger : public TargetAuraDispelTrigger { - public: - TargetRemoveEnrageTrigger(PlayerbotAI* ai) : TargetAuraDispelTrigger(ai, "tranquilizing shot", DISPEL_ENRAGE) {} - bool IsActive() override; +public: + TargetRemoveEnrageTrigger(PlayerbotAI* ai) : TargetAuraDispelTrigger(ai, "tranquilizing shot", DISPEL_ENRAGE) {} + bool IsActive() override; }; #endif diff --git a/src/strategy/mage/ArcaneMageStrategy.cpp b/src/strategy/mage/ArcaneMageStrategy.cpp index db97a4da..3546072b 100644 --- a/src/strategy/mage/ArcaneMageStrategy.cpp +++ b/src/strategy/mage/ArcaneMageStrategy.cpp @@ -1,53 +1,55 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ArcaneMageStrategy.h" + #include "Playerbots.h" class ArcaneMageStrategyActionNodeFactory : public NamedObjectFactory { - public: - ArcaneMageStrategyActionNodeFactory() - { - creators["arcane blast"] = &arcane_blast; - creators["arcane barrage"] = &arcane_barrage; - creators["arcane missiles"] = &arcane_missiles; - // creators["firebolt"] = &firebolt; - } +public: + ArcaneMageStrategyActionNodeFactory() + { + creators["arcane blast"] = &arcane_blast; + creators["arcane barrage"] = &arcane_barrage; + creators["arcane missiles"] = &arcane_missiles; + // creators["firebolt"] = &firebolt; + } - private: - static ActionNode* arcane_blast([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("arcane blast", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("arcane missiles"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* arcane_blast([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("arcane blast", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("arcane missiles"), nullptr), + /*C*/ nullptr); + } - static ActionNode* arcane_barrage([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("arcane barrage", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("arcane missiles"), nullptr), - /*C*/ nullptr); - } + static ActionNode* arcane_barrage([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("arcane barrage", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("arcane missiles"), nullptr), + /*C*/ nullptr); + } - static ActionNode* arcane_missiles([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("arcane missiles", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("fireball"), nullptr), - /*C*/ nullptr); - } + static ActionNode* arcane_missiles([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("arcane missiles", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("fireball"), nullptr), + /*C*/ nullptr); + } - // static ActionNode* firebolt([[maybe_unused]] PlayerbotAI* botAI) - // { - // return new ActionNode ("firebolt", - // /*P*/ nullptr, - // /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), - // /*C*/ nullptr); - // } + // static ActionNode* firebolt([[maybe_unused]] PlayerbotAI* botAI) + // { + // return new ActionNode ("firebolt", + // /*P*/ nullptr, + // /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), + // /*C*/ nullptr); + // } }; ArcaneMageStrategy::ArcaneMageStrategy(PlayerbotAI* botAI) : GenericMageStrategy(botAI) @@ -57,27 +59,23 @@ ArcaneMageStrategy::ArcaneMageStrategy(PlayerbotAI* botAI) : GenericMageStrategy NextAction** ArcaneMageStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("arcane blast", ACTION_DEFAULT + 0.1f), - new NextAction("shoot", ACTION_DEFAULT), - NULL); + return NextAction::array(0, new NextAction("arcane blast", ACTION_DEFAULT + 0.1f), + new NextAction("shoot", ACTION_DEFAULT), NULL); } void ArcaneMageStrategy::InitTriggers(std::vector& triggers) { GenericMageStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("arcane blast stack", NextAction::array(0, new NextAction("arcane missiles", 15.0f), NULL))); + triggers.push_back( + new TriggerNode("arcane blast stack", NextAction::array(0, new NextAction("arcane missiles", 15.0f), NULL))); } void ArcaneMageAoeStrategy::InitTriggers(std::vector& triggers) { - // triggers.push_back(new TriggerNode( - // "high aoe", - // NextAction::array(0, new NextAction("arcane explosion", 39.0f), NULL))); - - triggers.push_back(new TriggerNode( - "medium aoe", - NextAction::array(0, new NextAction("blizzard", 40.0f), NULL))); + // triggers.push_back(new TriggerNode( + // "high aoe", + // NextAction::array(0, new NextAction("arcane explosion", 39.0f), NULL))); + triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("blizzard", 40.0f), NULL))); } \ No newline at end of file diff --git a/src/strategy/mage/ArcaneMageStrategy.h b/src/strategy/mage/ArcaneMageStrategy.h index 73bd10ae..adcc51cf 100644 --- a/src/strategy/mage/ArcaneMageStrategy.h +++ b/src/strategy/mage/ArcaneMageStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ARCANEMAGESTRATEGY_H @@ -11,12 +12,12 @@ class PlayerbotAI; class ArcaneMageStrategy : public GenericMageStrategy { - public: - ArcaneMageStrategy(PlayerbotAI* botAI); +public: + ArcaneMageStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "arcane"; } - NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "arcane"; } + NextAction** getDefaultActions() override; }; class ArcaneMageAoeStrategy : public CombatStrategy diff --git a/src/strategy/mage/FireMageStrategy.cpp b/src/strategy/mage/FireMageStrategy.cpp index 8382c3b1..1d9512b3 100644 --- a/src/strategy/mage/FireMageStrategy.cpp +++ b/src/strategy/mage/FireMageStrategy.cpp @@ -1,31 +1,36 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "FireMageStrategy.h" + #include "Playerbots.h" NextAction** FireMageStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("fireball", ACTION_DEFAULT + 0.1f), - new NextAction("shoot", ACTION_DEFAULT), - NULL); + return NextAction::array(0, new NextAction("fireball", ACTION_DEFAULT + 0.1f), + new NextAction("shoot", ACTION_DEFAULT), NULL); } void FireMageStrategy::InitTriggers(std::vector& triggers) { GenericMageStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("pyroblast", NextAction::array(0, new NextAction("pyroblast", 10.0f), nullptr))); - triggers.push_back(new TriggerNode("hot streak", NextAction::array(0, new NextAction("pyroblast", 25.0f), nullptr))); - triggers.push_back(new TriggerNode("combustion", NextAction::array(0, new NextAction("combustion", 50.0f), nullptr))); - // triggers.push_back(new TriggerNode("enemy too close for spell", NextAction::array(0, new NextAction("dragon's breath", 70.0f), nullptr))); + // triggers.push_back(new TriggerNode("pyroblast", NextAction::array(0, new NextAction("pyroblast", 10.0f), + // nullptr))); + triggers.push_back( + new TriggerNode("hot streak", NextAction::array(0, new NextAction("pyroblast", 25.0f), nullptr))); + triggers.push_back( + new TriggerNode("combustion", NextAction::array(0, new NextAction("combustion", 50.0f), nullptr))); + // triggers.push_back(new TriggerNode("enemy too close for spell", NextAction::array(0, new NextAction("dragon's + // breath", 70.0f), nullptr))); } void FireMageAoeStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("flamestrike", 20.0f), nullptr))); - triggers.push_back(new TriggerNode("living bomb", NextAction::array(0, new NextAction("living bomb", 25.0f), nullptr))); + triggers.push_back( + new TriggerNode("medium aoe", NextAction::array(0, new NextAction("flamestrike", 20.0f), nullptr))); + triggers.push_back( + new TriggerNode("living bomb", NextAction::array(0, new NextAction("living bomb", 25.0f), nullptr))); } - diff --git a/src/strategy/mage/FireMageStrategy.h b/src/strategy/mage/FireMageStrategy.h index 08ae2645..4200fbe0 100644 --- a/src/strategy/mage/FireMageStrategy.h +++ b/src/strategy/mage/FireMageStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_FIREMAGESTRATEGY_H @@ -11,21 +12,21 @@ class PlayerbotAI; class FireMageStrategy : public GenericMageStrategy { - public: - FireMageStrategy(PlayerbotAI* botAI) : GenericMageStrategy(botAI) { } +public: + FireMageStrategy(PlayerbotAI* botAI) : GenericMageStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "fire"; } - NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "fire"; } + NextAction** getDefaultActions() override; }; class FireMageAoeStrategy : public CombatStrategy { - public: - FireMageAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + FireMageAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "fire aoe"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "fire aoe"; } }; #endif diff --git a/src/strategy/mage/FrostMageStrategy.cpp b/src/strategy/mage/FrostMageStrategy.cpp index 4898b1ad..f4b02dc7 100644 --- a/src/strategy/mage/FrostMageStrategy.cpp +++ b/src/strategy/mage/FrostMageStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "FrostMageStrategy.h" + #include "Playerbots.h" class FrostMageStrategyActionNodeFactory : public NamedObjectFactory @@ -15,38 +17,39 @@ public: creators["summon water elemental"] = &summon_water_elemental; creators["deep freeze"] = &deep_freeze; } + private: static ActionNode* cold_snap([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("cold snap", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - + { + return new ActionNode("cold snap", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* ice_barrier([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("ice barrier", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - + { + return new ActionNode("ice barrier", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* summon_water_elemental([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("summon water elemental", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - + { + return new ActionNode("summon water elemental", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* deep_freeze([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("deep freeze", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("ice lance"), nullptr), - /*C*/ nullptr); - } + { + return new ActionNode("deep freeze", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("ice lance"), nullptr), + /*C*/ nullptr); + } }; FrostMageStrategy::FrostMageStrategy(PlayerbotAI* botAI) : GenericMageStrategy(botAI) @@ -56,11 +59,8 @@ FrostMageStrategy::FrostMageStrategy(PlayerbotAI* botAI) : GenericMageStrategy(b NextAction** FrostMageStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("frostbolt", ACTION_DEFAULT + 0.1f), - new NextAction("shoot", ACTION_DEFAULT), - nullptr); - + return NextAction::array(0, new NextAction("frostbolt", ACTION_DEFAULT + 0.1f), + new NextAction("shoot", ACTION_DEFAULT), nullptr); } void FrostMageStrategy::InitTriggers(std::vector& triggers) @@ -68,36 +68,41 @@ void FrostMageStrategy::InitTriggers(std::vector& triggers) GenericMageStrategy::InitTriggers(triggers); triggers.push_back(new TriggerNode("icy veins", NextAction::array(0, new NextAction("icy veins", 50.0f), nullptr))); // No logic currently for cold snap usage.. possibly use right after icy veins drops off? - // triggers.push_back(new TriggerNode("cold snap", NextAction::array(0, new NextAction("cold snap", 50.0f), nullptr))); + // triggers.push_back(new TriggerNode("cold snap", NextAction::array(0, new NextAction("cold snap", 50.0f), + // nullptr))); - triggers.push_back(new TriggerNode("no pet", NextAction::array(0, new NextAction("summon water elemental", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("has pet", NextAction::array(0, new NextAction("toggle pet spell", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("ice barrier", NextAction::array(0, new NextAction("ice barrier", ACTION_NORMAL), nullptr))); - - triggers.push_back(new TriggerNode("brain freeze", NextAction::array(0, new NextAction("frostfire bolt", ACTION_NORMAL + 3), nullptr))); + triggers.push_back(new TriggerNode( + "no pet", NextAction::array(0, new NextAction("summon water elemental", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("has pet", NextAction::array(0, new NextAction("toggle pet spell", ACTION_HIGH + 1), nullptr))); + triggers.push_back( + new TriggerNode("ice barrier", NextAction::array(0, new NextAction("ice barrier", ACTION_NORMAL), nullptr))); + + triggers.push_back(new TriggerNode( + "brain freeze", NextAction::array(0, new NextAction("frostfire bolt", ACTION_NORMAL + 3), nullptr))); // Combo cast the last charge of fingers of frost for double crits. // Should only do this on the final charge of FoF. - triggers.push_back(new TriggerNode("fingers of frost single", NextAction::array(0, - new NextAction("frostbolt", ACTION_NORMAL + 2), - new NextAction("deep freeze", ACTION_NORMAL + 1), - nullptr))); + triggers.push_back(new TriggerNode("fingers of frost single", + NextAction::array(0, new NextAction("frostbolt", ACTION_NORMAL + 2), + new NextAction("deep freeze", ACTION_NORMAL + 1), nullptr))); // May not need this, frostbolt is the default action so probably don't need to specify. - // Maybe uncomment if you find the mage is prioritising auxillary spells while this buff is up, and wasting the proc. - // triggers.push_back(new TriggerNode("fingers of frost double", NextAction::array(0, new NextAction("frostbolt", ACTION_NORMAL), nullptr))); + // Maybe uncomment if you find the mage is prioritising auxillary spells while this buff is up, and wasting the + // proc. triggers.push_back(new TriggerNode("fingers of frost double", NextAction::array(0, new + // NextAction("frostbolt", ACTION_NORMAL), nullptr))); // Same 2-spell combo for various freeze procs - triggers.push_back(new TriggerNode("frost nova on target", NextAction::array(0, - new NextAction("frostbolt", ACTION_NORMAL + 2), - new NextAction("deep freeze", ACTION_NORMAL + 1), - nullptr))); - triggers.push_back(new TriggerNode("frostbite on target", NextAction::array(0, - new NextAction("frostbolt", ACTION_NORMAL + 2), - new NextAction("deep freeze", ACTION_NORMAL + 1), - nullptr))); + triggers.push_back(new TriggerNode("frost nova on target", + NextAction::array(0, new NextAction("frostbolt", ACTION_NORMAL + 2), + new NextAction("deep freeze", ACTION_NORMAL + 1), nullptr))); + triggers.push_back(new TriggerNode("frostbite on target", + NextAction::array(0, new NextAction("frostbolt", ACTION_NORMAL + 2), + new NextAction("deep freeze", ACTION_NORMAL + 1), nullptr))); } void FrostMageAoeStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("blizzard", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("light aoe", NextAction::array(0, new NextAction("cone of cold", ACTION_HIGH + 1), nullptr))); + triggers.push_back( + new TriggerNode("medium aoe", NextAction::array(0, new NextAction("blizzard", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("light aoe", NextAction::array(0, new NextAction("cone of cold", ACTION_HIGH + 1), nullptr))); } diff --git a/src/strategy/mage/FrostMageStrategy.h b/src/strategy/mage/FrostMageStrategy.h index f000fe04..17a1fe40 100644 --- a/src/strategy/mage/FrostMageStrategy.h +++ b/src/strategy/mage/FrostMageStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_FROSTMAGESTRATEGY_H @@ -11,21 +12,21 @@ class PlayerbotAI; class FrostMageStrategy : public GenericMageStrategy { - public: - FrostMageStrategy(PlayerbotAI* botAI); +public: + FrostMageStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "frost"; } - NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "frost"; } + NextAction** getDefaultActions() override; }; class FrostMageAoeStrategy : public CombatStrategy { - public: - FrostMageAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + FrostMageAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "frost aoe"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "frost aoe"; } }; #endif diff --git a/src/strategy/mage/GenericMageNonCombatStrategy.cpp b/src/strategy/mage/GenericMageNonCombatStrategy.cpp index f228b11a..963d9edb 100644 --- a/src/strategy/mage/GenericMageNonCombatStrategy.cpp +++ b/src/strategy/mage/GenericMageNonCombatStrategy.cpp @@ -1,44 +1,46 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericMageNonCombatStrategy.h" + #include "Playerbots.h" class GenericMageNonCombatStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericMageNonCombatStrategyActionNodeFactory() - { - creators["molten armor"] = &molten_armor; - creators["mage armor"] = &mage_armor; - creators["ice armor"] = &ice_armor; - } +public: + GenericMageNonCombatStrategyActionNodeFactory() + { + creators["molten armor"] = &molten_armor; + creators["mage armor"] = &mage_armor; + creators["ice armor"] = &ice_armor; + } - private: - static ActionNode* molten_armor([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("molten armor", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("mage armor"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* molten_armor([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("molten armor", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("mage armor"), nullptr), + /*C*/ nullptr); + } - static ActionNode* mage_armor([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("mage armor", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("ice armor"), nullptr), - /*C*/ nullptr); - } + static ActionNode* mage_armor([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("mage armor", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("ice armor"), nullptr), + /*C*/ nullptr); + } - static ActionNode* ice_armor([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("ice armor", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("frost armor"), nullptr), - /*C*/ nullptr); - } + static ActionNode* ice_armor([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("ice armor", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("frost armor"), nullptr), + /*C*/ nullptr); + } }; GenericMageNonCombatStrategy::GenericMageNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) @@ -50,25 +52,32 @@ void GenericMageNonCombatStrategy::InitTriggers(std::vector& trigg { NonCombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("arcane intellect", NextAction::array(0, new NextAction("arcane intellect", 21.0f), nullptr))); - // triggers.push_back(new TriggerNode("no drink", NextAction::array(0, new NextAction("conjure water", 16.0f), nullptr))); - // triggers.push_back(new TriggerNode("no food", NextAction::array(0, new NextAction("conjure food", 15.0f), nullptr))); + triggers.push_back( + new TriggerNode("arcane intellect", NextAction::array(0, new NextAction("arcane intellect", 21.0f), nullptr))); + // triggers.push_back(new TriggerNode("no drink", NextAction::array(0, new NextAction("conjure water", 16.0f), + // nullptr))); triggers.push_back(new TriggerNode("no food", NextAction::array(0, new NextAction("conjure + // food", 15.0f), nullptr))); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("apply oil", 1.0f), nullptr))); } void MageBuffManaStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("mage armor", NextAction::array(0, new NextAction("mage armor", 19.0f), nullptr))); + triggers.push_back( + new TriggerNode("mage armor", NextAction::array(0, new NextAction("mage armor", 19.0f), nullptr))); } void MageBuffDpsStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("mage armor", NextAction::array(0, new NextAction("molten armor", 19.0f), nullptr))); + triggers.push_back( + new TriggerNode("mage armor", NextAction::array(0, new NextAction("molten armor", 19.0f), nullptr))); } void MageBuffStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("arcane intellect on party", NextAction::array(0, new NextAction("arcane intellect on party", 20.0f), nullptr))); - // triggers.push_back(new TriggerNode("give water", NextAction::array(0, new NextAction("give water", 14.0f), nullptr))); - // triggers.push_back(new TriggerNode("give food", NextAction::array(0, new NextAction("give food", 13.0f), nullptr))); + triggers.push_back( + new TriggerNode("arcane intellect on party", + NextAction::array(0, new NextAction("arcane intellect on party", 20.0f), nullptr))); + // triggers.push_back(new TriggerNode("give water", NextAction::array(0, new NextAction("give water", 14.0f), + // nullptr))); triggers.push_back(new TriggerNode("give food", NextAction::array(0, new NextAction("give + // food", 13.0f), nullptr))); } diff --git a/src/strategy/mage/GenericMageNonCombatStrategy.h b/src/strategy/mage/GenericMageNonCombatStrategy.h index 65a87db7..81cb06eb 100644 --- a/src/strategy/mage/GenericMageNonCombatStrategy.h +++ b/src/strategy/mage/GenericMageNonCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICMAGENONCOMBATSTRATEGY_H @@ -11,38 +12,38 @@ class PlayerbotAI; class GenericMageNonCombatStrategy : public NonCombatStrategy { - public: - GenericMageNonCombatStrategy(PlayerbotAI* botAI); +public: + GenericMageNonCombatStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "nc"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "nc"; } + void InitTriggers(std::vector& triggers) override; }; class MageBuffManaStrategy : public Strategy { - public: - MageBuffManaStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + MageBuffManaStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "bmana"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bmana"; } }; class MageBuffDpsStrategy : public Strategy { - public: - MageBuffDpsStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + MageBuffDpsStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "bdps"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bdps"; } }; class MageBuffStrategy : public Strategy { - public: - MageBuffStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + MageBuffStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "buff"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "buff"; } }; #endif diff --git a/src/strategy/mage/GenericMageStrategy.cpp b/src/strategy/mage/GenericMageStrategy.cpp index 8c772ab4..ad5862cf 100644 --- a/src/strategy/mage/GenericMageStrategy.cpp +++ b/src/strategy/mage/GenericMageStrategy.cpp @@ -1,152 +1,154 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericMageStrategy.h" + #include "Playerbots.h" #include "RangedCombatStrategy.h" class GenericMageStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericMageStrategyActionNodeFactory() - { - creators["frostbolt"] = &frostbolt; - creators["frostfire bolt"] = &frostfire_bolt; - creators["ice lance"] = &ice_lance; - creators["fire blast"] = &fire_blast; - creators["scorch"] = &scorch; - creators["frost nova"] = &frost_nova; - creators["cone of cold"] = &cone_of_cold; - creators["icy veins"] = &icy_veins; - creators["combustion"] = &combustion; - creators["evocation"] = &evocation; - creators["dragon's breath"] = &dragons_breath; - creators["blast wave"] = &blast_wave; - creators["remove curse"] = &remove_curse; - creators["remove curse on party"] = &remove_curse_on_party; - creators["fireball"] = &fireball; - } +public: + GenericMageStrategyActionNodeFactory() + { + creators["frostbolt"] = &frostbolt; + creators["frostfire bolt"] = &frostfire_bolt; + creators["ice lance"] = &ice_lance; + creators["fire blast"] = &fire_blast; + creators["scorch"] = &scorch; + creators["frost nova"] = &frost_nova; + creators["cone of cold"] = &cone_of_cold; + creators["icy veins"] = &icy_veins; + creators["combustion"] = &combustion; + creators["evocation"] = &evocation; + creators["dragon's breath"] = &dragons_breath; + creators["blast wave"] = &blast_wave; + creators["remove curse"] = &remove_curse; + creators["remove curse on party"] = &remove_curse_on_party; + creators["fireball"] = &fireball; + } - private: - static ActionNode* frostbolt([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("frostbolt", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* frostbolt([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("frostbolt", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), + /*C*/ nullptr); + } - static ActionNode* frostfire_bolt([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("frostfire bolt", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("fireball"), nullptr), - /*C*/ nullptr); - } + static ActionNode* frostfire_bolt([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("frostfire bolt", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("fireball"), nullptr), + /*C*/ nullptr); + } - static ActionNode* ice_lance([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("ice lance", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* ice_lance([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("ice lance", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* fire_blast([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("fire blast", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("scorch"), nullptr), - /*C*/ nullptr); - } + static ActionNode* fire_blast([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("fire blast", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("scorch"), nullptr), + /*C*/ nullptr); + } - static ActionNode* scorch([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("scorch", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), - /*C*/ nullptr); - } + static ActionNode* scorch([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("scorch", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), + /*C*/ nullptr); + } - static ActionNode* frost_nova([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("frost nova", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* frost_nova([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("frost nova", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* cone_of_cold([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("cone of cold", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* cone_of_cold([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("cone of cold", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* icy_veins([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("icy veins", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* icy_veins([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("icy veins", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* combustion([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("combustion", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* combustion([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("combustion", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* evocation([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("evocation", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("mana potion"), nullptr), - /*C*/ nullptr); - } + static ActionNode* evocation([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("evocation", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("mana potion"), nullptr), + /*C*/ nullptr); + } - static ActionNode* dragons_breath([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("dragon's breath", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("blast wave"), nullptr), - /*C*/ NextAction::array(0, new NextAction("flamestrike", 71.0f), nullptr)); - } + static ActionNode* dragons_breath([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("dragon's breath", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("blast wave"), nullptr), + /*C*/ NextAction::array(0, new NextAction("flamestrike", 71.0f), nullptr)); + } - static ActionNode* blast_wave([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("blast wave", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("frost nova"), nullptr), - /*C*/ NextAction::array(0, new NextAction("flamestrike", 71.0f), nullptr)); - } + static ActionNode* blast_wave([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("blast wave", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("frost nova"), nullptr), + /*C*/ NextAction::array(0, new NextAction("flamestrike", 71.0f), nullptr)); + } - static ActionNode* remove_curse([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("remove curse", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("remove lesser curse"), nullptr), - /*C*/ nullptr); - } + static ActionNode* remove_curse([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("remove curse", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("remove lesser curse"), nullptr), + /*C*/ nullptr); + } - static ActionNode* remove_curse_on_party([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("remove curse on party", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("remove lesser curse on party"), nullptr), - /*C*/ nullptr); - } - static ActionNode* fireball([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("fireball", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), - /*C*/ nullptr); - } + static ActionNode* remove_curse_on_party([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("remove curse on party", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("remove lesser curse on party"), nullptr), + /*C*/ nullptr); + } + static ActionNode* fireball([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("fireball", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), + /*C*/ nullptr); + } }; GenericMageStrategy::GenericMageStrategy(PlayerbotAI* botAI) : RangedCombatStrategy(botAI) @@ -158,29 +160,44 @@ void GenericMageStrategy::InitTriggers(std::vector& triggers) { RangedCombatStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", ACTION_MOVE + 9), nullptr))); - triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new NextAction("frost nova", 50.0f), nullptr))); - triggers.push_back(new TriggerNode("counterspell on enemy healer", NextAction::array(0, new NextAction("counterspell on enemy healer", 40.0f), nullptr))); - triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("ice block", 80.0f), nullptr))); - triggers.push_back(new TriggerNode("spellsteal", NextAction::array(0, new NextAction("spellsteal", 40.0f), nullptr))); - triggers.push_back(new TriggerNode("medium threat", NextAction::array(0, new NextAction("invisibility", 60.0f), nullptr))); - triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("evocation", ACTION_EMERGENCY + 5), nullptr))); - triggers.push_back(new TriggerNode("fire ward", NextAction::array(0, new NextAction("fire ward", ACTION_EMERGENCY), nullptr))); - triggers.push_back(new TriggerNode("frost ward", NextAction::array(0, new NextAction("frost ward", ACTION_EMERGENCY), nullptr))); + // triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", + // ACTION_MOVE + 9), nullptr))); + triggers.push_back( + new TriggerNode("enemy is close", NextAction::array(0, new NextAction("frost nova", 50.0f), nullptr))); + triggers.push_back( + new TriggerNode("counterspell on enemy healer", + NextAction::array(0, new NextAction("counterspell on enemy healer", 40.0f), nullptr))); + triggers.push_back( + new TriggerNode("critical health", NextAction::array(0, new NextAction("ice block", 80.0f), nullptr))); + triggers.push_back( + new TriggerNode("spellsteal", NextAction::array(0, new NextAction("spellsteal", 40.0f), nullptr))); + triggers.push_back( + new TriggerNode("medium threat", NextAction::array(0, new NextAction("invisibility", 60.0f), nullptr))); + triggers.push_back( + new TriggerNode("low mana", NextAction::array(0, new NextAction("evocation", ACTION_EMERGENCY + 5), nullptr))); + triggers.push_back( + new TriggerNode("fire ward", NextAction::array(0, new NextAction("fire ward", ACTION_EMERGENCY), nullptr))); + triggers.push_back( + new TriggerNode("frost ward", NextAction::array(0, new NextAction("frost ward", ACTION_EMERGENCY), nullptr))); } void MageCureStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("remove curse", NextAction::array(0, new NextAction("remove curse", 41.0f), nullptr))); - triggers.push_back(new TriggerNode("remove curse on party", NextAction::array(0, new NextAction("remove curse on party", 40.0f), nullptr))); + triggers.push_back( + new TriggerNode("remove curse", NextAction::array(0, new NextAction("remove curse", 41.0f), nullptr))); + triggers.push_back(new TriggerNode("remove curse on party", + NextAction::array(0, new NextAction("remove curse on party", 40.0f), nullptr))); } void MageBoostStrategy::InitTriggers(std::vector& triggers) { triggers.push_back(new TriggerNode("icy veins", NextAction::array(0, new NextAction("icy veins", 50.0f), nullptr))); - triggers.push_back(new TriggerNode("presence of mind", NextAction::array(0, new NextAction("presence of mind", 42.0f), nullptr))); - // triggers.push_back(new TriggerNode("arcane power", NextAction::array(0, new NextAction("arcane power", 41.0f), nullptr))); - triggers.push_back(new TriggerNode("mirror image", NextAction::array(0, new NextAction("mirror image", 41.0f), nullptr))); + triggers.push_back( + new TriggerNode("presence of mind", NextAction::array(0, new NextAction("presence of mind", 42.0f), nullptr))); + // triggers.push_back(new TriggerNode("arcane power", NextAction::array(0, new NextAction("arcane power", 41.0f), + // nullptr))); + triggers.push_back( + new TriggerNode("mirror image", NextAction::array(0, new NextAction("mirror image", 41.0f), nullptr))); } void MageCcStrategy::InitTriggers(std::vector& triggers) diff --git a/src/strategy/mage/GenericMageStrategy.h b/src/strategy/mage/GenericMageStrategy.h index 54334366..4657eb95 100644 --- a/src/strategy/mage/GenericMageStrategy.h +++ b/src/strategy/mage/GenericMageStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICMAGESTRATEGY_H @@ -12,39 +13,42 @@ class PlayerbotAI; class GenericMageStrategy : public RangedCombatStrategy { - public: - GenericMageStrategy(PlayerbotAI* botAI); +public: + GenericMageStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "mage"; } - void InitTriggers(std::vector& triggers) override; - uint32 GetType() const override { return RangedCombatStrategy::GetType() | STRATEGY_TYPE_RANGED | STRATEGY_TYPE_DPS; } + std::string const getName() override { return "mage"; } + void InitTriggers(std::vector& triggers) override; + uint32 GetType() const override + { + return RangedCombatStrategy::GetType() | STRATEGY_TYPE_RANGED | STRATEGY_TYPE_DPS; + } }; class MageCureStrategy : public Strategy { - public: - MageCureStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + MageCureStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "cure"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cure"; } }; class MageBoostStrategy : public Strategy { - public: - MageBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + MageBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "boost"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "boost"; } }; class MageCcStrategy : public Strategy { - public: - MageCcStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + MageCcStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "cc"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cc"; } }; #endif diff --git a/src/strategy/mage/MageActions.cpp b/src/strategy/mage/MageActions.cpp index 455bad57..beb82636 100644 --- a/src/strategy/mage/MageActions.cpp +++ b/src/strategy/mage/MageActions.cpp @@ -1,15 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "MageActions.h" + #include "Playerbots.h" #include "ServerFacade.h" -Value* CastPolymorphAction::GetTargetValue() -{ - return context->GetValue("cc target", getName()); -} +Value* CastPolymorphAction::GetTargetValue() { return context->GetValue("cc target", getName()); } bool CastFrostNovaAction::isUseful() { diff --git a/src/strategy/mage/MageActions.h b/src/strategy/mage/MageActions.h index a9ae6ff9..844bea67 100644 --- a/src/strategy/mage/MageActions.h +++ b/src/strategy/mage/MageActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MAGEACTIONS_H @@ -15,152 +16,152 @@ BUFF_ACTION(CastFrostWardAction, "frost ward"); class CastFireballAction : public CastSpellAction { - public: - CastFireballAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "fireball") { } +public: + CastFireballAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "fireball") {} }; class CastScorchAction : public CastSpellAction { - public: - CastScorchAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "scorch") { } +public: + CastScorchAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "scorch") {} }; class CastFireBlastAction : public CastSpellAction { - public: - CastFireBlastAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "fire blast") { } +public: + CastFireBlastAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "fire blast") {} }; class CastArcaneBlastAction : public CastBuffSpellAction { - public: - CastArcaneBlastAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "arcane blast") { } - std::string const GetTargetName() override { return "current target"; } +public: + CastArcaneBlastAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "arcane blast") {} + std::string const GetTargetName() override { return "current target"; } }; class CastArcaneBarrageAction : public CastSpellAction { - public: - CastArcaneBarrageAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "arcane barrage") { } +public: + CastArcaneBarrageAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "arcane barrage") {} }; class CastArcaneMissilesAction : public CastSpellAction { - public: - CastArcaneMissilesAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "arcane missiles") { } +public: + CastArcaneMissilesAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "arcane missiles") {} }; class CastPyroblastAction : public CastSpellAction { - public: - CastPyroblastAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "pyroblast") { } +public: + CastPyroblastAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "pyroblast") {} }; class CastFlamestrikeAction : public CastSpellAction { - public: - CastFlamestrikeAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "flamestrike") { } - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } +public: + CastFlamestrikeAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "flamestrike") {} + ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } }; class CastFrostNovaAction : public CastSpellAction { - public: - CastFrostNovaAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "frost nova") { } - bool isUseful() override; +public: + CastFrostNovaAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "frost nova") {} + bool isUseful() override; }; class CastFrostboltAction : public CastSpellAction { - public: - CastFrostboltAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "frostbolt") { } +public: + CastFrostboltAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "frostbolt") {} }; class CastFrostfireBoltAction : public CastSpellAction { - public: - CastFrostfireBoltAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "frostfire bolt") { } +public: + CastFrostfireBoltAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "frostfire bolt") {} }; class CastIceLanceAction : public CastSpellAction { - public: - CastIceLanceAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "ice lance") { } +public: + CastIceLanceAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "ice lance") {} }; class CastDeepFreezeAction : public CastSpellAction { - public: - CastDeepFreezeAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "deep freeze") { } +public: + CastDeepFreezeAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "deep freeze") {} }; class CastBlizzardAction : public CastSpellAction { - public: - CastBlizzardAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "blizzard") { } - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } +public: + CastBlizzardAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "blizzard") {} + ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } }; class CastConeOfColdAction : public CastSpellAction { - public: - CastConeOfColdAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "cone of cold") { } - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } - bool isUseful() override; +public: + CastConeOfColdAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "cone of cold") {} + ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } + bool isUseful() override; }; class CastArcaneIntellectAction : public CastBuffSpellAction { - public: - CastArcaneIntellectAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "arcane intellect") { } +public: + CastArcaneIntellectAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "arcane intellect") {} }; class CastArcaneIntellectOnPartyAction : public BuffOnPartyAction { - public: - CastArcaneIntellectOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "arcane intellect") { } +public: + CastArcaneIntellectOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "arcane intellect") {} }; class CastRemoveCurseAction : public CastCureSpellAction { - public: - CastRemoveCurseAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "remove curse") { } +public: + CastRemoveCurseAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "remove curse") {} }; class CastRemoveLesserCurseAction : public CastCureSpellAction { - public: - CastRemoveLesserCurseAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "remove lesser curse") { } +public: + CastRemoveLesserCurseAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "remove lesser curse") {} }; class CastIcyVeinsAction : public CastBuffSpellAction { - public: - CastIcyVeinsAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "icy veins") { } +public: + CastIcyVeinsAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "icy veins") {} }; class CastColdSnapAction : public CastBuffSpellAction { - public: - CastColdSnapAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "cold snap") { } +public: + CastColdSnapAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "cold snap") {} }; class CastIceBarrierAction : public CastBuffSpellAction { - public: - CastIceBarrierAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "ice barrier") { } +public: + CastIceBarrierAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "ice barrier") {} }; class CastSummonWaterElementalAction : public CastBuffSpellAction { - public: - CastSummonWaterElementalAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "summon water elemental") { } +public: + CastSummonWaterElementalAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "summon water elemental") {} }; class CastCombustionAction : public CastBuffSpellAction { - public: - CastCombustionAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "combustion") { } +public: + CastCombustionAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "combustion") {} }; BEGIN_SPELL_ACTION(CastCounterspellAction, "counterspell") @@ -168,126 +169,129 @@ END_SPELL_ACTION() class CastRemoveCurseOnPartyAction : public CurePartyMemberAction { - public: - CastRemoveCurseOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "remove curse", DISPEL_CURSE) { } +public: + CastRemoveCurseOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "remove curse", DISPEL_CURSE) {} }; class CastRemoveLesserCurseOnPartyAction : public CurePartyMemberAction { - public: - CastRemoveLesserCurseOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "remove lesser curse", DISPEL_CURSE) { } +public: + CastRemoveLesserCurseOnPartyAction(PlayerbotAI* botAI) + : CurePartyMemberAction(botAI, "remove lesser curse", DISPEL_CURSE) + { + } }; class CastConjureFoodAction : public CastBuffSpellAction { - public: - CastConjureFoodAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "conjure food") { } +public: + CastConjureFoodAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "conjure food") {} }; class CastConjureWaterAction : public CastBuffSpellAction { - public: - CastConjureWaterAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "conjure water") { } +public: + CastConjureWaterAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "conjure water") {} }; class CastIceBlockAction : public CastBuffSpellAction { - public: - CastIceBlockAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "ice block") { } +public: + CastIceBlockAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "ice block") {} }; class CastMoltenArmorAction : public CastBuffSpellAction { - public: - CastMoltenArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "molten armor") { } +public: + CastMoltenArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "molten armor") {} }; class CastMageArmorAction : public CastBuffSpellAction { - public: - CastMageArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "mage armor") { } +public: + CastMageArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "mage armor") {} }; class CastIceArmorAction : public CastBuffSpellAction { - public: - CastIceArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "ice armor") { } +public: + CastIceArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "ice armor") {} }; class CastFrostArmorAction : public CastBuffSpellAction { - public: - CastFrostArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "frost armor") { } +public: + CastFrostArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "frost armor") {} }; class CastPolymorphAction : public CastBuffSpellAction { - public: - CastPolymorphAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "polymorph") { } - Value* GetTargetValue() override; +public: + CastPolymorphAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "polymorph") {} + Value* GetTargetValue() override; }; class CastSpellstealAction : public CastSpellAction { - public: - CastSpellstealAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "spellsteal") { } +public: + CastSpellstealAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "spellsteal") {} }; class CastLivingBombAction : public CastDebuffSpellAction { - public: - CastLivingBombAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "living bomb", true) { } +public: + CastLivingBombAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "living bomb", true) {} }; class CastDragonsBreathAction : public CastSpellAction { - public: - CastDragonsBreathAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "dragon's breath") { } - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } +public: + CastDragonsBreathAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "dragon's breath") {} + ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } }; class CastBlastWaveAction : public CastSpellAction { - public: - CastBlastWaveAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "blast wave") { } - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } +public: + CastBlastWaveAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "blast wave") {} + ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } }; class CastInvisibilityAction : public CastBuffSpellAction { - public: - CastInvisibilityAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "invisibility") { } +public: + CastInvisibilityAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "invisibility") {} }; class CastEvocationAction : public CastSpellAction { - public: - CastEvocationAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "evocation") { } - std::string const GetTargetName() override { return "self target"; } +public: + CastEvocationAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "evocation") {} + std::string const GetTargetName() override { return "self target"; } }; class CastCounterspellOnEnemyHealerAction : public CastSpellOnEnemyHealerAction { - public: - CastCounterspellOnEnemyHealerAction(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, "counterspell") { } +public: + CastCounterspellOnEnemyHealerAction(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, "counterspell") {} }; class CastArcanePowerAction : public CastBuffSpellAction { - public: - CastArcanePowerAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "arcane power") { } +public: + CastArcanePowerAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "arcane power") {} }; class CastPresenceOfMindAction : public CastBuffSpellAction { - public: - CastPresenceOfMindAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "presence of mind") { } +public: + CastPresenceOfMindAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "presence of mind") {} }; class CastMirrorImageAction : public CastBuffSpellAction { - public: - CastMirrorImageAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "mirror image") {} +public: + CastMirrorImageAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "mirror image") {} }; #endif diff --git a/src/strategy/mage/MageAiObjectContext.cpp b/src/strategy/mage/MageAiObjectContext.cpp index 8e8af0b1..23db7aa6 100644 --- a/src/strategy/mage/MageAiObjectContext.cpp +++ b/src/strategy/mage/MageAiObjectContext.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "MageAiObjectContext.h" + #include "ArcaneMageStrategy.h" #include "FireMageStrategy.h" #include "FrostMageStrategy.h" @@ -10,239 +12,245 @@ #include "MageActions.h" #include "MageTriggers.h" #include "NamedObjectContext.h" -#include "PullStrategy.h" #include "Playerbots.h" +#include "PullStrategy.h" class MageStrategyFactoryInternal : public NamedObjectContext { - public: - MageStrategyFactoryInternal() - { - creators["nc"] = &MageStrategyFactoryInternal::nc; - creators["pull"] = &MageStrategyFactoryInternal::pull; - creators["fire aoe"] = &MageStrategyFactoryInternal::fire_aoe; - creators["frost aoe"] = &MageStrategyFactoryInternal::frost_aoe; - creators["arcane aoe"] = &MageStrategyFactoryInternal::arcane_aoe; - creators["cure"] = &MageStrategyFactoryInternal::cure; - creators["buff"] = &MageStrategyFactoryInternal::buff; - creators["boost"] = &MageStrategyFactoryInternal::boost; - creators["cc"] = &MageStrategyFactoryInternal::cc; - } +public: + MageStrategyFactoryInternal() + { + creators["nc"] = &MageStrategyFactoryInternal::nc; + creators["pull"] = &MageStrategyFactoryInternal::pull; + creators["fire aoe"] = &MageStrategyFactoryInternal::fire_aoe; + creators["frost aoe"] = &MageStrategyFactoryInternal::frost_aoe; + creators["arcane aoe"] = &MageStrategyFactoryInternal::arcane_aoe; + creators["cure"] = &MageStrategyFactoryInternal::cure; + creators["buff"] = &MageStrategyFactoryInternal::buff; + creators["boost"] = &MageStrategyFactoryInternal::boost; + creators["cc"] = &MageStrategyFactoryInternal::cc; + } - private: - static Strategy* nc(PlayerbotAI* botAI) { return new GenericMageNonCombatStrategy(botAI); } - static Strategy* pull(PlayerbotAI* botAI) { return new PullStrategy(botAI, "shoot"); } - static Strategy* fire_aoe(PlayerbotAI* botAI) { return new FireMageAoeStrategy(botAI); } - static Strategy* frost_aoe(PlayerbotAI* botAI) { return new FrostMageAoeStrategy(botAI); } - static Strategy* arcane_aoe(PlayerbotAI* botAI) { return new ArcaneMageAoeStrategy(botAI); } - static Strategy* cure(PlayerbotAI* botAI) { return new MageCureStrategy(botAI); } - static Strategy* buff(PlayerbotAI* botAI) { return new MageBuffStrategy(botAI); } - static Strategy* boost(PlayerbotAI* botAI) { return new MageBoostStrategy(botAI); } - static Strategy* cc(PlayerbotAI* botAI) { return new MageCcStrategy(botAI); } +private: + static Strategy* nc(PlayerbotAI* botAI) { return new GenericMageNonCombatStrategy(botAI); } + static Strategy* pull(PlayerbotAI* botAI) { return new PullStrategy(botAI, "shoot"); } + static Strategy* fire_aoe(PlayerbotAI* botAI) { return new FireMageAoeStrategy(botAI); } + static Strategy* frost_aoe(PlayerbotAI* botAI) { return new FrostMageAoeStrategy(botAI); } + static Strategy* arcane_aoe(PlayerbotAI* botAI) { return new ArcaneMageAoeStrategy(botAI); } + static Strategy* cure(PlayerbotAI* botAI) { return new MageCureStrategy(botAI); } + static Strategy* buff(PlayerbotAI* botAI) { return new MageBuffStrategy(botAI); } + static Strategy* boost(PlayerbotAI* botAI) { return new MageBoostStrategy(botAI); } + static Strategy* cc(PlayerbotAI* botAI) { return new MageCcStrategy(botAI); } }; class MageCombatStrategyFactoryInternal : public NamedObjectContext { - public: - MageCombatStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["frost"] = &MageCombatStrategyFactoryInternal::frost; - creators["fire"] = &MageCombatStrategyFactoryInternal::fire; - creators["arcane"] = &MageCombatStrategyFactoryInternal::arcane; - } +public: + MageCombatStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["frost"] = &MageCombatStrategyFactoryInternal::frost; + creators["fire"] = &MageCombatStrategyFactoryInternal::fire; + creators["arcane"] = &MageCombatStrategyFactoryInternal::arcane; + } - private: - static Strategy* frost(PlayerbotAI* botAI) { return new FrostMageStrategy(botAI); } - static Strategy* fire(PlayerbotAI* botAI) { return new FireMageStrategy(botAI); } - static Strategy* arcane(PlayerbotAI* botAI) { return new ArcaneMageStrategy(botAI); } +private: + static Strategy* frost(PlayerbotAI* botAI) { return new FrostMageStrategy(botAI); } + static Strategy* fire(PlayerbotAI* botAI) { return new FireMageStrategy(botAI); } + static Strategy* arcane(PlayerbotAI* botAI) { return new ArcaneMageStrategy(botAI); } }; class MageBuffStrategyFactoryInternal : public NamedObjectContext { - public: - MageBuffStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["bmana"] = &MageBuffStrategyFactoryInternal::bmana; - creators["bdps"] = &MageBuffStrategyFactoryInternal::bdps; - } +public: + MageBuffStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["bmana"] = &MageBuffStrategyFactoryInternal::bmana; + creators["bdps"] = &MageBuffStrategyFactoryInternal::bdps; + } - private: - static Strategy* bmana(PlayerbotAI* botAI) { return new MageBuffManaStrategy(botAI); } - static Strategy* bdps(PlayerbotAI* botAI) { return new MageBuffDpsStrategy(botAI); } +private: + static Strategy* bmana(PlayerbotAI* botAI) { return new MageBuffManaStrategy(botAI); } + static Strategy* bdps(PlayerbotAI* botAI) { return new MageBuffDpsStrategy(botAI); } }; class MageTriggerFactoryInternal : public NamedObjectContext { - public: - MageTriggerFactoryInternal() - { - creators["fireball"] = &MageTriggerFactoryInternal::fireball; - creators["pyroblast"] = &MageTriggerFactoryInternal::pyroblast; - creators["combustion"] = &MageTriggerFactoryInternal::combustion; - creators["fingers of frost single"] = &MageTriggerFactoryInternal::fingers_of_frost_single; - creators["fingers of frost double"] = &MageTriggerFactoryInternal::fingers_of_frost_double; - creators["brain freeze"] = &MageTriggerFactoryInternal::brain_freeze; - creators["icy veins"] = &MageTriggerFactoryInternal::icy_veins; - creators["cold snap"] = &MageTriggerFactoryInternal::cold_snap; - creators["ice barrier"] = &MageTriggerFactoryInternal::ice_barrier; - creators["arcane intellect"] = &MageTriggerFactoryInternal::arcane_intellect; - creators["arcane intellect on party"] = &MageTriggerFactoryInternal::arcane_intellect_on_party; - creators["mage armor"] = &MageTriggerFactoryInternal::mage_armor; - creators["remove curse"] = &MageTriggerFactoryInternal::remove_curse; - creators["remove curse on party"] = &MageTriggerFactoryInternal::remove_curse_on_party; - creators["counterspell"] = &MageTriggerFactoryInternal::counterspell; - creators["polymorph"] = &MageTriggerFactoryInternal::polymorph; - creators["spellsteal"] = &MageTriggerFactoryInternal::spellsteal; - creators["hot streak"] = &MageTriggerFactoryInternal::hot_streak; - creators["living bomb"] = &MageTriggerFactoryInternal::living_bomb; - creators["missile barrage"] = &MageTriggerFactoryInternal::missile_barrage; - creators["arcane blast"] = &MageTriggerFactoryInternal::arcane_blast; - creators["counterspell on enemy healer"] = &MageTriggerFactoryInternal::counterspell_enemy_healer; - creators["arcane power"] = &MageTriggerFactoryInternal::arcane_power; - creators["presence of mind"] = &MageTriggerFactoryInternal::presence_of_mind; - creators["fire ward"] = &MageTriggerFactoryInternal::fire_ward; - creators["frost ward"] = &MageTriggerFactoryInternal::frost_ward; - creators["arcane blast stack"] = &MageTriggerFactoryInternal::arcane_blast_stack; - creators["mirror image"] = &MageTriggerFactoryInternal::mirror_image; - creators["frost nova on target"] = &MageTriggerFactoryInternal::frost_nova_on_target; - creators["frostbite on target"] = &MageTriggerFactoryInternal::frostbite_on_target; - } +public: + MageTriggerFactoryInternal() + { + creators["fireball"] = &MageTriggerFactoryInternal::fireball; + creators["pyroblast"] = &MageTriggerFactoryInternal::pyroblast; + creators["combustion"] = &MageTriggerFactoryInternal::combustion; + creators["fingers of frost single"] = &MageTriggerFactoryInternal::fingers_of_frost_single; + creators["fingers of frost double"] = &MageTriggerFactoryInternal::fingers_of_frost_double; + creators["brain freeze"] = &MageTriggerFactoryInternal::brain_freeze; + creators["icy veins"] = &MageTriggerFactoryInternal::icy_veins; + creators["cold snap"] = &MageTriggerFactoryInternal::cold_snap; + creators["ice barrier"] = &MageTriggerFactoryInternal::ice_barrier; + creators["arcane intellect"] = &MageTriggerFactoryInternal::arcane_intellect; + creators["arcane intellect on party"] = &MageTriggerFactoryInternal::arcane_intellect_on_party; + creators["mage armor"] = &MageTriggerFactoryInternal::mage_armor; + creators["remove curse"] = &MageTriggerFactoryInternal::remove_curse; + creators["remove curse on party"] = &MageTriggerFactoryInternal::remove_curse_on_party; + creators["counterspell"] = &MageTriggerFactoryInternal::counterspell; + creators["polymorph"] = &MageTriggerFactoryInternal::polymorph; + creators["spellsteal"] = &MageTriggerFactoryInternal::spellsteal; + creators["hot streak"] = &MageTriggerFactoryInternal::hot_streak; + creators["living bomb"] = &MageTriggerFactoryInternal::living_bomb; + creators["missile barrage"] = &MageTriggerFactoryInternal::missile_barrage; + creators["arcane blast"] = &MageTriggerFactoryInternal::arcane_blast; + creators["counterspell on enemy healer"] = &MageTriggerFactoryInternal::counterspell_enemy_healer; + creators["arcane power"] = &MageTriggerFactoryInternal::arcane_power; + creators["presence of mind"] = &MageTriggerFactoryInternal::presence_of_mind; + creators["fire ward"] = &MageTriggerFactoryInternal::fire_ward; + creators["frost ward"] = &MageTriggerFactoryInternal::frost_ward; + creators["arcane blast stack"] = &MageTriggerFactoryInternal::arcane_blast_stack; + creators["mirror image"] = &MageTriggerFactoryInternal::mirror_image; + creators["frost nova on target"] = &MageTriggerFactoryInternal::frost_nova_on_target; + creators["frostbite on target"] = &MageTriggerFactoryInternal::frostbite_on_target; + } - private: - static Trigger* presence_of_mind(PlayerbotAI* botAI) { return new PresenceOfMindTrigger(botAI); } - static Trigger* frost_ward(PlayerbotAI* botAI) { return new FrostWardTrigger(botAI); } - static Trigger* fire_ward(PlayerbotAI* botAI) { return new FireWardTrigger(botAI); } - static Trigger* arcane_power(PlayerbotAI* botAI) { return new ArcanePowerTrigger(botAI); } - static Trigger* hot_streak(PlayerbotAI* botAI) { return new HotStreakTrigger(botAI); } - static Trigger* fireball(PlayerbotAI* botAI) { return new FireballTrigger(botAI); } - static Trigger* pyroblast(PlayerbotAI* botAI) { return new PyroblastTrigger(botAI); } - static Trigger* combustion(PlayerbotAI* botAI) { return new CombustionTrigger(botAI); } - static Trigger* fingers_of_frost_single(PlayerbotAI* botAI) { return new FingersOfFrostSingleTrigger(botAI); } - static Trigger* fingers_of_frost_double(PlayerbotAI* botAI) { return new FingersOfFrostDoubleTrigger(botAI); } - static Trigger* brain_freeze(PlayerbotAI* botAI) { return new BrainFreezeTrigger(botAI); } - static Trigger* icy_veins(PlayerbotAI* botAI) { return new IcyVeinsTrigger(botAI); } - static Trigger* cold_snap(PlayerbotAI* botAI) { return new ColdSnapTrigger(botAI); } - static Trigger* ice_barrier(PlayerbotAI* botAI) { return new IceBarrierTrigger(botAI); } - static Trigger* arcane_intellect(PlayerbotAI* botAI) { return new ArcaneIntellectTrigger(botAI); } - static Trigger* arcane_intellect_on_party(PlayerbotAI* botAI) { return new ArcaneIntellectOnPartyTrigger(botAI); } - static Trigger* mage_armor(PlayerbotAI* botAI) { return new MageArmorTrigger(botAI); } - static Trigger* remove_curse(PlayerbotAI* botAI) { return new RemoveCurseTrigger(botAI); } - static Trigger* remove_curse_on_party(PlayerbotAI* botAI) { return new PartyMemberRemoveCurseTrigger(botAI); } - static Trigger* counterspell(PlayerbotAI* botAI) { return new CounterspellInterruptSpellTrigger(botAI); } - static Trigger* polymorph(PlayerbotAI* botAI) { return new PolymorphTrigger(botAI); } - static Trigger* spellsteal(PlayerbotAI* botAI) { return new SpellstealTrigger(botAI); } - static Trigger* living_bomb(PlayerbotAI* botAI) { return new LivingBombTrigger(botAI); } - static Trigger* missile_barrage(PlayerbotAI* botAI) { return new MissileBarrageTrigger(botAI); } - static Trigger* arcane_blast(PlayerbotAI* botAI) { return new ArcaneBlastTrigger(botAI); } - static Trigger* counterspell_enemy_healer(PlayerbotAI* botAI) { return new CounterspellEnemyHealerTrigger(botAI); } - static Trigger* arcane_blast_stack(PlayerbotAI* botAI) { return new ArcaneBlastStackTrigger(botAI); } - static Trigger* mirror_image(PlayerbotAI* botAI) { return new MirrorImageTrigger(botAI); } - static Trigger* frost_nova_on_target(PlayerbotAI* botAI) { return new FrostNovaOnTargetTrigger(botAI); } - static Trigger* frostbite_on_target(PlayerbotAI* botAI) { return new FrostbiteOnTargetTrigger(botAI); } +private: + static Trigger* presence_of_mind(PlayerbotAI* botAI) { return new PresenceOfMindTrigger(botAI); } + static Trigger* frost_ward(PlayerbotAI* botAI) { return new FrostWardTrigger(botAI); } + static Trigger* fire_ward(PlayerbotAI* botAI) { return new FireWardTrigger(botAI); } + static Trigger* arcane_power(PlayerbotAI* botAI) { return new ArcanePowerTrigger(botAI); } + static Trigger* hot_streak(PlayerbotAI* botAI) { return new HotStreakTrigger(botAI); } + static Trigger* fireball(PlayerbotAI* botAI) { return new FireballTrigger(botAI); } + static Trigger* pyroblast(PlayerbotAI* botAI) { return new PyroblastTrigger(botAI); } + static Trigger* combustion(PlayerbotAI* botAI) { return new CombustionTrigger(botAI); } + static Trigger* fingers_of_frost_single(PlayerbotAI* botAI) { return new FingersOfFrostSingleTrigger(botAI); } + static Trigger* fingers_of_frost_double(PlayerbotAI* botAI) { return new FingersOfFrostDoubleTrigger(botAI); } + static Trigger* brain_freeze(PlayerbotAI* botAI) { return new BrainFreezeTrigger(botAI); } + static Trigger* icy_veins(PlayerbotAI* botAI) { return new IcyVeinsTrigger(botAI); } + static Trigger* cold_snap(PlayerbotAI* botAI) { return new ColdSnapTrigger(botAI); } + static Trigger* ice_barrier(PlayerbotAI* botAI) { return new IceBarrierTrigger(botAI); } + static Trigger* arcane_intellect(PlayerbotAI* botAI) { return new ArcaneIntellectTrigger(botAI); } + static Trigger* arcane_intellect_on_party(PlayerbotAI* botAI) { return new ArcaneIntellectOnPartyTrigger(botAI); } + static Trigger* mage_armor(PlayerbotAI* botAI) { return new MageArmorTrigger(botAI); } + static Trigger* remove_curse(PlayerbotAI* botAI) { return new RemoveCurseTrigger(botAI); } + static Trigger* remove_curse_on_party(PlayerbotAI* botAI) { return new PartyMemberRemoveCurseTrigger(botAI); } + static Trigger* counterspell(PlayerbotAI* botAI) { return new CounterspellInterruptSpellTrigger(botAI); } + static Trigger* polymorph(PlayerbotAI* botAI) { return new PolymorphTrigger(botAI); } + static Trigger* spellsteal(PlayerbotAI* botAI) { return new SpellstealTrigger(botAI); } + static Trigger* living_bomb(PlayerbotAI* botAI) { return new LivingBombTrigger(botAI); } + static Trigger* missile_barrage(PlayerbotAI* botAI) { return new MissileBarrageTrigger(botAI); } + static Trigger* arcane_blast(PlayerbotAI* botAI) { return new ArcaneBlastTrigger(botAI); } + static Trigger* counterspell_enemy_healer(PlayerbotAI* botAI) { return new CounterspellEnemyHealerTrigger(botAI); } + static Trigger* arcane_blast_stack(PlayerbotAI* botAI) { return new ArcaneBlastStackTrigger(botAI); } + static Trigger* mirror_image(PlayerbotAI* botAI) { return new MirrorImageTrigger(botAI); } + static Trigger* frost_nova_on_target(PlayerbotAI* botAI) { return new FrostNovaOnTargetTrigger(botAI); } + static Trigger* frostbite_on_target(PlayerbotAI* botAI) { return new FrostbiteOnTargetTrigger(botAI); } }; class MageAiObjectContextInternal : public NamedObjectContext { - public: - MageAiObjectContextInternal() - { - creators["arcane power"] = &MageAiObjectContextInternal::arcane_power; - creators["presence of mind"] = &MageAiObjectContextInternal::presence_of_mind; - creators["frostbolt"] = &MageAiObjectContextInternal::frostbolt; - creators["frostfire bolt"] = &MageAiObjectContextInternal::frostfire_bolt; - creators["ice lance"] = &MageAiObjectContextInternal::ice_lance; - creators["deep freeze"] = &MageAiObjectContextInternal::deep_freeze; - creators["blizzard"] = &MageAiObjectContextInternal::blizzard; - creators["cone of cold"] = &MageAiObjectContextInternal::cone_of_cold; - creators["frost nova"] = &MageAiObjectContextInternal::frost_nova; - creators["arcane intellect"] = &MageAiObjectContextInternal::arcane_intellect; - creators["arcane intellect on party"] = &MageAiObjectContextInternal::arcane_intellect_on_party; - creators["conjure water"] = &MageAiObjectContextInternal::conjure_water; - creators["conjure food"] = &MageAiObjectContextInternal::conjure_food; - creators["molten armor"] = &MageAiObjectContextInternal::molten_armor; - creators["mage armor"] = &MageAiObjectContextInternal::mage_armor; - creators["ice armor"] = &MageAiObjectContextInternal::ice_armor; - creators["frost armor"] = &MageAiObjectContextInternal::frost_armor; - creators["fireball"] = &MageAiObjectContextInternal::fireball; - creators["pyroblast"] = &MageAiObjectContextInternal::pyroblast; - creators["flamestrike"] = &MageAiObjectContextInternal::flamestrike; - creators["fire blast"] = &MageAiObjectContextInternal::fire_blast; - creators["scorch"] = &MageAiObjectContextInternal::scorch; - creators["counterspell"] = &MageAiObjectContextInternal::counterspell; - creators["remove curse"] = &MageAiObjectContextInternal::remove_curse; - creators["remove curse on party"] = &MageAiObjectContextInternal::remove_curse_on_party; - creators["remove lesser curse"] = &MageAiObjectContextInternal::remove_lesser_curse; - creators["remove lesser curse on party"] = &MageAiObjectContextInternal::remove_lesser_curse_on_party; - creators["icy veins"] = &MageAiObjectContextInternal::icy_veins; - creators["cold snap"] = &MageAiObjectContextInternal::cold_snap; - creators["ice barrier"] = &MageAiObjectContextInternal::ice_barrier; - creators["summon water elemental"] = &MageAiObjectContextInternal::summon_water_elemental; - creators["combustion"] = &MageAiObjectContextInternal::combustion; - creators["ice block"] = &MageAiObjectContextInternal::ice_block; - creators["polymorph"] = &MageAiObjectContextInternal::polymorph; - creators["spellsteal"] = &MageAiObjectContextInternal::spellsteal; - creators["living bomb"] = &MageAiObjectContextInternal::living_bomb; - creators["dragon's breath"] = &MageAiObjectContextInternal::dragons_breath; - creators["blast wave"] = &MageAiObjectContextInternal::blast_wave; - creators["invisibility"] = &MageAiObjectContextInternal::invisibility; - creators["evocation"] = &MageAiObjectContextInternal::evocation; - creators["arcane blast"] = &MageAiObjectContextInternal::arcane_blast; - creators["arcane barrage"] = &MageAiObjectContextInternal::arcane_barrage; - creators["arcane missiles"] = &MageAiObjectContextInternal::arcane_missiles; - creators["counterspell on enemy healer"] = &MageAiObjectContextInternal::counterspell_on_enemy_healer; - creators["fire ward"] = &MageAiObjectContextInternal::fire_ward; - creators["frost ward"] = &MageAiObjectContextInternal::frost_ward; - creators["mirror image"] = &MageAiObjectContextInternal::mirror_image; - } +public: + MageAiObjectContextInternal() + { + creators["arcane power"] = &MageAiObjectContextInternal::arcane_power; + creators["presence of mind"] = &MageAiObjectContextInternal::presence_of_mind; + creators["frostbolt"] = &MageAiObjectContextInternal::frostbolt; + creators["frostfire bolt"] = &MageAiObjectContextInternal::frostfire_bolt; + creators["ice lance"] = &MageAiObjectContextInternal::ice_lance; + creators["deep freeze"] = &MageAiObjectContextInternal::deep_freeze; + creators["blizzard"] = &MageAiObjectContextInternal::blizzard; + creators["cone of cold"] = &MageAiObjectContextInternal::cone_of_cold; + creators["frost nova"] = &MageAiObjectContextInternal::frost_nova; + creators["arcane intellect"] = &MageAiObjectContextInternal::arcane_intellect; + creators["arcane intellect on party"] = &MageAiObjectContextInternal::arcane_intellect_on_party; + creators["conjure water"] = &MageAiObjectContextInternal::conjure_water; + creators["conjure food"] = &MageAiObjectContextInternal::conjure_food; + creators["molten armor"] = &MageAiObjectContextInternal::molten_armor; + creators["mage armor"] = &MageAiObjectContextInternal::mage_armor; + creators["ice armor"] = &MageAiObjectContextInternal::ice_armor; + creators["frost armor"] = &MageAiObjectContextInternal::frost_armor; + creators["fireball"] = &MageAiObjectContextInternal::fireball; + creators["pyroblast"] = &MageAiObjectContextInternal::pyroblast; + creators["flamestrike"] = &MageAiObjectContextInternal::flamestrike; + creators["fire blast"] = &MageAiObjectContextInternal::fire_blast; + creators["scorch"] = &MageAiObjectContextInternal::scorch; + creators["counterspell"] = &MageAiObjectContextInternal::counterspell; + creators["remove curse"] = &MageAiObjectContextInternal::remove_curse; + creators["remove curse on party"] = &MageAiObjectContextInternal::remove_curse_on_party; + creators["remove lesser curse"] = &MageAiObjectContextInternal::remove_lesser_curse; + creators["remove lesser curse on party"] = &MageAiObjectContextInternal::remove_lesser_curse_on_party; + creators["icy veins"] = &MageAiObjectContextInternal::icy_veins; + creators["cold snap"] = &MageAiObjectContextInternal::cold_snap; + creators["ice barrier"] = &MageAiObjectContextInternal::ice_barrier; + creators["summon water elemental"] = &MageAiObjectContextInternal::summon_water_elemental; + creators["combustion"] = &MageAiObjectContextInternal::combustion; + creators["ice block"] = &MageAiObjectContextInternal::ice_block; + creators["polymorph"] = &MageAiObjectContextInternal::polymorph; + creators["spellsteal"] = &MageAiObjectContextInternal::spellsteal; + creators["living bomb"] = &MageAiObjectContextInternal::living_bomb; + creators["dragon's breath"] = &MageAiObjectContextInternal::dragons_breath; + creators["blast wave"] = &MageAiObjectContextInternal::blast_wave; + creators["invisibility"] = &MageAiObjectContextInternal::invisibility; + creators["evocation"] = &MageAiObjectContextInternal::evocation; + creators["arcane blast"] = &MageAiObjectContextInternal::arcane_blast; + creators["arcane barrage"] = &MageAiObjectContextInternal::arcane_barrage; + creators["arcane missiles"] = &MageAiObjectContextInternal::arcane_missiles; + creators["counterspell on enemy healer"] = &MageAiObjectContextInternal::counterspell_on_enemy_healer; + creators["fire ward"] = &MageAiObjectContextInternal::fire_ward; + creators["frost ward"] = &MageAiObjectContextInternal::frost_ward; + creators["mirror image"] = &MageAiObjectContextInternal::mirror_image; + } - private: - static Action* presence_of_mind(PlayerbotAI* botAI) { return new CastPresenceOfMindAction(botAI); } - static Action* frost_ward(PlayerbotAI* botAI) { return new CastFrostWardAction(botAI); } - static Action* fire_ward(PlayerbotAI* botAI) { return new CastFireWardAction(botAI); } - static Action* arcane_power(PlayerbotAI* botAI) { return new CastArcanePowerAction(botAI); } - static Action* arcane_missiles(PlayerbotAI* botAI) { return new CastArcaneMissilesAction(botAI); } - static Action* arcane_barrage(PlayerbotAI* botAI) { return new CastArcaneBarrageAction(botAI); } - static Action* arcane_blast(PlayerbotAI* botAI) { return new CastArcaneBlastAction(botAI); } - static Action* frostbolt(PlayerbotAI* botAI) { return new CastFrostboltAction(botAI); } - static Action* frostfire_bolt(PlayerbotAI* botAI) { return new CastFrostfireBoltAction(botAI); } - static Action* ice_lance(PlayerbotAI* botAI) { return new CastIceLanceAction(botAI); } - static Action* deep_freeze(PlayerbotAI* botAI) { return new CastDeepFreezeAction(botAI); } - static Action* blizzard(PlayerbotAI* botAI) { return new CastBlizzardAction(botAI); } - static Action* cone_of_cold(PlayerbotAI* botAI) { return new CastConeOfColdAction(botAI); } - static Action* frost_nova(PlayerbotAI* botAI) { return new CastFrostNovaAction(botAI); } - static Action* arcane_intellect(PlayerbotAI* botAI) { return new CastArcaneIntellectAction(botAI); } - static Action* arcane_intellect_on_party(PlayerbotAI* botAI) { return new CastArcaneIntellectOnPartyAction(botAI); } - static Action* conjure_water(PlayerbotAI* botAI) { return new CastConjureWaterAction(botAI); } - static Action* conjure_food(PlayerbotAI* botAI) { return new CastConjureFoodAction(botAI); } - static Action* molten_armor(PlayerbotAI* botAI) { return new CastMoltenArmorAction(botAI); } - static Action* mage_armor(PlayerbotAI* botAI) { return new CastMageArmorAction(botAI); } - static Action* ice_armor(PlayerbotAI* botAI) { return new CastIceArmorAction(botAI); } - static Action* frost_armor(PlayerbotAI* botAI) { return new CastFrostArmorAction(botAI); } - static Action* fireball(PlayerbotAI* botAI) { return new CastFireballAction(botAI); } - static Action* pyroblast(PlayerbotAI* botAI) { return new CastPyroblastAction(botAI); } - static Action* flamestrike(PlayerbotAI* botAI) { return new CastFlamestrikeAction(botAI); } - static Action* fire_blast(PlayerbotAI* botAI) { return new CastFireBlastAction(botAI); } - static Action* scorch(PlayerbotAI* botAI) { return new CastScorchAction(botAI); } - static Action* counterspell(PlayerbotAI* botAI) { return new CastCounterspellAction(botAI); } - static Action* remove_curse(PlayerbotAI* botAI) { return new CastRemoveCurseAction(botAI); } - static Action* remove_curse_on_party(PlayerbotAI* botAI) { return new CastRemoveCurseOnPartyAction(botAI); } - static Action* remove_lesser_curse(PlayerbotAI* botAI) { return new CastRemoveLesserCurseAction(botAI); } - static Action* remove_lesser_curse_on_party(PlayerbotAI* botAI) { return new CastRemoveLesserCurseOnPartyAction(botAI); } - static Action* icy_veins(PlayerbotAI* botAI) { return new CastIcyVeinsAction(botAI); } - static Action* cold_snap(PlayerbotAI* botAI) { return new CastColdSnapAction(botAI); } - static Action* ice_barrier(PlayerbotAI* botAI) { return new CastIceBarrierAction(botAI); } - static Action* summon_water_elemental(PlayerbotAI* botAI) { return new CastSummonWaterElementalAction(botAI); } - static Action* combustion(PlayerbotAI* botAI) { return new CastCombustionAction(botAI); } - static Action* ice_block(PlayerbotAI* botAI) { return new CastIceBlockAction(botAI); } - static Action* polymorph(PlayerbotAI* botAI) { return new CastPolymorphAction(botAI); } - static Action* spellsteal(PlayerbotAI* botAI) { return new CastSpellstealAction(botAI); } - static Action* living_bomb(PlayerbotAI* botAI) { return new CastLivingBombAction(botAI); } - static Action* dragons_breath(PlayerbotAI* botAI) { return new CastDragonsBreathAction(botAI); } - static Action* blast_wave(PlayerbotAI* botAI) { return new CastBlastWaveAction(botAI); } - static Action* invisibility(PlayerbotAI* botAI) { return new CastInvisibilityAction(botAI); } - static Action* evocation(PlayerbotAI* botAI) { return new CastEvocationAction(botAI); } - static Action* counterspell_on_enemy_healer(PlayerbotAI* botAI) { return new CastCounterspellOnEnemyHealerAction(botAI); } - static Action* mirror_image(PlayerbotAI* botAI) { return new CastMirrorImageAction(botAI); } +private: + static Action* presence_of_mind(PlayerbotAI* botAI) { return new CastPresenceOfMindAction(botAI); } + static Action* frost_ward(PlayerbotAI* botAI) { return new CastFrostWardAction(botAI); } + static Action* fire_ward(PlayerbotAI* botAI) { return new CastFireWardAction(botAI); } + static Action* arcane_power(PlayerbotAI* botAI) { return new CastArcanePowerAction(botAI); } + static Action* arcane_missiles(PlayerbotAI* botAI) { return new CastArcaneMissilesAction(botAI); } + static Action* arcane_barrage(PlayerbotAI* botAI) { return new CastArcaneBarrageAction(botAI); } + static Action* arcane_blast(PlayerbotAI* botAI) { return new CastArcaneBlastAction(botAI); } + static Action* frostbolt(PlayerbotAI* botAI) { return new CastFrostboltAction(botAI); } + static Action* frostfire_bolt(PlayerbotAI* botAI) { return new CastFrostfireBoltAction(botAI); } + static Action* ice_lance(PlayerbotAI* botAI) { return new CastIceLanceAction(botAI); } + static Action* deep_freeze(PlayerbotAI* botAI) { return new CastDeepFreezeAction(botAI); } + static Action* blizzard(PlayerbotAI* botAI) { return new CastBlizzardAction(botAI); } + static Action* cone_of_cold(PlayerbotAI* botAI) { return new CastConeOfColdAction(botAI); } + static Action* frost_nova(PlayerbotAI* botAI) { return new CastFrostNovaAction(botAI); } + static Action* arcane_intellect(PlayerbotAI* botAI) { return new CastArcaneIntellectAction(botAI); } + static Action* arcane_intellect_on_party(PlayerbotAI* botAI) { return new CastArcaneIntellectOnPartyAction(botAI); } + static Action* conjure_water(PlayerbotAI* botAI) { return new CastConjureWaterAction(botAI); } + static Action* conjure_food(PlayerbotAI* botAI) { return new CastConjureFoodAction(botAI); } + static Action* molten_armor(PlayerbotAI* botAI) { return new CastMoltenArmorAction(botAI); } + static Action* mage_armor(PlayerbotAI* botAI) { return new CastMageArmorAction(botAI); } + static Action* ice_armor(PlayerbotAI* botAI) { return new CastIceArmorAction(botAI); } + static Action* frost_armor(PlayerbotAI* botAI) { return new CastFrostArmorAction(botAI); } + static Action* fireball(PlayerbotAI* botAI) { return new CastFireballAction(botAI); } + static Action* pyroblast(PlayerbotAI* botAI) { return new CastPyroblastAction(botAI); } + static Action* flamestrike(PlayerbotAI* botAI) { return new CastFlamestrikeAction(botAI); } + static Action* fire_blast(PlayerbotAI* botAI) { return new CastFireBlastAction(botAI); } + static Action* scorch(PlayerbotAI* botAI) { return new CastScorchAction(botAI); } + static Action* counterspell(PlayerbotAI* botAI) { return new CastCounterspellAction(botAI); } + static Action* remove_curse(PlayerbotAI* botAI) { return new CastRemoveCurseAction(botAI); } + static Action* remove_curse_on_party(PlayerbotAI* botAI) { return new CastRemoveCurseOnPartyAction(botAI); } + static Action* remove_lesser_curse(PlayerbotAI* botAI) { return new CastRemoveLesserCurseAction(botAI); } + static Action* remove_lesser_curse_on_party(PlayerbotAI* botAI) + { + return new CastRemoveLesserCurseOnPartyAction(botAI); + } + static Action* icy_veins(PlayerbotAI* botAI) { return new CastIcyVeinsAction(botAI); } + static Action* cold_snap(PlayerbotAI* botAI) { return new CastColdSnapAction(botAI); } + static Action* ice_barrier(PlayerbotAI* botAI) { return new CastIceBarrierAction(botAI); } + static Action* summon_water_elemental(PlayerbotAI* botAI) { return new CastSummonWaterElementalAction(botAI); } + static Action* combustion(PlayerbotAI* botAI) { return new CastCombustionAction(botAI); } + static Action* ice_block(PlayerbotAI* botAI) { return new CastIceBlockAction(botAI); } + static Action* polymorph(PlayerbotAI* botAI) { return new CastPolymorphAction(botAI); } + static Action* spellsteal(PlayerbotAI* botAI) { return new CastSpellstealAction(botAI); } + static Action* living_bomb(PlayerbotAI* botAI) { return new CastLivingBombAction(botAI); } + static Action* dragons_breath(PlayerbotAI* botAI) { return new CastDragonsBreathAction(botAI); } + static Action* blast_wave(PlayerbotAI* botAI) { return new CastBlastWaveAction(botAI); } + static Action* invisibility(PlayerbotAI* botAI) { return new CastInvisibilityAction(botAI); } + static Action* evocation(PlayerbotAI* botAI) { return new CastEvocationAction(botAI); } + static Action* counterspell_on_enemy_healer(PlayerbotAI* botAI) + { + return new CastCounterspellOnEnemyHealerAction(botAI); + } + static Action* mirror_image(PlayerbotAI* botAI) { return new CastMirrorImageAction(botAI); } }; MageAiObjectContext::MageAiObjectContext(PlayerbotAI* botAI) : AiObjectContext(botAI) diff --git a/src/strategy/mage/MageAiObjectContext.h b/src/strategy/mage/MageAiObjectContext.h index d5141ac3..3388faf9 100644 --- a/src/strategy/mage/MageAiObjectContext.h +++ b/src/strategy/mage/MageAiObjectContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MAGEAIOBJECTCONTEXT_H @@ -11,8 +12,8 @@ class PlayerbotAI; class MageAiObjectContext : public AiObjectContext { - public: - MageAiObjectContext(PlayerbotAI* botAI); +public: + MageAiObjectContext(PlayerbotAI* botAI); }; #endif diff --git a/src/strategy/mage/MageTriggers.cpp b/src/strategy/mage/MageTriggers.cpp index 72bea207..e935d51b 100644 --- a/src/strategy/mage/MageTriggers.cpp +++ b/src/strategy/mage/MageTriggers.cpp @@ -1,9 +1,11 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ -#include "MageActions.h" #include "MageTriggers.h" + +#include "MageActions.h" #include "Playerbots.h" bool ArcaneIntellectOnPartyTrigger::IsActive() @@ -19,31 +21,34 @@ bool ArcaneIntellectTrigger::IsActive() bool MageArmorTrigger::IsActive() { Unit* target = GetTarget(); - return !botAI->HasAura("ice armor", target) && !botAI->HasAura("frost armor", target) && !botAI->HasAura("molten armor", target) && !botAI->HasAura("mage armor", target); + return !botAI->HasAura("ice armor", target) && !botAI->HasAura("frost armor", target) && + !botAI->HasAura("molten armor", target) && !botAI->HasAura("mage armor", target); } bool FingersOfFrostSingleTrigger::IsActive() { // Fingers of Frost "stack" count is always 1. // The value is instead stored in the charges. - Aura *aura = botAI->GetAura(getName(), GetTarget(), false, true, -1); - return (aura && aura->GetCharges() == 1); + Aura* aura = botAI->GetAura(getName(), GetTarget(), false, true, -1); + return (aura && aura->GetCharges() == 1); } bool FrostNovaOnTargetTrigger::IsActive() { Unit* target = GetTarget(); - if (!target || !target->IsAlive() || !target->IsInWorld()) { + if (!target || !target->IsAlive() || !target->IsInWorld()) + { return false; } - return botAI->HasAura(spell, target); + return botAI->HasAura(spell, target); } bool FrostbiteOnTargetTrigger::IsActive() { Unit* target = GetTarget(); - if (!target || !target->IsAlive() || !target->IsInWorld()) { + if (!target || !target->IsAlive() || !target->IsInWorld()) + { return false; } - return botAI->HasAura(spell, target); + return botAI->HasAura(spell, target); } diff --git a/src/strategy/mage/MageTriggers.h b/src/strategy/mage/MageTriggers.h index 111ba341..dd531872 100644 --- a/src/strategy/mage/MageTriggers.h +++ b/src/strategy/mage/MageTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MAGETRIGGERS_H @@ -16,60 +17,60 @@ DEFLECT_TRIGGER(FrostWardTrigger, "frost ward"); class ArcaneIntellectOnPartyTrigger : public BuffOnPartyTrigger { - public: - ArcaneIntellectOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "arcane intellect", 2 * 2000) { } +public: + ArcaneIntellectOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "arcane intellect", 2 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class ArcaneIntellectTrigger : public BuffTrigger { - public: - ArcaneIntellectTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "arcane intellect", 2 * 2000) { } - bool IsActive() override; +public: + ArcaneIntellectTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "arcane intellect", 2 * 2000) {} + bool IsActive() override; }; class MageArmorTrigger : public BuffTrigger { - public: - MageArmorTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "mage armor", 5 * 2000) { } - bool IsActive() override; +public: + MageArmorTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "mage armor", 5 * 2000) {} + bool IsActive() override; }; class LivingBombTrigger : public DebuffTrigger { - public: - LivingBombTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "living bomb", 1, true) { } +public: + LivingBombTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "living bomb", 1, true) {} }; class FireballTrigger : public DebuffTrigger { - public: - FireballTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "fireball", 1, true) { } +public: + FireballTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "fireball", 1, true) {} }; class PyroblastTrigger : public DebuffTrigger { - public: - PyroblastTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "pyroblast", 1, true) { } +public: + PyroblastTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "pyroblast", 1, true) {} }; class HotStreakTrigger : public HasAuraTrigger { - public: - HotStreakTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "hot streak") { } +public: + HotStreakTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "hot streak") {} }; class MissileBarrageTrigger : public HasAuraTrigger { - public: - MissileBarrageTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "missile barrage") { } +public: + MissileBarrageTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "missile barrage") {} }; class ArcaneBlastTrigger : public BuffTrigger { - public: - ArcaneBlastTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "arcane blast") { } +public: + ArcaneBlastTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "arcane blast") {} }; class FingersOfFrostSingleTrigger : public HasAuraStackTrigger @@ -88,80 +89,82 @@ public: class BrainFreezeTrigger : public HasAuraTrigger { - public: - BrainFreezeTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "fireball!") { } +public: + BrainFreezeTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "fireball!") {} }; class CounterspellInterruptSpellTrigger : public InterruptSpellTrigger { - public: - CounterspellInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "counterspell") { } +public: + CounterspellInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "counterspell") {} }; class CombustionTrigger : public BoostTrigger { - public: - CombustionTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "combustion") { } +public: + CombustionTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "combustion") {} }; class IcyVeinsTrigger : public BoostTrigger { - public: - IcyVeinsTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "icy veins") { } +public: + IcyVeinsTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "icy veins") {} }; class ColdSnapTrigger : public BoostTrigger { - public: - ColdSnapTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "cold snap") { } +public: + ColdSnapTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "cold snap") {} }; class IceBarrierTrigger : public BuffTrigger { - public: - IceBarrierTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "ice barrier") { } +public: + IceBarrierTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "ice barrier") {} }; class PolymorphTrigger : public HasCcTargetTrigger { - public: - PolymorphTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "polymorph") { } +public: + PolymorphTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "polymorph") {} }; class RemoveCurseTrigger : public NeedCureTrigger { - public: - RemoveCurseTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "remove curse", DISPEL_CURSE) { } +public: + RemoveCurseTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "remove curse", DISPEL_CURSE) {} }; class PartyMemberRemoveCurseTrigger : public PartyMemberNeedCureTrigger { - public: - PartyMemberRemoveCurseTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "remove curse", DISPEL_CURSE) { } +public: + PartyMemberRemoveCurseTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "remove curse", DISPEL_CURSE) + { + } }; class SpellstealTrigger : public TargetAuraDispelTrigger { - public: - SpellstealTrigger(PlayerbotAI* botAI) : TargetAuraDispelTrigger(botAI, "spellsteal", DISPEL_MAGIC) { } +public: + SpellstealTrigger(PlayerbotAI* botAI) : TargetAuraDispelTrigger(botAI, "spellsteal", DISPEL_MAGIC) {} }; class CounterspellEnemyHealerTrigger : public InterruptEnemyHealerTrigger { - public: - CounterspellEnemyHealerTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "counterspell") { } +public: + CounterspellEnemyHealerTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "counterspell") {} }; class ArcanePowerTrigger : public BuffTrigger { - public: - ArcanePowerTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "arcane power") { } +public: + ArcanePowerTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "arcane power") {} }; class PresenceOfMindTrigger : public BuffTrigger { - public: - PresenceOfMindTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "presence of mind") { } +public: + PresenceOfMindTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "presence of mind") {} }; class ArcaneBlastStackTrigger : public HasAuraStackTrigger @@ -172,20 +175,20 @@ public: class MirrorImageTrigger : public BoostTrigger { - public: +public: MirrorImageTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "mirror image") {} }; class FrostNovaOnTargetTrigger : public DebuffTrigger { - public: +public: FrostNovaOnTargetTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "frost nova", 1, false) {} bool IsActive() override; }; class FrostbiteOnTargetTrigger : public DebuffTrigger { - public: +public: FrostbiteOnTargetTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "frostbite", 1, false) {} bool IsActive() override; }; diff --git a/src/strategy/paladin/DpsPaladinStrategy.cpp b/src/strategy/paladin/DpsPaladinStrategy.cpp index 1fe8ae1a..e3ecf5c2 100644 --- a/src/strategy/paladin/DpsPaladinStrategy.cpp +++ b/src/strategy/paladin/DpsPaladinStrategy.cpp @@ -1,70 +1,72 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DpsPaladinStrategy.h" + #include "Playerbots.h" #include "Strategy.h" class DpsPaladinStrategyActionNodeFactory : public NamedObjectFactory { - public: - DpsPaladinStrategyActionNodeFactory() - { - creators["sanctity aura"] = &sanctity_aura; - creators["retribution aura"] = &retribution_aura; - creators["seal of corruption"] = &seal_of_corruption; - creators["seal of vengeance"] = &seal_of_vengeance; - creators["seal of command"] = &seal_of_command; - creators["blessing of might"] = &blessing_of_might; - creators["crusader strike"] = &crusader_strike; - creators["repentance"] = &repentance; - creators["repentance on enemy healer"] = &repentance_on_enemy_healer; - creators["repentance on snare target"] = &repentance_on_snare_target; - creators["repentance of shield"] = &repentance_or_shield; - } +public: + DpsPaladinStrategyActionNodeFactory() + { + creators["sanctity aura"] = &sanctity_aura; + creators["retribution aura"] = &retribution_aura; + creators["seal of corruption"] = &seal_of_corruption; + creators["seal of vengeance"] = &seal_of_vengeance; + creators["seal of command"] = &seal_of_command; + creators["blessing of might"] = &blessing_of_might; + creators["crusader strike"] = &crusader_strike; + creators["repentance"] = &repentance; + creators["repentance on enemy healer"] = &repentance_on_enemy_healer; + creators["repentance on snare target"] = &repentance_on_snare_target; + creators["repentance of shield"] = &repentance_or_shield; + } - private: - static ActionNode* seal_of_corruption([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("seal of corruption", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("seal of vengeance"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* seal_of_corruption([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("seal of corruption", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("seal of vengeance"), nullptr), + /*C*/ nullptr); + } - static ActionNode* seal_of_vengeance([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("seal of vengeance", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("seal of righteousness"), nullptr), - /*C*/ nullptr); - } + static ActionNode* seal_of_vengeance([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("seal of vengeance", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("seal of righteousness"), nullptr), + /*C*/ nullptr); + } - static ActionNode* seal_of_command([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("seal of command", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("seal of corruption"), nullptr), - /*C*/ nullptr); - } + static ActionNode* seal_of_command([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("seal of command", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("seal of corruption"), nullptr), + /*C*/ nullptr); + } - static ActionNode* blessing_of_might([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("blessing of might", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("blessing of kings"), nullptr), - /*C*/ nullptr); - } + static ActionNode* blessing_of_might([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("blessing of might", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("blessing of kings"), nullptr), + /*C*/ nullptr); + } + + static ActionNode* crusader_strike([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("crusader strike", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* crusader_strike([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("crusader strike", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - ACTION_NODE_A(repentance, "repentance", "hammer of justice"); ACTION_NODE_A(repentance_on_enemy_healer, "repentance on enemy healer", "hammer of justice on enemy healer"); ACTION_NODE_A(repentance_on_snare_target, "repentance on snare target", "hammer of justice on snare target"); @@ -80,40 +82,45 @@ DpsPaladinStrategy::DpsPaladinStrategy(PlayerbotAI* botAI) : GenericPaladinStrat NextAction** DpsPaladinStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("crusader strike", ACTION_DEFAULT + 0.4f), - new NextAction("judgement of wisdom", ACTION_DEFAULT + 0.3f), - new NextAction("divine storm", ACTION_DEFAULT + 0.2f), - new NextAction("melee consecration", ACTION_DEFAULT + 0.1f), - new NextAction("melee", ACTION_DEFAULT), - NULL); + return NextAction::array(0, new NextAction("crusader strike", ACTION_DEFAULT + 0.4f), + new NextAction("judgement of wisdom", ACTION_DEFAULT + 0.3f), + new NextAction("divine storm", ACTION_DEFAULT + 0.2f), + new NextAction("melee consecration", ACTION_DEFAULT + 0.1f), + new NextAction("melee", ACTION_DEFAULT), NULL); } void DpsPaladinStrategy::InitTriggers(std::vector& triggers) { GenericPaladinStrategy::InitTriggers(triggers); + triggers.push_back( + new TriggerNode("seal", NextAction::array(0, new NextAction("seal of command", ACTION_HIGH), NULL))); + // triggers.push_back(new TriggerNode("seal", NextAction::array(0, new NextAction("seal of command", 90.0f), + // nullptr))); + triggers.push_back( + new TriggerNode("low mana", NextAction::array(0, new NextAction("seal of wisdom", ACTION_HIGH + 5), nullptr))); + // triggers.push_back(new TriggerNode("sanctity aura", NextAction::array(0, new NextAction("sanctity aura", 90.0f), + // nullptr))); triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("repentance or + // shield", ACTION_CRITICAL_HEAL + 3), new NextAction("holy light", ACTION_CRITICAL_HEAL + 2), nullptr))); + // triggers.push_back(new TriggerNode("judgement of wisdom", NextAction::array(0, new NextAction("judgement of + // wisdom", ACTION_NORMAL + 10), nullptr))); triggers.push_back(new TriggerNode("judgement", NextAction::array(0, + // new NextAction("judgement", ACTION_HIGH + 10), nullptr))); triggers.push_back(new TriggerNode("enemy is close", + // NextAction::array(0, new NextAction("consecration", ACTION_INTERRUPT), nullptr))); triggers.push_back(new + // TriggerNode("repentance on enemy healer", NextAction::array(0, new NextAction("repentance on enemy healer", + // ACTION_INTERRUPT + 2), nullptr))); triggers.push_back(new TriggerNode("repentance on snare target", + // NextAction::array(0, new NextAction("repentance on snare target", ACTION_INTERRUPT + 2), nullptr))); + // triggers.push_back(new TriggerNode("repentance", NextAction::array(0, new NextAction("repentance", + // ACTION_INTERRUPT + 2), nullptr))); triggers.push_back(new TriggerNode( - "seal", - NextAction::array(0, new NextAction("seal of command", ACTION_HIGH), NULL))); - // triggers.push_back(new TriggerNode("seal", NextAction::array(0, new NextAction("seal of command", 90.0f), nullptr))); - triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("seal of wisdom", ACTION_HIGH + 5), nullptr))); - // triggers.push_back(new TriggerNode("sanctity aura", NextAction::array(0, new NextAction("sanctity aura", 90.0f), nullptr))); - // triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("repentance or shield", ACTION_CRITICAL_HEAL + 3), new NextAction("holy light", ACTION_CRITICAL_HEAL + 2), nullptr))); - // triggers.push_back(new TriggerNode("judgement of wisdom", NextAction::array(0, new NextAction("judgement of wisdom", ACTION_NORMAL + 10), nullptr))); - // triggers.push_back(new TriggerNode("judgement", NextAction::array(0, new NextAction("judgement", ACTION_HIGH + 10), nullptr))); - // triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new NextAction("consecration", ACTION_INTERRUPT), nullptr))); - // triggers.push_back(new TriggerNode("repentance on enemy healer", NextAction::array(0, new NextAction("repentance on enemy healer", ACTION_INTERRUPT + 2), nullptr))); - // triggers.push_back(new TriggerNode("repentance on snare target", NextAction::array(0, new NextAction("repentance on snare target", ACTION_INTERRUPT + 2), nullptr))); - // triggers.push_back(new TriggerNode("repentance", NextAction::array(0, new NextAction("repentance", ACTION_INTERRUPT + 2), nullptr))); - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("melee consecration", ACTION_HIGH + 3), nullptr))); - triggers.push_back(new TriggerNode("art of war", NextAction::array(0, new NextAction("exorcism", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode("target critical health", NextAction::array(0, new NextAction("hammer of wrath", ACTION_HIGH), nullptr))); + "medium aoe", NextAction::array(0, new NextAction("melee consecration", ACTION_HIGH + 3), nullptr))); + triggers.push_back( + new TriggerNode("art of war", NextAction::array(0, new NextAction("exorcism", ACTION_HIGH + 2), nullptr))); + triggers.push_back(new TriggerNode("target critical health", + NextAction::array(0, new NextAction("hammer of wrath", ACTION_HIGH), nullptr))); // triggers.push_back(new TriggerNode( // "not facing target", // NextAction::array(0, new NextAction("set facing", ACTION_NORMAL + 7), NULL))); - triggers.push_back(new TriggerNode( - "enemy out of melee", - NextAction::array(0, new NextAction("reach melee", ACTION_NORMAL + 8), NULL))); + triggers.push_back(new TriggerNode("enemy out of melee", + NextAction::array(0, new NextAction("reach melee", ACTION_NORMAL + 8), NULL))); } diff --git a/src/strategy/paladin/DpsPaladinStrategy.h b/src/strategy/paladin/DpsPaladinStrategy.h index e8706be5..7a01396e 100644 --- a/src/strategy/paladin/DpsPaladinStrategy.h +++ b/src/strategy/paladin/DpsPaladinStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DPSPALADINSTRATEGY_H @@ -11,13 +12,13 @@ class PlayerbotAI; class DpsPaladinStrategy : public GenericPaladinStrategy { - public: - DpsPaladinStrategy(PlayerbotAI* botAI); +public: + DpsPaladinStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "dps"; } - NextAction** getDefaultActions() override; - uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_MELEE; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "dps"; } + NextAction** getDefaultActions() override; + uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_MELEE; } }; #endif diff --git a/src/strategy/paladin/GenericPaladinNonCombatStrategy.cpp b/src/strategy/paladin/GenericPaladinNonCombatStrategy.cpp index ea5ebec7..80e23cd3 100644 --- a/src/strategy/paladin/GenericPaladinNonCombatStrategy.cpp +++ b/src/strategy/paladin/GenericPaladinNonCombatStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericPaladinNonCombatStrategy.h" + #include "GenericPaladinStrategyActionNodeFactory.h" #include "Playerbots.h" @@ -15,10 +17,14 @@ void GenericPaladinNonCombatStrategy::InitTriggers(std::vector& tr { NonCombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("party member dead", NextAction::array(0, new NextAction("redemption", ACTION_CRITICAL_HEAL + 10), nullptr))); - triggers.push_back(new TriggerNode("party member almost full health", NextAction::array(0, new NextAction("flash of light on party", 25.0f), NULL))); - triggers.push_back(new TriggerNode("party member medium health", NextAction::array(0, new NextAction("holy light on party", 26.0f), NULL))); - triggers.push_back(new TriggerNode("party member low health", NextAction::array(0, new NextAction("holy light on party", 27.0f), NULL))); - triggers.push_back(new TriggerNode("party member critical health", NextAction::array(0, new NextAction("holy light on party", 28.0f), NULL))); - + triggers.push_back(new TriggerNode( + "party member dead", NextAction::array(0, new NextAction("redemption", ACTION_CRITICAL_HEAL + 10), nullptr))); + triggers.push_back(new TriggerNode("party member almost full health", + NextAction::array(0, new NextAction("flash of light on party", 25.0f), NULL))); + triggers.push_back(new TriggerNode("party member medium health", + NextAction::array(0, new NextAction("holy light on party", 26.0f), NULL))); + triggers.push_back(new TriggerNode("party member low health", + NextAction::array(0, new NextAction("holy light on party", 27.0f), NULL))); + triggers.push_back(new TriggerNode("party member critical health", + NextAction::array(0, new NextAction("holy light on party", 28.0f), NULL))); } diff --git a/src/strategy/paladin/GenericPaladinNonCombatStrategy.h b/src/strategy/paladin/GenericPaladinNonCombatStrategy.h index 2e7830ec..3b52f222 100644 --- a/src/strategy/paladin/GenericPaladinNonCombatStrategy.h +++ b/src/strategy/paladin/GenericPaladinNonCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICPALADINNONCOMBATSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class GenericPaladinNonCombatStrategy : public NonCombatStrategy { - public: - GenericPaladinNonCombatStrategy(PlayerbotAI* botAI); +public: + GenericPaladinNonCombatStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "nc"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "nc"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/paladin/GenericPaladinStrategy.cpp b/src/strategy/paladin/GenericPaladinStrategy.cpp index 88983bac..68d5bc84 100644 --- a/src/strategy/paladin/GenericPaladinStrategy.cpp +++ b/src/strategy/paladin/GenericPaladinStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericPaladinStrategy.h" + #include "GenericPaladinStrategyActionNodeFactory.h" #include "Playerbots.h" @@ -15,35 +17,58 @@ void GenericPaladinStrategy::InitTriggers(std::vector& triggers) { CombatStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("divine shield", ACTION_CRITICAL_HEAL + 2), new NextAction("holy light", ACTION_CRITICAL_HEAL + 2), nullptr))); - triggers.push_back(new TriggerNode("hammer of justice interrupt", NextAction::array(0, new NextAction("hammer of justice", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("hammer of justice on enemy healer", NextAction::array(0, new NextAction("hammer of justice on enemy healer", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("hammer of justice on snare target", NextAction::array(0, new NextAction("hammer of justice on snare target", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("lay on hands", ACTION_EMERGENCY), nullptr))); - triggers.push_back(new TriggerNode("party member critical health", NextAction::array(0, new NextAction("lay on hands on party", ACTION_EMERGENCY + 1), nullptr))); - triggers.push_back(new TriggerNode("protect party member", NextAction::array(0, new NextAction("blessing of protection on party", ACTION_EMERGENCY + 2), nullptr))); + // triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("divine shield", + // ACTION_CRITICAL_HEAL + 2), new NextAction("holy light", ACTION_CRITICAL_HEAL + 2), nullptr))); + triggers.push_back( + new TriggerNode("hammer of justice interrupt", + NextAction::array(0, new NextAction("hammer of justice", ACTION_INTERRUPT), nullptr))); triggers.push_back(new TriggerNode( - "medium mana", - NextAction::array(0, new NextAction("divine plea", ACTION_HIGH), NULL))); + "hammer of justice on enemy healer", + NextAction::array(0, new NextAction("hammer of justice on enemy healer", ACTION_INTERRUPT), nullptr))); + triggers.push_back(new TriggerNode( + "hammer of justice on snare target", + NextAction::array(0, new NextAction("hammer of justice on snare target", ACTION_INTERRUPT), nullptr))); + triggers.push_back(new TriggerNode( + "critical health", NextAction::array(0, new NextAction("lay on hands", ACTION_EMERGENCY), nullptr))); + triggers.push_back( + new TriggerNode("party member critical health", + NextAction::array(0, new NextAction("lay on hands on party", ACTION_EMERGENCY + 1), nullptr))); + triggers.push_back(new TriggerNode( + "protect party member", + NextAction::array(0, new NextAction("blessing of protection on party", ACTION_EMERGENCY + 2), nullptr))); + triggers.push_back( + new TriggerNode("medium mana", NextAction::array(0, new NextAction("divine plea", ACTION_HIGH), NULL))); } void PaladinCureStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("cleanse cure disease", NextAction::array(0, new NextAction("cleanse disease", ACTION_DISPEL + 2), nullptr))); - triggers.push_back(new TriggerNode("cleanse party member cure disease", NextAction::array(0, new NextAction("cleanse disease on party", ACTION_DISPEL + 1), nullptr))); - triggers.push_back(new TriggerNode("cleanse cure poison", NextAction::array(0, new NextAction("cleanse poison", ACTION_DISPEL + 2), nullptr))); - triggers.push_back(new TriggerNode("cleanse party member cure poison", NextAction::array(0, new NextAction("cleanse poison on party", ACTION_DISPEL + 1), nullptr))); - triggers.push_back(new TriggerNode("cleanse cure magic", NextAction::array(0, new NextAction("cleanse magic", ACTION_DISPEL + 2), nullptr))); - triggers.push_back(new TriggerNode("cleanse party member cure magic", NextAction::array(0, new NextAction("cleanse magic on party", ACTION_DISPEL + 1), nullptr))); + triggers.push_back(new TriggerNode( + "cleanse cure disease", NextAction::array(0, new NextAction("cleanse disease", ACTION_DISPEL + 2), nullptr))); + triggers.push_back( + new TriggerNode("cleanse party member cure disease", + NextAction::array(0, new NextAction("cleanse disease on party", ACTION_DISPEL + 1), nullptr))); + triggers.push_back(new TriggerNode( + "cleanse cure poison", NextAction::array(0, new NextAction("cleanse poison", ACTION_DISPEL + 2), nullptr))); + triggers.push_back( + new TriggerNode("cleanse party member cure poison", + NextAction::array(0, new NextAction("cleanse poison on party", ACTION_DISPEL + 1), nullptr))); + triggers.push_back(new TriggerNode( + "cleanse cure magic", NextAction::array(0, new NextAction("cleanse magic", ACTION_DISPEL + 2), nullptr))); + triggers.push_back( + new TriggerNode("cleanse party member cure magic", + NextAction::array(0, new NextAction("cleanse magic on party", ACTION_DISPEL + 1), nullptr))); } void PaladinBoostStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("avenging wrath", NextAction::array(0, new NextAction("avenging wrath", ACTION_HIGH + 2), nullptr))); - // triggers.push_back(new TriggerNode("divine favor", NextAction::array(0, new NextAction("divine favor", ACTION_HIGH + 1), nullptr))); + triggers.push_back(new TriggerNode( + "avenging wrath", NextAction::array(0, new NextAction("avenging wrath", ACTION_HIGH + 2), nullptr))); + // triggers.push_back(new TriggerNode("divine favor", NextAction::array(0, new NextAction("divine favor", + // ACTION_HIGH + 1), nullptr))); } void PaladinCcStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("turn undead", NextAction::array(0, new NextAction("turn undead", ACTION_HIGH + 1), nullptr))); + triggers.push_back( + new TriggerNode("turn undead", NextAction::array(0, new NextAction("turn undead", ACTION_HIGH + 1), nullptr))); } diff --git a/src/strategy/paladin/GenericPaladinStrategy.h b/src/strategy/paladin/GenericPaladinStrategy.h index 53034885..4922a1bc 100644 --- a/src/strategy/paladin/GenericPaladinStrategy.h +++ b/src/strategy/paladin/GenericPaladinStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICPALADINSTRATEGY_H @@ -11,38 +12,38 @@ class PlayerbotAI; class GenericPaladinStrategy : public CombatStrategy { - public: - GenericPaladinStrategy(PlayerbotAI* botAI); +public: + GenericPaladinStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "paladin"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "paladin"; } }; class PaladinCureStrategy : public Strategy { - public: - PaladinCureStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinCureStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "cure"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cure"; } }; class PaladinBoostStrategy : public Strategy { - public: - PaladinBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "boost"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "boost"; } }; class PaladinCcStrategy : public Strategy { - public: - PaladinCcStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinCcStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "cc"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cc"; } }; #endif diff --git a/src/strategy/paladin/GenericPaladinStrategyActionNodeFactory.h b/src/strategy/paladin/GenericPaladinStrategyActionNodeFactory.h index e2e00f2f..68617eba 100644 --- a/src/strategy/paladin/GenericPaladinStrategyActionNodeFactory.h +++ b/src/strategy/paladin/GenericPaladinStrategyActionNodeFactory.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICPALADINSTRATEGYACTIONNODEFACTORY_H @@ -12,236 +13,238 @@ class PlayerbotAI; class GenericPaladinStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericPaladinStrategyActionNodeFactory() - { - // creators["seal of light"] = &seal_of_light; - creators["cleanse poison"] = &cleanse_poison; - creators["cleanse disease"] = &cleanse_disease; - creators["cleanse magic"] = &cleanse_magic; - creators["cleanse poison on party"] = &cleanse_poison_on_party; - creators["cleanse disease on party"] = &cleanse_disease_on_party; - // creators["seal of wisdom"] = &seal_of_wisdom; - creators["seal of justice"] = &seal_of_justice; - creators["hand of reckoning"] = &hand_of_reckoning; - creators["judgement"] = &judgement; - creators["judgement of wisdom"] = &judgement_of_wisdom; - creators["divine shield"] = &divine_shield; - creators["flash of light"] = &flash_of_light; - creators["flash of light on party"] = &flash_of_light_on_party; - creators["holy wrath"] = &holy_wrath; - creators["lay on hands"] = &lay_on_hands; - creators["lay on hands on party"] = &lay_on_hands_on_party; - creators["hammer of wrath"] = &hammer_of_wrath; - creators["retribution aura"] = &retribution_aura; - creators["blessing of kings"] = &blessing_of_kings; - creators["blessing of wisdom"] = &blessing_of_wisdom; - creators["blessing of kings on party"] = &blessing_of_kings_on_party; - creators["blessing of wisdom on party"] = &blessing_of_wisdom_on_party; - creators["blessing of sanctuary"] = &blessing_of_sanctuary; - creators["seal of command"] = &seal_of_command; - creators["taunt spell"] = &hand_of_reckoning; - creators["righteous defense"] = &righteous_defense; - creators["avenger's shield"] = &avengers_shield; - creators["divine sacrifice"] = &divine_sacrifice; - } - private: - static ActionNode* blessing_of_sanctuary(PlayerbotAI* ai) - { - return new ActionNode ("blessing of sanctuary", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* blessing_of_kings(PlayerbotAI* ai) - { - return new ActionNode ("blessing of kings", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* blessing_of_wisdom(PlayerbotAI* ai) - { - return new ActionNode ("blessing of wisdom", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* blessing_of_kings_on_party(PlayerbotAI* ai) - { - return new ActionNode ("blessing of kings on party", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* blessing_of_wisdom_on_party(PlayerbotAI* ai) - { - return new ActionNode ("blessing of wisdom on party", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* retribution_aura(PlayerbotAI* ai) - { - return new ActionNode ("retribution aura", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("devotion aura"), nullptr), - /*C*/ nullptr); - } - static ActionNode* lay_on_hands(PlayerbotAI* ai) - { - return new ActionNode ("lay on hands", - /*P*/ nullptr, - /*A*/ nullptr, // NextAction::array(0, new NextAction("divine shield"), new NextAction("flash of light"), NULL), - /*C*/ nullptr); - } - static ActionNode* lay_on_hands_on_party(PlayerbotAI* ai) - { - return new ActionNode ("lay on hands on party", - /*P*/ nullptr, - /*A*/ nullptr, // NextAction::array(0, new NextAction("flash of light"), NULL), - /*C*/ nullptr); - } - // static ActionNode* seal_of_light(PlayerbotAI* ai) - // { - // return new ActionNode ("seal of light", - // /*P*/ NULL, - // /*A*/ NextAction::array(0, new NextAction("seal of justice"), NULL), - // /*C*/ NULL); - // } - static ActionNode* cleanse_poison(PlayerbotAI* ai) - { - return new ActionNode ("cleanse poison", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("purify poison"), nullptr), - /*C*/ nullptr); - } - static ActionNode* cleanse_magic(PlayerbotAI* ai) - { - return new ActionNode ("cleanse magic", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* cleanse_disease(PlayerbotAI* ai) - { - return new ActionNode ("cleanse disease", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("purify disease"), nullptr), - /*C*/ nullptr); - } - static ActionNode* cleanse_poison_on_party(PlayerbotAI* ai) - { - return new ActionNode ("cleanse poison on party", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("purify poison on party"), nullptr), - /*C*/ nullptr); - } - static ActionNode* cleanse_disease_on_party(PlayerbotAI* ai) - { - return new ActionNode ("cleanse disease on party", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("purify disease on party"), nullptr), - /*C*/ nullptr); - } - // static ActionNode* seal_of_wisdom(PlayerbotAI* ai) - // { - // return new ActionNode ("seal of wisdom", - // /*P*/ NULL, - // /*A*/ NextAction::array(0, new NextAction("seal of justice"), NULL), - // /*C*/ NULL); - // } - static ActionNode* seal_of_justice(PlayerbotAI* ai) - { - return new ActionNode ("seal of justice", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("seal of righteousness"), nullptr), - /*C*/ nullptr); - } - static ActionNode* hand_of_reckoning(PlayerbotAI* ai) - { - return new ActionNode ("hand of reckoning", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("righteous defense"), nullptr), - /*C*/ nullptr); - } - static ActionNode* righteous_defense(PlayerbotAI* ai) - { - return new ActionNode ("righteous defense", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("avenger's shield"), nullptr), - /*C*/ nullptr); - } - static ActionNode* avengers_shield(PlayerbotAI* ai) - { - return new ActionNode ("avenger's shield", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("judgement of wisdom"), nullptr), - /*C*/ nullptr); - } - static ActionNode* divine_sacrifice(PlayerbotAI* ai) - { - return new ActionNode ("divine sacrifice", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ NextAction::array(0, new NextAction("cancel divine sacrifice"), nullptr)); - } - static ActionNode* judgement_of_wisdom(PlayerbotAI* ai) - { - return new ActionNode ("judgement of wisdom", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("judgement of light"), nullptr), - /*C*/ nullptr); - } - static ActionNode* judgement(PlayerbotAI* ai) - { - return new ActionNode ("judgement", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* divine_shield(PlayerbotAI* ai) - { - return new ActionNode ("divine shield", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("divine protection"), nullptr), - /*C*/ nullptr); - } - static ActionNode* flash_of_light(PlayerbotAI* ai) - { - return new ActionNode ("flash of light", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("holy light"), nullptr), - /*C*/ nullptr); - } - static ActionNode* flash_of_light_on_party(PlayerbotAI* ai) - { - return new ActionNode ("flash of light on party", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("holy light on party"), nullptr), - /*C*/ nullptr); - } - static ActionNode* holy_wrath(PlayerbotAI* ai) - { - return new ActionNode ("holy wrath", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* hammer_of_wrath(PlayerbotAI* ai) - { - return new ActionNode ("hammer of wrath", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* seal_of_command(PlayerbotAI* ai) - { - return new ActionNode ("seal of command", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("seal of righteousness"), nullptr), - /*C*/ nullptr); - } +public: + GenericPaladinStrategyActionNodeFactory() + { + // creators["seal of light"] = &seal_of_light; + creators["cleanse poison"] = &cleanse_poison; + creators["cleanse disease"] = &cleanse_disease; + creators["cleanse magic"] = &cleanse_magic; + creators["cleanse poison on party"] = &cleanse_poison_on_party; + creators["cleanse disease on party"] = &cleanse_disease_on_party; + // creators["seal of wisdom"] = &seal_of_wisdom; + creators["seal of justice"] = &seal_of_justice; + creators["hand of reckoning"] = &hand_of_reckoning; + creators["judgement"] = &judgement; + creators["judgement of wisdom"] = &judgement_of_wisdom; + creators["divine shield"] = &divine_shield; + creators["flash of light"] = &flash_of_light; + creators["flash of light on party"] = &flash_of_light_on_party; + creators["holy wrath"] = &holy_wrath; + creators["lay on hands"] = &lay_on_hands; + creators["lay on hands on party"] = &lay_on_hands_on_party; + creators["hammer of wrath"] = &hammer_of_wrath; + creators["retribution aura"] = &retribution_aura; + creators["blessing of kings"] = &blessing_of_kings; + creators["blessing of wisdom"] = &blessing_of_wisdom; + creators["blessing of kings on party"] = &blessing_of_kings_on_party; + creators["blessing of wisdom on party"] = &blessing_of_wisdom_on_party; + creators["blessing of sanctuary"] = &blessing_of_sanctuary; + creators["seal of command"] = &seal_of_command; + creators["taunt spell"] = &hand_of_reckoning; + creators["righteous defense"] = &righteous_defense; + creators["avenger's shield"] = &avengers_shield; + creators["divine sacrifice"] = &divine_sacrifice; + } + +private: + static ActionNode* blessing_of_sanctuary(PlayerbotAI* ai) + { + return new ActionNode("blessing of sanctuary", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* blessing_of_kings(PlayerbotAI* ai) + { + return new ActionNode("blessing of kings", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* blessing_of_wisdom(PlayerbotAI* ai) + { + return new ActionNode("blessing of wisdom", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* blessing_of_kings_on_party(PlayerbotAI* ai) + { + return new ActionNode("blessing of kings on party", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* blessing_of_wisdom_on_party(PlayerbotAI* ai) + { + return new ActionNode("blessing of wisdom on party", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* retribution_aura(PlayerbotAI* ai) + { + return new ActionNode("retribution aura", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("devotion aura"), nullptr), + /*C*/ nullptr); + } + static ActionNode* lay_on_hands(PlayerbotAI* ai) + { + return new ActionNode("lay on hands", + /*P*/ nullptr, + /*A*/ nullptr, // NextAction::array(0, new NextAction("divine shield"), new + // NextAction("flash of light"), NULL), + /*C*/ nullptr); + } + static ActionNode* lay_on_hands_on_party(PlayerbotAI* ai) + { + return new ActionNode("lay on hands on party", + /*P*/ nullptr, + /*A*/ nullptr, // NextAction::array(0, new NextAction("flash of light"), NULL), + /*C*/ nullptr); + } + // static ActionNode* seal_of_light(PlayerbotAI* ai) + // { + // return new ActionNode ("seal of light", + // /*P*/ NULL, + // /*A*/ NextAction::array(0, new NextAction("seal of justice"), NULL), + // /*C*/ NULL); + // } + static ActionNode* cleanse_poison(PlayerbotAI* ai) + { + return new ActionNode("cleanse poison", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("purify poison"), nullptr), + /*C*/ nullptr); + } + static ActionNode* cleanse_magic(PlayerbotAI* ai) + { + return new ActionNode("cleanse magic", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* cleanse_disease(PlayerbotAI* ai) + { + return new ActionNode("cleanse disease", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("purify disease"), nullptr), + /*C*/ nullptr); + } + static ActionNode* cleanse_poison_on_party(PlayerbotAI* ai) + { + return new ActionNode("cleanse poison on party", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("purify poison on party"), nullptr), + /*C*/ nullptr); + } + static ActionNode* cleanse_disease_on_party(PlayerbotAI* ai) + { + return new ActionNode("cleanse disease on party", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("purify disease on party"), nullptr), + /*C*/ nullptr); + } + // static ActionNode* seal_of_wisdom(PlayerbotAI* ai) + // { + // return new ActionNode ("seal of wisdom", + // /*P*/ NULL, + // /*A*/ NextAction::array(0, new NextAction("seal of justice"), NULL), + // /*C*/ NULL); + // } + static ActionNode* seal_of_justice(PlayerbotAI* ai) + { + return new ActionNode("seal of justice", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("seal of righteousness"), nullptr), + /*C*/ nullptr); + } + static ActionNode* hand_of_reckoning(PlayerbotAI* ai) + { + return new ActionNode("hand of reckoning", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("righteous defense"), nullptr), + /*C*/ nullptr); + } + static ActionNode* righteous_defense(PlayerbotAI* ai) + { + return new ActionNode("righteous defense", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("avenger's shield"), nullptr), + /*C*/ nullptr); + } + static ActionNode* avengers_shield(PlayerbotAI* ai) + { + return new ActionNode("avenger's shield", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("judgement of wisdom"), nullptr), + /*C*/ nullptr); + } + static ActionNode* divine_sacrifice(PlayerbotAI* ai) + { + return new ActionNode("divine sacrifice", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ NextAction::array(0, new NextAction("cancel divine sacrifice"), nullptr)); + } + static ActionNode* judgement_of_wisdom(PlayerbotAI* ai) + { + return new ActionNode("judgement of wisdom", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("judgement of light"), nullptr), + /*C*/ nullptr); + } + static ActionNode* judgement(PlayerbotAI* ai) + { + return new ActionNode("judgement", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* divine_shield(PlayerbotAI* ai) + { + return new ActionNode("divine shield", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("divine protection"), nullptr), + /*C*/ nullptr); + } + static ActionNode* flash_of_light(PlayerbotAI* ai) + { + return new ActionNode("flash of light", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("holy light"), nullptr), + /*C*/ nullptr); + } + static ActionNode* flash_of_light_on_party(PlayerbotAI* ai) + { + return new ActionNode("flash of light on party", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("holy light on party"), nullptr), + /*C*/ nullptr); + } + static ActionNode* holy_wrath(PlayerbotAI* ai) + { + return new ActionNode("holy wrath", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* hammer_of_wrath(PlayerbotAI* ai) + { + return new ActionNode("hammer of wrath", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* seal_of_command(PlayerbotAI* ai) + { + return new ActionNode("seal of command", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("seal of righteousness"), nullptr), + /*C*/ nullptr); + } }; #endif diff --git a/src/strategy/paladin/HealPaladinStrategy.cpp b/src/strategy/paladin/HealPaladinStrategy.cpp index d34dafe0..dd1edf23 100644 --- a/src/strategy/paladin/HealPaladinStrategy.cpp +++ b/src/strategy/paladin/HealPaladinStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HealPaladinStrategy.h" + #include "Playerbots.h" #include "Strategy.h" @@ -32,50 +34,48 @@ void HealPaladinStrategy::InitTriggers(std::vector& triggers) { GenericPaladinStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("concentration aura", NextAction::array(0, new NextAction("concentration aura", ACTION_NORMAL), nullptr))); - triggers.push_back(new TriggerNode("seal", NextAction::array(0, new NextAction("seal of wisdom", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new NextAction("divine illumination", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("divine favor", ACTION_HIGH + 1), nullptr))); - // triggers.push_back(new TriggerNode("blessing", NextAction::array(0, new NextAction("blessing of sanctuary", ACTION_HIGH + 9), nullptr))); - triggers.push_back(new TriggerNode("party member to heal out of spell range", NextAction::array(0, new NextAction("reach party member to heal", ACTION_EMERGENCY + 3), nullptr))); - + // triggers.push_back(new TriggerNode("concentration aura", NextAction::array(0, new NextAction("concentration + // aura", ACTION_NORMAL), nullptr))); + triggers.push_back( + new TriggerNode("seal", NextAction::array(0, new NextAction("seal of wisdom", ACTION_HIGH), nullptr))); triggers.push_back(new TriggerNode( - "medium group heal occasion", - NextAction::array(0, new NextAction("divine sacrifice", ACTION_CRITICAL_HEAL + 5), nullptr))); - + "medium mana", NextAction::array(0, new NextAction("divine illumination", ACTION_HIGH + 2), nullptr))); + triggers.push_back( + new TriggerNode("low mana", NextAction::array(0, new NextAction("divine favor", ACTION_HIGH + 1), nullptr))); + // triggers.push_back(new TriggerNode("blessing", NextAction::array(0, new NextAction("blessing of sanctuary", + // ACTION_HIGH + 9), nullptr))); triggers.push_back(new TriggerNode( - "party member critical health", - NextAction::array(0, - new NextAction("holy shock on party", ACTION_CRITICAL_HEAL + 6), - new NextAction("divine sacrifice", ACTION_CRITICAL_HEAL + 5), - new NextAction("holy light on party", ACTION_CRITICAL_HEAL + 4), - nullptr))); + "party member to heal out of spell range", + NextAction::array(0, new NextAction("reach party member to heal", ACTION_EMERGENCY + 3), nullptr))); - triggers.push_back(new TriggerNode( - "party member low health", - NextAction::array(0, - new NextAction("holy light on party", ACTION_MEDIUM_HEAL + 5), - nullptr))); + triggers.push_back( + new TriggerNode("medium group heal occasion", + NextAction::array(0, new NextAction("divine sacrifice", ACTION_CRITICAL_HEAL + 5), nullptr))); + + triggers.push_back( + new TriggerNode("party member critical health", + NextAction::array(0, new NextAction("holy shock on party", ACTION_CRITICAL_HEAL + 6), + new NextAction("divine sacrifice", ACTION_CRITICAL_HEAL + 5), + new NextAction("holy light on party", ACTION_CRITICAL_HEAL + 4), nullptr))); + + triggers.push_back( + new TriggerNode("party member low health", + NextAction::array(0, new NextAction("holy light on party", ACTION_MEDIUM_HEAL + 5), nullptr))); + + triggers.push_back( + new TriggerNode("party member medium health", + NextAction::array(0, new NextAction("holy light on party", ACTION_LIGHT_HEAL + 9), + new NextAction("flash of light on party", ACTION_LIGHT_HEAL + 8), nullptr))); - triggers.push_back(new TriggerNode( - "party member medium health", - NextAction::array(0, - new NextAction("holy light on party", ACTION_LIGHT_HEAL + 9), - new NextAction("flash of light on party", ACTION_LIGHT_HEAL + 8), - nullptr))); - triggers.push_back(new TriggerNode( "party member almost full health", - NextAction::array(0, - new NextAction("flash of light on party", ACTION_LIGHT_HEAL + 3), - nullptr))); + NextAction::array(0, new NextAction("flash of light on party", ACTION_LIGHT_HEAL + 3), nullptr))); triggers.push_back(new TriggerNode( "beacon of light on main tank", - NextAction::array(0, new NextAction("beacon of light on main tank", ACTION_CRITICAL_HEAL + 7), nullptr))); + NextAction::array(0, new NextAction("beacon of light on main tank", ACTION_CRITICAL_HEAL + 7), nullptr))); triggers.push_back(new TriggerNode( "sacred shield on main tank", - NextAction::array(0, new NextAction("sacred shield on main tank", ACTION_CRITICAL_HEAL + 6), nullptr))); - + NextAction::array(0, new NextAction("sacred shield on main tank", ACTION_CRITICAL_HEAL + 6), nullptr))); } diff --git a/src/strategy/paladin/HealPaladinStrategy.h b/src/strategy/paladin/HealPaladinStrategy.h index b15bf22f..e740ab37 100644 --- a/src/strategy/paladin/HealPaladinStrategy.h +++ b/src/strategy/paladin/HealPaladinStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HEALPALADINSTRATEGY_H @@ -11,13 +12,13 @@ class PlayerbotAI; class HealPaladinStrategy : public GenericPaladinStrategy { - public: - HealPaladinStrategy(PlayerbotAI* botAI); +public: + HealPaladinStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "heal"; } - NextAction** getDefaultActions() override; - uint32 GetType() const override { return STRATEGY_TYPE_HEAL | STRATEGY_TYPE_RANGED; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "heal"; } + NextAction** getDefaultActions() override; + uint32 GetType() const override { return STRATEGY_TYPE_HEAL | STRATEGY_TYPE_RANGED; } }; #endif diff --git a/src/strategy/paladin/PaladinActions.cpp b/src/strategy/paladin/PaladinActions.cpp index 6a56478b..402d4a56 100644 --- a/src/strategy/paladin/PaladinActions.cpp +++ b/src/strategy/paladin/PaladinActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PaladinActions.h" + #include "AiFactory.h" #include "Event.h" #include "PlayerbotAI.h" @@ -13,7 +15,8 @@ inline std::string const GetActualBlessingOfMight(Unit* target) { - if (!target->ToPlayer()) { + if (!target->ToPlayer()) + { return "blessing of might"; } int tab = AiFactory::GetPlayerSpecTab(target->ToPlayer()); @@ -25,17 +28,20 @@ inline std::string const GetActualBlessingOfMight(Unit* target) return "blessing of wisdom"; break; case CLASS_SHAMAN: - if (tab == SHAMAN_TAB_ELEMENTAL || tab == SHAMAN_TAB_RESTORATION) { + if (tab == SHAMAN_TAB_ELEMENTAL || tab == SHAMAN_TAB_RESTORATION) + { return "blessing of wisdom"; } break; case CLASS_DRUID: - if (tab == DRUID_TAB_RESTORATION || tab == DRUID_TAB_BALANCE) { + if (tab == DRUID_TAB_RESTORATION || tab == DRUID_TAB_BALANCE) + { return "blessing of wisdom"; } break; case CLASS_PALADIN: - if (tab == PALADIN_TAB_HOLY) { + if (tab == PALADIN_TAB_HOLY) + { return "blessing of wisdom"; } break; @@ -46,7 +52,8 @@ inline std::string const GetActualBlessingOfMight(Unit* target) inline std::string const GetActualBlessingOfWisdom(Unit* target) { - if (!target->ToPlayer()) { + if (!target->ToPlayer()) + { return "blessing of might"; } int tab = AiFactory::GetPlayerSpecTab(target->ToPlayer()); @@ -59,17 +66,20 @@ inline std::string const GetActualBlessingOfWisdom(Unit* target) return "blessing of might"; break; case CLASS_SHAMAN: - if (tab == SHAMAN_TAB_ENHANCEMENT) { + if (tab == SHAMAN_TAB_ENHANCEMENT) + { return "blessing of might"; } break; case CLASS_DRUID: - if (tab == DRUID_TAB_FERAL) { + if (tab == DRUID_TAB_FERAL) + { return "blessing of might"; } break; case CLASS_PALADIN: - if (tab == PALADIN_TAB_PROTECTION || tab == PALADIN_TAB_RETRIBUTION) { + if (tab == PALADIN_TAB_PROTECTION || tab == PALADIN_TAB_RETRIBUTION) + { return "blessing of might"; } break; @@ -97,7 +107,6 @@ Value* CastBlessingOfMightOnPartyAction::GetTargetValue() return context->GetValue("party member without aura", "blessing of might,blessing of wisdom"); } - bool CastBlessingOfMightOnPartyAction::Execute(Event event) { Unit* target = GetTarget(); @@ -130,20 +139,15 @@ bool CastBlessingOfWisdomOnPartyAction::Execute(Event event) return botAI->CastSpell(GetActualBlessingOfWisdom(target), target); } -bool CastSealSpellAction::isUseful() -{ - return AI_VALUE2(bool, "combat", "self target"); -} +bool CastSealSpellAction::isUseful() { return AI_VALUE2(bool, "combat", "self target"); } -Value* CastTurnUndeadAction::GetTargetValue() -{ - return context->GetValue("cc target", getName()); -} +Value* CastTurnUndeadAction::GetTargetValue() { return context->GetValue("cc target", getName()); } Unit* CastRighteousDefenseAction::GetTarget() { Unit* current_target = AI_VALUE(Unit*, "current target"); - if (!current_target) { + if (!current_target) + { return NULL; } return current_target->GetVictim(); @@ -153,12 +157,14 @@ bool CastMeleeConsecrationAction::isUseful() { Unit* target = GetTarget(); // float dis = distance + CONTACT_DISTANCE; - return target && bot->IsWithinMeleeRange(target); // sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", GetTargetName()), distance); + return target && bot->IsWithinMeleeRange(target); // sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, + // "distance", GetTargetName()), distance); } bool CastDivineSacrificeAction::isUseful() { - return GetTarget() && (GetTarget() != nullptr) && CastSpellAction::isUseful() && !botAI->HasAura("divine guardian", GetTarget(), false, false, -1, true); + return GetTarget() && (GetTarget() != nullptr) && CastSpellAction::isUseful() && + !botAI->HasAura("divine guardian", GetTarget(), false, false, -1, true); } bool CastCancelDivineSacrificeAction::Execute(Event event) diff --git a/src/strategy/paladin/PaladinActions.h b/src/strategy/paladin/PaladinActions.h index 24a3874a..826c82e2 100644 --- a/src/strategy/paladin/PaladinActions.h +++ b/src/strategy/paladin/PaladinActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PALADINACTIONS_H @@ -45,9 +46,9 @@ MELEE_ACTION(CastConsecrationAction, "consecration"); class CastMeleeConsecrationAction : public CastSpellAction { - public: - CastMeleeConsecrationAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "consecration") {} - bool isUseful() override; +public: + CastMeleeConsecrationAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "consecration") {} + bool isUseful() override; }; // repentance @@ -55,7 +56,7 @@ SNARE_ACTION(CastRepentanceSnareAction, "repentance"); DEBUFF_ACTION(CastRepentanceAction, "repentance"); ENEMY_HEALER_ACTION(CastRepentanceOnHealerAction, "repentance"); -//hamme of wrath +// hamme of wrath SPELL_ACTION(CastHammerOfWrathAction, "hammer of wrath"); // buffs @@ -68,260 +69,273 @@ BUFF_ACTION(CastRighteousFuryAction, "righteous fury"); class CastDivineStormAction : public CastBuffSpellAction { - public: - CastDivineStormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "divine storm") { } +public: + CastDivineStormAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "divine storm") {} }; class CastCrusaderStrikeAction : public CastMeleeSpellAction { - public: - CastCrusaderStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "crusader strike") { } +public: + CastCrusaderStrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "crusader strike") {} }; class CastSealSpellAction : public CastBuffSpellAction { - public: - CastSealSpellAction(PlayerbotAI* botAI, std::string const name) : CastBuffSpellAction(botAI, name) { } +public: + CastSealSpellAction(PlayerbotAI* botAI, std::string const name) : CastBuffSpellAction(botAI, name) {} - bool isUseful() override; + bool isUseful() override; }; class CastBlessingOfMightAction : public CastBuffSpellAction { - public: - CastBlessingOfMightAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "blessing of might") { } +public: + CastBlessingOfMightAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "blessing of might") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class CastBlessingOnPartyAction : public BuffOnPartyAction { - public: - CastBlessingOnPartyAction(PlayerbotAI* botAI, std::string const name) : BuffOnPartyAction(botAI, name), name(name) { } +public: + CastBlessingOnPartyAction(PlayerbotAI* botAI, std::string const name) : BuffOnPartyAction(botAI, name), name(name) + { + } - Value* GetTargetValue() override; + Value* GetTargetValue() override; - private: - std::string name; +private: + std::string name; }; class CastBlessingOfMightOnPartyAction : public BuffOnPartyAction { - public: - CastBlessingOfMightOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "blessing of might") { } +public: + CastBlessingOfMightOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "blessing of might") {} - std::string const getName() override { return "blessing of might on party";} - Value* GetTargetValue() override; - bool Execute(Event event) override; + std::string const getName() override { return "blessing of might on party"; } + Value* GetTargetValue() override; + bool Execute(Event event) override; }; class CastBlessingOfWisdomAction : public CastBuffSpellAction { - public: - CastBlessingOfWisdomAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "blessing of wisdom") { } +public: + CastBlessingOfWisdomAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "blessing of wisdom") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class CastBlessingOfWisdomOnPartyAction : public BuffOnPartyAction { - public: - CastBlessingOfWisdomOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "blessing of wisdom") { } +public: + CastBlessingOfWisdomOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "blessing of wisdom") {} - std::string const getName() override { return "blessing of wisdom on party";} - Value* GetTargetValue() override; - bool Execute(Event event) override; + std::string const getName() override { return "blessing of wisdom on party"; } + Value* GetTargetValue() override; + bool Execute(Event event) override; }; class CastBlessingOfKingsAction : public CastBuffSpellAction { - public: - CastBlessingOfKingsAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "blessing of kings") { } +public: + CastBlessingOfKingsAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "blessing of kings") {} }; class CastBlessingOfKingsOnPartyAction : public CastBlessingOnPartyAction { - public: - CastBlessingOfKingsOnPartyAction(PlayerbotAI* botAI) : CastBlessingOnPartyAction(botAI, "blessing of kings") { } +public: + CastBlessingOfKingsOnPartyAction(PlayerbotAI* botAI) : CastBlessingOnPartyAction(botAI, "blessing of kings") {} - std::string const getName() override { return "blessing of kings on party";} + std::string const getName() override { return "blessing of kings on party"; } }; class CastBlessingOfSanctuaryAction : public CastBuffSpellAction { - public: - CastBlessingOfSanctuaryAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "blessing of sanctuary") { } +public: + CastBlessingOfSanctuaryAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "blessing of sanctuary") {} }; class CastBlessingOfSanctuaryOnPartyAction : public CastBlessingOnPartyAction { - public: - CastBlessingOfSanctuaryOnPartyAction(PlayerbotAI* botAI) : CastBlessingOnPartyAction(botAI, "blessing of sanctuary") { } +public: + CastBlessingOfSanctuaryOnPartyAction(PlayerbotAI* botAI) : CastBlessingOnPartyAction(botAI, "blessing of sanctuary") + { + } - std::string const getName() override { return "blessing of sanctuary on party";} + std::string const getName() override { return "blessing of sanctuary on party"; } }; class CastHolyLightAction : public CastHealingSpellAction { - public: - CastHolyLightAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "holy light") { } +public: + CastHolyLightAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "holy light") {} }; class CastHolyShockOnPartyAction : public HealPartyMemberAction { - public: - CastHolyShockOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "holy shock", 25.0f, HealingManaEfficiency::LOW) { } +public: + CastHolyShockOnPartyAction(PlayerbotAI* botAI) + : HealPartyMemberAction(botAI, "holy shock", 25.0f, HealingManaEfficiency::LOW) + { + } }; class CastHolyLightOnPartyAction : public HealPartyMemberAction { - public: - CastHolyLightOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "holy light", 50.0f, HealingManaEfficiency::MEDIUM) { } +public: + CastHolyLightOnPartyAction(PlayerbotAI* botAI) + : HealPartyMemberAction(botAI, "holy light", 50.0f, HealingManaEfficiency::MEDIUM) + { + } }; class CastFlashOfLightAction : public CastHealingSpellAction { - public: - CastFlashOfLightAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "flash of light") { } +public: + CastFlashOfLightAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "flash of light") {} }; class CastFlashOfLightOnPartyAction : public HealPartyMemberAction { - public: - CastFlashOfLightOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "flash of light", 15.0f, HealingManaEfficiency::HIGH) { } +public: + CastFlashOfLightOnPartyAction(PlayerbotAI* botAI) + : HealPartyMemberAction(botAI, "flash of light", 15.0f, HealingManaEfficiency::HIGH) + { + } }; class CastLayOnHandsAction : public CastHealingSpellAction { - public: - CastLayOnHandsAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "lay on hands") { } +public: + CastLayOnHandsAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "lay on hands") {} }; class CastLayOnHandsOnPartyAction : public HealPartyMemberAction { - public: - CastLayOnHandsOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "lay on hands") { } +public: + CastLayOnHandsOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "lay on hands") {} }; class CastDivineProtectionAction : public CastBuffSpellAction { - public: - CastDivineProtectionAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "divine protection") { } +public: + CastDivineProtectionAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "divine protection") {} }; class CastDivineProtectionOnPartyAction : public HealPartyMemberAction { - public: - CastDivineProtectionOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "divine protection") { } +public: + CastDivineProtectionOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "divine protection") {} - std::string const getName() override { return "divine protection on party"; } + std::string const getName() override { return "divine protection on party"; } }; -class CastDivineShieldAction: public CastBuffSpellAction +class CastDivineShieldAction : public CastBuffSpellAction { - public: - CastDivineShieldAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "divine shield") { } +public: + CastDivineShieldAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "divine shield") {} }; class CastHolyWrathAction : public CastMeleeSpellAction { - public: - CastHolyWrathAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "holy wrath") { } +public: + CastHolyWrathAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "holy wrath") {} }; class CastHammerOfJusticeAction : public CastMeleeSpellAction { - public: - CastHammerOfJusticeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "hammer of justice") { } +public: + CastHammerOfJusticeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "hammer of justice") {} }; class CastHammerOfTheRighteousAction : public CastMeleeSpellAction { - public: - CastHammerOfTheRighteousAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "hammer of the righteous") { } +public: + CastHammerOfTheRighteousAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "hammer of the righteous") {} }; class CastPurifyPoisonAction : public CastCureSpellAction { - public: - CastPurifyPoisonAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "purify") { } +public: + CastPurifyPoisonAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "purify") {} }; class CastPurifyDiseaseAction : public CastCureSpellAction { - public: - CastPurifyDiseaseAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "purify") { } +public: + CastPurifyDiseaseAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "purify") {} }; class CastPurifyPoisonOnPartyAction : public CurePartyMemberAction { - public: - CastPurifyPoisonOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "purify", DISPEL_POISON) { } +public: + CastPurifyPoisonOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "purify", DISPEL_POISON) {} - std::string const getName() override { return "purify poison on party"; } + std::string const getName() override { return "purify poison on party"; } }; class CastPurifyDiseaseOnPartyAction : public CurePartyMemberAction { - public: - CastPurifyDiseaseOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "purify", DISPEL_DISEASE) { } +public: + CastPurifyDiseaseOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "purify", DISPEL_DISEASE) {} - std::string const getName() override { return "purify disease on party"; } + std::string const getName() override { return "purify disease on party"; } }; class CastHandOfReckoningAction : public CastSpellAction { - public: - CastHandOfReckoningAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "hand of reckoning") { } +public: + CastHandOfReckoningAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "hand of reckoning") {} }; class CastRighteousDefenseAction : public CastSpellAction { - public: - CastRighteousDefenseAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "righteous defense") { } - virtual Unit* GetTarget() override; +public: + CastRighteousDefenseAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "righteous defense") {} + virtual Unit* GetTarget() override; }; class CastCleansePoisonAction : public CastCureSpellAction { - public: - CastCleansePoisonAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "cleanse") { } +public: + CastCleansePoisonAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "cleanse") {} }; class CastCleanseDiseaseAction : public CastCureSpellAction { - public: - CastCleanseDiseaseAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "cleanse") { } +public: + CastCleanseDiseaseAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "cleanse") {} }; class CastCleanseMagicAction : public CastCureSpellAction { - public: - CastCleanseMagicAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "cleanse") { } +public: + CastCleanseMagicAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "cleanse") {} }; class CastCleansePoisonOnPartyAction : public CurePartyMemberAction { - public: - CastCleansePoisonOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "cleanse", DISPEL_POISON) { } +public: + CastCleansePoisonOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "cleanse", DISPEL_POISON) {} - std::string const getName() override { return "cleanse poison on party"; } + std::string const getName() override { return "cleanse poison on party"; } }; class CastCleanseDiseaseOnPartyAction : public CurePartyMemberAction { - public: - CastCleanseDiseaseOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "cleanse", DISPEL_DISEASE) { } +public: + CastCleanseDiseaseOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "cleanse", DISPEL_DISEASE) {} - std::string const getName() override { return "cleanse disease on party"; } + std::string const getName() override { return "cleanse disease on party"; } }; class CastCleanseMagicOnPartyAction : public CurePartyMemberAction { - public: - CastCleanseMagicOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "cleanse", DISPEL_MAGIC) { } +public: + CastCleanseMagicOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "cleanse", DISPEL_MAGIC) {} - std::string const getName() override { return "cleanse magic on party"; } + std::string const getName() override { return "cleanse magic on party"; } }; BEGIN_SPELL_ACTION(CastAvengersShieldAction, "avenger's shield") @@ -332,34 +346,37 @@ END_SPELL_ACTION() class CastHolyShieldAction : public CastBuffSpellAction { - public: - CastHolyShieldAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "holy shield") { } +public: + CastHolyShieldAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "holy shield") {} }; class CastRedemptionAction : public ResurrectPartyMemberAction { - public: - CastRedemptionAction(PlayerbotAI* botAI) : ResurrectPartyMemberAction(botAI, "redemption") { } +public: + CastRedemptionAction(PlayerbotAI* botAI) : ResurrectPartyMemberAction(botAI, "redemption") {} }; class CastHammerOfJusticeOnEnemyHealerAction : public CastSpellOnEnemyHealerAction { - public: - CastHammerOfJusticeOnEnemyHealerAction(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, "hammer of justice") { } +public: + CastHammerOfJusticeOnEnemyHealerAction(PlayerbotAI* botAI) + : CastSpellOnEnemyHealerAction(botAI, "hammer of justice") + { + } }; class CastHammerOfJusticeSnareAction : public CastSnareSpellAction { - public: - CastHammerOfJusticeSnareAction(PlayerbotAI* botAI) : CastSnareSpellAction(botAI, "hammer of justice") { } +public: + CastHammerOfJusticeSnareAction(PlayerbotAI* botAI) : CastSnareSpellAction(botAI, "hammer of justice") {} }; class CastTurnUndeadAction : public CastBuffSpellAction { - public: - CastTurnUndeadAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "turn undead") { } +public: + CastTurnUndeadAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "turn undead") {} - Value* GetTargetValue() override; + Value* GetTargetValue() override; }; PROTECT_ACTION(CastBlessingOfProtectionProtectAction, "blessing of protection"); @@ -367,51 +384,51 @@ PROTECT_ACTION(CastBlessingOfProtectionProtectAction, "blessing of protection"); class CastDivinePleaAction : public CastBuffSpellAction { public: - CastDivinePleaAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, "divine plea") {} + CastDivinePleaAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, "divine plea") {} }; class ShieldOfRighteousnessAction : public CastMeleeSpellAction { public: - ShieldOfRighteousnessAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "shield of righteousness") {} + ShieldOfRighteousnessAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "shield of righteousness") {} }; class CastBeaconOfLightOnMainTankAction : public BuffOnMainTankAction { public: - CastBeaconOfLightOnMainTankAction(PlayerbotAI* ai) : BuffOnMainTankAction(ai, "beacon of light", true) {} + CastBeaconOfLightOnMainTankAction(PlayerbotAI* ai) : BuffOnMainTankAction(ai, "beacon of light", true) {} }; class CastSacredShieldOnMainTankAction : public BuffOnMainTankAction { public: - CastSacredShieldOnMainTankAction(PlayerbotAI* ai) : BuffOnMainTankAction(ai, "sacred shield", false) {} + CastSacredShieldOnMainTankAction(PlayerbotAI* ai) : BuffOnMainTankAction(ai, "sacred shield", false) {} }; class CastAvengingWrathAction : public CastBuffSpellAction { - public: - CastAvengingWrathAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "avenging wrath") {} +public: + CastAvengingWrathAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "avenging wrath") {} }; class CastDivineIlluminationAction : public CastBuffSpellAction { - public: - CastDivineIlluminationAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "divine illumination") {} +public: + CastDivineIlluminationAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "divine illumination") {} }; class CastDivineSacrificeAction : public CastBuffSpellAction { - public: - CastDivineSacrificeAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "divine sacrifice") {} - bool isUseful() override; +public: + CastDivineSacrificeAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "divine sacrifice") {} + bool isUseful() override; }; class CastCancelDivineSacrificeAction : public Action { - public: - CastCancelDivineSacrificeAction(PlayerbotAI* botAI) : Action(botAI, "cancel divine sacrifice") {} - bool Execute(Event event) override; - bool isUseful() override; +public: + CastCancelDivineSacrificeAction(PlayerbotAI* botAI) : Action(botAI, "cancel divine sacrifice") {} + bool Execute(Event event) override; + bool isUseful() override; }; #endif diff --git a/src/strategy/paladin/PaladinAiObjectContext.cpp b/src/strategy/paladin/PaladinAiObjectContext.cpp index 68766229..770069a1 100644 --- a/src/strategy/paladin/PaladinAiObjectContext.cpp +++ b/src/strategy/paladin/PaladinAiObjectContext.cpp @@ -1,352 +1,400 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PaladinAiObjectContext.h" + #include "DpsPaladinStrategy.h" +#include "GenericPaladinNonCombatStrategy.h" +#include "HealPaladinStrategy.h" +#include "NamedObjectContext.h" #include "PaladinActions.h" #include "PaladinBuffStrategies.h" #include "PaladinTriggers.h" -#include "GenericPaladinNonCombatStrategy.h" -#include "HealPaladinStrategy.h" -#include "TankPaladinStrategy.h" -#include "NamedObjectContext.h" #include "Playerbots.h" +#include "TankPaladinStrategy.h" class PaladinStrategyFactoryInternal : public NamedObjectContext { - public: - PaladinStrategyFactoryInternal() - { - creators["nc"] = &PaladinStrategyFactoryInternal::nc; - creators["cure"] = &PaladinStrategyFactoryInternal::cure; - creators["boost"] = &PaladinStrategyFactoryInternal::boost; - creators["cc"] = &PaladinStrategyFactoryInternal::cc; - creators["bthreat"] = &PaladinStrategyFactoryInternal::bthreat; - } +public: + PaladinStrategyFactoryInternal() + { + creators["nc"] = &PaladinStrategyFactoryInternal::nc; + creators["cure"] = &PaladinStrategyFactoryInternal::cure; + creators["boost"] = &PaladinStrategyFactoryInternal::boost; + creators["cc"] = &PaladinStrategyFactoryInternal::cc; + creators["bthreat"] = &PaladinStrategyFactoryInternal::bthreat; + } - private: - static Strategy* nc(PlayerbotAI* botAI) { return new GenericPaladinNonCombatStrategy(botAI); } - static Strategy* cure(PlayerbotAI* botAI) { return new PaladinCureStrategy(botAI); } - static Strategy* boost(PlayerbotAI* botAI) { return new PaladinBoostStrategy(botAI); } - static Strategy* cc(PlayerbotAI* botAI) { return new PaladinCcStrategy(botAI); } - static Strategy* bthreat(PlayerbotAI* botAI) { return new PaladinBuffThreatStrategy(botAI); } +private: + static Strategy* nc(PlayerbotAI* botAI) { return new GenericPaladinNonCombatStrategy(botAI); } + static Strategy* cure(PlayerbotAI* botAI) { return new PaladinCureStrategy(botAI); } + static Strategy* boost(PlayerbotAI* botAI) { return new PaladinBoostStrategy(botAI); } + static Strategy* cc(PlayerbotAI* botAI) { return new PaladinCcStrategy(botAI); } + static Strategy* bthreat(PlayerbotAI* botAI) { return new PaladinBuffThreatStrategy(botAI); } }; class PaladinResistanceStrategyFactoryInternal : public NamedObjectContext { - public: - PaladinResistanceStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["rshadow"] = &PaladinResistanceStrategyFactoryInternal::rshadow; - creators["rfrost"] = &PaladinResistanceStrategyFactoryInternal::rfrost; - creators["rfire"] = &PaladinResistanceStrategyFactoryInternal::rfire; - creators["baoe"] = &PaladinResistanceStrategyFactoryInternal::baoe; - creators["barmor"] = &PaladinResistanceStrategyFactoryInternal::barmor; - creators["bcast"] = &PaladinResistanceStrategyFactoryInternal::bcast; - } +public: + PaladinResistanceStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["rshadow"] = &PaladinResistanceStrategyFactoryInternal::rshadow; + creators["rfrost"] = &PaladinResistanceStrategyFactoryInternal::rfrost; + creators["rfire"] = &PaladinResistanceStrategyFactoryInternal::rfire; + creators["baoe"] = &PaladinResistanceStrategyFactoryInternal::baoe; + creators["barmor"] = &PaladinResistanceStrategyFactoryInternal::barmor; + creators["bcast"] = &PaladinResistanceStrategyFactoryInternal::bcast; + } - private: - static Strategy* rshadow(PlayerbotAI* botAI) { return new PaladinShadowResistanceStrategy(botAI); } - static Strategy* rfrost(PlayerbotAI* botAI) { return new PaladinFrostResistanceStrategy(botAI); } - static Strategy* rfire(PlayerbotAI* botAI) { return new PaladinFireResistanceStrategy(botAI); } - static Strategy* baoe(PlayerbotAI* botAI) { return new PaladinBuffAoeStrategy(botAI); } - static Strategy* barmor(PlayerbotAI* botAI) { return new PaladinBuffArmorStrategy(botAI); } - static Strategy* bcast(PlayerbotAI* botAI) { return new PaladinBuffCastStrategy(botAI); } +private: + static Strategy* rshadow(PlayerbotAI* botAI) { return new PaladinShadowResistanceStrategy(botAI); } + static Strategy* rfrost(PlayerbotAI* botAI) { return new PaladinFrostResistanceStrategy(botAI); } + static Strategy* rfire(PlayerbotAI* botAI) { return new PaladinFireResistanceStrategy(botAI); } + static Strategy* baoe(PlayerbotAI* botAI) { return new PaladinBuffAoeStrategy(botAI); } + static Strategy* barmor(PlayerbotAI* botAI) { return new PaladinBuffArmorStrategy(botAI); } + static Strategy* bcast(PlayerbotAI* botAI) { return new PaladinBuffCastStrategy(botAI); } }; class PaladinBuffStrategyFactoryInternal : public NamedObjectContext { - public: - PaladinBuffStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["bhealth"] = &PaladinBuffStrategyFactoryInternal::bhealth; - creators["bmana"] = &PaladinBuffStrategyFactoryInternal::bmana; - creators["bdps"] = &PaladinBuffStrategyFactoryInternal::bdps; - creators["bstats"] = &PaladinBuffStrategyFactoryInternal::bstats; - } +public: + PaladinBuffStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["bhealth"] = &PaladinBuffStrategyFactoryInternal::bhealth; + creators["bmana"] = &PaladinBuffStrategyFactoryInternal::bmana; + creators["bdps"] = &PaladinBuffStrategyFactoryInternal::bdps; + creators["bstats"] = &PaladinBuffStrategyFactoryInternal::bstats; + } - private: - static Strategy* bhealth(PlayerbotAI* botAI) { return new PaladinBuffHealthStrategy(botAI); } - static Strategy* bmana(PlayerbotAI* botAI) { return new PaladinBuffManaStrategy(botAI); } - static Strategy* bdps(PlayerbotAI* botAI) { return new PaladinBuffDpsStrategy(botAI); } - static Strategy* bstats(PlayerbotAI* botAI) { return new PaladinBuffStatsStrategy(botAI); } +private: + static Strategy* bhealth(PlayerbotAI* botAI) { return new PaladinBuffHealthStrategy(botAI); } + static Strategy* bmana(PlayerbotAI* botAI) { return new PaladinBuffManaStrategy(botAI); } + static Strategy* bdps(PlayerbotAI* botAI) { return new PaladinBuffDpsStrategy(botAI); } + static Strategy* bstats(PlayerbotAI* botAI) { return new PaladinBuffStatsStrategy(botAI); } }; class PaladinCombatStrategyFactoryInternal : public NamedObjectContext { - public: - PaladinCombatStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["tank"] = &PaladinCombatStrategyFactoryInternal::tank; - creators["dps"] = &PaladinCombatStrategyFactoryInternal::dps; - creators["heal"] = &PaladinCombatStrategyFactoryInternal::heal; - } +public: + PaladinCombatStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["tank"] = &PaladinCombatStrategyFactoryInternal::tank; + creators["dps"] = &PaladinCombatStrategyFactoryInternal::dps; + creators["heal"] = &PaladinCombatStrategyFactoryInternal::heal; + } - private: - static Strategy* tank(PlayerbotAI* botAI) { return new TankPaladinStrategy(botAI); } - static Strategy* dps(PlayerbotAI* botAI) { return new DpsPaladinStrategy(botAI); } - static Strategy* heal(PlayerbotAI* botAI) { return new HealPaladinStrategy(botAI); } +private: + static Strategy* tank(PlayerbotAI* botAI) { return new TankPaladinStrategy(botAI); } + static Strategy* dps(PlayerbotAI* botAI) { return new DpsPaladinStrategy(botAI); } + static Strategy* heal(PlayerbotAI* botAI) { return new HealPaladinStrategy(botAI); } }; class PaladinTriggerFactoryInternal : public NamedObjectContext { - public: - PaladinTriggerFactoryInternal() - { - creators["judgement"] = &PaladinTriggerFactoryInternal::judgement; - creators["judgement of wisdom"] = &PaladinTriggerFactoryInternal::judgement_of_wisdom; - creators["judgement of light"] = &PaladinTriggerFactoryInternal::judgement_of_light; - creators["blessing"] = &PaladinTriggerFactoryInternal::blessing; - creators["seal"] = &PaladinTriggerFactoryInternal::seal; - creators["art of war"] = &PaladinTriggerFactoryInternal::art_of_war; - creators["blessing on party"] = &PaladinTriggerFactoryInternal::blessing_on_party; - creators["crusader aura"] = &PaladinTriggerFactoryInternal::crusader_aura; - creators["retribution aura"] = &PaladinTriggerFactoryInternal::retribution_aura; - creators["devotion aura"] = &PaladinTriggerFactoryInternal::devotion_aura; - creators["sanctity aura"] = &PaladinTriggerFactoryInternal::sanctity_aura; - creators["concentration aura"] = &PaladinTriggerFactoryInternal::concentration_aura; - creators["shadow resistance aura"] = &PaladinTriggerFactoryInternal::shadow_resistance_aura; - creators["frost resistance aura"] = &PaladinTriggerFactoryInternal::frost_resistance_aura; - creators["fire resistance aura"] = &PaladinTriggerFactoryInternal::fire_resistance_aura; - creators["hammer of justice snare"] = &PaladinTriggerFactoryInternal::hammer_of_justice_snare; - creators["hammer of justice interrupt"] = &PaladinTriggerFactoryInternal::hammer_of_justice_interrupt; - creators["cleanse cure disease"] = &PaladinTriggerFactoryInternal::CleanseCureDisease; - creators["cleanse party member cure disease"] = &PaladinTriggerFactoryInternal::CleanseCurePartyMemberDisease; - creators["cleanse cure poison"] = &PaladinTriggerFactoryInternal::CleanseCurePoison; - creators["cleanse party member cure poison"] = &PaladinTriggerFactoryInternal::CleanseCurePartyMemberPoison; - creators["cleanse cure magic"] = &PaladinTriggerFactoryInternal::CleanseCureMagic; - creators["cleanse party member cure magic"] = &PaladinTriggerFactoryInternal::CleanseCurePartyMemberMagic; - creators["righteous fury"] = &PaladinTriggerFactoryInternal::righteous_fury; - creators["holy shield"] = &PaladinTriggerFactoryInternal::holy_shield; - creators["hammer of justice on enemy healer"] = &PaladinTriggerFactoryInternal::hammer_of_justice_on_enemy_target; - creators["hammer of justice on snare target"] = &PaladinTriggerFactoryInternal::hammer_of_justice_on_snare_target; - creators["divine favor"] = &PaladinTriggerFactoryInternal::divine_favor; - creators["turn undead"] = &PaladinTriggerFactoryInternal::turn_undead; - creators["avenger's shield"] = &PaladinTriggerFactoryInternal::avenger_shield; - creators["consecration"] = &PaladinTriggerFactoryInternal::consecration; - creators["repentance on enemy healer"] = &PaladinTriggerFactoryInternal::repentance_on_enemy_healer; - creators["repentance on snare target"] = &PaladinTriggerFactoryInternal::repentance_on_snare_target; - creators["repentance interrupt"] = &PaladinTriggerFactoryInternal::repentance_interrupt; - creators["beacon of light on main tank"] = &PaladinTriggerFactoryInternal::beacon_of_light_on_main_tank; - creators["sacred shield on main tank"] = &PaladinTriggerFactoryInternal::sacred_shield_on_main_tank; +public: + PaladinTriggerFactoryInternal() + { + creators["judgement"] = &PaladinTriggerFactoryInternal::judgement; + creators["judgement of wisdom"] = &PaladinTriggerFactoryInternal::judgement_of_wisdom; + creators["judgement of light"] = &PaladinTriggerFactoryInternal::judgement_of_light; + creators["blessing"] = &PaladinTriggerFactoryInternal::blessing; + creators["seal"] = &PaladinTriggerFactoryInternal::seal; + creators["art of war"] = &PaladinTriggerFactoryInternal::art_of_war; + creators["blessing on party"] = &PaladinTriggerFactoryInternal::blessing_on_party; + creators["crusader aura"] = &PaladinTriggerFactoryInternal::crusader_aura; + creators["retribution aura"] = &PaladinTriggerFactoryInternal::retribution_aura; + creators["devotion aura"] = &PaladinTriggerFactoryInternal::devotion_aura; + creators["sanctity aura"] = &PaladinTriggerFactoryInternal::sanctity_aura; + creators["concentration aura"] = &PaladinTriggerFactoryInternal::concentration_aura; + creators["shadow resistance aura"] = &PaladinTriggerFactoryInternal::shadow_resistance_aura; + creators["frost resistance aura"] = &PaladinTriggerFactoryInternal::frost_resistance_aura; + creators["fire resistance aura"] = &PaladinTriggerFactoryInternal::fire_resistance_aura; + creators["hammer of justice snare"] = &PaladinTriggerFactoryInternal::hammer_of_justice_snare; + creators["hammer of justice interrupt"] = &PaladinTriggerFactoryInternal::hammer_of_justice_interrupt; + creators["cleanse cure disease"] = &PaladinTriggerFactoryInternal::CleanseCureDisease; + creators["cleanse party member cure disease"] = &PaladinTriggerFactoryInternal::CleanseCurePartyMemberDisease; + creators["cleanse cure poison"] = &PaladinTriggerFactoryInternal::CleanseCurePoison; + creators["cleanse party member cure poison"] = &PaladinTriggerFactoryInternal::CleanseCurePartyMemberPoison; + creators["cleanse cure magic"] = &PaladinTriggerFactoryInternal::CleanseCureMagic; + creators["cleanse party member cure magic"] = &PaladinTriggerFactoryInternal::CleanseCurePartyMemberMagic; + creators["righteous fury"] = &PaladinTriggerFactoryInternal::righteous_fury; + creators["holy shield"] = &PaladinTriggerFactoryInternal::holy_shield; + creators["hammer of justice on enemy healer"] = + &PaladinTriggerFactoryInternal::hammer_of_justice_on_enemy_target; + creators["hammer of justice on snare target"] = + &PaladinTriggerFactoryInternal::hammer_of_justice_on_snare_target; + creators["divine favor"] = &PaladinTriggerFactoryInternal::divine_favor; + creators["turn undead"] = &PaladinTriggerFactoryInternal::turn_undead; + creators["avenger's shield"] = &PaladinTriggerFactoryInternal::avenger_shield; + creators["consecration"] = &PaladinTriggerFactoryInternal::consecration; + creators["repentance on enemy healer"] = &PaladinTriggerFactoryInternal::repentance_on_enemy_healer; + creators["repentance on snare target"] = &PaladinTriggerFactoryInternal::repentance_on_snare_target; + creators["repentance interrupt"] = &PaladinTriggerFactoryInternal::repentance_interrupt; + creators["beacon of light on main tank"] = &PaladinTriggerFactoryInternal::beacon_of_light_on_main_tank; + creators["sacred shield on main tank"] = &PaladinTriggerFactoryInternal::sacred_shield_on_main_tank; - creators["blessing of kings on party"] = &PaladinTriggerFactoryInternal::blessing_of_kings_on_party; - creators["blessing of wisdom on party"] = &PaladinTriggerFactoryInternal::blessing_of_wisdom_on_party; - creators["blessing of might on party"] = &PaladinTriggerFactoryInternal::blessing_of_might_on_party; + creators["blessing of kings on party"] = &PaladinTriggerFactoryInternal::blessing_of_kings_on_party; + creators["blessing of wisdom on party"] = &PaladinTriggerFactoryInternal::blessing_of_wisdom_on_party; + creators["blessing of might on party"] = &PaladinTriggerFactoryInternal::blessing_of_might_on_party; - creators["avenging wrath"] = &PaladinTriggerFactoryInternal::avenging_wrath; - } + creators["avenging wrath"] = &PaladinTriggerFactoryInternal::avenging_wrath; + } - private: - static Trigger* turn_undead(PlayerbotAI* botAI) { return new TurnUndeadTrigger(botAI); } - static Trigger* divine_favor(PlayerbotAI* botAI) { return new DivineFavorTrigger(botAI); } - static Trigger* holy_shield(PlayerbotAI* botAI) { return new HolyShieldTrigger(botAI); } - static Trigger* righteous_fury(PlayerbotAI* botAI) { return new RighteousFuryTrigger(botAI); } - static Trigger* judgement(PlayerbotAI* botAI) { return new JudgementTrigger(botAI); } - static Trigger* judgement_of_wisdom(PlayerbotAI* botAI) { return new JudgementOfWisdomTrigger(botAI); } - static Trigger* judgement_of_light(PlayerbotAI* botAI) { return new JudgementOfLightTrigger(botAI); } - static Trigger* blessing(PlayerbotAI* botAI) { return new BlessingTrigger(botAI); } - static Trigger* seal(PlayerbotAI* botAI) { return new SealTrigger(botAI); } - static Trigger* art_of_war(PlayerbotAI* botAI) { return new ArtOfWarTrigger(botAI); } - static Trigger* blessing_on_party(PlayerbotAI* botAI) { return new BlessingOnPartyTrigger(botAI); } - static Trigger* crusader_aura(PlayerbotAI* botAI) { return new CrusaderAuraTrigger(botAI); } - static Trigger* retribution_aura(PlayerbotAI* botAI) { return new RetributionAuraTrigger(botAI); } - static Trigger* devotion_aura(PlayerbotAI* botAI) { return new DevotionAuraTrigger(botAI); } - static Trigger* sanctity_aura(PlayerbotAI* botAI) { return new SanctityAuraTrigger(botAI); } - static Trigger* concentration_aura(PlayerbotAI* botAI) { return new ConcentrationAuraTrigger(botAI); } - static Trigger* shadow_resistance_aura(PlayerbotAI* botAI) { return new ShadowResistanceAuraTrigger(botAI); } - static Trigger* frost_resistance_aura(PlayerbotAI* botAI) { return new FrostResistanceAuraTrigger(botAI); } - static Trigger* fire_resistance_aura(PlayerbotAI* botAI) { return new FireResistanceAuraTrigger(botAI); } - static Trigger* hammer_of_justice_snare(PlayerbotAI* botAI) { return new HammerOfJusticeSnareTrigger(botAI); } - static Trigger* hammer_of_justice_interrupt(PlayerbotAI* botAI) { return new HammerOfJusticeInterruptSpellTrigger(botAI); } - static Trigger* CleanseCureDisease(PlayerbotAI* botAI) { return new CleanseCureDiseaseTrigger(botAI); } - static Trigger* CleanseCurePartyMemberDisease(PlayerbotAI* botAI) { return new CleanseCurePartyMemberDiseaseTrigger(botAI); } - static Trigger* CleanseCurePoison(PlayerbotAI* botAI) { return new CleanseCurePoisonTrigger(botAI); } - static Trigger* CleanseCurePartyMemberPoison(PlayerbotAI* botAI) { return new CleanseCurePartyMemberPoisonTrigger(botAI); } - static Trigger* CleanseCureMagic(PlayerbotAI* botAI) { return new CleanseCureMagicTrigger(botAI); } - static Trigger* CleanseCurePartyMemberMagic(PlayerbotAI* botAI) { return new CleanseCurePartyMemberMagicTrigger(botAI); } - static Trigger* hammer_of_justice_on_enemy_target(PlayerbotAI* botAI) { return new HammerOfJusticeEnemyHealerTrigger(botAI); } - static Trigger* hammer_of_justice_on_snare_target(PlayerbotAI* botAI) { return new HammerOfJusticeSnareTrigger(botAI); } - static Trigger* avenger_shield(PlayerbotAI* botAI) { return new AvengerShieldTrigger(botAI); } - static Trigger* consecration(PlayerbotAI* botAI) { return new ConsecrationTrigger(botAI); } - static Trigger* repentance_on_enemy_healer(PlayerbotAI* botAI) { return new RepentanceOnHealerTrigger(botAI); } - static Trigger* repentance_on_snare_target(PlayerbotAI* botAI) { return new RepentanceSnareTrigger(botAI); } - static Trigger* repentance_interrupt(PlayerbotAI* botAI) { return new RepentanceInterruptTrigger(botAI); } - static Trigger* beacon_of_light_on_main_tank(PlayerbotAI* ai) { return new BeaconOfLightOnMainTankTrigger(ai); } - static Trigger* sacred_shield_on_main_tank(PlayerbotAI* ai) { return new SacredShieldOnMainTankTrigger(ai); } +private: + static Trigger* turn_undead(PlayerbotAI* botAI) { return new TurnUndeadTrigger(botAI); } + static Trigger* divine_favor(PlayerbotAI* botAI) { return new DivineFavorTrigger(botAI); } + static Trigger* holy_shield(PlayerbotAI* botAI) { return new HolyShieldTrigger(botAI); } + static Trigger* righteous_fury(PlayerbotAI* botAI) { return new RighteousFuryTrigger(botAI); } + static Trigger* judgement(PlayerbotAI* botAI) { return new JudgementTrigger(botAI); } + static Trigger* judgement_of_wisdom(PlayerbotAI* botAI) { return new JudgementOfWisdomTrigger(botAI); } + static Trigger* judgement_of_light(PlayerbotAI* botAI) { return new JudgementOfLightTrigger(botAI); } + static Trigger* blessing(PlayerbotAI* botAI) { return new BlessingTrigger(botAI); } + static Trigger* seal(PlayerbotAI* botAI) { return new SealTrigger(botAI); } + static Trigger* art_of_war(PlayerbotAI* botAI) { return new ArtOfWarTrigger(botAI); } + static Trigger* blessing_on_party(PlayerbotAI* botAI) { return new BlessingOnPartyTrigger(botAI); } + static Trigger* crusader_aura(PlayerbotAI* botAI) { return new CrusaderAuraTrigger(botAI); } + static Trigger* retribution_aura(PlayerbotAI* botAI) { return new RetributionAuraTrigger(botAI); } + static Trigger* devotion_aura(PlayerbotAI* botAI) { return new DevotionAuraTrigger(botAI); } + static Trigger* sanctity_aura(PlayerbotAI* botAI) { return new SanctityAuraTrigger(botAI); } + static Trigger* concentration_aura(PlayerbotAI* botAI) { return new ConcentrationAuraTrigger(botAI); } + static Trigger* shadow_resistance_aura(PlayerbotAI* botAI) { return new ShadowResistanceAuraTrigger(botAI); } + static Trigger* frost_resistance_aura(PlayerbotAI* botAI) { return new FrostResistanceAuraTrigger(botAI); } + static Trigger* fire_resistance_aura(PlayerbotAI* botAI) { return new FireResistanceAuraTrigger(botAI); } + static Trigger* hammer_of_justice_snare(PlayerbotAI* botAI) { return new HammerOfJusticeSnareTrigger(botAI); } + static Trigger* hammer_of_justice_interrupt(PlayerbotAI* botAI) + { + return new HammerOfJusticeInterruptSpellTrigger(botAI); + } + static Trigger* CleanseCureDisease(PlayerbotAI* botAI) { return new CleanseCureDiseaseTrigger(botAI); } + static Trigger* CleanseCurePartyMemberDisease(PlayerbotAI* botAI) + { + return new CleanseCurePartyMemberDiseaseTrigger(botAI); + } + static Trigger* CleanseCurePoison(PlayerbotAI* botAI) { return new CleanseCurePoisonTrigger(botAI); } + static Trigger* CleanseCurePartyMemberPoison(PlayerbotAI* botAI) + { + return new CleanseCurePartyMemberPoisonTrigger(botAI); + } + static Trigger* CleanseCureMagic(PlayerbotAI* botAI) { return new CleanseCureMagicTrigger(botAI); } + static Trigger* CleanseCurePartyMemberMagic(PlayerbotAI* botAI) + { + return new CleanseCurePartyMemberMagicTrigger(botAI); + } + static Trigger* hammer_of_justice_on_enemy_target(PlayerbotAI* botAI) + { + return new HammerOfJusticeEnemyHealerTrigger(botAI); + } + static Trigger* hammer_of_justice_on_snare_target(PlayerbotAI* botAI) + { + return new HammerOfJusticeSnareTrigger(botAI); + } + static Trigger* avenger_shield(PlayerbotAI* botAI) { return new AvengerShieldTrigger(botAI); } + static Trigger* consecration(PlayerbotAI* botAI) { return new ConsecrationTrigger(botAI); } + static Trigger* repentance_on_enemy_healer(PlayerbotAI* botAI) { return new RepentanceOnHealerTrigger(botAI); } + static Trigger* repentance_on_snare_target(PlayerbotAI* botAI) { return new RepentanceSnareTrigger(botAI); } + static Trigger* repentance_interrupt(PlayerbotAI* botAI) { return new RepentanceInterruptTrigger(botAI); } + static Trigger* beacon_of_light_on_main_tank(PlayerbotAI* ai) { return new BeaconOfLightOnMainTankTrigger(ai); } + static Trigger* sacred_shield_on_main_tank(PlayerbotAI* ai) { return new SacredShieldOnMainTankTrigger(ai); } - static Trigger* blessing_of_kings_on_party(PlayerbotAI* botAI) { return new BlessingOfKingsOnPartyTrigger(botAI); } - static Trigger* blessing_of_wisdom_on_party(PlayerbotAI* botAI) { return new BlessingOfWisdomOnPartyTrigger(botAI); } - static Trigger* blessing_of_might_on_party(PlayerbotAI* botAI) { return new BlessingOfMightOnPartyTrigger(botAI); } + static Trigger* blessing_of_kings_on_party(PlayerbotAI* botAI) { return new BlessingOfKingsOnPartyTrigger(botAI); } + static Trigger* blessing_of_wisdom_on_party(PlayerbotAI* botAI) + { + return new BlessingOfWisdomOnPartyTrigger(botAI); + } + static Trigger* blessing_of_might_on_party(PlayerbotAI* botAI) { return new BlessingOfMightOnPartyTrigger(botAI); } - static Trigger* avenging_wrath(PlayerbotAI* botAI) { return new AvengingWrathTrigger(botAI); } + static Trigger* avenging_wrath(PlayerbotAI* botAI) { return new AvengingWrathTrigger(botAI); } }; class PaladinAiObjectContextInternal : public NamedObjectContext { - public: - PaladinAiObjectContextInternal() - { - creators["seal of command"] = &PaladinAiObjectContextInternal::seal_of_command; - creators["seal of vengeance"] = &PaladinAiObjectContextInternal::seal_of_vengeance; - creators["seal of corruption"] = &PaladinAiObjectContextInternal::seal_of_corruption; - creators["blessing of might"] = &PaladinAiObjectContextInternal::blessing_of_might; - creators["blessing of wisdom"] = &PaladinAiObjectContextInternal::blessing_of_wisdom; - creators["blessing of kings"] = &PaladinAiObjectContextInternal::blessing_of_kings; - creators["blessing of sanctuary"] = &PaladinAiObjectContextInternal::blessing_of_sanctuary; - creators["divine storm"] = &PaladinAiObjectContextInternal::divine_storm; - creators["blessing of kings on party"] = &PaladinAiObjectContextInternal::blessing_of_kings_on_party; - creators["blessing of might on party"] = &PaladinAiObjectContextInternal::blessing_of_might_on_party; - creators["blessing of wisdom on party"] = &PaladinAiObjectContextInternal::blessing_of_wisdom_on_party; - creators["redemption"] = &PaladinAiObjectContextInternal::redemption; - creators["crusader strike"] = &PaladinAiObjectContextInternal::crusader_strike; - creators["crusader aura"] = &PaladinAiObjectContextInternal::crusader_aura; - creators["seal of light"] = &PaladinAiObjectContextInternal::seal_of_light; - creators["devotion aura"] = &PaladinAiObjectContextInternal::devotion_aura; - creators["concentration aura"] = &PaladinAiObjectContextInternal::concentration_aura; - creators["holy wrath"] = &PaladinAiObjectContextInternal::holy_wrath; - creators["consecration"] = &PaladinAiObjectContextInternal::consecration; - creators["melee consecration"] = &PaladinAiObjectContextInternal::melee_consecration; - creators["cleanse disease"] = &PaladinAiObjectContextInternal::cleanse_disease; - creators["cleanse poison"] = &PaladinAiObjectContextInternal::cleanse_poison; - creators["cleanse magic"] = &PaladinAiObjectContextInternal::cleanse_magic; - creators["purify disease"] = &PaladinAiObjectContextInternal::purify_disease; - creators["purify poison"] = &PaladinAiObjectContextInternal::purify_poison; - creators["cleanse poison on party"] = &PaladinAiObjectContextInternal::cleanse_poison_on_party; - creators["cleanse disease on party"] = &PaladinAiObjectContextInternal::cleanse_disease_on_party; - creators["cleanse magic on party"] = &PaladinAiObjectContextInternal::cleanse_magic_on_party; - creators["purify poison on party"] = &PaladinAiObjectContextInternal::purify_poison_on_party; - creators["purify disease on party"] = &PaladinAiObjectContextInternal::purify_disease_on_party; - creators["seal of wisdom"] = &PaladinAiObjectContextInternal::seal_of_wisdom; - creators["seal of justice"] = &PaladinAiObjectContextInternal::seal_of_justice; - creators["seal of righteousness"] = &PaladinAiObjectContextInternal::seal_of_righteousness; - creators["flash of light"] = &PaladinAiObjectContextInternal::flash_of_light; - creators["hand of reckoning"] = &PaladinAiObjectContextInternal::hand_of_reckoning; - creators["avenger's shield"] = &PaladinAiObjectContextInternal::avengers_shield; - creators["exorcism"] = &PaladinAiObjectContextInternal::exorcism; - creators["judgement"] = &PaladinAiObjectContextInternal::judgement; - creators["judgement of light"] = &PaladinAiObjectContextInternal::judgement_of_light; - creators["judgement of wisdom"] = &PaladinAiObjectContextInternal::judgement_of_wisdom; - creators["divine shield"] = &PaladinAiObjectContextInternal::divine_shield; - creators["divine protection"] = &PaladinAiObjectContextInternal::divine_protection; - creators["divine protection on party"] =&PaladinAiObjectContextInternal::divine_protection_on_party; - creators["hammer of justice"] = &PaladinAiObjectContextInternal::hammer_of_justice; - creators["flash of light on party"] = &PaladinAiObjectContextInternal::flash_of_light_on_party; - creators["holy light"] = &PaladinAiObjectContextInternal::holy_light; - creators["holy light on party"] = &PaladinAiObjectContextInternal::holy_light_on_party; - creators["lay on hands"] = &PaladinAiObjectContextInternal::lay_on_hands; - creators["lay on hands on party"] = &PaladinAiObjectContextInternal::lay_on_hands_on_party; - creators["judgement of justice"] = &PaladinAiObjectContextInternal::judgement_of_justice; - creators["hammer of wrath"] = &PaladinAiObjectContextInternal::hammer_of_wrath; - creators["holy shield"] = &PaladinAiObjectContextInternal::holy_shield; - creators["hammer of the righteous"] = &PaladinAiObjectContextInternal::hammer_of_the_righteous; - creators["retribution aura"] = &PaladinAiObjectContextInternal::retribution_aura; - creators["shadow resistance aura"] = &PaladinAiObjectContextInternal::shadow_resistance_aura; - creators["frost resistance aura"] = &PaladinAiObjectContextInternal::frost_resistance_aura; - creators["fire resistance aura"] = &PaladinAiObjectContextInternal::fire_resistance_aura; - creators["righteous fury"] = &PaladinAiObjectContextInternal::righteous_fury; - creators["hammer of justice on enemy healer"] = &PaladinAiObjectContextInternal::hammer_of_justice_on_enemy_healer; - creators["hammer of justice on snare target"] = &PaladinAiObjectContextInternal::hammer_of_justice_on_snare_target; - creators["divine favor"] = &PaladinAiObjectContextInternal::divine_favor; - creators["turn undead"] = &PaladinAiObjectContextInternal::turn_undead; - creators["blessing of protection on party"] = &PaladinAiObjectContextInternal::blessing_of_protection_on_party; - creators["righteous defense"] = &PaladinAiObjectContextInternal::righteous_defense; - creators["repentance"] = &PaladinAiObjectContextInternal::repentance; - creators["repentance on snare target"] = &PaladinAiObjectContextInternal::repentance_on_snare_target; - creators["repentance on enemy healer"] = &PaladinAiObjectContextInternal::repentance_on_enemy_healer; - creators["sanctity aura"] = &PaladinAiObjectContextInternal::sanctity_aura; - creators["holy shock"] = &PaladinAiObjectContextInternal::holy_shock; - creators["holy shock on party"] = &PaladinAiObjectContextInternal::holy_shock_on_party; - creators["divine plea"] = &PaladinAiObjectContextInternal::divine_plea; - creators["shield of righteousness"] = &PaladinAiObjectContextInternal::shield_of_righteousness; - creators["beacon of light on main tank"] = &PaladinAiObjectContextInternal::beacon_of_light_on_main_tank; - creators["sacred shield on main tank"] = &PaladinAiObjectContextInternal::sacred_shield_on_main_tank; - creators["avenging wrath"] = &PaladinAiObjectContextInternal::avenging_wrath; - creators["divine illumination"] = &PaladinAiObjectContextInternal::divine_illumination; - creators["divine sacrifice"] = &PaladinAiObjectContextInternal::divine_sacrifice; - creators["cancel divine sacrifice"] = &PaladinAiObjectContextInternal::cancel_divine_sacrifice; - } +public: + PaladinAiObjectContextInternal() + { + creators["seal of command"] = &PaladinAiObjectContextInternal::seal_of_command; + creators["seal of vengeance"] = &PaladinAiObjectContextInternal::seal_of_vengeance; + creators["seal of corruption"] = &PaladinAiObjectContextInternal::seal_of_corruption; + creators["blessing of might"] = &PaladinAiObjectContextInternal::blessing_of_might; + creators["blessing of wisdom"] = &PaladinAiObjectContextInternal::blessing_of_wisdom; + creators["blessing of kings"] = &PaladinAiObjectContextInternal::blessing_of_kings; + creators["blessing of sanctuary"] = &PaladinAiObjectContextInternal::blessing_of_sanctuary; + creators["divine storm"] = &PaladinAiObjectContextInternal::divine_storm; + creators["blessing of kings on party"] = &PaladinAiObjectContextInternal::blessing_of_kings_on_party; + creators["blessing of might on party"] = &PaladinAiObjectContextInternal::blessing_of_might_on_party; + creators["blessing of wisdom on party"] = &PaladinAiObjectContextInternal::blessing_of_wisdom_on_party; + creators["redemption"] = &PaladinAiObjectContextInternal::redemption; + creators["crusader strike"] = &PaladinAiObjectContextInternal::crusader_strike; + creators["crusader aura"] = &PaladinAiObjectContextInternal::crusader_aura; + creators["seal of light"] = &PaladinAiObjectContextInternal::seal_of_light; + creators["devotion aura"] = &PaladinAiObjectContextInternal::devotion_aura; + creators["concentration aura"] = &PaladinAiObjectContextInternal::concentration_aura; + creators["holy wrath"] = &PaladinAiObjectContextInternal::holy_wrath; + creators["consecration"] = &PaladinAiObjectContextInternal::consecration; + creators["melee consecration"] = &PaladinAiObjectContextInternal::melee_consecration; + creators["cleanse disease"] = &PaladinAiObjectContextInternal::cleanse_disease; + creators["cleanse poison"] = &PaladinAiObjectContextInternal::cleanse_poison; + creators["cleanse magic"] = &PaladinAiObjectContextInternal::cleanse_magic; + creators["purify disease"] = &PaladinAiObjectContextInternal::purify_disease; + creators["purify poison"] = &PaladinAiObjectContextInternal::purify_poison; + creators["cleanse poison on party"] = &PaladinAiObjectContextInternal::cleanse_poison_on_party; + creators["cleanse disease on party"] = &PaladinAiObjectContextInternal::cleanse_disease_on_party; + creators["cleanse magic on party"] = &PaladinAiObjectContextInternal::cleanse_magic_on_party; + creators["purify poison on party"] = &PaladinAiObjectContextInternal::purify_poison_on_party; + creators["purify disease on party"] = &PaladinAiObjectContextInternal::purify_disease_on_party; + creators["seal of wisdom"] = &PaladinAiObjectContextInternal::seal_of_wisdom; + creators["seal of justice"] = &PaladinAiObjectContextInternal::seal_of_justice; + creators["seal of righteousness"] = &PaladinAiObjectContextInternal::seal_of_righteousness; + creators["flash of light"] = &PaladinAiObjectContextInternal::flash_of_light; + creators["hand of reckoning"] = &PaladinAiObjectContextInternal::hand_of_reckoning; + creators["avenger's shield"] = &PaladinAiObjectContextInternal::avengers_shield; + creators["exorcism"] = &PaladinAiObjectContextInternal::exorcism; + creators["judgement"] = &PaladinAiObjectContextInternal::judgement; + creators["judgement of light"] = &PaladinAiObjectContextInternal::judgement_of_light; + creators["judgement of wisdom"] = &PaladinAiObjectContextInternal::judgement_of_wisdom; + creators["divine shield"] = &PaladinAiObjectContextInternal::divine_shield; + creators["divine protection"] = &PaladinAiObjectContextInternal::divine_protection; + creators["divine protection on party"] = &PaladinAiObjectContextInternal::divine_protection_on_party; + creators["hammer of justice"] = &PaladinAiObjectContextInternal::hammer_of_justice; + creators["flash of light on party"] = &PaladinAiObjectContextInternal::flash_of_light_on_party; + creators["holy light"] = &PaladinAiObjectContextInternal::holy_light; + creators["holy light on party"] = &PaladinAiObjectContextInternal::holy_light_on_party; + creators["lay on hands"] = &PaladinAiObjectContextInternal::lay_on_hands; + creators["lay on hands on party"] = &PaladinAiObjectContextInternal::lay_on_hands_on_party; + creators["judgement of justice"] = &PaladinAiObjectContextInternal::judgement_of_justice; + creators["hammer of wrath"] = &PaladinAiObjectContextInternal::hammer_of_wrath; + creators["holy shield"] = &PaladinAiObjectContextInternal::holy_shield; + creators["hammer of the righteous"] = &PaladinAiObjectContextInternal::hammer_of_the_righteous; + creators["retribution aura"] = &PaladinAiObjectContextInternal::retribution_aura; + creators["shadow resistance aura"] = &PaladinAiObjectContextInternal::shadow_resistance_aura; + creators["frost resistance aura"] = &PaladinAiObjectContextInternal::frost_resistance_aura; + creators["fire resistance aura"] = &PaladinAiObjectContextInternal::fire_resistance_aura; + creators["righteous fury"] = &PaladinAiObjectContextInternal::righteous_fury; + creators["hammer of justice on enemy healer"] = + &PaladinAiObjectContextInternal::hammer_of_justice_on_enemy_healer; + creators["hammer of justice on snare target"] = + &PaladinAiObjectContextInternal::hammer_of_justice_on_snare_target; + creators["divine favor"] = &PaladinAiObjectContextInternal::divine_favor; + creators["turn undead"] = &PaladinAiObjectContextInternal::turn_undead; + creators["blessing of protection on party"] = &PaladinAiObjectContextInternal::blessing_of_protection_on_party; + creators["righteous defense"] = &PaladinAiObjectContextInternal::righteous_defense; + creators["repentance"] = &PaladinAiObjectContextInternal::repentance; + creators["repentance on snare target"] = &PaladinAiObjectContextInternal::repentance_on_snare_target; + creators["repentance on enemy healer"] = &PaladinAiObjectContextInternal::repentance_on_enemy_healer; + creators["sanctity aura"] = &PaladinAiObjectContextInternal::sanctity_aura; + creators["holy shock"] = &PaladinAiObjectContextInternal::holy_shock; + creators["holy shock on party"] = &PaladinAiObjectContextInternal::holy_shock_on_party; + creators["divine plea"] = &PaladinAiObjectContextInternal::divine_plea; + creators["shield of righteousness"] = &PaladinAiObjectContextInternal::shield_of_righteousness; + creators["beacon of light on main tank"] = &PaladinAiObjectContextInternal::beacon_of_light_on_main_tank; + creators["sacred shield on main tank"] = &PaladinAiObjectContextInternal::sacred_shield_on_main_tank; + creators["avenging wrath"] = &PaladinAiObjectContextInternal::avenging_wrath; + creators["divine illumination"] = &PaladinAiObjectContextInternal::divine_illumination; + creators["divine sacrifice"] = &PaladinAiObjectContextInternal::divine_sacrifice; + creators["cancel divine sacrifice"] = &PaladinAiObjectContextInternal::cancel_divine_sacrifice; + } - private: - static Action* blessing_of_protection_on_party(PlayerbotAI* botAI) { return new CastBlessingOfProtectionProtectAction(botAI); } - static Action* turn_undead(PlayerbotAI* botAI) { return new CastTurnUndeadAction(botAI); } - static Action* divine_favor(PlayerbotAI* botAI) { return new CastDivineFavorAction(botAI); } - static Action* righteous_fury(PlayerbotAI* botAI) { return new CastRighteousFuryAction(botAI); } - static Action* seal_of_command(PlayerbotAI* botAI) { return new CastSealOfCommandAction(botAI); } - static Action* seal_of_vengeance(PlayerbotAI* botAI) { return new CastSealOfVengeanceAction(botAI); } - static Action* seal_of_corruption(PlayerbotAI* botAI) { return new CastSealOfCorruptionAction(botAI); } - static Action* blessing_of_sanctuary(PlayerbotAI* botAI) { return new CastBlessingOfSanctuaryAction(botAI); } - static Action* blessing_of_might(PlayerbotAI* botAI) { return new CastBlessingOfMightAction(botAI); } - static Action* blessing_of_wisdom(PlayerbotAI* botAI) { return new CastBlessingOfWisdomAction(botAI); } - static Action* blessing_of_kings(PlayerbotAI* botAI) { return new CastBlessingOfKingsAction(botAI); } - static Action* divine_storm(PlayerbotAI* botAI) { return new CastDivineStormAction(botAI); } - static Action* blessing_of_kings_on_party(PlayerbotAI* botAI) { return new CastBlessingOfKingsOnPartyAction(botAI); } - static Action* blessing_of_might_on_party(PlayerbotAI* botAI) { return new CastBlessingOfMightOnPartyAction(botAI); } - static Action* blessing_of_wisdom_on_party(PlayerbotAI* botAI) { return new CastBlessingOfWisdomOnPartyAction(botAI); } - static Action* redemption(PlayerbotAI* botAI) { return new CastRedemptionAction(botAI); } - static Action* crusader_strike(PlayerbotAI* botAI) { return new CastCrusaderStrikeAction(botAI); } - static Action* crusader_aura(PlayerbotAI* botAI) { return new CastCrusaderAuraAction(botAI); } - static Action* seal_of_light(PlayerbotAI* botAI) { return new CastSealOfLightAction(botAI); } - static Action* devotion_aura(PlayerbotAI* botAI) { return new CastDevotionAuraAction(botAI); } - static Action* concentration_aura(PlayerbotAI* botAI) { return new CastConcentrationAuraAction(botAI); } - static Action* holy_wrath(PlayerbotAI* botAI) { return new CastHolyWrathAction(botAI); } - static Action* consecration(PlayerbotAI* botAI) { return new CastConsecrationAction(botAI); } - static Action* melee_consecration(PlayerbotAI* botAI) { return new CastMeleeConsecrationAction(botAI); } - static Action* cleanse_poison(PlayerbotAI* botAI) { return new CastCleansePoisonAction(botAI); } - static Action* cleanse_disease(PlayerbotAI* botAI) { return new CastCleanseDiseaseAction(botAI); } - static Action* cleanse_magic(PlayerbotAI* botAI) { return new CastCleanseMagicAction(botAI); } - static Action* purify_poison(PlayerbotAI* botAI) { return new CastPurifyPoisonAction(botAI); } - static Action* purify_disease(PlayerbotAI* botAI) { return new CastPurifyDiseaseAction(botAI); } - static Action* cleanse_poison_on_party(PlayerbotAI* botAI) { return new CastCleansePoisonOnPartyAction(botAI); } - static Action* cleanse_disease_on_party(PlayerbotAI* botAI) { return new CastCleanseDiseaseOnPartyAction(botAI); } - static Action* cleanse_magic_on_party(PlayerbotAI* botAI) { return new CastCleanseMagicOnPartyAction(botAI); } - static Action* purify_poison_on_party(PlayerbotAI* botAI) { return new CastPurifyPoisonOnPartyAction(botAI); } - static Action* purify_disease_on_party(PlayerbotAI* botAI) { return new CastPurifyDiseaseOnPartyAction(botAI); } - static Action* seal_of_wisdom(PlayerbotAI* botAI) { return new CastSealOfWisdomAction(botAI); } - static Action* seal_of_justice(PlayerbotAI* botAI) { return new CastSealOfJusticeAction(botAI); } - static Action* seal_of_righteousness(PlayerbotAI* botAI) { return new CastSealOfRighteousnessAction(botAI); } - static Action* flash_of_light(PlayerbotAI* botAI) { return new CastFlashOfLightAction(botAI); } - static Action* hand_of_reckoning(PlayerbotAI* botAI) { return new CastHandOfReckoningAction(botAI); } - static Action* avengers_shield(PlayerbotAI* botAI) { return new CastAvengersShieldAction(botAI); } - static Action* exorcism(PlayerbotAI* botAI) { return new CastExorcismAction(botAI); } - static Action* judgement(PlayerbotAI* botAI) { return new CastJudgementAction(botAI); } - static Action* judgement_of_light(PlayerbotAI* botAI) { return new CastJudgementOfLightAction(botAI); } - static Action* judgement_of_wisdom(PlayerbotAI* botAI) { return new CastJudgementOfWisdomAction(botAI); } - static Action* divine_shield(PlayerbotAI* botAI) { return new CastDivineShieldAction(botAI); } - static Action* divine_protection(PlayerbotAI* botAI) { return new CastDivineProtectionAction(botAI); } - static Action* divine_protection_on_party(PlayerbotAI* botAI) { return new CastDivineProtectionOnPartyAction(botAI); } - static Action* hammer_of_justice(PlayerbotAI* botAI) { return new CastHammerOfJusticeAction(botAI); } - static Action* flash_of_light_on_party(PlayerbotAI* botAI) { return new CastFlashOfLightOnPartyAction(botAI); } - static Action* holy_light(PlayerbotAI* botAI) { return new CastHolyLightAction(botAI); } - static Action* holy_light_on_party(PlayerbotAI* botAI) { return new CastHolyLightOnPartyAction(botAI); } - static Action* lay_on_hands(PlayerbotAI* botAI) { return new CastLayOnHandsAction(botAI); } - static Action* lay_on_hands_on_party(PlayerbotAI* botAI) { return new CastLayOnHandsOnPartyAction(botAI); } - static Action* judgement_of_justice(PlayerbotAI* botAI) { return new CastJudgementOfJusticeAction(botAI); } - static Action* hammer_of_wrath(PlayerbotAI* botAI) { return new CastHammerOfWrathAction(botAI); } - static Action* holy_shield(PlayerbotAI* botAI) { return new CastHolyShieldAction(botAI); } - static Action* hammer_of_the_righteous(PlayerbotAI* botAI) { return new CastHammerOfTheRighteousAction(botAI); } - static Action* retribution_aura(PlayerbotAI* botAI) { return new CastRetributionAuraAction(botAI); } - static Action* shadow_resistance_aura(PlayerbotAI* botAI) { return new CastShadowResistanceAuraAction(botAI); } - static Action* frost_resistance_aura(PlayerbotAI* botAI) { return new CastFrostResistanceAuraAction(botAI); } - static Action* fire_resistance_aura(PlayerbotAI* botAI) { return new CastFireResistanceAuraAction(botAI); } - static Action* hammer_of_justice_on_enemy_healer(PlayerbotAI* botAI) { return new CastHammerOfJusticeOnEnemyHealerAction(botAI); } - static Action* hammer_of_justice_on_snare_target(PlayerbotAI* botAI) { return new CastHammerOfJusticeSnareAction(botAI); } - static Action* righteous_defense(PlayerbotAI* botAI) { return new CastRighteousDefenseAction(botAI); } - static Action* repentance(PlayerbotAI* botAI) { return new CastRepentanceAction(botAI); } - static Action* repentance_on_snare_target(PlayerbotAI* botAI) { return new CastRepentanceSnareAction(botAI); } - static Action* repentance_on_enemy_healer(PlayerbotAI* botAI) { return new CastRepentanceOnHealerAction(botAI); } - static Action* sanctity_aura(PlayerbotAI* botAI) { return new CastSanctityAuraAction(botAI); } - static Action* holy_shock(PlayerbotAI* botAI) { return new CastHolyShockAction(botAI); } - static Action* holy_shock_on_party(PlayerbotAI* botAI) { return new CastHolyShockOnPartyAction(botAI); } - static Action* divine_plea(PlayerbotAI* ai) { return new CastDivinePleaAction(ai); } - static Action* shield_of_righteousness(PlayerbotAI* ai) { return new ShieldOfRighteousnessAction(ai); } - static Action* beacon_of_light_on_main_tank(PlayerbotAI* ai) { return new CastBeaconOfLightOnMainTankAction(ai); } - static Action* sacred_shield_on_main_tank(PlayerbotAI* ai) { return new CastSacredShieldOnMainTankAction(ai); } - static Action* avenging_wrath(PlayerbotAI* ai) { return new CastAvengingWrathAction(ai); } - static Action* divine_illumination(PlayerbotAI* ai) { return new CastDivineIlluminationAction(ai); } - static Action* divine_sacrifice(PlayerbotAI* ai) { return new CastDivineSacrificeAction(ai); } - static Action* cancel_divine_sacrifice(PlayerbotAI* ai) { return new CastCancelDivineSacrificeAction(ai); } +private: + static Action* blessing_of_protection_on_party(PlayerbotAI* botAI) + { + return new CastBlessingOfProtectionProtectAction(botAI); + } + static Action* turn_undead(PlayerbotAI* botAI) { return new CastTurnUndeadAction(botAI); } + static Action* divine_favor(PlayerbotAI* botAI) { return new CastDivineFavorAction(botAI); } + static Action* righteous_fury(PlayerbotAI* botAI) { return new CastRighteousFuryAction(botAI); } + static Action* seal_of_command(PlayerbotAI* botAI) { return new CastSealOfCommandAction(botAI); } + static Action* seal_of_vengeance(PlayerbotAI* botAI) { return new CastSealOfVengeanceAction(botAI); } + static Action* seal_of_corruption(PlayerbotAI* botAI) { return new CastSealOfCorruptionAction(botAI); } + static Action* blessing_of_sanctuary(PlayerbotAI* botAI) { return new CastBlessingOfSanctuaryAction(botAI); } + static Action* blessing_of_might(PlayerbotAI* botAI) { return new CastBlessingOfMightAction(botAI); } + static Action* blessing_of_wisdom(PlayerbotAI* botAI) { return new CastBlessingOfWisdomAction(botAI); } + static Action* blessing_of_kings(PlayerbotAI* botAI) { return new CastBlessingOfKingsAction(botAI); } + static Action* divine_storm(PlayerbotAI* botAI) { return new CastDivineStormAction(botAI); } + static Action* blessing_of_kings_on_party(PlayerbotAI* botAI) + { + return new CastBlessingOfKingsOnPartyAction(botAI); + } + static Action* blessing_of_might_on_party(PlayerbotAI* botAI) + { + return new CastBlessingOfMightOnPartyAction(botAI); + } + static Action* blessing_of_wisdom_on_party(PlayerbotAI* botAI) + { + return new CastBlessingOfWisdomOnPartyAction(botAI); + } + static Action* redemption(PlayerbotAI* botAI) { return new CastRedemptionAction(botAI); } + static Action* crusader_strike(PlayerbotAI* botAI) { return new CastCrusaderStrikeAction(botAI); } + static Action* crusader_aura(PlayerbotAI* botAI) { return new CastCrusaderAuraAction(botAI); } + static Action* seal_of_light(PlayerbotAI* botAI) { return new CastSealOfLightAction(botAI); } + static Action* devotion_aura(PlayerbotAI* botAI) { return new CastDevotionAuraAction(botAI); } + static Action* concentration_aura(PlayerbotAI* botAI) { return new CastConcentrationAuraAction(botAI); } + static Action* holy_wrath(PlayerbotAI* botAI) { return new CastHolyWrathAction(botAI); } + static Action* consecration(PlayerbotAI* botAI) { return new CastConsecrationAction(botAI); } + static Action* melee_consecration(PlayerbotAI* botAI) { return new CastMeleeConsecrationAction(botAI); } + static Action* cleanse_poison(PlayerbotAI* botAI) { return new CastCleansePoisonAction(botAI); } + static Action* cleanse_disease(PlayerbotAI* botAI) { return new CastCleanseDiseaseAction(botAI); } + static Action* cleanse_magic(PlayerbotAI* botAI) { return new CastCleanseMagicAction(botAI); } + static Action* purify_poison(PlayerbotAI* botAI) { return new CastPurifyPoisonAction(botAI); } + static Action* purify_disease(PlayerbotAI* botAI) { return new CastPurifyDiseaseAction(botAI); } + static Action* cleanse_poison_on_party(PlayerbotAI* botAI) { return new CastCleansePoisonOnPartyAction(botAI); } + static Action* cleanse_disease_on_party(PlayerbotAI* botAI) { return new CastCleanseDiseaseOnPartyAction(botAI); } + static Action* cleanse_magic_on_party(PlayerbotAI* botAI) { return new CastCleanseMagicOnPartyAction(botAI); } + static Action* purify_poison_on_party(PlayerbotAI* botAI) { return new CastPurifyPoisonOnPartyAction(botAI); } + static Action* purify_disease_on_party(PlayerbotAI* botAI) { return new CastPurifyDiseaseOnPartyAction(botAI); } + static Action* seal_of_wisdom(PlayerbotAI* botAI) { return new CastSealOfWisdomAction(botAI); } + static Action* seal_of_justice(PlayerbotAI* botAI) { return new CastSealOfJusticeAction(botAI); } + static Action* seal_of_righteousness(PlayerbotAI* botAI) { return new CastSealOfRighteousnessAction(botAI); } + static Action* flash_of_light(PlayerbotAI* botAI) { return new CastFlashOfLightAction(botAI); } + static Action* hand_of_reckoning(PlayerbotAI* botAI) { return new CastHandOfReckoningAction(botAI); } + static Action* avengers_shield(PlayerbotAI* botAI) { return new CastAvengersShieldAction(botAI); } + static Action* exorcism(PlayerbotAI* botAI) { return new CastExorcismAction(botAI); } + static Action* judgement(PlayerbotAI* botAI) { return new CastJudgementAction(botAI); } + static Action* judgement_of_light(PlayerbotAI* botAI) { return new CastJudgementOfLightAction(botAI); } + static Action* judgement_of_wisdom(PlayerbotAI* botAI) { return new CastJudgementOfWisdomAction(botAI); } + static Action* divine_shield(PlayerbotAI* botAI) { return new CastDivineShieldAction(botAI); } + static Action* divine_protection(PlayerbotAI* botAI) { return new CastDivineProtectionAction(botAI); } + static Action* divine_protection_on_party(PlayerbotAI* botAI) + { + return new CastDivineProtectionOnPartyAction(botAI); + } + static Action* hammer_of_justice(PlayerbotAI* botAI) { return new CastHammerOfJusticeAction(botAI); } + static Action* flash_of_light_on_party(PlayerbotAI* botAI) { return new CastFlashOfLightOnPartyAction(botAI); } + static Action* holy_light(PlayerbotAI* botAI) { return new CastHolyLightAction(botAI); } + static Action* holy_light_on_party(PlayerbotAI* botAI) { return new CastHolyLightOnPartyAction(botAI); } + static Action* lay_on_hands(PlayerbotAI* botAI) { return new CastLayOnHandsAction(botAI); } + static Action* lay_on_hands_on_party(PlayerbotAI* botAI) { return new CastLayOnHandsOnPartyAction(botAI); } + static Action* judgement_of_justice(PlayerbotAI* botAI) { return new CastJudgementOfJusticeAction(botAI); } + static Action* hammer_of_wrath(PlayerbotAI* botAI) { return new CastHammerOfWrathAction(botAI); } + static Action* holy_shield(PlayerbotAI* botAI) { return new CastHolyShieldAction(botAI); } + static Action* hammer_of_the_righteous(PlayerbotAI* botAI) { return new CastHammerOfTheRighteousAction(botAI); } + static Action* retribution_aura(PlayerbotAI* botAI) { return new CastRetributionAuraAction(botAI); } + static Action* shadow_resistance_aura(PlayerbotAI* botAI) { return new CastShadowResistanceAuraAction(botAI); } + static Action* frost_resistance_aura(PlayerbotAI* botAI) { return new CastFrostResistanceAuraAction(botAI); } + static Action* fire_resistance_aura(PlayerbotAI* botAI) { return new CastFireResistanceAuraAction(botAI); } + static Action* hammer_of_justice_on_enemy_healer(PlayerbotAI* botAI) + { + return new CastHammerOfJusticeOnEnemyHealerAction(botAI); + } + static Action* hammer_of_justice_on_snare_target(PlayerbotAI* botAI) + { + return new CastHammerOfJusticeSnareAction(botAI); + } + static Action* righteous_defense(PlayerbotAI* botAI) { return new CastRighteousDefenseAction(botAI); } + static Action* repentance(PlayerbotAI* botAI) { return new CastRepentanceAction(botAI); } + static Action* repentance_on_snare_target(PlayerbotAI* botAI) { return new CastRepentanceSnareAction(botAI); } + static Action* repentance_on_enemy_healer(PlayerbotAI* botAI) { return new CastRepentanceOnHealerAction(botAI); } + static Action* sanctity_aura(PlayerbotAI* botAI) { return new CastSanctityAuraAction(botAI); } + static Action* holy_shock(PlayerbotAI* botAI) { return new CastHolyShockAction(botAI); } + static Action* holy_shock_on_party(PlayerbotAI* botAI) { return new CastHolyShockOnPartyAction(botAI); } + static Action* divine_plea(PlayerbotAI* ai) { return new CastDivinePleaAction(ai); } + static Action* shield_of_righteousness(PlayerbotAI* ai) { return new ShieldOfRighteousnessAction(ai); } + static Action* beacon_of_light_on_main_tank(PlayerbotAI* ai) { return new CastBeaconOfLightOnMainTankAction(ai); } + static Action* sacred_shield_on_main_tank(PlayerbotAI* ai) { return new CastSacredShieldOnMainTankAction(ai); } + static Action* avenging_wrath(PlayerbotAI* ai) { return new CastAvengingWrathAction(ai); } + static Action* divine_illumination(PlayerbotAI* ai) { return new CastDivineIlluminationAction(ai); } + static Action* divine_sacrifice(PlayerbotAI* ai) { return new CastDivineSacrificeAction(ai); } + static Action* cancel_divine_sacrifice(PlayerbotAI* ai) { return new CastCancelDivineSacrificeAction(ai); } }; PaladinAiObjectContext::PaladinAiObjectContext(PlayerbotAI* botAI) : AiObjectContext(botAI) diff --git a/src/strategy/paladin/PaladinAiObjectContext.h b/src/strategy/paladin/PaladinAiObjectContext.h index 7e4de053..c865a8fc 100644 --- a/src/strategy/paladin/PaladinAiObjectContext.h +++ b/src/strategy/paladin/PaladinAiObjectContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PALADINAIOBJECTCONTEXT_H @@ -11,8 +12,8 @@ class PlayerbotAI; class PaladinAiObjectContext : public AiObjectContext { - public: - PaladinAiObjectContext(PlayerbotAI* botAI); +public: + PaladinAiObjectContext(PlayerbotAI* botAI); }; #endif diff --git a/src/strategy/paladin/PaladinBuffStrategies.cpp b/src/strategy/paladin/PaladinBuffStrategies.cpp index 912a9e4e..01aa6ffc 100644 --- a/src/strategy/paladin/PaladinBuffStrategies.cpp +++ b/src/strategy/paladin/PaladinBuffStrategies.cpp @@ -1,65 +1,88 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PaladinBuffStrategies.h" + #include "Playerbots.h" void PaladinBuffManaStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("blessing of wisdom on party", NextAction::array(0, new NextAction("blessing of wisdom on party", 11.0f), nullptr))); - // triggers.push_back(new TriggerNode("blessing", NextAction::array(0, new NextAction("blessing of wisdom", ACTION_HIGH + 8), nullptr))); + triggers.push_back( + new TriggerNode("blessing of wisdom on party", + NextAction::array(0, new NextAction("blessing of wisdom on party", 11.0f), nullptr))); + // triggers.push_back(new TriggerNode("blessing", NextAction::array(0, new NextAction("blessing of wisdom", + // ACTION_HIGH + 8), nullptr))); } void PaladinBuffHealthStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("blessing of kings on party", NextAction::array(0, new NextAction("blessing of kings on party", 11.0f), nullptr))); - // triggers.push_back(new TriggerNode("blessing", NextAction::array(0, new NextAction("blessing of kings", ACTION_HIGH + 8), nullptr))); + triggers.push_back( + new TriggerNode("blessing of kings on party", + NextAction::array(0, new NextAction("blessing of kings on party", 11.0f), nullptr))); + // triggers.push_back(new TriggerNode("blessing", NextAction::array(0, new NextAction("blessing of kings", + // ACTION_HIGH + 8), nullptr))); } void PaladinBuffDpsStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("blessing of might on party", NextAction::array(0, new NextAction("blessing of might on party", 11.0f), nullptr))); - // triggers.push_back(new TriggerNode("blessing", NextAction::array(0, new NextAction("blessing of might", ACTION_HIGH + 8), nullptr))); + triggers.push_back( + new TriggerNode("blessing of might on party", + NextAction::array(0, new NextAction("blessing of might on party", 11.0f), nullptr))); + // triggers.push_back(new TriggerNode("blessing", NextAction::array(0, new NextAction("blessing of might", + // ACTION_HIGH + 8), nullptr))); } void PaladinShadowResistanceStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("shadow resistance aura", NextAction::array(0, new NextAction("shadow resistance aura", ACTION_NORMAL), nullptr))); + triggers.push_back( + new TriggerNode("shadow resistance aura", + NextAction::array(0, new NextAction("shadow resistance aura", ACTION_NORMAL), nullptr))); } void PaladinFrostResistanceStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("frost resistance aura", NextAction::array(0, new NextAction("frost resistance aura", ACTION_NORMAL), nullptr))); + triggers.push_back( + new TriggerNode("frost resistance aura", + NextAction::array(0, new NextAction("frost resistance aura", ACTION_NORMAL), nullptr))); } void PaladinFireResistanceStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("fire resistance aura", NextAction::array(0, new NextAction("fire resistance aura", ACTION_NORMAL), nullptr))); + triggers.push_back(new TriggerNode( + "fire resistance aura", NextAction::array(0, new NextAction("fire resistance aura", ACTION_NORMAL), nullptr))); } void PaladinBuffArmorStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("devotion aura", NextAction::array(0, new NextAction("devotion aura", ACTION_NORMAL), nullptr))); + triggers.push_back(new TriggerNode("devotion aura", + NextAction::array(0, new NextAction("devotion aura", ACTION_NORMAL), nullptr))); } void PaladinBuffAoeStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("retribution aura", NextAction::array(0, new NextAction("retribution aura", ACTION_NORMAL), nullptr))); + triggers.push_back(new TriggerNode( + "retribution aura", NextAction::array(0, new NextAction("retribution aura", ACTION_NORMAL), nullptr))); } void PaladinBuffCastStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("concentration aura", NextAction::array(0, new NextAction("concentration aura", ACTION_NORMAL), nullptr))); + triggers.push_back(new TriggerNode( + "concentration aura", NextAction::array(0, new NextAction("concentration aura", ACTION_NORMAL), nullptr))); } void PaladinBuffThreatStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("righteous fury", NextAction::array(0, new NextAction("righteous fury", ACTION_HIGH + 8), nullptr))); + triggers.push_back(new TriggerNode( + "righteous fury", NextAction::array(0, new NextAction("righteous fury", ACTION_HIGH + 8), nullptr))); } void PaladinBuffStatsStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("blessing of kings on party", NextAction::array(0, new NextAction("blessing of kings on party", 11.0f), nullptr))); - // triggers.push_back(new TriggerNode("blessing", NextAction::array(0, new NextAction("blessing of kings", ACTION_HIGH + 8), nullptr))); + triggers.push_back( + new TriggerNode("blessing of kings on party", + NextAction::array(0, new NextAction("blessing of kings on party", 11.0f), nullptr))); + // triggers.push_back(new TriggerNode("blessing", NextAction::array(0, new NextAction("blessing of kings", + // ACTION_HIGH + 8), nullptr))); } diff --git a/src/strategy/paladin/PaladinBuffStrategies.h b/src/strategy/paladin/PaladinBuffStrategies.h index 9c9e5ad4..f16707cf 100644 --- a/src/strategy/paladin/PaladinBuffStrategies.h +++ b/src/strategy/paladin/PaladinBuffStrategies.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PALADINBUFFSTRATEGIES_H @@ -11,101 +12,101 @@ class PlayerbotAI; class PaladinBuffManaStrategy : public Strategy { - public: - PaladinBuffManaStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinBuffManaStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "bmana"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bmana"; } }; class PaladinBuffHealthStrategy : public Strategy { - public: - PaladinBuffHealthStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinBuffHealthStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "bhealth"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bhealth"; } }; class PaladinBuffDpsStrategy : public Strategy { - public: - PaladinBuffDpsStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinBuffDpsStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "bdps"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bdps"; } }; class PaladinBuffArmorStrategy : public Strategy { - public: - PaladinBuffArmorStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinBuffArmorStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "barmor"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "barmor"; } }; class PaladinBuffAoeStrategy : public Strategy { - public: - PaladinBuffAoeStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinBuffAoeStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "baoe"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "baoe"; } }; class PaladinBuffCastStrategy : public Strategy { - public: - PaladinBuffCastStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinBuffCastStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "bcast"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bcast"; } }; class PaladinBuffThreatStrategy : public Strategy { - public: - PaladinBuffThreatStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinBuffThreatStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "bthreat"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bthreat"; } }; class PaladinBuffStatsStrategy : public Strategy { - public: - PaladinBuffStatsStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinBuffStatsStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "bstats"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bstats"; } }; class PaladinShadowResistanceStrategy : public Strategy { - public: - PaladinShadowResistanceStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinShadowResistanceStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "rshadow"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "rshadow"; } }; class PaladinFrostResistanceStrategy : public Strategy { - public: - PaladinFrostResistanceStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinFrostResistanceStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "rfrost"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "rfrost"; } }; class PaladinFireResistanceStrategy : public Strategy { - public: - PaladinFireResistanceStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PaladinFireResistanceStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "rfire"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "rfire"; } }; #endif diff --git a/src/strategy/paladin/PaladinTriggers.cpp b/src/strategy/paladin/PaladinTriggers.cpp index 1a7f1faf..14cd3b2b 100644 --- a/src/strategy/paladin/PaladinTriggers.cpp +++ b/src/strategy/paladin/PaladinTriggers.cpp @@ -1,28 +1,32 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ -#include "PaladinActions.h" #include "PaladinTriggers.h" + +#include "PaladinActions.h" #include "PlayerbotAIConfig.h" #include "Playerbots.h" bool SealTrigger::IsActive() { - Unit* target = GetTarget(); - return !botAI->HasAura("seal of justice", target) && !botAI->HasAura("seal of command", target) && !botAI->HasAura("seal of vengeance", target) && - !botAI->HasAura("seal of corruption", target) && !botAI->HasAura("seal of righteousness", target) && !botAI->HasAura("seal of light", target) && - (!botAI->HasAura("seal of wisdom", target) || AI_VALUE2(uint8, "mana", "self target") > 70); + Unit* target = GetTarget(); + return !botAI->HasAura("seal of justice", target) && !botAI->HasAura("seal of command", target) && + !botAI->HasAura("seal of vengeance", target) && !botAI->HasAura("seal of corruption", target) && + !botAI->HasAura("seal of righteousness", target) && !botAI->HasAura("seal of light", target) && + (!botAI->HasAura("seal of wisdom", target) || AI_VALUE2(uint8, "mana", "self target") > 70); } bool CrusaderAuraTrigger::IsActive() { - Unit* target = GetTarget(); - return AI_VALUE2(bool, "mounted", "self target") && !botAI->HasAura("crusader aura", target); + Unit* target = GetTarget(); + return AI_VALUE2(bool, "mounted", "self target") && !botAI->HasAura("crusader aura", target); } bool BlessingTrigger::IsActive() { Unit* target = GetTarget(); - return SpellTrigger::IsActive() && !botAI->HasAnyAuraOf(target, "blessing of might", "blessing of wisdom", "blessing of kings", "blessing of sanctuary", nullptr); + return SpellTrigger::IsActive() && !botAI->HasAnyAuraOf(target, "blessing of might", "blessing of wisdom", + "blessing of kings", "blessing of sanctuary", nullptr); } diff --git a/src/strategy/paladin/PaladinTriggers.h b/src/strategy/paladin/PaladinTriggers.h index 6a9239bb..37ba6470 100644 --- a/src/strategy/paladin/PaladinTriggers.h +++ b/src/strategy/paladin/PaladinTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PALADINTRIGGERS_H @@ -46,18 +47,18 @@ BUFF_TRIGGER(SanctityAuraTrigger, "sanctity aura"); class CrusaderAuraTrigger : public BuffTrigger { - public: - CrusaderAuraTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "crusader aura") { } +public: + CrusaderAuraTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "crusader aura") {} - bool IsActive() override; + bool IsActive() override; }; class SealTrigger : public BuffTrigger { - public: - SealTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "seal") { } +public: + SealTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "seal") {} - bool IsActive() override; + bool IsActive() override; }; // judgements @@ -72,118 +73,127 @@ INTERRUPT_HEALER_TRIGGER(RepentanceOnHealerTrigger, "repentance on enemy healer" SNARE_TRIGGER(RepentanceSnareTrigger, "repentance on snare target"); INTERRUPT_TRIGGER(RepentanceInterruptTrigger, "repentance"); - class BlessingOnPartyTrigger : public BuffOnPartyTrigger { - public: - BlessingOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "blessing of kings,blessing of might,blessing of wisdom", 2 * 2000) { } +public: + BlessingOnPartyTrigger(PlayerbotAI* botAI) + : BuffOnPartyTrigger(botAI, "blessing of kings,blessing of might,blessing of wisdom", 2 * 2000) + { + } }; class BlessingTrigger : public BuffTrigger { - public: - BlessingTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "blessing of sanctuary", 2 * 2000) { } +public: + BlessingTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "blessing of sanctuary", 2 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class HammerOfJusticeInterruptSpellTrigger : public InterruptSpellTrigger { - public: - HammerOfJusticeInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "hammer of justice") { } +public: + HammerOfJusticeInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "hammer of justice") {} }; class HammerOfJusticeSnareTrigger : public SnareTargetTrigger { - public: - HammerOfJusticeSnareTrigger(PlayerbotAI* botAI) : SnareTargetTrigger(botAI, "hammer of justice") { } +public: + HammerOfJusticeSnareTrigger(PlayerbotAI* botAI) : SnareTargetTrigger(botAI, "hammer of justice") {} }; class ArtOfWarTrigger : public HasAuraTrigger { - public: - ArtOfWarTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "the art of war") { } +public: + ArtOfWarTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "the art of war") {} }; class ShadowResistanceAuraTrigger : public BuffTrigger { - public: - ShadowResistanceAuraTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "shadow resistance aura") { } +public: + ShadowResistanceAuraTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "shadow resistance aura") {} }; class FrostResistanceAuraTrigger : public BuffTrigger { - public: - FrostResistanceAuraTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "frost resistance aura") { } +public: + FrostResistanceAuraTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "frost resistance aura") {} }; class FireResistanceAuraTrigger : public BuffTrigger { - public: - FireResistanceAuraTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "fire resistance aura") { } +public: + FireResistanceAuraTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "fire resistance aura") {} }; class DevotionAuraTrigger : public BuffTrigger { - public: - DevotionAuraTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "devotion aura") { } +public: + DevotionAuraTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "devotion aura") {} }; BUFF_TRIGGER(ConcentrationAuraTrigger, "concentration aura"); - class CleanseCureDiseaseTrigger : public NeedCureTrigger { - public: - CleanseCureDiseaseTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cleanse", DISPEL_DISEASE) { } +public: + CleanseCureDiseaseTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cleanse", DISPEL_DISEASE) {} }; class CleanseCurePartyMemberDiseaseTrigger : public PartyMemberNeedCureTrigger { - public: - CleanseCurePartyMemberDiseaseTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "cleanse", DISPEL_DISEASE) { } +public: + CleanseCurePartyMemberDiseaseTrigger(PlayerbotAI* botAI) + : PartyMemberNeedCureTrigger(botAI, "cleanse", DISPEL_DISEASE) + { + } }; class CleanseCurePoisonTrigger : public NeedCureTrigger { - public: - CleanseCurePoisonTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cleanse", DISPEL_POISON) { } +public: + CleanseCurePoisonTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cleanse", DISPEL_POISON) {} }; class CleanseCurePartyMemberPoisonTrigger : public PartyMemberNeedCureTrigger { - public: - CleanseCurePartyMemberPoisonTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "cleanse", DISPEL_POISON) { } +public: + CleanseCurePartyMemberPoisonTrigger(PlayerbotAI* botAI) + : PartyMemberNeedCureTrigger(botAI, "cleanse", DISPEL_POISON) + { + } }; class CleanseCureMagicTrigger : public NeedCureTrigger { - public: - CleanseCureMagicTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cleanse", DISPEL_MAGIC) { } +public: + CleanseCureMagicTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cleanse", DISPEL_MAGIC) {} }; class CleanseCurePartyMemberMagicTrigger : public PartyMemberNeedCureTrigger { - public: - CleanseCurePartyMemberMagicTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "cleanse", DISPEL_MAGIC) { } +public: + CleanseCurePartyMemberMagicTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "cleanse", DISPEL_MAGIC) + { + } }; class HammerOfJusticeEnemyHealerTrigger : public InterruptEnemyHealerTrigger { - public: - HammerOfJusticeEnemyHealerTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "hammer of justice") { } +public: + HammerOfJusticeEnemyHealerTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "hammer of justice") {} }; class DivineFavorTrigger : public BuffTrigger { - public: - DivineFavorTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "divine favor") { } +public: + DivineFavorTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "divine favor") {} }; class TurnUndeadTrigger : public HasCcTargetTrigger { - public: - TurnUndeadTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "turn undead") { } +public: + TurnUndeadTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "turn undead") {} }; DEBUFF_TRIGGER(AvengerShieldTrigger, "avenger's shield"); @@ -202,25 +212,31 @@ public: class BlessingOfKingsOnPartyTrigger : public BuffOnPartyTrigger { - public: - BlessingOfKingsOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "blessing of kings", 2 * 2000) { } +public: + BlessingOfKingsOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "blessing of kings", 2 * 2000) {} }; class BlessingOfWisdomOnPartyTrigger : public BuffOnPartyTrigger { - public: - BlessingOfWisdomOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "blessing of might,blessing of wisdom", 2 * 2000) { } +public: + BlessingOfWisdomOnPartyTrigger(PlayerbotAI* botAI) + : BuffOnPartyTrigger(botAI, "blessing of might,blessing of wisdom", 2 * 2000) + { + } }; class BlessingOfMightOnPartyTrigger : public BuffOnPartyTrigger { - public: - BlessingOfMightOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "blessing of might,blessing of wisdom", 2 * 2000) { } +public: + BlessingOfMightOnPartyTrigger(PlayerbotAI* botAI) + : BuffOnPartyTrigger(botAI, "blessing of might,blessing of wisdom", 2 * 2000) + { + } }; class AvengingWrathTrigger : public BoostTrigger { - public: - AvengingWrathTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "avenging wrath") {} +public: + AvengingWrathTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "avenging wrath") {} }; #endif diff --git a/src/strategy/paladin/TankPaladinStrategy.cpp b/src/strategy/paladin/TankPaladinStrategy.cpp index cb1ca7b5..517a639a 100644 --- a/src/strategy/paladin/TankPaladinStrategy.cpp +++ b/src/strategy/paladin/TankPaladinStrategy.cpp @@ -1,54 +1,56 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TankPaladinStrategy.h" + #include "Playerbots.h" class TankPaladinStrategyActionNodeFactory : public NamedObjectFactory { - public: - TankPaladinStrategyActionNodeFactory() - { - // creators["seal of vengeance"] = &seal_of_vengeance; - creators["seal of corruption"] = &seal_of_corruption; - creators["seal of vengeance"] = &seal_of_vengeance; - creators["seal of command"] = &seal_of_command; - creators["hand of reckoning"] = &hand_of_reckoning; - creators["taunt spell"] = &hand_of_reckoning; - } +public: + TankPaladinStrategyActionNodeFactory() + { + // creators["seal of vengeance"] = &seal_of_vengeance; + creators["seal of corruption"] = &seal_of_corruption; + creators["seal of vengeance"] = &seal_of_vengeance; + creators["seal of command"] = &seal_of_command; + creators["hand of reckoning"] = &hand_of_reckoning; + creators["taunt spell"] = &hand_of_reckoning; + } - private: - // static ActionNode* seal_of_vengeance([[maybe_unused]] PlayerbotAI* botAI) - // { - // return new ActionNode("seal of vengeance", - // /*P*/ nullptr, - // /*A*/ NextAction::array(0, new NextAction("seal of righteousness"), nullptr), - // /*C*/ nullptr); - // } - static ActionNode* seal_of_command([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("seal of command", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("seal of corruption"), nullptr), - /*C*/ nullptr); - } - static ActionNode* seal_of_corruption([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("seal of corruption", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("seal of vengeance"), nullptr), - /*C*/ nullptr); - } +private: + // static ActionNode* seal_of_vengeance([[maybe_unused]] PlayerbotAI* botAI) + // { + // return new ActionNode("seal of vengeance", + // /*P*/ nullptr, + // /*A*/ NextAction::array(0, new NextAction("seal of righteousness"), nullptr), + // /*C*/ nullptr); + // } + static ActionNode* seal_of_command([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("seal of command", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("seal of corruption"), nullptr), + /*C*/ nullptr); + } + static ActionNode* seal_of_corruption([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("seal of corruption", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("seal of vengeance"), nullptr), + /*C*/ nullptr); + } - static ActionNode* seal_of_vengeance([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("seal of vengeance", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("seal of righteousness"), nullptr), - /*C*/ nullptr); - } - ACTION_NODE_A(hand_of_reckoning, "hand of reckoning", "righteous defense"); + static ActionNode* seal_of_vengeance([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("seal of vengeance", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("seal of righteousness"), nullptr), + /*C*/ nullptr); + } + ACTION_NODE_A(hand_of_reckoning, "hand of reckoning", "righteous defense"); }; TankPaladinStrategy::TankPaladinStrategy(PlayerbotAI* botAI) : GenericPaladinStrategy(botAI) @@ -58,49 +60,56 @@ TankPaladinStrategy::TankPaladinStrategy(PlayerbotAI* botAI) : GenericPaladinStr NextAction** TankPaladinStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("shield of righteousness", ACTION_DEFAULT + 0.6f), - new NextAction("hammer of the righteous", ACTION_DEFAULT + 0.5f), - new NextAction("judgement of wisdom", ACTION_DEFAULT + 0.4f), - // new NextAction("avenger's shield", ACTION_NORMAL + 3), - // new NextAction("consecration", ACTION_NORMAL + 2), - new NextAction("melee", ACTION_DEFAULT), - NULL); + return NextAction::array(0, new NextAction("shield of righteousness", ACTION_DEFAULT + 0.6f), + new NextAction("hammer of the righteous", ACTION_DEFAULT + 0.5f), + new NextAction("judgement of wisdom", ACTION_DEFAULT + 0.4f), + // new NextAction("avenger's shield", ACTION_NORMAL + 3), + // new NextAction("consecration", ACTION_NORMAL + 2), + new NextAction("melee", ACTION_DEFAULT), NULL); } void TankPaladinStrategy::InitTriggers(std::vector& triggers) { GenericPaladinStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("seal", NextAction::array(0, new NextAction("seal of command", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("seal of wisdom", ACTION_HIGH + 9), nullptr))); - // triggers.push_back(new TriggerNode("devotion aura", NextAction::array(0, new NextAction("devotion aura", 90.0f), NULL))); + triggers.push_back( + new TriggerNode("seal", NextAction::array(0, new NextAction("seal of command", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("low mana", NextAction::array(0, new NextAction("seal of wisdom", ACTION_HIGH + 9), nullptr))); + // triggers.push_back(new TriggerNode("devotion aura", NextAction::array(0, new NextAction("devotion aura", 90.0f), + // NULL))); - triggers.push_back(new TriggerNode("light aoe", NextAction::array(0, new NextAction("avenger's shield", ACTION_HIGH + 5), nullptr))); - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, - new NextAction("melee consecration", ACTION_HIGH + 7), - new NextAction("avenger's shield", ACTION_HIGH + 6), nullptr))); - // triggers.push_back(new TriggerNode("avenger's shield", NextAction::array(0, new NextAction("avenger's shield", ACTION_HIGH + 7), nullptr))); - triggers.push_back(new TriggerNode("lose aggro", NextAction::array(0, new NextAction("hand of reckoning", ACTION_HIGH + 7), nullptr))); - // triggers.push_back(new TriggerNode("almost full health", NextAction::array(0, new NextAction("holy shield", ACTION_HIGH + 4), nullptr))); - triggers.push_back(new TriggerNode("medium health", NextAction::array(0, new NextAction("holy shield", ACTION_HIGH + 4), nullptr))); - triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("holy shield", ACTION_HIGH + 4), nullptr))); - triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("holy shield", ACTION_HIGH + 4), nullptr))); - // triggers.push_back(new TriggerNode("blessing", NextAction::array(0, new NextAction("blessing of sanctuary", ACTION_HIGH + 9), nullptr))); - triggers.push_back(new TriggerNode("target critical health", NextAction::array(0, new NextAction("hammer of wrath", ACTION_CRITICAL_HEAL), nullptr))); triggers.push_back(new TriggerNode( - "righteous fury", - NextAction::array(0, new NextAction("righteous fury", ACTION_HIGH + 8), nullptr))); + "light aoe", NextAction::array(0, new NextAction("avenger's shield", ACTION_HIGH + 5), nullptr))); + triggers.push_back( + new TriggerNode("medium aoe", NextAction::array(0, new NextAction("melee consecration", ACTION_HIGH + 7), + new NextAction("avenger's shield", ACTION_HIGH + 6), nullptr))); + // triggers.push_back(new TriggerNode("avenger's shield", NextAction::array(0, new NextAction("avenger's shield", + // ACTION_HIGH + 7), nullptr))); triggers.push_back(new TriggerNode( - "medium group heal occasion", - NextAction::array(0, new NextAction("divine sacrifice", ACTION_HIGH + 5), nullptr))); + "lose aggro", NextAction::array(0, new NextAction("hand of reckoning", ACTION_HIGH + 7), nullptr))); + // triggers.push_back(new TriggerNode("almost full health", NextAction::array(0, new NextAction("holy shield", + // ACTION_HIGH + 4), nullptr))); + triggers.push_back(new TriggerNode("medium health", + NextAction::array(0, new NextAction("holy shield", ACTION_HIGH + 4), nullptr))); + triggers.push_back( + new TriggerNode("low health", NextAction::array(0, new NextAction("holy shield", ACTION_HIGH + 4), nullptr))); + triggers.push_back(new TriggerNode("critical health", + NextAction::array(0, new NextAction("holy shield", ACTION_HIGH + 4), nullptr))); + // triggers.push_back(new TriggerNode("blessing", NextAction::array(0, new NextAction("blessing of sanctuary", + // ACTION_HIGH + 9), nullptr))); + triggers.push_back( + new TriggerNode("target critical health", + NextAction::array(0, new NextAction("hammer of wrath", ACTION_CRITICAL_HEAL), nullptr))); triggers.push_back(new TriggerNode( - "enough mana", - NextAction::array(0, new NextAction("melee consecration", ACTION_HIGH + 4), nullptr))); + "righteous fury", NextAction::array(0, new NextAction("righteous fury", ACTION_HIGH + 8), nullptr))); + triggers.push_back( + new TriggerNode("medium group heal occasion", + NextAction::array(0, new NextAction("divine sacrifice", ACTION_HIGH + 5), nullptr))); triggers.push_back(new TriggerNode( - "not facing target", - NextAction::array(0, new NextAction("set facing", ACTION_NORMAL + 7), nullptr))); + "enough mana", NextAction::array(0, new NextAction("melee consecration", ACTION_HIGH + 4), nullptr))); + triggers.push_back(new TriggerNode("not facing target", + NextAction::array(0, new NextAction("set facing", ACTION_NORMAL + 7), nullptr))); triggers.push_back(new TriggerNode( - "enemy out of melee", - NextAction::array(0, new NextAction("reach melee", ACTION_NORMAL + 8), nullptr))); + "enemy out of melee", NextAction::array(0, new NextAction("reach melee", ACTION_NORMAL + 8), nullptr))); } diff --git a/src/strategy/paladin/TankPaladinStrategy.h b/src/strategy/paladin/TankPaladinStrategy.h index 09655ad2..9216c948 100644 --- a/src/strategy/paladin/TankPaladinStrategy.h +++ b/src/strategy/paladin/TankPaladinStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TANKPALADINSTRATEGY_H @@ -11,13 +12,13 @@ class PlayerbotAI; class TankPaladinStrategy : public GenericPaladinStrategy { - public: - TankPaladinStrategy(PlayerbotAI* botAI); +public: + TankPaladinStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "tank"; } - NextAction** getDefaultActions() override; - uint32 GetType() const override { return STRATEGY_TYPE_TANK | STRATEGY_TYPE_MELEE; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "tank"; } + NextAction** getDefaultActions() override; + uint32 GetType() const override { return STRATEGY_TYPE_TANK | STRATEGY_TYPE_MELEE; } }; #endif diff --git a/src/strategy/priest/GenericPriestStrategy.cpp b/src/strategy/priest/GenericPriestStrategy.cpp index ab66777c..b087c79e 100644 --- a/src/strategy/priest/GenericPriestStrategy.cpp +++ b/src/strategy/priest/GenericPriestStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericPriestStrategy.h" + #include "GenericPriestStrategyActionNodeFactory.h" #include "HealPriestStrategy.h" #include "Playerbots.h" @@ -16,35 +18,37 @@ void GenericPriestStrategy::InitTriggers(std::vector& triggers) { CombatStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("medium health", NextAction::array(0, new NextAction("greater heal", 25.0f), nullptr))); - // triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("power word: shield", 61.0f), new NextAction("greater heal", 60.0f), nullptr))); - // triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("remove shadowform", 72.0f), new NextAction("power word: shield", 71.0f), new NextAction("flash heal", 70.0f), nullptr))); - // triggers.push_back(new TriggerNode("party member critical health", NextAction::array(0, new NextAction("remove shadowform", 62.0f), new NextAction("power word: shield on party", 61.0f), new NextAction("flash heal on party", 60.0f), nullptr))); + // triggers.push_back(new TriggerNode("medium health", NextAction::array(0, new NextAction("greater heal", 25.0f), + // nullptr))); triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("power word: + // shield", 61.0f), new NextAction("greater heal", 60.0f), nullptr))); triggers.push_back(new TriggerNode("critical + // health", NextAction::array(0, new NextAction("remove shadowform", 72.0f), new NextAction("power word: + // shield", 71.0f), new NextAction("flash heal", 70.0f), nullptr))); triggers.push_back(new TriggerNode("party + // member critical health", NextAction::array(0, new NextAction("remove shadowform", 62.0f), new NextAction("power + // word: shield on party", 61.0f), new NextAction("flash heal on party", 60.0f), nullptr))); triggers.push_back(new TriggerNode("medium threat", NextAction::array(0, new NextAction("fade", 55.0f), nullptr))); - // triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new NextAction("psychic scream", 50.0f), nullptr))); - // triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("inner focus", 42.0f), nullptr))); - // triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new NextAction("symbol of hope", ACTION_EMERGENCY), nullptr))); - // triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("consume magic", 10.0f), nullptr))); - // triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("desperate prayer", ACTION_EMERGENCY), nullptr))); - // triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new NextAction("elune's grace", ACTION_EMERGENCY), nullptr))); - // triggers.push_back(new TriggerNode("chastise", NextAction::array(0, new NextAction("chastise", ACTION_INTERRUPT), nullptr))); + // triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new NextAction("psychic + // scream", 50.0f), nullptr))); triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new + // NextAction("inner focus", 42.0f), nullptr))); triggers.push_back(new TriggerNode("medium mana", + // NextAction::array(0, new NextAction("symbol of hope", ACTION_EMERGENCY), nullptr))); triggers.push_back(new + // TriggerNode("low mana", NextAction::array(0, new NextAction("consume magic", 10.0f), nullptr))); + // triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("desperate prayer", + // ACTION_EMERGENCY), nullptr))); triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new + // NextAction("elune's grace", ACTION_EMERGENCY), nullptr))); triggers.push_back(new TriggerNode("chastise", + // NextAction::array(0, new NextAction("chastise", ACTION_INTERRUPT), nullptr))); triggers.push_back(new TriggerNode( - "critical health", - NextAction::array(0, new NextAction("power word: shield", ACTION_NORMAL), NULL))); + "critical health", NextAction::array(0, new NextAction("power word: shield", ACTION_NORMAL), NULL))); - triggers.push_back(new TriggerNode( - "low health", - NextAction::array(0, new NextAction("power word: shield", ACTION_HIGH), NULL))); + triggers.push_back( + new TriggerNode("low health", NextAction::array(0, new NextAction("power word: shield", ACTION_HIGH), NULL))); - triggers.push_back(new TriggerNode( - "medium mana", - NextAction::array(0, new NextAction("shadowfiend", ACTION_HIGH + 1), NULL))); + triggers.push_back( + new TriggerNode("medium mana", NextAction::array(0, new NextAction("shadowfiend", ACTION_HIGH + 1), NULL))); - triggers.push_back(new TriggerNode( - "low mana", - NextAction::array(0, new NextAction("hymn of hope", ACTION_HIGH), NULL))); - - triggers.push_back(new TriggerNode("enemy too close for spell", NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); + triggers.push_back( + new TriggerNode("low mana", NextAction::array(0, new NextAction("hymn of hope", ACTION_HIGH), NULL))); + + triggers.push_back(new TriggerNode("enemy too close for spell", + NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("apply oil", 1.0f), nullptr))); } @@ -55,20 +59,27 @@ PriestCureStrategy::PriestCureStrategy(PlayerbotAI* botAI) : Strategy(botAI) void PriestCureStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("dispel magic", NextAction::array(0, new NextAction("dispel magic", 41.0f), nullptr))); - triggers.push_back(new TriggerNode("dispel magic on party", NextAction::array(0, new NextAction("dispel magic on party", 40.0f), nullptr))); - triggers.push_back(new TriggerNode("cure disease", NextAction::array(0, new NextAction("abolish disease", 31.0f), nullptr))); - triggers.push_back(new TriggerNode("party member cure disease", NextAction::array(0, new NextAction("abolish disease on party", 30.0f), nullptr))); + triggers.push_back( + new TriggerNode("dispel magic", NextAction::array(0, new NextAction("dispel magic", 41.0f), nullptr))); + triggers.push_back(new TriggerNode("dispel magic on party", + NextAction::array(0, new NextAction("dispel magic on party", 40.0f), nullptr))); + triggers.push_back( + new TriggerNode("cure disease", NextAction::array(0, new NextAction("abolish disease", 31.0f), nullptr))); + triggers.push_back(new TriggerNode( + "party member cure disease", NextAction::array(0, new NextAction("abolish disease on party", 30.0f), nullptr))); } void PriestBoostStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("inner focus", NextAction::array(0, new NextAction("inner focus", 42.0f), nullptr))); - triggers.push_back(new TriggerNode("power infusion", NextAction::array(0, new NextAction("power infusion", 41.0f), nullptr))); + triggers.push_back( + new TriggerNode("inner focus", NextAction::array(0, new NextAction("inner focus", 42.0f), nullptr))); + triggers.push_back( + new TriggerNode("power infusion", NextAction::array(0, new NextAction("power infusion", 41.0f), nullptr))); triggers.push_back(new TriggerNode("boost", NextAction::array(0, new NextAction("shadowfiend", 20.0f), nullptr))); } void PriestCcStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("shackle undead", NextAction::array(0, new NextAction("shackle undead", 31.0f), nullptr))); + triggers.push_back( + new TriggerNode("shackle undead", NextAction::array(0, new NextAction("shackle undead", 31.0f), nullptr))); } diff --git a/src/strategy/priest/GenericPriestStrategy.h b/src/strategy/priest/GenericPriestStrategy.h index fb8510cd..7c6684af 100644 --- a/src/strategy/priest/GenericPriestStrategy.h +++ b/src/strategy/priest/GenericPriestStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICPRIESTSTRATEGY_H @@ -12,37 +13,37 @@ class PlayerbotAI; class GenericPriestStrategy : public RangedCombatStrategy { - public: - GenericPriestStrategy(PlayerbotAI* botAI); +public: + GenericPriestStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; + void InitTriggers(std::vector& triggers) override; }; class PriestCureStrategy : public Strategy { - public: - PriestCureStrategy(PlayerbotAI* botAI); +public: + PriestCureStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "cure"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cure"; } }; class PriestBoostStrategy : public Strategy { - public: - PriestBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PriestBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "boost"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "boost"; } }; class PriestCcStrategy : public Strategy { - public: - PriestCcStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + PriestCcStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "cc"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cc"; } }; #endif diff --git a/src/strategy/priest/GenericPriestStrategyActionNodeFactory.h b/src/strategy/priest/GenericPriestStrategyActionNodeFactory.h index e12a9a40..a6c612b5 100644 --- a/src/strategy/priest/GenericPriestStrategyActionNodeFactory.h +++ b/src/strategy/priest/GenericPriestStrategyActionNodeFactory.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICPRIESTSTRATEGYACTIONNODEFACTORY_H @@ -10,197 +11,197 @@ class GenericPriestStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericPriestStrategyActionNodeFactory() - { - creators["inner fire"] = &inner_fire; - creators["holy nova"] = &holy_nova; - creators["power word: fortitude"] = &power_word_fortitude; - creators["power word: fortitude on party"] = &power_word_fortitude_on_party; - creators["divine spirit"] = &divine_spirit; - creators["divine spirit on party"] = &divine_spirit_on_party; - creators["power word: shield"] = &power_word_shield; - // creators["power word: shield on party"] = &power_word_shield_on_party; - creators["renew"] = &renew; - creators["renew on party"] = &renew_on_party; - creators["greater heal"] = &greater_heal; - creators["greater heal on party"] = &greater_heal_on_party; - creators["heal"] = &heal; - creators["heal on party"] = &heal_on_party; - creators["lesser heal"] = &lesser_heal; - creators["lesser heal on party"] = &lesser_heal_on_party; - creators["flash heal"] = &flash_heal; - creators["flash heal on party"] = &flash_heal_on_party; - creators["psychic scream"] = &psychic_scream; - // creators["fade"] = &fade; - creators["shadowfiend"] = &shadowfiend; - } +public: + GenericPriestStrategyActionNodeFactory() + { + creators["inner fire"] = &inner_fire; + creators["holy nova"] = &holy_nova; + creators["power word: fortitude"] = &power_word_fortitude; + creators["power word: fortitude on party"] = &power_word_fortitude_on_party; + creators["divine spirit"] = &divine_spirit; + creators["divine spirit on party"] = &divine_spirit_on_party; + creators["power word: shield"] = &power_word_shield; + // creators["power word: shield on party"] = &power_word_shield_on_party; + creators["renew"] = &renew; + creators["renew on party"] = &renew_on_party; + creators["greater heal"] = &greater_heal; + creators["greater heal on party"] = &greater_heal_on_party; + creators["heal"] = &heal; + creators["heal on party"] = &heal_on_party; + creators["lesser heal"] = &lesser_heal; + creators["lesser heal on party"] = &lesser_heal_on_party; + creators["flash heal"] = &flash_heal; + creators["flash heal on party"] = &flash_heal_on_party; + creators["psychic scream"] = &psychic_scream; + // creators["fade"] = &fade; + creators["shadowfiend"] = &shadowfiend; + } - private: - static ActionNode* inner_fire(PlayerbotAI* ai) - { - return new ActionNode ("inner fire", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* holy_nova(PlayerbotAI* ai) - { - return new ActionNode ("holy nova", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* power_word_fortitude(PlayerbotAI* ai) - { - return new ActionNode ("power word: fortitude", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* power_word_fortitude_on_party(PlayerbotAI* ai) - { - return new ActionNode ("power word: fortitude on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* divine_spirit(PlayerbotAI* ai) - { - return new ActionNode ("divine spirit", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* divine_spirit_on_party(PlayerbotAI* ai) - { - return new ActionNode ("divine spirit on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* power_word_shield(PlayerbotAI* ai) - { - return new ActionNode ("power word: shield", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - // /*A*/ NextAction::array(0, new NextAction("renew", 50.0f), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* power_word_shield_on_party(PlayerbotAI* ai) - { - return new ActionNode ("power word: shield on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - // /*A*/ NextAction::array(0, new NextAction("renew on party", 50.0f), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* renew(PlayerbotAI* ai) - { - return new ActionNode ("renew", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* renew_on_party(PlayerbotAI* ai) - { - return new ActionNode ("renew on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* greater_heal(PlayerbotAI* ai) - { - return new ActionNode ("greater heal", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NextAction::array(0, new NextAction("heal"), NULL), - /*C*/ NULL); - } - static ActionNode* greater_heal_on_party(PlayerbotAI* ai) - { - return new ActionNode ("greater heal on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NextAction::array(0, new NextAction("heal on party"), NULL), - /*C*/ NULL); - } - static ActionNode* heal(PlayerbotAI* ai) - { - return new ActionNode ("heal", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NextAction::array(0, new NextAction("lesser heal"), NULL), - /*C*/ NULL); - } - static ActionNode* heal_on_party(PlayerbotAI* ai) - { - return new ActionNode ("heal on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NextAction::array(0, new NextAction("lesser heal on party"), NULL), - /*C*/ NULL); - } - static ActionNode* lesser_heal(PlayerbotAI* ai) - { - return new ActionNode ("lesser heal", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* lesser_heal_on_party(PlayerbotAI* ai) - { - return new ActionNode ("lesser heal on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* flash_heal(PlayerbotAI* ai) - { - return new ActionNode ("flash heal", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NextAction::array(0, new NextAction("greater heal"), NULL), - /*C*/ NULL); - } - static ActionNode* flash_heal_on_party(PlayerbotAI* ai) - { - return new ActionNode ("flash heal on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NextAction::array(0, new NextAction("greater heal on party"), NULL), - /*C*/ NULL); - } - static ActionNode* psychic_scream(PlayerbotAI* ai) - { - return new ActionNode ("psychic scream", - /*P*/ NULL, - /*A*/ NextAction::array(0, new NextAction("fade"), NULL), - /*C*/ NULL); - } - // static ActionNode* fade(PlayerbotAI* ai) - // { - // return new ActionNode ("fade", - // /*P*/ NULL, - // /*A*/ NextAction::array(0, new NextAction("flee"), NULL), - // /*C*/ NULL); - // } - static ActionNode* shadowfiend(PlayerbotAI* ai) - { - return new ActionNode ("shadowfiend", - /*P*/ NULL, - // /*A*/ NextAction::array(0, new NextAction("hymn of hope"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } +private: + static ActionNode* inner_fire(PlayerbotAI* ai) + { + return new ActionNode("inner fire", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* holy_nova(PlayerbotAI* ai) + { + return new ActionNode("holy nova", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* power_word_fortitude(PlayerbotAI* ai) + { + return new ActionNode("power word: fortitude", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* power_word_fortitude_on_party(PlayerbotAI* ai) + { + return new ActionNode("power word: fortitude on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* divine_spirit(PlayerbotAI* ai) + { + return new ActionNode("divine spirit", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* divine_spirit_on_party(PlayerbotAI* ai) + { + return new ActionNode("divine spirit on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* power_word_shield(PlayerbotAI* ai) + { + return new ActionNode("power word: shield", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + // /*A*/ NextAction::array(0, new NextAction("renew", 50.0f), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* power_word_shield_on_party(PlayerbotAI* ai) + { + return new ActionNode("power word: shield on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + // /*A*/ NextAction::array(0, new NextAction("renew on party", 50.0f), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* renew(PlayerbotAI* ai) + { + return new ActionNode("renew", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* renew_on_party(PlayerbotAI* ai) + { + return new ActionNode("renew on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* greater_heal(PlayerbotAI* ai) + { + return new ActionNode("greater heal", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NextAction::array(0, new NextAction("heal"), NULL), + /*C*/ NULL); + } + static ActionNode* greater_heal_on_party(PlayerbotAI* ai) + { + return new ActionNode("greater heal on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NextAction::array(0, new NextAction("heal on party"), NULL), + /*C*/ NULL); + } + static ActionNode* heal(PlayerbotAI* ai) + { + return new ActionNode("heal", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NextAction::array(0, new NextAction("lesser heal"), NULL), + /*C*/ NULL); + } + static ActionNode* heal_on_party(PlayerbotAI* ai) + { + return new ActionNode("heal on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NextAction::array(0, new NextAction("lesser heal on party"), NULL), + /*C*/ NULL); + } + static ActionNode* lesser_heal(PlayerbotAI* ai) + { + return new ActionNode("lesser heal", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* lesser_heal_on_party(PlayerbotAI* ai) + { + return new ActionNode("lesser heal on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* flash_heal(PlayerbotAI* ai) + { + return new ActionNode("flash heal", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NextAction::array(0, new NextAction("greater heal"), NULL), + /*C*/ NULL); + } + static ActionNode* flash_heal_on_party(PlayerbotAI* ai) + { + return new ActionNode("flash heal on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NextAction::array(0, new NextAction("greater heal on party"), NULL), + /*C*/ NULL); + } + static ActionNode* psychic_scream(PlayerbotAI* ai) + { + return new ActionNode("psychic scream", + /*P*/ NULL, + /*A*/ NextAction::array(0, new NextAction("fade"), NULL), + /*C*/ NULL); + } + // static ActionNode* fade(PlayerbotAI* ai) + // { + // return new ActionNode ("fade", + // /*P*/ NULL, + // /*A*/ NextAction::array(0, new NextAction("flee"), NULL), + // /*C*/ NULL); + // } + static ActionNode* shadowfiend(PlayerbotAI* ai) + { + return new ActionNode("shadowfiend", + /*P*/ NULL, + // /*A*/ NextAction::array(0, new NextAction("hymn of hope"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } }; class CurePriestStrategyActionNodeFactory : public NamedObjectFactory { - public: - CurePriestStrategyActionNodeFactory() - { - creators["abolish disease"] = &abolish_disease; - creators["abolish disease on party"] = &abolish_disease_on_party; - } +public: + CurePriestStrategyActionNodeFactory() + { + creators["abolish disease"] = &abolish_disease; + creators["abolish disease on party"] = &abolish_disease_on_party; + } - private: - ACTION_NODE_A(abolish_disease, "abolish disease", "cure disease"); - ACTION_NODE_A(abolish_disease_on_party, "abolish disease on party", "cure disease on party"); +private: + ACTION_NODE_A(abolish_disease, "abolish disease", "cure disease"); + ACTION_NODE_A(abolish_disease_on_party, "abolish disease on party", "cure disease on party"); }; #endif diff --git a/src/strategy/priest/HealPriestStrategy.cpp b/src/strategy/priest/HealPriestStrategy.cpp index 53998500..25f8e8bd 100644 --- a/src/strategy/priest/HealPriestStrategy.cpp +++ b/src/strategy/priest/HealPriestStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HealPriestStrategy.h" + #include "GenericPriestStrategyActionNodeFactory.h" #include "Playerbots.h" @@ -24,75 +26,73 @@ void HealPriestStrategy::InitTriggers(std::vector& triggers) // "enemy out of spell", // NextAction::array(0, new NextAction("reach spell", ACTION_NORMAL + 9), NULL))); - // triggers.push_back(new TriggerNode( - // "medium aoe heal", - // NextAction::array(0, - // new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 8), + // triggers.push_back(new TriggerNode( + // "medium aoe heal", + // NextAction::array(0, + // new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 8), // // new NextAction("power word: shield on almost full health below", ACTION_MEDIUM_HEAL + 7), // NULL))); triggers.push_back(new TriggerNode( - "group heal occasion", - NextAction::array(0, - new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 8), - new NextAction("power word: shield on almost full health below", ACTION_MEDIUM_HEAL + 7), - NULL))); + "group heal occasion", + NextAction::array(0, new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 8), + new NextAction("power word: shield on almost full health below", ACTION_MEDIUM_HEAL + 7), + NULL))); triggers.push_back(new TriggerNode( "medium group heal occasion", - NextAction::array(0, - new NextAction("divine hymn", ACTION_CRITICAL_HEAL + 6), - new NextAction("prayer of healing on party", ACTION_CRITICAL_HEAL + 5), - nullptr))); + NextAction::array(0, new NextAction("divine hymn", ACTION_CRITICAL_HEAL + 6), + new NextAction("prayer of healing on party", ACTION_CRITICAL_HEAL + 5), nullptr))); triggers.push_back(new TriggerNode( "party member critical health", - NextAction::array(0, - new NextAction("power word: shield on party", ACTION_CRITICAL_HEAL + 6), - new NextAction("penance on party", ACTION_CRITICAL_HEAL + 4), - new NextAction("flash heal on party", ACTION_CRITICAL_HEAL + 3), - new NextAction("prayer of mending on party", ACTION_CRITICAL_HEAL + 2), - NULL))); + NextAction::array(0, new NextAction("power word: shield on party", ACTION_CRITICAL_HEAL + 6), + new NextAction("penance on party", ACTION_CRITICAL_HEAL + 4), + new NextAction("flash heal on party", ACTION_CRITICAL_HEAL + 3), + new NextAction("prayer of mending on party", ACTION_CRITICAL_HEAL + 2), NULL))); + + triggers.push_back( + new TriggerNode("party member low health", + NextAction::array(0, new NextAction("power word: shield on party", ACTION_MEDIUM_HEAL + 4), + new NextAction("penance on party", ACTION_MEDIUM_HEAL + 2), + new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 2), + new NextAction("prayer of mending on party", ACTION_MEDIUM_HEAL + 1), + new NextAction("flash heal on party", ACTION_MEDIUM_HEAL + 0), NULL))); + + triggers.push_back( + new TriggerNode("party member medium health", + NextAction::array(0, new NextAction("power word: shield on party", ACTION_LIGHT_HEAL + 9), + new NextAction("penance on party", ACTION_LIGHT_HEAL + 7), + new NextAction("circle of healing", ACTION_LIGHT_HEAL + 7), + new NextAction("prayer of mending on party", ACTION_LIGHT_HEAL + 6), + new NextAction("flash heal on party", ACTION_LIGHT_HEAL + 5), + // new NextAction("renew on party", ACTION_LIGHT_HEAL + 8), + NULL))); + + triggers.push_back( + new TriggerNode("party member almost full health", + NextAction::array(0, + // new NextAction("penance on party", ACTION_LIGHT_HEAL + 3), + new NextAction("renew on party", ACTION_LIGHT_HEAL + 2), NULL))); + + // triggers.push_back(new TriggerNode("almost full health", NextAction::array(0, new NextAction("renew", 43.f), + // nullptr))); triggers.push_back(new TriggerNode("party member almost full health", NextAction::array(0, new + // NextAction("heal on party", 41.0f), new NextAction("renew on party", 40.0f), nullptr))); triggers.push_back(new + // TriggerNode("party member medium health", NextAction::array(0, new NextAction("greater heal on party", 47.0f), + // nullptr))); triggers.push_back(new TriggerNode("party member low health", NextAction::array(0, new + // NextAction("power word: shield on party", 51.0f), new NextAction("greater heal on party", 50.0f), nullptr))); + triggers.push_back(new TriggerNode( + "party member to heal out of spell range", + NextAction::array(0, new NextAction("reach party member to heal", ACTION_CRITICAL_HEAL + 10), nullptr))); + // triggers.push_back(new TriggerNode("medium aoe heal", NextAction::array(0, new NextAction("prayer of + // mending", 49.0f), nullptr))); triggers.push_back(new TriggerNode("medium aoe heal", NextAction::array(0, new + // NextAction("circle of healing", 48.0f), nullptr))); triggers.push_back(new TriggerNode("binding heal", + // NextAction::array(0, new NextAction("binding heal", 52.0f), nullptr))); triggers.push_back(new TriggerNode("low + // mana", NextAction::array(0, new NextAction("shadowfiend", ACTION_HIGH), nullptr))); triggers.push_back(new TriggerNode( - "party member low health", - NextAction::array(0, - new NextAction("power word: shield on party", ACTION_MEDIUM_HEAL + 4), - new NextAction("penance on party", ACTION_MEDIUM_HEAL + 2), - new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 2), - new NextAction("prayer of mending on party", ACTION_MEDIUM_HEAL + 1), - new NextAction("flash heal on party", ACTION_MEDIUM_HEAL + 0), - NULL))); - - triggers.push_back(new TriggerNode( - "party member medium health", - NextAction::array(0, - new NextAction("power word: shield on party", ACTION_LIGHT_HEAL + 9), - new NextAction("penance on party", ACTION_LIGHT_HEAL + 7), - new NextAction("circle of healing", ACTION_LIGHT_HEAL + 7), - new NextAction("prayer of mending on party", ACTION_LIGHT_HEAL + 6), - new NextAction("flash heal on party", ACTION_LIGHT_HEAL + 5), - // new NextAction("renew on party", ACTION_LIGHT_HEAL + 8), - NULL))); - - triggers.push_back(new TriggerNode( - "party member almost full health", - NextAction::array(0, - // new NextAction("penance on party", ACTION_LIGHT_HEAL + 3), - new NextAction("renew on party", ACTION_LIGHT_HEAL + 2), - NULL))); - - // triggers.push_back(new TriggerNode("almost full health", NextAction::array(0, new NextAction("renew", 43.f), nullptr))); - // triggers.push_back(new TriggerNode("party member almost full health", NextAction::array(0, new NextAction("heal on party", 41.0f), new NextAction("renew on party", 40.0f), nullptr))); - // triggers.push_back(new TriggerNode("party member medium health", NextAction::array(0, new NextAction("greater heal on party", 47.0f), nullptr))); - // triggers.push_back(new TriggerNode("party member low health", NextAction::array(0, new NextAction("power word: shield on party", 51.0f), new NextAction("greater heal on party", 50.0f), nullptr))); - triggers.push_back(new TriggerNode("party member to heal out of spell range", NextAction::array(0, new NextAction("reach party member to heal", ACTION_CRITICAL_HEAL + 10), nullptr))); - // triggers.push_back(new TriggerNode("medium aoe heal", NextAction::array(0, new NextAction("prayer of mending", 49.0f), nullptr))); - // triggers.push_back(new TriggerNode("medium aoe heal", NextAction::array(0, new NextAction("circle of healing", 48.0f), nullptr))); - // triggers.push_back(new TriggerNode("binding heal", NextAction::array(0, new NextAction("binding heal", 52.0f), nullptr))); - // triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("shadowfiend", ACTION_HIGH), nullptr))); - - triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("pain suppression", ACTION_EMERGENCY + 1), nullptr))); - triggers.push_back(new TriggerNode("protect party member", NextAction::array(0, new NextAction("pain suppression on party", ACTION_EMERGENCY), nullptr))); - + "critical health", NextAction::array(0, new NextAction("pain suppression", ACTION_EMERGENCY + 1), nullptr))); + triggers.push_back( + new TriggerNode("protect party member", + NextAction::array(0, new NextAction("pain suppression on party", ACTION_EMERGENCY), nullptr))); } diff --git a/src/strategy/priest/HealPriestStrategy.h b/src/strategy/priest/HealPriestStrategy.h index 59b95dcb..b93f05c8 100644 --- a/src/strategy/priest/HealPriestStrategy.h +++ b/src/strategy/priest/HealPriestStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HEALPRIESTSTRATEGY_H @@ -11,13 +12,13 @@ class PlayerbotAI; class HealPriestStrategy : public GenericPriestStrategy { - public: - HealPriestStrategy(PlayerbotAI* botAI); +public: + HealPriestStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - NextAction** getDefaultActions() override; - std::string const getName() override { return "heal"; } - uint32 GetType() const override { return STRATEGY_TYPE_HEAL | STRATEGY_TYPE_RANGED; } + void InitTriggers(std::vector& triggers) override; + NextAction** getDefaultActions() override; + std::string const getName() override { return "heal"; } + uint32 GetType() const override { return STRATEGY_TYPE_HEAL | STRATEGY_TYPE_RANGED; } }; #endif diff --git a/src/strategy/priest/HolyPriestStrategy.cpp b/src/strategy/priest/HolyPriestStrategy.cpp index 27d3d1d7..decae30d 100644 --- a/src/strategy/priest/HolyPriestStrategy.cpp +++ b/src/strategy/priest/HolyPriestStrategy.cpp @@ -1,26 +1,25 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HolyPriestStrategy.h" + #include "Playerbots.h" class HolyPriestStrategyActionNodeFactory : public NamedObjectFactory { - public: - HolyPriestStrategyActionNodeFactory() - { - creators["smite"] = &smite; - } +public: + HolyPriestStrategyActionNodeFactory() { creators["smite"] = &smite; } - private: - static ActionNode* smite([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("smite", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* smite([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("smite", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), + /*C*/ nullptr); + } }; HolyPriestStrategy::HolyPriestStrategy(PlayerbotAI* botAI) : HealPriestStrategy(botAI) @@ -30,17 +29,23 @@ HolyPriestStrategy::HolyPriestStrategy(PlayerbotAI* botAI) : HealPriestStrategy( NextAction** HolyPriestStrategy::getDefaultActions() { - return NextAction::array(0, new NextAction("smite", ACTION_DEFAULT + 0.2f), new NextAction("mana burn", ACTION_DEFAULT + 0.1f), new NextAction("starshards", ACTION_DEFAULT), nullptr); + return NextAction::array(0, new NextAction("smite", ACTION_DEFAULT + 0.2f), + new NextAction("mana burn", ACTION_DEFAULT + 0.1f), + new NextAction("starshards", ACTION_DEFAULT), nullptr); } void HolyPriestStrategy::InitTriggers(std::vector& triggers) { HealPriestStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("holy fire", NextAction::array(0, new NextAction("holy fire", ACTION_NORMAL + 9), nullptr))); - triggers.push_back(new TriggerNode("shadowfiend", NextAction::array(0, new NextAction("shadowfiend", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new NextAction("shadowfiend", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("mana burn", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("holy fire", NextAction::array(0, new NextAction("holy fire", ACTION_NORMAL + 9), nullptr))); + triggers.push_back( + new TriggerNode("shadowfiend", NextAction::array(0, new NextAction("shadowfiend", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("medium mana", NextAction::array(0, new NextAction("shadowfiend", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("low mana", NextAction::array(0, new NextAction("mana burn", ACTION_HIGH), nullptr))); } HolyHealPriestStrategy::HolyHealPriestStrategy(PlayerbotAI* botAI) : GenericPriestStrategy(botAI) @@ -57,51 +62,43 @@ void HolyHealPriestStrategy::InitTriggers(std::vector& triggers) { GenericPriestStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode( - "group heal occasion", - NextAction::array(0, - new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 8), - NULL))); + triggers.push_back( + new TriggerNode("group heal occasion", + NextAction::array(0, new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 8), NULL))); triggers.push_back(new TriggerNode( "medium group heal occasion", - NextAction::array(0, - new NextAction("divine hymn", ACTION_CRITICAL_HEAL + 6), - new NextAction("prayer of healing on party", ACTION_CRITICAL_HEAL + 5), - nullptr))); + NextAction::array(0, new NextAction("divine hymn", ACTION_CRITICAL_HEAL + 6), + new NextAction("prayer of healing on party", ACTION_CRITICAL_HEAL + 5), nullptr))); triggers.push_back(new TriggerNode( "party member critical health", - NextAction::array(0, - new NextAction("power word: shield on party", ACTION_CRITICAL_HEAL + 5), - new NextAction("flash heal on party", ACTION_CRITICAL_HEAL + 3), - new NextAction("prayer of mending on party", ACTION_CRITICAL_HEAL + 2), - NULL))); + NextAction::array(0, new NextAction("power word: shield on party", ACTION_CRITICAL_HEAL + 5), + new NextAction("flash heal on party", ACTION_CRITICAL_HEAL + 3), + new NextAction("prayer of mending on party", ACTION_CRITICAL_HEAL + 2), NULL))); + + triggers.push_back( + new TriggerNode("party member low health", + NextAction::array(0, new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 4), + new NextAction("greater heal on party", ACTION_MEDIUM_HEAL + 3), + new NextAction("prayer of mending on party", ACTION_MEDIUM_HEAL + 2), + new NextAction("flash heal on party", ACTION_MEDIUM_HEAL + 1), NULL))); + + triggers.push_back( + new TriggerNode("party member medium health", + NextAction::array(0, new NextAction("circle of healing", ACTION_LIGHT_HEAL + 7), + new NextAction("prayer of mending on party", ACTION_LIGHT_HEAL + 6), + new NextAction("flash heal on party", ACTION_LIGHT_HEAL + 5), + // new NextAction("renew on party", ACTION_LIGHT_HEAL + 8), + NULL))); + + triggers.push_back( + new TriggerNode("party member almost full health", + NextAction::array(0, new NextAction("renew on party", ACTION_LIGHT_HEAL + 2), + // new NextAction("flash heal on party", ACTION_LIGHT_HEAL + 1), + NULL))); triggers.push_back(new TriggerNode( - "party member low health", - NextAction::array(0, - new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 4), - new NextAction("greater heal on party", ACTION_MEDIUM_HEAL + 3), - new NextAction("prayer of mending on party", ACTION_MEDIUM_HEAL + 2), - new NextAction("flash heal on party", ACTION_MEDIUM_HEAL + 1), - NULL))); - - triggers.push_back(new TriggerNode( - "party member medium health", - NextAction::array(0, - new NextAction("circle of healing", ACTION_LIGHT_HEAL + 7), - new NextAction("prayer of mending on party", ACTION_LIGHT_HEAL + 6), - new NextAction("flash heal on party", ACTION_LIGHT_HEAL + 5), - // new NextAction("renew on party", ACTION_LIGHT_HEAL + 8), - NULL))); - - triggers.push_back(new TriggerNode( - "party member almost full health", - NextAction::array(0, - new NextAction("renew on party", ACTION_LIGHT_HEAL + 2), - // new NextAction("flash heal on party", ACTION_LIGHT_HEAL + 1), - NULL))); - - triggers.push_back(new TriggerNode("party member to heal out of spell range", NextAction::array(0, new NextAction("reach party member to heal", ACTION_CRITICAL_HEAL + 10), nullptr))); + "party member to heal out of spell range", + NextAction::array(0, new NextAction("reach party member to heal", ACTION_CRITICAL_HEAL + 10), nullptr))); } diff --git a/src/strategy/priest/HolyPriestStrategy.h b/src/strategy/priest/HolyPriestStrategy.h index 108cdf68..9bdd3bef 100644 --- a/src/strategy/priest/HolyPriestStrategy.h +++ b/src/strategy/priest/HolyPriestStrategy.h @@ -1,36 +1,36 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HOLYPRIESTSTRATEGY_H #define _PLAYERBOT_HOLYPRIESTSTRATEGY_H -#include "HealPriestStrategy.h" #include "GenericPriestStrategyActionNodeFactory.h" +#include "HealPriestStrategy.h" class PlayerbotAI; class HolyPriestStrategy : public HealPriestStrategy { - public: - HolyPriestStrategy(PlayerbotAI* botAI); +public: + HolyPriestStrategy(PlayerbotAI* botAI); - NextAction** getDefaultActions() override; - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "holy dps"; } - uint32 GetType() const override { return STRATEGY_TYPE_DPS | STRATEGY_TYPE_RANGED; } + NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "holy dps"; } + uint32 GetType() const override { return STRATEGY_TYPE_DPS | STRATEGY_TYPE_RANGED; } }; class HolyHealPriestStrategy : public GenericPriestStrategy { - public: - HolyHealPriestStrategy(PlayerbotAI* botAI); +public: + HolyHealPriestStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - NextAction** getDefaultActions() override; - std::string const getName() override { return "holy heal"; } - uint32 GetType() const override { return STRATEGY_TYPE_HEAL | STRATEGY_TYPE_RANGED; } + void InitTriggers(std::vector& triggers) override; + NextAction** getDefaultActions() override; + std::string const getName() override { return "holy heal"; } + uint32 GetType() const override { return STRATEGY_TYPE_HEAL | STRATEGY_TYPE_RANGED; } }; - #endif diff --git a/src/strategy/priest/PriestActions.cpp b/src/strategy/priest/PriestActions.cpp index 079d4efd..3a94dafc 100644 --- a/src/strategy/priest/PriestActions.cpp +++ b/src/strategy/priest/PriestActions.cpp @@ -1,20 +1,16 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PriestActions.h" + #include "Event.h" #include "Playerbots.h" -bool CastRemoveShadowformAction::isUseful() -{ - return botAI->HasAura("shadowform", AI_VALUE(Unit*, "self target")); -} +bool CastRemoveShadowformAction::isUseful() { return botAI->HasAura("shadowform", AI_VALUE(Unit*, "self target")); } -bool CastRemoveShadowformAction::isPossible() -{ - return true; -} +bool CastRemoveShadowformAction::isPossible() { return true; } bool CastRemoveShadowformAction::Execute(Event event) { @@ -24,22 +20,26 @@ bool CastRemoveShadowformAction::Execute(Event event) Unit* CastPowerWordShieldOnAlmostFullHealthBelow::GetTarget() { - Group *group = bot->GetGroup(); - for (GroupReference *gref = group->GetFirstMember(); gref; gref = gref->next()) + Group* group = bot->GetGroup(); + for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next()) { Player* player = gref->GetSource(); if (!player) continue; - if (player->isDead()) { + if (player->isDead()) + { continue; } - if (player->GetHealthPct() > sPlayerbotAIConfig->almostFullHealth) { + if (player->GetHealthPct() > sPlayerbotAIConfig->almostFullHealth) + { continue; } - if (player->GetDistance2d(bot) > sPlayerbotAIConfig->spellDistance) { + if (player->GetDistance2d(bot) > sPlayerbotAIConfig->spellDistance) + { continue; } - if (botAI->HasAnyAuraOf(player, "weakened soul", "power word: shield", nullptr)) { + if (botAI->HasAnyAuraOf(player, "weakened soul", "power word: shield", nullptr)) + { continue; } return player; @@ -49,22 +49,26 @@ Unit* CastPowerWordShieldOnAlmostFullHealthBelow::GetTarget() bool CastPowerWordShieldOnAlmostFullHealthBelow::isUseful() { - Group *group = bot->GetGroup(); - for (GroupReference *gref = group->GetFirstMember(); gref; gref = gref->next()) + Group* group = bot->GetGroup(); + for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next()) { Player* player = gref->GetSource(); if (!player) continue; - if (player->isDead()) { + if (player->isDead()) + { continue; } - if (player->GetHealthPct() > sPlayerbotAIConfig->almostFullHealth) { + if (player->GetHealthPct() > sPlayerbotAIConfig->almostFullHealth) + { continue; } - if (player->GetDistance2d(bot) > sPlayerbotAIConfig->spellDistance) { + if (player->GetDistance2d(bot) > sPlayerbotAIConfig->spellDistance) + { continue; } - if (botAI->HasAnyAuraOf(player, "weakened soul", "power word: shield", nullptr)) { + if (botAI->HasAnyAuraOf(player, "weakened soul", "power word: shield", nullptr)) + { continue; } return true; diff --git a/src/strategy/priest/PriestActions.h b/src/strategy/priest/PriestActions.h index 5e4737b9..e7a95937 100644 --- a/src/strategy/priest/PriestActions.h +++ b/src/strategy/priest/PriestActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PRIESTACTIONS_H @@ -22,7 +23,8 @@ CURE_ACTION(CastDispelMagicAction, "dispel magic"); CURE_PARTY_ACTION(CastDispelMagicOnPartyAction, "dispel magic", DISPEL_MAGIC); SPELL_ACTION(CastDispelMagicOnTargetAction, "dispel magic"); CC_ACTION(CastShackleUndeadAction, "shackle undead"); -SPELL_ACTION_U(CastManaBurnAction, "mana burn", AI_VALUE2(uint8, "mana", "self target") < 50 && AI_VALUE2(uint8, "mana", "current target") >= 20); +SPELL_ACTION_U(CastManaBurnAction, "mana burn", + AI_VALUE2(uint8, "mana", "self target") < 50 && AI_VALUE2(uint8, "mana", "current target") >= 20); BUFF_ACTION(CastLevitateAction, "levitate"); BUFF_ACTION(CastDivineSpiritAction, "divine spirit"); BUFF_PARTY_ACTION(CastDivineSpiritOnPartyAction, "divine spirit"); @@ -99,7 +101,9 @@ BUFF_ACTION(CastShadowguardAction, "shadowguard"); HEAL_ACTION(CastDesperatePrayerAction, "desperate prayer"); BUFF_ACTION(CastFearWardAction, "fear ward"); BUFF_PARTY_ACTION(CastFearWardOnPartyAction, "fear ward"); -SPELL_ACTION_U(CastStarshardsAction, "starshards", (AI_VALUE2(uint8, "mana", "self target") > 50 && AI_VALUE(Unit*, "current target") && AI_VALUE2(float, "distance", "current target") > 15.0f)); +SPELL_ACTION_U(CastStarshardsAction, "starshards", + (AI_VALUE2(uint8, "mana", "self target") > 50 && AI_VALUE(Unit*, "current target") && + AI_VALUE2(float, "distance", "current target") > 15.0f)); BUFF_ACTION(CastElunesGraceAction, "elune's grace"); BUFF_ACTION(CastFeedbackAction, "feedback"); BUFF_ACTION(CastSymbolOfHopeAction, "symbol of hope"); @@ -108,12 +112,12 @@ SNARE_ACTION(CastChastiseAction, "chastise"); class CastRemoveShadowformAction : public Action { - public: - CastRemoveShadowformAction(PlayerbotAI* botAI) : Action(botAI, "remove shadowform") { } +public: + CastRemoveShadowformAction(PlayerbotAI* botAI) : Action(botAI, "remove shadowform") {} - bool isUseful() override; - bool isPossible() override; - bool Execute(Event event) override; + bool isUseful() override; + bool isPossible() override; + bool Execute(Event event) override; }; class CastDispersionAction : public CastSpellAction @@ -126,7 +130,9 @@ public: class CastPenanceOnPartyAction : public HealPartyMemberAction { public: - CastPenanceOnPartyAction(PlayerbotAI* ai) : HealPartyMemberAction(ai, "penance", 25.0f, HealingManaEfficiency::HIGH) {} + CastPenanceOnPartyAction(PlayerbotAI* ai) : HealPartyMemberAction(ai, "penance", 25.0f, HealingManaEfficiency::HIGH) + { + } }; class CastHymnOfHopeAction : public CastSpellAction @@ -150,17 +156,21 @@ public: virtual std::string const GetTargetName() { return "current target"; } }; -class CastPowerWordShieldOnAlmostFullHealthBelow : public HealPartyMemberAction { +class CastPowerWordShieldOnAlmostFullHealthBelow : public HealPartyMemberAction +{ public: - CastPowerWordShieldOnAlmostFullHealthBelow(PlayerbotAI* ai) : HealPartyMemberAction(ai, "power word: shield", 15.0f, HealingManaEfficiency::HIGH) {} + CastPowerWordShieldOnAlmostFullHealthBelow(PlayerbotAI* ai) + : HealPartyMemberAction(ai, "power word: shield", 15.0f, HealingManaEfficiency::HIGH) + { + } bool isUseful() override; Unit* GetTarget() override; }; class CastMindSearAction : public CastSpellAction { - public: - CastMindSearAction(PlayerbotAI* ai) : CastSpellAction(ai, "mind sear") {} - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } +public: + CastMindSearAction(PlayerbotAI* ai) : CastSpellAction(ai, "mind sear") {} + ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } }; #endif diff --git a/src/strategy/priest/PriestAiObjectContext.cpp b/src/strategy/priest/PriestAiObjectContext.cpp index 690539a5..d48d1109 100644 --- a/src/strategy/priest/PriestAiObjectContext.cpp +++ b/src/strategy/priest/PriestAiObjectContext.cpp @@ -1,314 +1,344 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PriestAiObjectContext.h" + #include "HolyPriestStrategy.h" +#include "NamedObjectContext.h" +#include "Playerbots.h" #include "PriestActions.h" #include "PriestNonCombatStrategy.h" #include "PriestTriggers.h" -#include "ShadowPriestStrategy.h" -#include "NamedObjectContext.h" #include "PullStrategy.h" -#include "Playerbots.h" +#include "ShadowPriestStrategy.h" class PriestStrategyFactoryInternal : public NamedObjectContext { - public: - PriestStrategyFactoryInternal() - { - creators["nc"] = &PriestStrategyFactoryInternal::nc; - creators["pull"] = &PriestStrategyFactoryInternal::pull; - creators["aoe"] = &PriestStrategyFactoryInternal::shadow_aoe; - creators["shadow aoe"] = &PriestStrategyFactoryInternal::shadow_aoe; - creators["dps debuff"] = &PriestStrategyFactoryInternal::shadow_debuff; - creators["shadow debuff"] = &PriestStrategyFactoryInternal::shadow_debuff; - creators["cure"] = &PriestStrategyFactoryInternal::cure; - creators["buff"] = &PriestStrategyFactoryInternal::buff; - creators["boost"] = &PriestStrategyFactoryInternal::boost; - creators["rshadow"] = &PriestStrategyFactoryInternal::rshadow; - creators["cc"] = &PriestStrategyFactoryInternal::cc; - } +public: + PriestStrategyFactoryInternal() + { + creators["nc"] = &PriestStrategyFactoryInternal::nc; + creators["pull"] = &PriestStrategyFactoryInternal::pull; + creators["aoe"] = &PriestStrategyFactoryInternal::shadow_aoe; + creators["shadow aoe"] = &PriestStrategyFactoryInternal::shadow_aoe; + creators["dps debuff"] = &PriestStrategyFactoryInternal::shadow_debuff; + creators["shadow debuff"] = &PriestStrategyFactoryInternal::shadow_debuff; + creators["cure"] = &PriestStrategyFactoryInternal::cure; + creators["buff"] = &PriestStrategyFactoryInternal::buff; + creators["boost"] = &PriestStrategyFactoryInternal::boost; + creators["rshadow"] = &PriestStrategyFactoryInternal::rshadow; + creators["cc"] = &PriestStrategyFactoryInternal::cc; + } - private: - static Strategy* cc(PlayerbotAI* botAI) { return new PriestCcStrategy(botAI); } - static Strategy* rshadow(PlayerbotAI* botAI) { return new PriestShadowResistanceStrategy(botAI); } - static Strategy* boost(PlayerbotAI* botAI) { return new PriestBoostStrategy(botAI); } - static Strategy* buff(PlayerbotAI* botAI) { return new PriestBuffStrategy(botAI); } - static Strategy* nc(PlayerbotAI* botAI) { return new PriestNonCombatStrategy(botAI); } - static Strategy* shadow_aoe(PlayerbotAI* botAI) { return new ShadowPriestAoeStrategy(botAI); } - static Strategy* pull(PlayerbotAI* botAI) { return new PullStrategy(botAI, "shoot"); } - static Strategy* shadow_debuff(PlayerbotAI* botAI) { return new ShadowPriestDebuffStrategy(botAI); } - static Strategy* cure(PlayerbotAI* botAI) { return new PriestCureStrategy(botAI); } +private: + static Strategy* cc(PlayerbotAI* botAI) { return new PriestCcStrategy(botAI); } + static Strategy* rshadow(PlayerbotAI* botAI) { return new PriestShadowResistanceStrategy(botAI); } + static Strategy* boost(PlayerbotAI* botAI) { return new PriestBoostStrategy(botAI); } + static Strategy* buff(PlayerbotAI* botAI) { return new PriestBuffStrategy(botAI); } + static Strategy* nc(PlayerbotAI* botAI) { return new PriestNonCombatStrategy(botAI); } + static Strategy* shadow_aoe(PlayerbotAI* botAI) { return new ShadowPriestAoeStrategy(botAI); } + static Strategy* pull(PlayerbotAI* botAI) { return new PullStrategy(botAI, "shoot"); } + static Strategy* shadow_debuff(PlayerbotAI* botAI) { return new ShadowPriestDebuffStrategy(botAI); } + static Strategy* cure(PlayerbotAI* botAI) { return new PriestCureStrategy(botAI); } }; class PriestCombatStrategyFactoryInternal : public NamedObjectContext { - public: - PriestCombatStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["heal"] = &PriestCombatStrategyFactoryInternal::heal; - creators["shadow"] = &PriestCombatStrategyFactoryInternal::dps; - creators["dps"] = &PriestCombatStrategyFactoryInternal::dps; - creators["holy dps"] = &PriestCombatStrategyFactoryInternal::holy_dps; - creators["holy heal"] = &PriestCombatStrategyFactoryInternal::holy_heal; - } +public: + PriestCombatStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["heal"] = &PriestCombatStrategyFactoryInternal::heal; + creators["shadow"] = &PriestCombatStrategyFactoryInternal::dps; + creators["dps"] = &PriestCombatStrategyFactoryInternal::dps; + creators["holy dps"] = &PriestCombatStrategyFactoryInternal::holy_dps; + creators["holy heal"] = &PriestCombatStrategyFactoryInternal::holy_heal; + } - private: - static Strategy* heal(PlayerbotAI* botAI) { return new HealPriestStrategy(botAI); } - static Strategy* dps(PlayerbotAI* botAI) { return new ShadowPriestStrategy(botAI); } - static Strategy* holy_dps(PlayerbotAI* botAI) { return new HolyPriestStrategy(botAI); } - static Strategy* holy_heal(PlayerbotAI* botAI) { return new HolyHealPriestStrategy(botAI); } +private: + static Strategy* heal(PlayerbotAI* botAI) { return new HealPriestStrategy(botAI); } + static Strategy* dps(PlayerbotAI* botAI) { return new ShadowPriestStrategy(botAI); } + static Strategy* holy_dps(PlayerbotAI* botAI) { return new HolyPriestStrategy(botAI); } + static Strategy* holy_heal(PlayerbotAI* botAI) { return new HolyHealPriestStrategy(botAI); } }; class PriestTriggerFactoryInternal : public NamedObjectContext { - public: - PriestTriggerFactoryInternal() - { - creators["devouring plague"] = &PriestTriggerFactoryInternal::devouring_plague; - creators["shadow word: pain"] = &PriestTriggerFactoryInternal::shadow_word_pain; - creators["shadow word: pain on attacker"] = &PriestTriggerFactoryInternal::shadow_word_pain_on_attacker; - creators["dispel magic"] = &PriestTriggerFactoryInternal::dispel_magic; - creators["dispel magic on party"] = &PriestTriggerFactoryInternal::dispel_magic_party_member; - creators["cure disease"] = &PriestTriggerFactoryInternal::cure_disease; - creators["party member cure disease"] = &PriestTriggerFactoryInternal::party_member_cure_disease; - creators["power word: fortitude"] = &PriestTriggerFactoryInternal::power_word_fortitude; - creators["power word: fortitude on party"] = &PriestTriggerFactoryInternal::power_word_fortitude_on_party; - creators["divine spirit"] = &PriestTriggerFactoryInternal::divine_spirit; - creators["divine spirit on party"] = &PriestTriggerFactoryInternal::divine_spirit_on_party; - creators["inner fire"] = &PriestTriggerFactoryInternal::inner_fire; - creators["vampiric touch"] = &PriestTriggerFactoryInternal::vampiric_touch; - creators["vampiric touch on attacker"] = &PriestTriggerFactoryInternal::vampiric_touch_on_attacker; - creators["shadowform"] = &PriestTriggerFactoryInternal::shadowform; - creators["vampiric embrace"] = &PriestTriggerFactoryInternal::vampiric_embrace; - creators["power infusion"] = &PriestTriggerFactoryInternal::power_infusion; - creators["inner focus"] = &PriestTriggerFactoryInternal::inner_focus; - creators["shadow protection"] = &PriestTriggerFactoryInternal::shadow_protection; - creators["shadow protection on party"] = &PriestTriggerFactoryInternal::shadow_protection_on_party; - creators["shackle undead"] = &PriestTriggerFactoryInternal::shackle_undead; - creators["prayer of fortitude on party"] = &PriestTriggerFactoryInternal::prayer_of_fortitude_on_party; - creators["prayer of spirit on party"] = &PriestTriggerFactoryInternal::prayer_of_spirit_on_party; - creators["holy fire"] = &PriestTriggerFactoryInternal::holy_fire; - creators["touch of weakness"] = &PriestTriggerFactoryInternal::touch_of_weakness; - creators["hex of weakness"] = &PriestTriggerFactoryInternal::hex_of_weakness; - creators["shadowguard"] = &PriestTriggerFactoryInternal::shadowguard; - creators["fear ward"] = &PriestTriggerFactoryInternal::fear_ward; - creators["feedback"] = &PriestTriggerFactoryInternal::feedback; - creators["binding heal"] = &PriestTriggerFactoryInternal::binding_heal; - creators["chastise"] = &PriestTriggerFactoryInternal::chastise; - creators["silence"] = &PriestTriggerFactoryInternal::silence; - creators["silence on enemy healer"] = &PriestTriggerFactoryInternal::silence_on_enemy_healer; - creators["shadowfiend"] = &PriestTriggerFactoryInternal::shadowfiend; - } +public: + PriestTriggerFactoryInternal() + { + creators["devouring plague"] = &PriestTriggerFactoryInternal::devouring_plague; + creators["shadow word: pain"] = &PriestTriggerFactoryInternal::shadow_word_pain; + creators["shadow word: pain on attacker"] = &PriestTriggerFactoryInternal::shadow_word_pain_on_attacker; + creators["dispel magic"] = &PriestTriggerFactoryInternal::dispel_magic; + creators["dispel magic on party"] = &PriestTriggerFactoryInternal::dispel_magic_party_member; + creators["cure disease"] = &PriestTriggerFactoryInternal::cure_disease; + creators["party member cure disease"] = &PriestTriggerFactoryInternal::party_member_cure_disease; + creators["power word: fortitude"] = &PriestTriggerFactoryInternal::power_word_fortitude; + creators["power word: fortitude on party"] = &PriestTriggerFactoryInternal::power_word_fortitude_on_party; + creators["divine spirit"] = &PriestTriggerFactoryInternal::divine_spirit; + creators["divine spirit on party"] = &PriestTriggerFactoryInternal::divine_spirit_on_party; + creators["inner fire"] = &PriestTriggerFactoryInternal::inner_fire; + creators["vampiric touch"] = &PriestTriggerFactoryInternal::vampiric_touch; + creators["vampiric touch on attacker"] = &PriestTriggerFactoryInternal::vampiric_touch_on_attacker; + creators["shadowform"] = &PriestTriggerFactoryInternal::shadowform; + creators["vampiric embrace"] = &PriestTriggerFactoryInternal::vampiric_embrace; + creators["power infusion"] = &PriestTriggerFactoryInternal::power_infusion; + creators["inner focus"] = &PriestTriggerFactoryInternal::inner_focus; + creators["shadow protection"] = &PriestTriggerFactoryInternal::shadow_protection; + creators["shadow protection on party"] = &PriestTriggerFactoryInternal::shadow_protection_on_party; + creators["shackle undead"] = &PriestTriggerFactoryInternal::shackle_undead; + creators["prayer of fortitude on party"] = &PriestTriggerFactoryInternal::prayer_of_fortitude_on_party; + creators["prayer of spirit on party"] = &PriestTriggerFactoryInternal::prayer_of_spirit_on_party; + creators["holy fire"] = &PriestTriggerFactoryInternal::holy_fire; + creators["touch of weakness"] = &PriestTriggerFactoryInternal::touch_of_weakness; + creators["hex of weakness"] = &PriestTriggerFactoryInternal::hex_of_weakness; + creators["shadowguard"] = &PriestTriggerFactoryInternal::shadowguard; + creators["fear ward"] = &PriestTriggerFactoryInternal::fear_ward; + creators["feedback"] = &PriestTriggerFactoryInternal::feedback; + creators["binding heal"] = &PriestTriggerFactoryInternal::binding_heal; + creators["chastise"] = &PriestTriggerFactoryInternal::chastise; + creators["silence"] = &PriestTriggerFactoryInternal::silence; + creators["silence on enemy healer"] = &PriestTriggerFactoryInternal::silence_on_enemy_healer; + creators["shadowfiend"] = &PriestTriggerFactoryInternal::shadowfiend; + } - private: - static Trigger* vampiric_embrace(PlayerbotAI* botAI) { return new VampiricEmbraceTrigger(botAI); } - static Trigger* shadowform(PlayerbotAI* botAI) { return new ShadowformTrigger(botAI); } - static Trigger* vampiric_touch(PlayerbotAI* botAI) { return new VampiricTouchTrigger(botAI); } - static Trigger* vampiric_touch_on_attacker(PlayerbotAI* botAI) { return new VampiricTouchOnAttackerTrigger(botAI); } - static Trigger* devouring_plague(PlayerbotAI* botAI) { return new DevouringPlagueTrigger(botAI); } - static Trigger* shadow_word_pain(PlayerbotAI* botAI) { return new PowerWordPainTrigger(botAI); } - static Trigger* shadow_word_pain_on_attacker(PlayerbotAI* botAI) { return new PowerWordPainOnAttackerTrigger(botAI); } - static Trigger* dispel_magic(PlayerbotAI* botAI) { return new DispelMagicTrigger(botAI); } - static Trigger* dispel_magic_party_member(PlayerbotAI* botAI) { return new DispelMagicPartyMemberTrigger(botAI); } - static Trigger* cure_disease(PlayerbotAI* botAI) { return new CureDiseaseTrigger(botAI); } - static Trigger* party_member_cure_disease(PlayerbotAI* botAI) { return new PartyMemberCureDiseaseTrigger(botAI); } - static Trigger* power_word_fortitude(PlayerbotAI* botAI) { return new PowerWordFortitudeTrigger(botAI); } - static Trigger* power_word_fortitude_on_party(PlayerbotAI* botAI) { return new PowerWordFortitudeOnPartyTrigger(botAI); } - static Trigger* divine_spirit(PlayerbotAI* botAI) { return new DivineSpiritTrigger(botAI); } - static Trigger* divine_spirit_on_party(PlayerbotAI* botAI) { return new DivineSpiritOnPartyTrigger(botAI); } - static Trigger* inner_fire(PlayerbotAI* botAI) { return new InnerFireTrigger(botAI); } - static Trigger* power_infusion(PlayerbotAI* botAI) { return new PowerInfusionTrigger(botAI); } - static Trigger* inner_focus(PlayerbotAI* botAI) { return new InnerFocusTrigger(botAI); } - static Trigger* shadow_protection_on_party(PlayerbotAI* botAI) { return new ShadowProtectionOnPartyTrigger(botAI); } - static Trigger* shadow_protection(PlayerbotAI* botAI) { return new ShadowProtectionTrigger(botAI); } - static Trigger* shackle_undead(PlayerbotAI* botAI) { return new ShackleUndeadTrigger(botAI); } - static Trigger* prayer_of_fortitude_on_party(PlayerbotAI* botAI) { return new PrayerOfFortitudeTrigger(botAI); } - static Trigger* prayer_of_spirit_on_party(PlayerbotAI* botAI) { return new PrayerOfSpiritTrigger(botAI); } - static Trigger* feedback(PlayerbotAI* botAI) { return new FeedbackTrigger(botAI); } - static Trigger* fear_ward(PlayerbotAI* botAI) { return new FearWardTrigger(botAI); } - static Trigger* shadowguard(PlayerbotAI* botAI) { return new ShadowguardTrigger(botAI); } - static Trigger* hex_of_weakness(PlayerbotAI* botAI) { return new HexOfWeaknessTrigger(botAI); } - static Trigger* touch_of_weakness(PlayerbotAI* botAI) { return new TouchOfWeaknessTrigger(botAI); } - static Trigger* holy_fire(PlayerbotAI* botAI) { return new HolyFireTrigger(botAI); } - static Trigger* shadowfiend(PlayerbotAI* botAI) { return new ShadowfiendTrigger(botAI); } - static Trigger* silence_on_enemy_healer(PlayerbotAI* botAI) { return new SilenceEnemyHealerTrigger(botAI); } - static Trigger* silence(PlayerbotAI* botAI) { return new SilenceTrigger(botAI); } - static Trigger* chastise(PlayerbotAI* botAI) { return new ChastiseTrigger(botAI); } - static Trigger* binding_heal(PlayerbotAI* botAI) { return new BindingHealTrigger(botAI); } +private: + static Trigger* vampiric_embrace(PlayerbotAI* botAI) { return new VampiricEmbraceTrigger(botAI); } + static Trigger* shadowform(PlayerbotAI* botAI) { return new ShadowformTrigger(botAI); } + static Trigger* vampiric_touch(PlayerbotAI* botAI) { return new VampiricTouchTrigger(botAI); } + static Trigger* vampiric_touch_on_attacker(PlayerbotAI* botAI) { return new VampiricTouchOnAttackerTrigger(botAI); } + static Trigger* devouring_plague(PlayerbotAI* botAI) { return new DevouringPlagueTrigger(botAI); } + static Trigger* shadow_word_pain(PlayerbotAI* botAI) { return new PowerWordPainTrigger(botAI); } + static Trigger* shadow_word_pain_on_attacker(PlayerbotAI* botAI) + { + return new PowerWordPainOnAttackerTrigger(botAI); + } + static Trigger* dispel_magic(PlayerbotAI* botAI) { return new DispelMagicTrigger(botAI); } + static Trigger* dispel_magic_party_member(PlayerbotAI* botAI) { return new DispelMagicPartyMemberTrigger(botAI); } + static Trigger* cure_disease(PlayerbotAI* botAI) { return new CureDiseaseTrigger(botAI); } + static Trigger* party_member_cure_disease(PlayerbotAI* botAI) { return new PartyMemberCureDiseaseTrigger(botAI); } + static Trigger* power_word_fortitude(PlayerbotAI* botAI) { return new PowerWordFortitudeTrigger(botAI); } + static Trigger* power_word_fortitude_on_party(PlayerbotAI* botAI) + { + return new PowerWordFortitudeOnPartyTrigger(botAI); + } + static Trigger* divine_spirit(PlayerbotAI* botAI) { return new DivineSpiritTrigger(botAI); } + static Trigger* divine_spirit_on_party(PlayerbotAI* botAI) { return new DivineSpiritOnPartyTrigger(botAI); } + static Trigger* inner_fire(PlayerbotAI* botAI) { return new InnerFireTrigger(botAI); } + static Trigger* power_infusion(PlayerbotAI* botAI) { return new PowerInfusionTrigger(botAI); } + static Trigger* inner_focus(PlayerbotAI* botAI) { return new InnerFocusTrigger(botAI); } + static Trigger* shadow_protection_on_party(PlayerbotAI* botAI) { return new ShadowProtectionOnPartyTrigger(botAI); } + static Trigger* shadow_protection(PlayerbotAI* botAI) { return new ShadowProtectionTrigger(botAI); } + static Trigger* shackle_undead(PlayerbotAI* botAI) { return new ShackleUndeadTrigger(botAI); } + static Trigger* prayer_of_fortitude_on_party(PlayerbotAI* botAI) { return new PrayerOfFortitudeTrigger(botAI); } + static Trigger* prayer_of_spirit_on_party(PlayerbotAI* botAI) { return new PrayerOfSpiritTrigger(botAI); } + static Trigger* feedback(PlayerbotAI* botAI) { return new FeedbackTrigger(botAI); } + static Trigger* fear_ward(PlayerbotAI* botAI) { return new FearWardTrigger(botAI); } + static Trigger* shadowguard(PlayerbotAI* botAI) { return new ShadowguardTrigger(botAI); } + static Trigger* hex_of_weakness(PlayerbotAI* botAI) { return new HexOfWeaknessTrigger(botAI); } + static Trigger* touch_of_weakness(PlayerbotAI* botAI) { return new TouchOfWeaknessTrigger(botAI); } + static Trigger* holy_fire(PlayerbotAI* botAI) { return new HolyFireTrigger(botAI); } + static Trigger* shadowfiend(PlayerbotAI* botAI) { return new ShadowfiendTrigger(botAI); } + static Trigger* silence_on_enemy_healer(PlayerbotAI* botAI) { return new SilenceEnemyHealerTrigger(botAI); } + static Trigger* silence(PlayerbotAI* botAI) { return new SilenceTrigger(botAI); } + static Trigger* chastise(PlayerbotAI* botAI) { return new ChastiseTrigger(botAI); } + static Trigger* binding_heal(PlayerbotAI* botAI) { return new BindingHealTrigger(botAI); } }; class PriestAiObjectContextInternal : public NamedObjectContext { - public: - PriestAiObjectContextInternal() - { - creators["power infusion"] = &PriestAiObjectContextInternal::power_infusion; - creators["inner focus"] = &PriestAiObjectContextInternal::inner_focus; - creators["shadow word: pain"] = &PriestAiObjectContextInternal::shadow_word_pain; - creators["shadow word: pain on attacker"] = &PriestAiObjectContextInternal::shadow_word_pain_on_attacker; - creators["devouring plague"] = &PriestAiObjectContextInternal::devouring_plague; - creators["mind flay"] = &PriestAiObjectContextInternal::mind_flay; - creators["holy fire"] = &PriestAiObjectContextInternal::holy_fire; - creators["smite"] = &PriestAiObjectContextInternal::smite; - creators["mind blast"] = &PriestAiObjectContextInternal::mind_blast; - creators["shadowform"] = &PriestAiObjectContextInternal::shadowform; - creators["remove shadowform"] = &PriestAiObjectContextInternal::remove_shadowform; - creators["holy nova"] = &PriestAiObjectContextInternal::holy_nova; - creators["power word: fortitude"] = &PriestAiObjectContextInternal::power_word_fortitude; - creators["power word: fortitude on party"] = &PriestAiObjectContextInternal::power_word_fortitude_on_party; - creators["divine spirit"] = &PriestAiObjectContextInternal::divine_spirit; - creators["divine spirit on party"] = &PriestAiObjectContextInternal::divine_spirit_on_party; - creators["power word: shield"] = &PriestAiObjectContextInternal::power_word_shield; - creators["power word: shield on party"] = &PriestAiObjectContextInternal::power_word_shield_on_party; - creators["power word: shield on almost full health below"] = &PriestAiObjectContextInternal::power_word_shield_on_almost_full_health_below; - creators["renew"] = &PriestAiObjectContextInternal::renew; - creators["renew on party"] = &PriestAiObjectContextInternal::renew_on_party; - creators["greater heal"] = &PriestAiObjectContextInternal::greater_heal; - creators["greater heal on party"] = &PriestAiObjectContextInternal::greater_heal_on_party; - creators["heal"] = &PriestAiObjectContextInternal::heal; - creators["heal on party"] = &PriestAiObjectContextInternal::heal_on_party; - creators["lesser heal"] = &PriestAiObjectContextInternal::lesser_heal; - creators["lesser heal on party"] = &PriestAiObjectContextInternal::lesser_heal_on_party; - creators["flash heal"] = &PriestAiObjectContextInternal::flash_heal; - creators["flash heal on party"] = &PriestAiObjectContextInternal::flash_heal_on_party; - creators["dispel magic"] = &PriestAiObjectContextInternal::dispel_magic; - creators["dispel magic on party"] = &PriestAiObjectContextInternal::dispel_magic_on_party; - creators["dispel magic on target"] = &PriestAiObjectContextInternal::dispel_magic_on_target; - creators["cure disease"] = &PriestAiObjectContextInternal::cure_disease; - creators["cure disease on party"] = &PriestAiObjectContextInternal::cure_disease_on_party; - creators["abolish disease"] = &PriestAiObjectContextInternal::abolish_disease; - creators["abolish disease on party"] = &PriestAiObjectContextInternal::abolish_disease_on_party; - creators["fade"] = &PriestAiObjectContextInternal::fade; - creators["inner fire"] = &PriestAiObjectContextInternal::inner_fire; - creators["resurrection"] = &PriestAiObjectContextInternal::resurrection; - creators["circle of healing"] = &PriestAiObjectContextInternal::circle_of_healing; - creators["psychic scream"] = &PriestAiObjectContextInternal::psychic_scream; - creators["vampiric touch"] = &PriestAiObjectContextInternal::vampiric_touch; - creators["vampiric touch on attacker"] = &PriestAiObjectContextInternal::vampiric_touch_on_attacker; - creators["vampiric embrace"] = &PriestAiObjectContextInternal::vampiric_embrace; - creators["dispersion"] = &PriestAiObjectContextInternal::dispersion; - creators["shadow protection"] = &PriestAiObjectContextInternal::shadow_protection; - creators["shadow protection on party"] = &PriestAiObjectContextInternal::shadow_protection_on_party; - creators["shackle undead"] = &PriestAiObjectContextInternal::shackle_undead; - creators["prayer of fortitude on party"] = &PriestAiObjectContextInternal::prayer_of_fortitude_on_party; - creators["prayer of spirit on party"] = &PriestAiObjectContextInternal::prayer_of_spirit_on_party; - creators["power infusion on party"] = &PriestAiObjectContextInternal::power_infusion_on_party; - creators["silence"] = &PriestAiObjectContextInternal::silence; - creators["silence on enemy healer"] = &PriestAiObjectContextInternal::silence_on_enemy_healer; - creators["mana burn"] = &PriestAiObjectContextInternal::mana_burn; - creators["levitate"] = &PriestAiObjectContextInternal::levitate; - creators["prayer of healing on party"] = &PriestAiObjectContextInternal::prayer_of_healing; - creators["lightwell"] = &PriestAiObjectContextInternal::lightwell; - creators["mind soothe"] = &PriestAiObjectContextInternal::mind_soothe; - creators["touch of weakness"] = &PriestAiObjectContextInternal::touch_of_weakness; - creators["hex of weakness"] = &PriestAiObjectContextInternal::hex_of_weakness; - creators["shadowguard"] = &PriestAiObjectContextInternal::shadowguard; - creators["desperate prayer"] = &PriestAiObjectContextInternal::desperate_prayer; - creators["fear ward"] = &PriestAiObjectContextInternal::fear_ward; - creators["fear ward on party"] = &PriestAiObjectContextInternal::fear_ward_on_party; - creators["starshards"] = &PriestAiObjectContextInternal::starshards; - creators["elune's grace"] = &PriestAiObjectContextInternal::elunes_grace; - creators["feedback"] = &PriestAiObjectContextInternal::feedback; - creators["symbol of hope"] = &PriestAiObjectContextInternal::symbol_of_hope; - creators["consume magic"] = &PriestAiObjectContextInternal::consume_magic; - creators["chastise"] = &PriestAiObjectContextInternal::chastise; - creators["shadow word: death"] = &PriestAiObjectContextInternal::shadow_word_death; - creators["shadowfiend"] = &PriestAiObjectContextInternal::shadowfiend; - creators["mass dispel"] = &PriestAiObjectContextInternal::mass_dispel; - creators["pain suppression"] = &PriestAiObjectContextInternal::pain_suppression; - creators["pain suppression on party"] = &PriestAiObjectContextInternal::pain_suppression_on_party; - creators["prayer of mending on party"] = &PriestAiObjectContextInternal::prayer_of_mending; - creators["binding heal"] = &PriestAiObjectContextInternal::binding_heal; - creators["penance on party"] = &PriestAiObjectContextInternal::penance_on_party; - creators["hymn of hope"] = &PriestAiObjectContextInternal::hymn_of_hope; - creators["divine hymn"] = &PriestAiObjectContextInternal::divine_hymn; - creators["mind sear"] = &PriestAiObjectContextInternal::mind_sear; - } +public: + PriestAiObjectContextInternal() + { + creators["power infusion"] = &PriestAiObjectContextInternal::power_infusion; + creators["inner focus"] = &PriestAiObjectContextInternal::inner_focus; + creators["shadow word: pain"] = &PriestAiObjectContextInternal::shadow_word_pain; + creators["shadow word: pain on attacker"] = &PriestAiObjectContextInternal::shadow_word_pain_on_attacker; + creators["devouring plague"] = &PriestAiObjectContextInternal::devouring_plague; + creators["mind flay"] = &PriestAiObjectContextInternal::mind_flay; + creators["holy fire"] = &PriestAiObjectContextInternal::holy_fire; + creators["smite"] = &PriestAiObjectContextInternal::smite; + creators["mind blast"] = &PriestAiObjectContextInternal::mind_blast; + creators["shadowform"] = &PriestAiObjectContextInternal::shadowform; + creators["remove shadowform"] = &PriestAiObjectContextInternal::remove_shadowform; + creators["holy nova"] = &PriestAiObjectContextInternal::holy_nova; + creators["power word: fortitude"] = &PriestAiObjectContextInternal::power_word_fortitude; + creators["power word: fortitude on party"] = &PriestAiObjectContextInternal::power_word_fortitude_on_party; + creators["divine spirit"] = &PriestAiObjectContextInternal::divine_spirit; + creators["divine spirit on party"] = &PriestAiObjectContextInternal::divine_spirit_on_party; + creators["power word: shield"] = &PriestAiObjectContextInternal::power_word_shield; + creators["power word: shield on party"] = &PriestAiObjectContextInternal::power_word_shield_on_party; + creators["power word: shield on almost full health below"] = + &PriestAiObjectContextInternal::power_word_shield_on_almost_full_health_below; + creators["renew"] = &PriestAiObjectContextInternal::renew; + creators["renew on party"] = &PriestAiObjectContextInternal::renew_on_party; + creators["greater heal"] = &PriestAiObjectContextInternal::greater_heal; + creators["greater heal on party"] = &PriestAiObjectContextInternal::greater_heal_on_party; + creators["heal"] = &PriestAiObjectContextInternal::heal; + creators["heal on party"] = &PriestAiObjectContextInternal::heal_on_party; + creators["lesser heal"] = &PriestAiObjectContextInternal::lesser_heal; + creators["lesser heal on party"] = &PriestAiObjectContextInternal::lesser_heal_on_party; + creators["flash heal"] = &PriestAiObjectContextInternal::flash_heal; + creators["flash heal on party"] = &PriestAiObjectContextInternal::flash_heal_on_party; + creators["dispel magic"] = &PriestAiObjectContextInternal::dispel_magic; + creators["dispel magic on party"] = &PriestAiObjectContextInternal::dispel_magic_on_party; + creators["dispel magic on target"] = &PriestAiObjectContextInternal::dispel_magic_on_target; + creators["cure disease"] = &PriestAiObjectContextInternal::cure_disease; + creators["cure disease on party"] = &PriestAiObjectContextInternal::cure_disease_on_party; + creators["abolish disease"] = &PriestAiObjectContextInternal::abolish_disease; + creators["abolish disease on party"] = &PriestAiObjectContextInternal::abolish_disease_on_party; + creators["fade"] = &PriestAiObjectContextInternal::fade; + creators["inner fire"] = &PriestAiObjectContextInternal::inner_fire; + creators["resurrection"] = &PriestAiObjectContextInternal::resurrection; + creators["circle of healing"] = &PriestAiObjectContextInternal::circle_of_healing; + creators["psychic scream"] = &PriestAiObjectContextInternal::psychic_scream; + creators["vampiric touch"] = &PriestAiObjectContextInternal::vampiric_touch; + creators["vampiric touch on attacker"] = &PriestAiObjectContextInternal::vampiric_touch_on_attacker; + creators["vampiric embrace"] = &PriestAiObjectContextInternal::vampiric_embrace; + creators["dispersion"] = &PriestAiObjectContextInternal::dispersion; + creators["shadow protection"] = &PriestAiObjectContextInternal::shadow_protection; + creators["shadow protection on party"] = &PriestAiObjectContextInternal::shadow_protection_on_party; + creators["shackle undead"] = &PriestAiObjectContextInternal::shackle_undead; + creators["prayer of fortitude on party"] = &PriestAiObjectContextInternal::prayer_of_fortitude_on_party; + creators["prayer of spirit on party"] = &PriestAiObjectContextInternal::prayer_of_spirit_on_party; + creators["power infusion on party"] = &PriestAiObjectContextInternal::power_infusion_on_party; + creators["silence"] = &PriestAiObjectContextInternal::silence; + creators["silence on enemy healer"] = &PriestAiObjectContextInternal::silence_on_enemy_healer; + creators["mana burn"] = &PriestAiObjectContextInternal::mana_burn; + creators["levitate"] = &PriestAiObjectContextInternal::levitate; + creators["prayer of healing on party"] = &PriestAiObjectContextInternal::prayer_of_healing; + creators["lightwell"] = &PriestAiObjectContextInternal::lightwell; + creators["mind soothe"] = &PriestAiObjectContextInternal::mind_soothe; + creators["touch of weakness"] = &PriestAiObjectContextInternal::touch_of_weakness; + creators["hex of weakness"] = &PriestAiObjectContextInternal::hex_of_weakness; + creators["shadowguard"] = &PriestAiObjectContextInternal::shadowguard; + creators["desperate prayer"] = &PriestAiObjectContextInternal::desperate_prayer; + creators["fear ward"] = &PriestAiObjectContextInternal::fear_ward; + creators["fear ward on party"] = &PriestAiObjectContextInternal::fear_ward_on_party; + creators["starshards"] = &PriestAiObjectContextInternal::starshards; + creators["elune's grace"] = &PriestAiObjectContextInternal::elunes_grace; + creators["feedback"] = &PriestAiObjectContextInternal::feedback; + creators["symbol of hope"] = &PriestAiObjectContextInternal::symbol_of_hope; + creators["consume magic"] = &PriestAiObjectContextInternal::consume_magic; + creators["chastise"] = &PriestAiObjectContextInternal::chastise; + creators["shadow word: death"] = &PriestAiObjectContextInternal::shadow_word_death; + creators["shadowfiend"] = &PriestAiObjectContextInternal::shadowfiend; + creators["mass dispel"] = &PriestAiObjectContextInternal::mass_dispel; + creators["pain suppression"] = &PriestAiObjectContextInternal::pain_suppression; + creators["pain suppression on party"] = &PriestAiObjectContextInternal::pain_suppression_on_party; + creators["prayer of mending on party"] = &PriestAiObjectContextInternal::prayer_of_mending; + creators["binding heal"] = &PriestAiObjectContextInternal::binding_heal; + creators["penance on party"] = &PriestAiObjectContextInternal::penance_on_party; + creators["hymn of hope"] = &PriestAiObjectContextInternal::hymn_of_hope; + creators["divine hymn"] = &PriestAiObjectContextInternal::divine_hymn; + creators["mind sear"] = &PriestAiObjectContextInternal::mind_sear; + } - private: - static Action* shadow_protection_on_party(PlayerbotAI* botAI) { return new CastShadowProtectionOnPartyAction(botAI); } - static Action* shadow_protection(PlayerbotAI* botAI) { return new CastShadowProtectionAction(botAI); } - static Action* power_infusion(PlayerbotAI* botAI) { return new CastPowerInfusionAction(botAI); } - static Action* inner_focus(PlayerbotAI* botAI) { return new CastInnerFocusAction(botAI); } - static Action* dispersion(PlayerbotAI* botAI) { return new CastDispersionAction(botAI); } - static Action* vampiric_embrace(PlayerbotAI* botAI) { return new CastVampiricEmbraceAction(botAI); } - static Action* vampiric_touch(PlayerbotAI* botAI) { return new CastVampiricTouchAction(botAI); } - static Action* vampiric_touch_on_attacker(PlayerbotAI* botAI) { return new CastVampiricTouchOnAttackerAction(botAI); } - static Action* psychic_scream(PlayerbotAI* botAI) { return new CastPsychicScreamAction(botAI); } - static Action* circle_of_healing(PlayerbotAI* botAI) { return new CastCircleOfHealingAction(botAI); } - static Action* resurrection(PlayerbotAI* botAI) { return new CastResurrectionAction(botAI); } - static Action* shadow_word_pain(PlayerbotAI* botAI) { return new CastPowerWordPainAction(botAI); } - static Action* shadow_word_pain_on_attacker(PlayerbotAI* botAI) { return new CastPowerWordPainOnAttackerAction(botAI); } - static Action* devouring_plague(PlayerbotAI* botAI) { return new CastDevouringPlagueAction(botAI); } - static Action* mind_flay(PlayerbotAI* botAI) { return new CastMindFlayAction(botAI); } - static Action* holy_fire(PlayerbotAI* botAI) { return new CastHolyFireAction(botAI); } - static Action* smite(PlayerbotAI* botAI) { return new CastSmiteAction(botAI); } - static Action* mind_blast(PlayerbotAI* botAI) { return new CastMindBlastAction(botAI); } - static Action* shadowform(PlayerbotAI* botAI) { return new CastShadowformAction(botAI); } - static Action* remove_shadowform(PlayerbotAI* botAI) { return new CastRemoveShadowformAction(botAI); } - static Action* holy_nova(PlayerbotAI* botAI) { return new CastHolyNovaAction(botAI); } - static Action* power_word_fortitude(PlayerbotAI* botAI) { return new CastPowerWordFortitudeAction(botAI); } - static Action* power_word_fortitude_on_party(PlayerbotAI* botAI) { return new CastPowerWordFortitudeOnPartyAction(botAI); } - static Action* divine_spirit(PlayerbotAI* botAI) { return new CastDivineSpiritAction(botAI); } - static Action* divine_spirit_on_party(PlayerbotAI* botAI) { return new CastDivineSpiritOnPartyAction(botAI); } - static Action* power_word_shield(PlayerbotAI* botAI) { return new CastPowerWordShieldAction(botAI); } - static Action* power_word_shield_on_party(PlayerbotAI* botAI) { return new CastPowerWordShieldOnPartyAction(botAI); } - static Action* power_word_shield_on_almost_full_health_below(PlayerbotAI* ai) { return new CastPowerWordShieldOnAlmostFullHealthBelow(ai); } - static Action* renew(PlayerbotAI* botAI) { return new CastRenewAction(botAI); } - static Action* renew_on_party(PlayerbotAI* botAI) { return new CastRenewOnPartyAction(botAI); } - static Action* greater_heal(PlayerbotAI* botAI) { return new CastGreaterHealAction(botAI); } - static Action* greater_heal_on_party(PlayerbotAI* botAI) { return new CastGreaterHealOnPartyAction(botAI); } - static Action* heal(PlayerbotAI* botAI) { return new CastHealAction(botAI); } - static Action* heal_on_party(PlayerbotAI* botAI) { return new CastHealOnPartyAction(botAI); } - static Action* lesser_heal(PlayerbotAI* botAI) { return new CastLesserHealAction(botAI); } - static Action* lesser_heal_on_party(PlayerbotAI* botAI) { return new CastLesserHealOnPartyAction(botAI); } - static Action* flash_heal(PlayerbotAI* botAI) { return new CastFlashHealAction(botAI); } - static Action* flash_heal_on_party(PlayerbotAI* botAI) { return new CastFlashHealOnPartyAction(botAI); } - static Action* dispel_magic(PlayerbotAI* botAI) { return new CastDispelMagicAction(botAI); } - static Action* dispel_magic_on_party(PlayerbotAI* botAI) { return new CastDispelMagicOnPartyAction(botAI); } - static Action* dispel_magic_on_target(PlayerbotAI* botAI) { return new CastDispelMagicOnTargetAction(botAI); } - static Action* cure_disease(PlayerbotAI* botAI) { return new CastCureDiseaseAction(botAI); } - static Action* cure_disease_on_party(PlayerbotAI* botAI) { return new CastCureDiseaseOnPartyAction(botAI); } - static Action* abolish_disease(PlayerbotAI* botAI) { return new CastAbolishDiseaseAction(botAI); } - static Action* abolish_disease_on_party(PlayerbotAI* botAI) { return new CastAbolishDiseaseOnPartyAction(botAI); } - static Action* fade(PlayerbotAI* botAI) { return new CastFadeAction(botAI); } - static Action* inner_fire(PlayerbotAI* botAI) { return new CastInnerFireAction(botAI); } - static Action* shackle_undead(PlayerbotAI* botAI) { return new CastShackleUndeadAction(botAI); } - static Action* prayer_of_spirit_on_party(PlayerbotAI* botAI) { return new CastPrayerOfSpiritOnPartyAction(botAI); } - static Action* prayer_of_fortitude_on_party(PlayerbotAI* botAI) { return new CastPrayerOfFortitudeOnPartyAction(botAI); } - static Action* feedback(PlayerbotAI* botAI) { return new CastFeedbackAction(botAI); } - static Action* elunes_grace(PlayerbotAI* botAI) { return new CastElunesGraceAction(botAI); } - static Action* starshards(PlayerbotAI* botAI) { return new CastStarshardsAction(botAI); } - static Action* fear_ward_on_party(PlayerbotAI* botAI) { return new CastFearWardOnPartyAction(botAI); } - static Action* fear_ward(PlayerbotAI* botAI) { return new CastFearWardAction(botAI); } - static Action* desperate_prayer(PlayerbotAI* botAI) { return new CastDesperatePrayerAction(botAI); } - static Action* shadowguard(PlayerbotAI* botAI) { return new CastShadowguardAction(botAI); } - static Action* hex_of_weakness(PlayerbotAI* botAI) { return new CastHexOfWeaknessAction(botAI); } - static Action* touch_of_weakness(PlayerbotAI* botAI) { return new CastTouchOfWeaknessAction(botAI); } - static Action* mind_soothe(PlayerbotAI* botAI) { return new CastMindSootheAction(botAI); } - static Action* lightwell(PlayerbotAI* botAI) { return new CastLightwellAction(botAI); } - static Action* prayer_of_healing(PlayerbotAI* botAI) { return new CastPrayerOfHealingAction(botAI); } - static Action* levitate(PlayerbotAI* botAI) { return new CastLevitateAction(botAI); } - static Action* mana_burn(PlayerbotAI* botAI) { return new CastManaBurnAction(botAI); } - static Action* silence_on_enemy_healer(PlayerbotAI* botAI) { return new CastSilenceOnEnemyHealerAction(botAI); } - static Action* silence(PlayerbotAI* botAI) { return new CastSilenceAction(botAI); } - static Action* power_infusion_on_party(PlayerbotAI* botAI) { return new CastPowerInfusionOnPartyAction(botAI); } - static Action* binding_heal(PlayerbotAI* botAI) { return new CastBindingHealAction(botAI); } - static Action* prayer_of_mending(PlayerbotAI* botAI) { return new CastPrayerOfMendingAction(botAI); } - static Action* pain_suppression_on_party(PlayerbotAI* botAI) { return new CastPainSuppressionProtectAction(botAI); } - static Action* pain_suppression(PlayerbotAI* botAI) { return new CastPainSuppressionAction(botAI); } - static Action* mass_dispel(PlayerbotAI* botAI) { return new CastMassDispelAction(botAI); } - static Action* shadowfiend(PlayerbotAI* botAI) { return new CastShadowfiendAction(botAI); } - static Action* shadow_word_death(PlayerbotAI* botAI) { return new CastShadowWordDeathAction(botAI); } - static Action* chastise(PlayerbotAI* botAI) { return new CastChastiseAction(botAI); } - static Action* consume_magic(PlayerbotAI* botAI) { return new CastConsumeMagicAction(botAI); } - static Action* symbol_of_hope(PlayerbotAI* botAI) { return new CastSymbolOfHopeAction(botAI); } - static Action* penance_on_party(PlayerbotAI* ai) { return new CastPenanceOnPartyAction(ai); } - static Action* hymn_of_hope(PlayerbotAI* ai) { return new CastHymnOfHopeAction(ai); } - static Action* divine_hymn(PlayerbotAI* ai) { return new CastDivineHymnAction(ai); } - static Action* mind_sear(PlayerbotAI* ai) { return new CastMindSearAction(ai); } +private: + static Action* shadow_protection_on_party(PlayerbotAI* botAI) + { + return new CastShadowProtectionOnPartyAction(botAI); + } + static Action* shadow_protection(PlayerbotAI* botAI) { return new CastShadowProtectionAction(botAI); } + static Action* power_infusion(PlayerbotAI* botAI) { return new CastPowerInfusionAction(botAI); } + static Action* inner_focus(PlayerbotAI* botAI) { return new CastInnerFocusAction(botAI); } + static Action* dispersion(PlayerbotAI* botAI) { return new CastDispersionAction(botAI); } + static Action* vampiric_embrace(PlayerbotAI* botAI) { return new CastVampiricEmbraceAction(botAI); } + static Action* vampiric_touch(PlayerbotAI* botAI) { return new CastVampiricTouchAction(botAI); } + static Action* vampiric_touch_on_attacker(PlayerbotAI* botAI) + { + return new CastVampiricTouchOnAttackerAction(botAI); + } + static Action* psychic_scream(PlayerbotAI* botAI) { return new CastPsychicScreamAction(botAI); } + static Action* circle_of_healing(PlayerbotAI* botAI) { return new CastCircleOfHealingAction(botAI); } + static Action* resurrection(PlayerbotAI* botAI) { return new CastResurrectionAction(botAI); } + static Action* shadow_word_pain(PlayerbotAI* botAI) { return new CastPowerWordPainAction(botAI); } + static Action* shadow_word_pain_on_attacker(PlayerbotAI* botAI) + { + return new CastPowerWordPainOnAttackerAction(botAI); + } + static Action* devouring_plague(PlayerbotAI* botAI) { return new CastDevouringPlagueAction(botAI); } + static Action* mind_flay(PlayerbotAI* botAI) { return new CastMindFlayAction(botAI); } + static Action* holy_fire(PlayerbotAI* botAI) { return new CastHolyFireAction(botAI); } + static Action* smite(PlayerbotAI* botAI) { return new CastSmiteAction(botAI); } + static Action* mind_blast(PlayerbotAI* botAI) { return new CastMindBlastAction(botAI); } + static Action* shadowform(PlayerbotAI* botAI) { return new CastShadowformAction(botAI); } + static Action* remove_shadowform(PlayerbotAI* botAI) { return new CastRemoveShadowformAction(botAI); } + static Action* holy_nova(PlayerbotAI* botAI) { return new CastHolyNovaAction(botAI); } + static Action* power_word_fortitude(PlayerbotAI* botAI) { return new CastPowerWordFortitudeAction(botAI); } + static Action* power_word_fortitude_on_party(PlayerbotAI* botAI) + { + return new CastPowerWordFortitudeOnPartyAction(botAI); + } + static Action* divine_spirit(PlayerbotAI* botAI) { return new CastDivineSpiritAction(botAI); } + static Action* divine_spirit_on_party(PlayerbotAI* botAI) { return new CastDivineSpiritOnPartyAction(botAI); } + static Action* power_word_shield(PlayerbotAI* botAI) { return new CastPowerWordShieldAction(botAI); } + static Action* power_word_shield_on_party(PlayerbotAI* botAI) + { + return new CastPowerWordShieldOnPartyAction(botAI); + } + static Action* power_word_shield_on_almost_full_health_below(PlayerbotAI* ai) + { + return new CastPowerWordShieldOnAlmostFullHealthBelow(ai); + } + static Action* renew(PlayerbotAI* botAI) { return new CastRenewAction(botAI); } + static Action* renew_on_party(PlayerbotAI* botAI) { return new CastRenewOnPartyAction(botAI); } + static Action* greater_heal(PlayerbotAI* botAI) { return new CastGreaterHealAction(botAI); } + static Action* greater_heal_on_party(PlayerbotAI* botAI) { return new CastGreaterHealOnPartyAction(botAI); } + static Action* heal(PlayerbotAI* botAI) { return new CastHealAction(botAI); } + static Action* heal_on_party(PlayerbotAI* botAI) { return new CastHealOnPartyAction(botAI); } + static Action* lesser_heal(PlayerbotAI* botAI) { return new CastLesserHealAction(botAI); } + static Action* lesser_heal_on_party(PlayerbotAI* botAI) { return new CastLesserHealOnPartyAction(botAI); } + static Action* flash_heal(PlayerbotAI* botAI) { return new CastFlashHealAction(botAI); } + static Action* flash_heal_on_party(PlayerbotAI* botAI) { return new CastFlashHealOnPartyAction(botAI); } + static Action* dispel_magic(PlayerbotAI* botAI) { return new CastDispelMagicAction(botAI); } + static Action* dispel_magic_on_party(PlayerbotAI* botAI) { return new CastDispelMagicOnPartyAction(botAI); } + static Action* dispel_magic_on_target(PlayerbotAI* botAI) { return new CastDispelMagicOnTargetAction(botAI); } + static Action* cure_disease(PlayerbotAI* botAI) { return new CastCureDiseaseAction(botAI); } + static Action* cure_disease_on_party(PlayerbotAI* botAI) { return new CastCureDiseaseOnPartyAction(botAI); } + static Action* abolish_disease(PlayerbotAI* botAI) { return new CastAbolishDiseaseAction(botAI); } + static Action* abolish_disease_on_party(PlayerbotAI* botAI) { return new CastAbolishDiseaseOnPartyAction(botAI); } + static Action* fade(PlayerbotAI* botAI) { return new CastFadeAction(botAI); } + static Action* inner_fire(PlayerbotAI* botAI) { return new CastInnerFireAction(botAI); } + static Action* shackle_undead(PlayerbotAI* botAI) { return new CastShackleUndeadAction(botAI); } + static Action* prayer_of_spirit_on_party(PlayerbotAI* botAI) { return new CastPrayerOfSpiritOnPartyAction(botAI); } + static Action* prayer_of_fortitude_on_party(PlayerbotAI* botAI) + { + return new CastPrayerOfFortitudeOnPartyAction(botAI); + } + static Action* feedback(PlayerbotAI* botAI) { return new CastFeedbackAction(botAI); } + static Action* elunes_grace(PlayerbotAI* botAI) { return new CastElunesGraceAction(botAI); } + static Action* starshards(PlayerbotAI* botAI) { return new CastStarshardsAction(botAI); } + static Action* fear_ward_on_party(PlayerbotAI* botAI) { return new CastFearWardOnPartyAction(botAI); } + static Action* fear_ward(PlayerbotAI* botAI) { return new CastFearWardAction(botAI); } + static Action* desperate_prayer(PlayerbotAI* botAI) { return new CastDesperatePrayerAction(botAI); } + static Action* shadowguard(PlayerbotAI* botAI) { return new CastShadowguardAction(botAI); } + static Action* hex_of_weakness(PlayerbotAI* botAI) { return new CastHexOfWeaknessAction(botAI); } + static Action* touch_of_weakness(PlayerbotAI* botAI) { return new CastTouchOfWeaknessAction(botAI); } + static Action* mind_soothe(PlayerbotAI* botAI) { return new CastMindSootheAction(botAI); } + static Action* lightwell(PlayerbotAI* botAI) { return new CastLightwellAction(botAI); } + static Action* prayer_of_healing(PlayerbotAI* botAI) { return new CastPrayerOfHealingAction(botAI); } + static Action* levitate(PlayerbotAI* botAI) { return new CastLevitateAction(botAI); } + static Action* mana_burn(PlayerbotAI* botAI) { return new CastManaBurnAction(botAI); } + static Action* silence_on_enemy_healer(PlayerbotAI* botAI) { return new CastSilenceOnEnemyHealerAction(botAI); } + static Action* silence(PlayerbotAI* botAI) { return new CastSilenceAction(botAI); } + static Action* power_infusion_on_party(PlayerbotAI* botAI) { return new CastPowerInfusionOnPartyAction(botAI); } + static Action* binding_heal(PlayerbotAI* botAI) { return new CastBindingHealAction(botAI); } + static Action* prayer_of_mending(PlayerbotAI* botAI) { return new CastPrayerOfMendingAction(botAI); } + static Action* pain_suppression_on_party(PlayerbotAI* botAI) { return new CastPainSuppressionProtectAction(botAI); } + static Action* pain_suppression(PlayerbotAI* botAI) { return new CastPainSuppressionAction(botAI); } + static Action* mass_dispel(PlayerbotAI* botAI) { return new CastMassDispelAction(botAI); } + static Action* shadowfiend(PlayerbotAI* botAI) { return new CastShadowfiendAction(botAI); } + static Action* shadow_word_death(PlayerbotAI* botAI) { return new CastShadowWordDeathAction(botAI); } + static Action* chastise(PlayerbotAI* botAI) { return new CastChastiseAction(botAI); } + static Action* consume_magic(PlayerbotAI* botAI) { return new CastConsumeMagicAction(botAI); } + static Action* symbol_of_hope(PlayerbotAI* botAI) { return new CastSymbolOfHopeAction(botAI); } + static Action* penance_on_party(PlayerbotAI* ai) { return new CastPenanceOnPartyAction(ai); } + static Action* hymn_of_hope(PlayerbotAI* ai) { return new CastHymnOfHopeAction(ai); } + static Action* divine_hymn(PlayerbotAI* ai) { return new CastDivineHymnAction(ai); } + static Action* mind_sear(PlayerbotAI* ai) { return new CastMindSearAction(ai); } }; PriestAiObjectContext::PriestAiObjectContext(PlayerbotAI* botAI) : AiObjectContext(botAI) diff --git a/src/strategy/priest/PriestAiObjectContext.h b/src/strategy/priest/PriestAiObjectContext.h index 5cf0ff2b..81c491b7 100644 --- a/src/strategy/priest/PriestAiObjectContext.h +++ b/src/strategy/priest/PriestAiObjectContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PRIESTAIOBJECTCONTEXT_H @@ -11,8 +12,8 @@ class PlayerbotAI; class PriestAiObjectContext : public AiObjectContext { - public: - PriestAiObjectContext(PlayerbotAI* botAI); +public: + PriestAiObjectContext(PlayerbotAI* botAI); }; #endif diff --git a/src/strategy/priest/PriestNonCombatStrategy.cpp b/src/strategy/priest/PriestNonCombatStrategy.cpp index 4d55c77b..161ac361 100644 --- a/src/strategy/priest/PriestNonCombatStrategy.cpp +++ b/src/strategy/priest/PriestNonCombatStrategy.cpp @@ -1,10 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PriestNonCombatStrategy.h" -#include "PriestNonCombatStrategyActionNodeFactory.h" + #include "Playerbots.h" +#include "PriestNonCombatStrategyActionNodeFactory.h" PriestNonCombatStrategy::PriestNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { @@ -15,69 +17,77 @@ void PriestNonCombatStrategy::InitTriggers(std::vector& triggers) { NonCombatStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("power word: fortitude", NextAction::array(0, new NextAction("power word: fortitude", 12.0f), nullptr))); - // triggers.push_back(new TriggerNode("divine spirit", NextAction::array(0, new NextAction("divine spirit", 14.0f), nullptr))); - triggers.push_back(new TriggerNode("inner fire", NextAction::array(0, new NextAction("inner fire", 10.0f), nullptr))); - // triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("greater heal", 70.0f), nullptr))); - // triggers.push_back(new TriggerNode("party member critical health", NextAction::array(0, new NextAction("greater heal on party", 60.0f), nullptr))); - // triggers.push_back(new TriggerNode("medium health", NextAction::array(0, new NextAction("renew", 41.0f), nullptr))); - // triggers.push_back(new TriggerNode("party member medium health", NextAction::array(0, new NextAction("renew on party", 40.0f), nullptr))); - // triggers.push_back(new TriggerNode("medium aoe heal", NextAction::array(0, new NextAction("lightwell", 42.f), nullptr))); - triggers.push_back(new TriggerNode("party member dead", NextAction::array(0, new NextAction("remove shadowform", ACTION_CRITICAL_HEAL + 11), new NextAction("resurrection", ACTION_CRITICAL_HEAL + 10), nullptr))); - //triggers.push_back(new TriggerNode("swimming", NextAction::array(0, new NextAction("levitate", 1.0f), nullptr))); + // triggers.push_back(new TriggerNode("power word: fortitude", NextAction::array(0, new NextAction("power word: + // fortitude", 12.0f), nullptr))); triggers.push_back(new TriggerNode("divine spirit", NextAction::array(0, new + // NextAction("divine spirit", 14.0f), nullptr))); + triggers.push_back( + new TriggerNode("inner fire", NextAction::array(0, new NextAction("inner fire", 10.0f), nullptr))); + // triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("greater heal", 70.0f), + // nullptr))); triggers.push_back(new TriggerNode("party member critical health", NextAction::array(0, new + // NextAction("greater heal on party", 60.0f), nullptr))); triggers.push_back(new TriggerNode("medium health", + // NextAction::array(0, new NextAction("renew", 41.0f), nullptr))); triggers.push_back(new TriggerNode("party member + // medium health", NextAction::array(0, new NextAction("renew on party", 40.0f), nullptr))); triggers.push_back(new + // TriggerNode("medium aoe heal", NextAction::array(0, new NextAction("lightwell", 42.f), nullptr))); + triggers.push_back(new TriggerNode( + "party member dead", NextAction::array(0, new NextAction("remove shadowform", ACTION_CRITICAL_HEAL + 11), + new NextAction("resurrection", ACTION_CRITICAL_HEAL + 10), nullptr))); + // triggers.push_back(new TriggerNode("swimming", NextAction::array(0, new NextAction("levitate", 1.0f), nullptr))); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("apply oil", 1.0f), nullptr))); - triggers.push_back(new TriggerNode( - "party member critical health", - NextAction::array(0, - new NextAction("renew on party", ACTION_CRITICAL_HEAL + 3), - new NextAction("penance on party", ACTION_CRITICAL_HEAL + 2), - new NextAction("greater heal on party", ACTION_CRITICAL_HEAL + 1), - NULL))); + triggers.push_back( + new TriggerNode("party member critical health", + NextAction::array(0, new NextAction("renew on party", ACTION_CRITICAL_HEAL + 3), + new NextAction("penance on party", ACTION_CRITICAL_HEAL + 2), + new NextAction("greater heal on party", ACTION_CRITICAL_HEAL + 1), NULL))); - triggers.push_back(new TriggerNode( - "party member low health", - NextAction::array(0, - new NextAction("renew on party", ACTION_MEDIUM_HEAL + 3), - new NextAction("penance on party", ACTION_MEDIUM_HEAL + 2), - new NextAction("greater heal on party", ACTION_MEDIUM_HEAL + 1), - NULL))); + triggers.push_back( + new TriggerNode("party member low health", + NextAction::array(0, new NextAction("renew on party", ACTION_MEDIUM_HEAL + 3), + new NextAction("penance on party", ACTION_MEDIUM_HEAL + 2), + new NextAction("greater heal on party", ACTION_MEDIUM_HEAL + 1), NULL))); - triggers.push_back(new TriggerNode( - "party member medium health", - NextAction::array(0, - new NextAction("renew on party", ACTION_LIGHT_HEAL + 9), - new NextAction("penance on party", ACTION_LIGHT_HEAL + 8), - NULL))); - - triggers.push_back(new TriggerNode( - "party member almost full health", - NextAction::array(0, - new NextAction("renew on party", ACTION_LIGHT_HEAL + 3), - NULL))); + triggers.push_back( + new TriggerNode("party member medium health", + NextAction::array(0, new NextAction("renew on party", ACTION_LIGHT_HEAL + 9), + new NextAction("penance on party", ACTION_LIGHT_HEAL + 8), NULL))); - triggers.push_back(new TriggerNode( - "medium aoe heal", - NextAction::array(0, new NextAction("circle of healing", 27.0f), NULL))); + triggers.push_back( + new TriggerNode("party member almost full health", + NextAction::array(0, new NextAction("renew on party", ACTION_LIGHT_HEAL + 3), NULL))); + + triggers.push_back( + new TriggerNode("medium aoe heal", NextAction::array(0, new NextAction("circle of healing", 27.0f), NULL))); } void PriestBuffStrategy::InitTriggers(std::vector& triggers) { NonCombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("prayer of fortitude on party", NextAction::array(0, new NextAction("prayer of fortitude on party", 12.0f), nullptr))); - triggers.push_back(new TriggerNode("prayer of spirit on party", NextAction::array(0, new NextAction("prayer of spirit on party", 14.0f), nullptr))); - triggers.push_back(new TriggerNode("power word: fortitude on party", NextAction::array(0, new NextAction("power word: fortitude on party", 11.0f), nullptr))); - triggers.push_back(new TriggerNode("divine spirit on party", NextAction::array(0, new NextAction("divine spirit on party", 13.0f), nullptr))); - // triggers.push_back(new TriggerNode("fear ward", NextAction::array(0, new NextAction("fear ward", 10.0f), nullptr))); - // triggers.push_back(new TriggerNode("touch of weakness", NextAction::array(0, new NextAction("touch of weakness", 10.0f), nullptr))); - // triggers.push_back(new TriggerNode("shadowguard", NextAction::array(0, new NextAction("shadowguard", 10.0f), nullptr))); + triggers.push_back( + new TriggerNode("prayer of fortitude on party", + NextAction::array(0, new NextAction("prayer of fortitude on party", 12.0f), nullptr))); + triggers.push_back( + new TriggerNode("prayer of spirit on party", + NextAction::array(0, new NextAction("prayer of spirit on party", 14.0f), nullptr))); + triggers.push_back( + new TriggerNode("power word: fortitude on party", + NextAction::array(0, new NextAction("power word: fortitude on party", 11.0f), nullptr))); + triggers.push_back(new TriggerNode("divine spirit on party", + NextAction::array(0, new NextAction("divine spirit on party", 13.0f), nullptr))); + // triggers.push_back(new TriggerNode("fear ward", NextAction::array(0, new NextAction("fear ward", 10.0f), + // nullptr))); triggers.push_back(new TriggerNode("touch of weakness", NextAction::array(0, new NextAction("touch of + // weakness", 10.0f), nullptr))); triggers.push_back(new TriggerNode("shadowguard", NextAction::array(0, new + // NextAction("shadowguard", 10.0f), nullptr))); } void PriestShadowResistanceStrategy::InitTriggers(std::vector& triggers) { NonCombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("shadow protection", NextAction::array(0, new NextAction("shadow protection", 12.0f), nullptr))); - triggers.push_back(new TriggerNode("shadow protection on party", NextAction::array(0, new NextAction("shadow protection on party", 11.0f), nullptr))); - // triggers.push_back(new TriggerNode("shadow protection on party", NextAction::array(0, new NextAction("shadow protection on party", 10.0f), nullptr))); + triggers.push_back(new TriggerNode("shadow protection", + NextAction::array(0, new NextAction("shadow protection", 12.0f), nullptr))); + triggers.push_back( + new TriggerNode("shadow protection on party", + NextAction::array(0, new NextAction("shadow protection on party", 11.0f), nullptr))); + // triggers.push_back(new TriggerNode("shadow protection on party", NextAction::array(0, new NextAction("shadow + // protection on party", 10.0f), nullptr))); } diff --git a/src/strategy/priest/PriestNonCombatStrategy.h b/src/strategy/priest/PriestNonCombatStrategy.h index f4d31e34..88849519 100644 --- a/src/strategy/priest/PriestNonCombatStrategy.h +++ b/src/strategy/priest/PriestNonCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PRIESTNONCOMBATSTRATEGY_H @@ -11,29 +12,29 @@ class PlayerbotAI; class PriestNonCombatStrategy : public NonCombatStrategy { - public: - PriestNonCombatStrategy(PlayerbotAI* botAI); +public: + PriestNonCombatStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "nc"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "nc"; } }; class PriestBuffStrategy : public NonCombatStrategy { - public: - PriestBuffStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + PriestBuffStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "buff"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "buff"; } }; class PriestShadowResistanceStrategy : public NonCombatStrategy { - public: - PriestShadowResistanceStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + PriestShadowResistanceStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "rshadow"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "rshadow"; } }; #endif diff --git a/src/strategy/priest/PriestNonCombatStrategyActionNodeFactory.h b/src/strategy/priest/PriestNonCombatStrategyActionNodeFactory.h index 3d2bece1..84318fcb 100644 --- a/src/strategy/priest/PriestNonCombatStrategyActionNodeFactory.h +++ b/src/strategy/priest/PriestNonCombatStrategyActionNodeFactory.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PRIESTNONCOMBATSTRATEGYACTIONNODEFACTORY_H @@ -12,141 +13,141 @@ class PlayerbotAI; class PriestNonCombatStrategyActionNodeFactory : public NamedObjectFactory { - public: - PriestNonCombatStrategyActionNodeFactory() - { - creators["holy nova"] = &holy_nova; - creators["power word: shield"] = &power_word_shield; - creators["power word: shield on party"] = &power_word_shield_on_party; - creators["renew"] = &renew; - creators["renew on party"] = &renew_on_party; - creators["greater heal"] = &greater_heal; - creators["greater heal on party"] = &greater_heal_on_party; - creators["heal"] = &heal; - creators["heal on party"] = &heal_on_party; - creators["lesser heal"] = &lesser_heal; - creators["lesser heal on party"] = &lesser_heal_on_party; - creators["flash heal"] = &flash_heal; - creators["flash heal on party"] = &flash_heal_on_party; - creators["circle of healing"] = &circle_of_healing; - creators["prayer of fortitude on party"] = &prayer_of_fortitude_on_party; - creators["prayer of spirit on party"] = &prayer_of_spirit_on_party; - } +public: + PriestNonCombatStrategyActionNodeFactory() + { + creators["holy nova"] = &holy_nova; + creators["power word: shield"] = &power_word_shield; + creators["power word: shield on party"] = &power_word_shield_on_party; + creators["renew"] = &renew; + creators["renew on party"] = &renew_on_party; + creators["greater heal"] = &greater_heal; + creators["greater heal on party"] = &greater_heal_on_party; + creators["heal"] = &heal; + creators["heal on party"] = &heal_on_party; + creators["lesser heal"] = &lesser_heal; + creators["lesser heal on party"] = &lesser_heal_on_party; + creators["flash heal"] = &flash_heal; + creators["flash heal on party"] = &flash_heal_on_party; + creators["circle of healing"] = &circle_of_healing; + creators["prayer of fortitude on party"] = &prayer_of_fortitude_on_party; + creators["prayer of spirit on party"] = &prayer_of_spirit_on_party; + } - private: - static ActionNode* holy_nova(PlayerbotAI* ai) - { - return new ActionNode ("holy nova", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* power_word_shield(PlayerbotAI* ai) - { - return new ActionNode ("power word: shield", - /*P*/ NULL, - /*A*/ NextAction::array(0, new NextAction("renew", 50.0f), NULL), - /*C*/ NULL); - } - static ActionNode* power_word_shield_on_party(PlayerbotAI* ai) - { - return new ActionNode ("power word: shield on party", - /*P*/ NULL, - /*A*/ NextAction::array(0, new NextAction("renew on party", 50.0f), NULL), - /*C*/ NULL); - } - static ActionNode* renew(PlayerbotAI* ai) - { - return new ActionNode ("renew", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* renew_on_party(PlayerbotAI* ai) - { - return new ActionNode ("renew on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* greater_heal(PlayerbotAI* ai) - { - return new ActionNode ("greater heal", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NextAction::array(0, new NextAction("heal"), NULL), - /*C*/ NULL); - } - static ActionNode* greater_heal_on_party(PlayerbotAI* ai) - { - return new ActionNode ("greater heal on party", - /*P*/ NULL, - /*A*/ NextAction::array(0, new NextAction("heal on party"), NULL), - /*C*/ NULL); - } - static ActionNode* heal(PlayerbotAI* ai) - { - return new ActionNode ("heal", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NextAction::array(0, new NextAction("lesser heal"), NULL), - /*C*/ NULL); - } - static ActionNode* heal_on_party(PlayerbotAI* ai) - { - return new ActionNode ("heal on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NextAction::array(0, new NextAction("lesser heal on party"), NULL), - /*C*/ NULL); - } - static ActionNode* lesser_heal(PlayerbotAI* ai) - { - return new ActionNode ("lesser heal", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* lesser_heal_on_party(PlayerbotAI* ai) - { - return new ActionNode ("lesser heal on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* flash_heal(PlayerbotAI* ai) - { - return new ActionNode ("flash heal", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* flash_heal_on_party(PlayerbotAI* ai) - { - return new ActionNode ("flash heal on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* circle_of_healing(PlayerbotAI* ai) - { - return new ActionNode ("circle of healing", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - // /*A*/ NextAction::array(0, new NextAction("flash heal on party"), NULL), - /*A*/ NULL, - /*C*/ NULL); - } - static ActionNode* prayer_of_fortitude_on_party(PlayerbotAI* ai) - { - return new ActionNode ("prayer of fortitude on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NextAction::array(0, new NextAction("power word: fortitude on party"), NULL), - /*C*/ NULL); - } - static ActionNode* prayer_of_spirit_on_party(PlayerbotAI* ai) - { - return new ActionNode ("prayer of spirit on party", - /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), - /*A*/ NextAction::array(0, new NextAction("divine spirit on party"), NULL), - /*C*/ NULL); - } +private: + static ActionNode* holy_nova(PlayerbotAI* ai) + { + return new ActionNode("holy nova", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* power_word_shield(PlayerbotAI* ai) + { + return new ActionNode("power word: shield", + /*P*/ NULL, + /*A*/ NextAction::array(0, new NextAction("renew", 50.0f), NULL), + /*C*/ NULL); + } + static ActionNode* power_word_shield_on_party(PlayerbotAI* ai) + { + return new ActionNode("power word: shield on party", + /*P*/ NULL, + /*A*/ NextAction::array(0, new NextAction("renew on party", 50.0f), NULL), + /*C*/ NULL); + } + static ActionNode* renew(PlayerbotAI* ai) + { + return new ActionNode("renew", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* renew_on_party(PlayerbotAI* ai) + { + return new ActionNode("renew on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* greater_heal(PlayerbotAI* ai) + { + return new ActionNode("greater heal", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NextAction::array(0, new NextAction("heal"), NULL), + /*C*/ NULL); + } + static ActionNode* greater_heal_on_party(PlayerbotAI* ai) + { + return new ActionNode("greater heal on party", + /*P*/ NULL, + /*A*/ NextAction::array(0, new NextAction("heal on party"), NULL), + /*C*/ NULL); + } + static ActionNode* heal(PlayerbotAI* ai) + { + return new ActionNode("heal", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NextAction::array(0, new NextAction("lesser heal"), NULL), + /*C*/ NULL); + } + static ActionNode* heal_on_party(PlayerbotAI* ai) + { + return new ActionNode("heal on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NextAction::array(0, new NextAction("lesser heal on party"), NULL), + /*C*/ NULL); + } + static ActionNode* lesser_heal(PlayerbotAI* ai) + { + return new ActionNode("lesser heal", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* lesser_heal_on_party(PlayerbotAI* ai) + { + return new ActionNode("lesser heal on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* flash_heal(PlayerbotAI* ai) + { + return new ActionNode("flash heal", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* flash_heal_on_party(PlayerbotAI* ai) + { + return new ActionNode("flash heal on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* circle_of_healing(PlayerbotAI* ai) + { + return new ActionNode("circle of healing", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + // /*A*/ NextAction::array(0, new NextAction("flash heal on party"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* prayer_of_fortitude_on_party(PlayerbotAI* ai) + { + return new ActionNode("prayer of fortitude on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NextAction::array(0, new NextAction("power word: fortitude on party"), NULL), + /*C*/ NULL); + } + static ActionNode* prayer_of_spirit_on_party(PlayerbotAI* ai) + { + return new ActionNode("prayer of spirit on party", + /*P*/ NextAction::array(0, new NextAction("remove shadowform"), NULL), + /*A*/ NextAction::array(0, new NextAction("divine spirit on party"), NULL), + /*C*/ NULL); + } }; #endif diff --git a/src/strategy/priest/PriestTriggers.cpp b/src/strategy/priest/PriestTriggers.cpp index c5b48d54..1aceeb03 100644 --- a/src/strategy/priest/PriestTriggers.cpp +++ b/src/strategy/priest/PriestTriggers.cpp @@ -1,45 +1,51 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PriestTriggers.h" + #include "Playerbots.h" bool PowerWordFortitudeOnPartyTrigger::IsActive() { - return BuffOnPartyTrigger::IsActive() && !botAI->HasAura("power word : fortitude", GetTarget()) && !botAI->HasAura("prayer of fortitude", GetTarget()); + return BuffOnPartyTrigger::IsActive() && !botAI->HasAura("power word : fortitude", GetTarget()) && + !botAI->HasAura("prayer of fortitude", GetTarget()); } bool PowerWordFortitudeTrigger::IsActive() { - return BuffTrigger::IsActive() && !botAI->HasAura("power word: fortitude", GetTarget()) && !botAI->HasAura("prayer of fortitude", GetTarget()); + return BuffTrigger::IsActive() && !botAI->HasAura("power word: fortitude", GetTarget()) && + !botAI->HasAura("prayer of fortitude", GetTarget()); } bool DivineSpiritOnPartyTrigger::IsActive() { - return BuffOnPartyTrigger::IsActive() && !botAI->HasAura("divine spirit", GetTarget()) && !botAI->HasAura("prayer of spirit", GetTarget()); + return BuffOnPartyTrigger::IsActive() && !botAI->HasAura("divine spirit", GetTarget()) && + !botAI->HasAura("prayer of spirit", GetTarget()); } bool DivineSpiritTrigger::IsActive() { - return BuffTrigger::IsActive() && !botAI->HasAura("divine spirit", GetTarget()) && !botAI->HasAura("prayer of spirit", GetTarget()); + return BuffTrigger::IsActive() && !botAI->HasAura("divine spirit", GetTarget()) && + !botAI->HasAura("prayer of spirit", GetTarget()); } bool PrayerOfFortitudeTrigger::IsActive() { - return BuffOnPartyTrigger::IsActive() && - !botAI->HasAura("prayer of fortitude", GetTarget()) && - botAI->GetBot()->IsInSameGroupWith((Player*)GetTarget()) && - botAI->GetBuffedCount((Player*)GetTarget(), "prayer of fortitude") < 4 && !botAI->GetBuffedCount((Player*)GetTarget(), "power word: fortitude"); + return BuffOnPartyTrigger::IsActive() && !botAI->HasAura("prayer of fortitude", GetTarget()) && + botAI->GetBot()->IsInSameGroupWith((Player*)GetTarget()) && + botAI->GetBuffedCount((Player*)GetTarget(), "prayer of fortitude") < 4 && + !botAI->GetBuffedCount((Player*)GetTarget(), "power word: fortitude"); } bool PrayerOfSpiritTrigger::IsActive() { - return BuffOnPartyTrigger::IsActive() && - !botAI->HasAura("prayer of spirit", GetTarget()) && - botAI->GetBot()->IsInSameGroupWith((Player*)GetTarget()) && - //botAI->GetManaPercent() > 50 && - botAI->GetBuffedCount((Player*) GetTarget(), "prayer of spirit") < 4 && !botAI->GetBuffedCount((Player*) GetTarget(), "divine spirit"); + return BuffOnPartyTrigger::IsActive() && !botAI->HasAura("prayer of spirit", GetTarget()) && + botAI->GetBot()->IsInSameGroupWith((Player*)GetTarget()) && + // botAI->GetManaPercent() > 50 && + botAI->GetBuffedCount((Player*)GetTarget(), "prayer of spirit") < 4 && + !botAI->GetBuffedCount((Player*)GetTarget(), "divine spirit"); } bool InnerFireTrigger::IsActive() @@ -48,21 +54,17 @@ bool InnerFireTrigger::IsActive() return SpellTrigger::IsActive() && !botAI->HasAura(spell, target); } -bool ShadowformTrigger::IsActive() -{ - return !botAI->HasAura("shadowform", bot); -} +bool ShadowformTrigger::IsActive() { return !botAI->HasAura("shadowform", bot); } -bool ShadowfiendTrigger::IsActive() -{ - return BoostTrigger::IsActive() && !bot->HasSpellCooldown(34433); -} +bool ShadowfiendTrigger::IsActive() { return BoostTrigger::IsActive() && !bot->HasSpellCooldown(34433); } -BindingHealTrigger::BindingHealTrigger(PlayerbotAI* botAI) : PartyMemberLowHealthTrigger(botAI, "binding heal", sPlayerbotAIConfig->lowHealth, 0) +BindingHealTrigger::BindingHealTrigger(PlayerbotAI* botAI) + : PartyMemberLowHealthTrigger(botAI, "binding heal", sPlayerbotAIConfig->lowHealth, 0) { } bool BindingHealTrigger::IsActive() { - return PartyMemberLowHealthTrigger::IsActive() && AI_VALUE2(uint8, "health", "self target") < sPlayerbotAIConfig->mediumHealth; + return PartyMemberLowHealthTrigger::IsActive() && + AI_VALUE2(uint8, "health", "self target") < sPlayerbotAIConfig->mediumHealth; } diff --git a/src/strategy/priest/PriestTriggers.h b/src/strategy/priest/PriestTriggers.h index 126c8663..fbfeeb57 100644 --- a/src/strategy/priest/PriestTriggers.h +++ b/src/strategy/priest/PriestTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PRIESTTRIGGERS_H @@ -43,58 +44,60 @@ BOOST_TRIGGER_A(ShadowfiendTrigger, "shadowfiend"); class PowerWordFortitudeOnPartyTrigger : public BuffOnPartyTrigger { - public: - PowerWordFortitudeOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "power word: fortitude", 4 * 2000) { } +public: + PowerWordFortitudeOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "power word: fortitude", 4 * 2000) + { + } - bool IsActive() override; + bool IsActive() override; }; class PowerWordFortitudeTrigger : public BuffTrigger { - public: - PowerWordFortitudeTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "power word: fortitude", 4 * 2000) { } +public: + PowerWordFortitudeTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "power word: fortitude", 4 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class DivineSpiritOnPartyTrigger : public BuffOnPartyTrigger { - public: - DivineSpiritOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "divine spirit", 4 * 2000) { } +public: + DivineSpiritOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "divine spirit", 4 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class DivineSpiritTrigger : public BuffTrigger { - public: - DivineSpiritTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "divine spirit", 4 * 2000) { } +public: + DivineSpiritTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "divine spirit", 4 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class PrayerOfFortitudeTrigger : public BuffOnPartyTrigger { - public: - PrayerOfFortitudeTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "prayer of fortitude", 3 * 2000) { } +public: + PrayerOfFortitudeTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "prayer of fortitude", 3 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class PrayerOfSpiritTrigger : public BuffOnPartyTrigger { - public: - PrayerOfSpiritTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "prayer of spirit", 2 * 2000) { } +public: + PrayerOfSpiritTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "prayer of spirit", 2 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class BindingHealTrigger : public PartyMemberLowHealthTrigger { - public: - BindingHealTrigger(PlayerbotAI* botAI); +public: + BindingHealTrigger(PlayerbotAI* botAI); - bool IsActive() override; + bool IsActive() override; }; #endif diff --git a/src/strategy/priest/ShadowPriestStrategy.cpp b/src/strategy/priest/ShadowPriestStrategy.cpp index 8c00165b..474ce4db 100644 --- a/src/strategy/priest/ShadowPriestStrategy.cpp +++ b/src/strategy/priest/ShadowPriestStrategy.cpp @@ -1,10 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ShadowPriestStrategy.h" -#include "ShadowPriestStrategyActionNodeFactory.h" + #include "Playerbots.h" +#include "ShadowPriestStrategyActionNodeFactory.h" ShadowPriestStrategy::ShadowPriestStrategy(PlayerbotAI* botAI) : GenericPriestStrategy(botAI) { @@ -13,41 +15,56 @@ ShadowPriestStrategy::ShadowPriestStrategy(PlayerbotAI* botAI) : GenericPriestSt NextAction** ShadowPriestStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("mind blast", ACTION_DEFAULT + 0.2f), - // new NextAction("shadow word: death", 12.0f), - new NextAction("mind flay", ACTION_DEFAULT + 0.1f), - new NextAction("shoot", ACTION_DEFAULT), - NULL); + return NextAction::array(0, new NextAction("mind blast", ACTION_DEFAULT + 0.2f), + // new NextAction("shadow word: death", 12.0f), + new NextAction("mind flay", ACTION_DEFAULT + 0.1f), + new NextAction("shoot", ACTION_DEFAULT), NULL); } void ShadowPriestStrategy::InitTriggers(std::vector& triggers) { GenericPriestStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", ACTION_MOVE + 9), nullptr))); - triggers.push_back(new TriggerNode("shadowform", NextAction::array(0, new NextAction("shadowform", ACTION_HIGH), nullptr))); - //triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("dispersion", ACTION_EMERGENCY + 5), nullptr))); - triggers.push_back(new TriggerNode("vampiric embrace", NextAction::array(0, new NextAction("vampiric embrace", 16.0f), nullptr))); - triggers.push_back(new TriggerNode("silence", NextAction::array(0, new NextAction("silence", ACTION_INTERRUPT + 1), nullptr))); - triggers.push_back(new TriggerNode("silence on enemy healer", NextAction::array(0, new NextAction("silence on enemy healer", ACTION_INTERRUPT), nullptr))); - // triggers.push_back(new TriggerNode("shadowfiend", NextAction::array(0, new NextAction("shadowfiend", ACTION_HIGH), nullptr))); - // triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new NextAction("shadowfiend", ACTION_HIGH), nullptr))); - // triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("mana burn", ACTION_HIGH), nullptr))); + // triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", + // ACTION_MOVE + 9), nullptr))); + triggers.push_back( + new TriggerNode("shadowform", NextAction::array(0, new NextAction("shadowform", ACTION_HIGH), nullptr))); + // triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("dispersion", ACTION_EMERGENCY + // + 5), nullptr))); + triggers.push_back( + new TriggerNode("vampiric embrace", NextAction::array(0, new NextAction("vampiric embrace", 16.0f), nullptr))); + triggers.push_back( + new TriggerNode("silence", NextAction::array(0, new NextAction("silence", ACTION_INTERRUPT + 1), nullptr))); + triggers.push_back( + new TriggerNode("silence on enemy healer", + NextAction::array(0, new NextAction("silence on enemy healer", ACTION_INTERRUPT), nullptr))); + // triggers.push_back(new TriggerNode("shadowfiend", NextAction::array(0, new NextAction("shadowfiend", + // ACTION_HIGH), nullptr))); triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new + // NextAction("shadowfiend", ACTION_HIGH), nullptr))); triggers.push_back(new TriggerNode("low mana", + // NextAction::array(0, new NextAction("mana burn", ACTION_HIGH), nullptr))); } void ShadowPriestAoeStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("shadow word: pain on attacker", NextAction::array(0, new NextAction("shadow word: pain on attacker", ACTION_NORMAL + 5), nullptr))); - triggers.push_back(new TriggerNode("vampiric touch on attacker", NextAction::array(0, new NextAction("vampiric touch on attacker", ACTION_NORMAL + 4), nullptr))); - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("mind sear", ACTION_HIGH + 4), nullptr))); + triggers.push_back(new TriggerNode( + "shadow word: pain on attacker", + NextAction::array(0, new NextAction("shadow word: pain on attacker", ACTION_NORMAL + 5), nullptr))); + triggers.push_back(new TriggerNode( + "vampiric touch on attacker", + NextAction::array(0, new NextAction("vampiric touch on attacker", ACTION_NORMAL + 4), nullptr))); + triggers.push_back( + new TriggerNode("medium aoe", NextAction::array(0, new NextAction("mind sear", ACTION_HIGH + 4), nullptr))); } void ShadowPriestDebuffStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("devouring plague", NextAction::array(0, new NextAction("devouring plague", ACTION_HIGH + 3), nullptr))); - triggers.push_back(new TriggerNode("vampiric touch", NextAction::array(0, new NextAction("vampiric touch", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode("shadow word: pain", NextAction::array(0, new NextAction("shadow word: pain", ACTION_HIGH + 1), nullptr))); - // triggers.push_back(new TriggerNode("feedback", NextAction::array(0, new NextAction("feedback", 80.0f), nullptr))); - // triggers.push_back(new TriggerNode("hex of weakness", NextAction::array(0, new NextAction("hex of weakness", 10.0f), nullptr))); + triggers.push_back(new TriggerNode( + "devouring plague", NextAction::array(0, new NextAction("devouring plague", ACTION_HIGH + 3), nullptr))); + triggers.push_back(new TriggerNode( + "vampiric touch", NextAction::array(0, new NextAction("vampiric touch", ACTION_HIGH + 2), nullptr))); + triggers.push_back(new TriggerNode( + "shadow word: pain", NextAction::array(0, new NextAction("shadow word: pain", ACTION_HIGH + 1), nullptr))); + // triggers.push_back(new TriggerNode("feedback", NextAction::array(0, new NextAction("feedback", 80.0f), + // nullptr))); triggers.push_back(new TriggerNode("hex of weakness", NextAction::array(0, new NextAction("hex of + // weakness", 10.0f), nullptr))); } diff --git a/src/strategy/priest/ShadowPriestStrategy.h b/src/strategy/priest/ShadowPriestStrategy.h index 7167f696..8ceadc7b 100644 --- a/src/strategy/priest/ShadowPriestStrategy.h +++ b/src/strategy/priest/ShadowPriestStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SHADOWPRIESTSTRATEGY_H @@ -11,31 +12,31 @@ class PlayerbotAI; class ShadowPriestStrategy : public GenericPriestStrategy { - public: - ShadowPriestStrategy(PlayerbotAI* botAI); +public: + ShadowPriestStrategy(PlayerbotAI* botAI); - NextAction** getDefaultActions() override; - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "shadow"; } - uint32 GetType() const override { return STRATEGY_TYPE_DPS | STRATEGY_TYPE_RANGED; } + NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "shadow"; } + uint32 GetType() const override { return STRATEGY_TYPE_DPS | STRATEGY_TYPE_RANGED; } }; class ShadowPriestAoeStrategy : public CombatStrategy { - public: - ShadowPriestAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + ShadowPriestAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "shadow aoe"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "shadow aoe"; } }; class ShadowPriestDebuffStrategy : public CombatStrategy { - public: - ShadowPriestDebuffStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + ShadowPriestDebuffStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "shadow debuff"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "shadow debuff"; } }; #endif diff --git a/src/strategy/priest/ShadowPriestStrategyActionNodeFactory.h b/src/strategy/priest/ShadowPriestStrategyActionNodeFactory.h index 49bc26a3..eac9053f 100644 --- a/src/strategy/priest/ShadowPriestStrategyActionNodeFactory.h +++ b/src/strategy/priest/ShadowPriestStrategyActionNodeFactory.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SHADOWPRIESTSTRATEGYACTIONNODEFACTORY_H @@ -12,47 +13,47 @@ class PlayerbotAI; class ShadowPriestStrategyActionNodeFactory : public NamedObjectFactory { - public: - ShadowPriestStrategyActionNodeFactory() - { - creators["mind blast"] = &mind_blast; - creators["dispersion"] = &dispersion; - creators["mind flay"] = &mind_flay; - creators["smite"] = &smite; - } +public: + ShadowPriestStrategyActionNodeFactory() + { + creators["mind blast"] = &mind_blast; + creators["dispersion"] = &dispersion; + creators["mind flay"] = &mind_flay; + creators["smite"] = &smite; + } - private: - static ActionNode* mind_blast(PlayerbotAI* botAI) - { - return new ActionNode ("mind blast", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("mind flay"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* mind_blast(PlayerbotAI* botAI) + { + return new ActionNode("mind blast", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("mind flay"), nullptr), + /*C*/ nullptr); + } - static ActionNode* mind_flay(PlayerbotAI* botAI) - { - return new ActionNode ("mind flay", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("smite"), nullptr), - /*C*/ nullptr); - } + static ActionNode* mind_flay(PlayerbotAI* botAI) + { + return new ActionNode("mind flay", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("smite"), nullptr), + /*C*/ nullptr); + } - static ActionNode* smite(PlayerbotAI* botAI) - { - return new ActionNode ("smite", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), - /*C*/ nullptr); - } + static ActionNode* smite(PlayerbotAI* botAI) + { + return new ActionNode("smite", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), + /*C*/ nullptr); + } - static ActionNode* dispersion(PlayerbotAI* botAI) - { - return new ActionNode ("dispersion", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("mana potion"), nullptr), - /*C*/ nullptr); - } + static ActionNode* dispersion(PlayerbotAI* botAI) + { + return new ActionNode("dispersion", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("mana potion"), nullptr), + /*C*/ nullptr); + } }; #endif diff --git a/src/strategy/raids/RaidActionContext.h b/src/strategy/raids/RaidActionContext.h index 644aee0e..e96c71e1 100644 --- a/src/strategy/raids/RaidActionContext.h +++ b/src/strategy/raids/RaidActionContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RAIDACTIONCONTEXTACTION_H @@ -11,16 +12,22 @@ class RaidActionContext : public NamedObjectContext { - public: - RaidActionContext() - { - creators["bwl check onyxia scale cloak"] = &RaidActionContext::bwl_check_onyxia_scale_cloak; - creators["bwl turn off suppression device"] = &RaidActionContext::bwl_turn_off_suppression_device; - } +public: + RaidActionContext() + { + creators["bwl check onyxia scale cloak"] = &RaidActionContext::bwl_check_onyxia_scale_cloak; + creators["bwl turn off suppression device"] = &RaidActionContext::bwl_turn_off_suppression_device; + } - private: - static Action* bwl_check_onyxia_scale_cloak(PlayerbotAI* botAI) { return new BwlOnyxiaScaleCloakAuraCheckAction(botAI); } - static Action* bwl_turn_off_suppression_device(PlayerbotAI* botAI) { return new BwlTurnOffSuppressionDeviceAction(botAI); } +private: + static Action* bwl_check_onyxia_scale_cloak(PlayerbotAI* botAI) + { + return new BwlOnyxiaScaleCloakAuraCheckAction(botAI); + } + static Action* bwl_turn_off_suppression_device(PlayerbotAI* botAI) + { + return new BwlTurnOffSuppressionDeviceAction(botAI); + } }; #endif diff --git a/src/strategy/raids/RaidStrategyContext.h b/src/strategy/raids/RaidStrategyContext.h index 2d40d5f2..2d610000 100644 --- a/src/strategy/raids/RaidStrategyContext.h +++ b/src/strategy/raids/RaidStrategyContext.h @@ -7,15 +7,16 @@ class RaidStrategyContext : public NamedObjectContext { - public: - RaidStrategyContext() : NamedObjectContext(false, true) - { - creators["naxx"] = &RaidStrategyContext::naxx; - creators["bwl"] = &RaidStrategyContext::bwl; - } - private: - static Strategy* naxx(PlayerbotAI* botAI) { return new RaidNaxxStrategy(botAI); } - static Strategy* bwl(PlayerbotAI* botAI) { return new RaidBwlStrategy(botAI); } +public: + RaidStrategyContext() : NamedObjectContext(false, true) + { + creators["naxx"] = &RaidStrategyContext::naxx; + creators["bwl"] = &RaidStrategyContext::bwl; + } + +private: + static Strategy* naxx(PlayerbotAI* botAI) { return new RaidNaxxStrategy(botAI); } + static Strategy* bwl(PlayerbotAI* botAI) { return new RaidBwlStrategy(botAI); } }; #endif \ No newline at end of file diff --git a/src/strategy/raids/RaidTriggerContext.h b/src/strategy/raids/RaidTriggerContext.h index 93803f48..69b45002 100644 --- a/src/strategy/raids/RaidTriggerContext.h +++ b/src/strategy/raids/RaidTriggerContext.h @@ -1,24 +1,23 @@ // /* -// * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. +// * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it +// and/or modify it under version 2 of the License, or (at your option), any later version. // */ #ifndef _PLAYERBOT_RAIDTRIGGERCONTEXT_H #define _PLAYERBOT_RAIDTRIGGERCONTEXT_H -#include "NamedObjectContext.h" #include "AiObjectContext.h" -#include "raids/naxxramas/RaidNaxxTriggers.h" +#include "NamedObjectContext.h" #include "raids/blackwinglair/RaidBwlTriggers.h" +#include "raids/naxxramas/RaidNaxxTriggers.h" -class RaidTriggerContext : public NamedObjectContext +class RaidTriggerContext : public NamedObjectContext { - public: - RaidTriggerContext() - { - creators["bwl suppression device"] = &RaidTriggerContext::bwl_suppression_device; - } - private: - static Trigger* bwl_suppression_device(PlayerbotAI* ai) { return new BwlSuppressionDeviceTrigger(ai); } +public: + RaidTriggerContext() { creators["bwl suppression device"] = &RaidTriggerContext::bwl_suppression_device; } + +private: + static Trigger* bwl_suppression_device(PlayerbotAI* ai) { return new BwlSuppressionDeviceTrigger(ai); } }; #endif \ No newline at end of file diff --git a/src/strategy/raids/blackwinglair/RaidBwlActions.cpp b/src/strategy/raids/blackwinglair/RaidBwlActions.cpp index ef9a13eb..5ab02fef 100644 --- a/src/strategy/raids/blackwinglair/RaidBwlActions.cpp +++ b/src/strategy/raids/blackwinglair/RaidBwlActions.cpp @@ -1,4 +1,5 @@ #include "RaidBwlActions.h" + #include "Playerbots.h" bool BwlOnyxiaScaleCloakAuraCheckAction::Execute(Event event) @@ -7,10 +8,7 @@ bool BwlOnyxiaScaleCloakAuraCheckAction::Execute(Event event) return true; } -bool BwlOnyxiaScaleCloakAuraCheckAction::isUseful() -{ - return !bot->HasAura(22683); -} +bool BwlOnyxiaScaleCloakAuraCheckAction::isUseful() { return !bot->HasAura(22683); } bool BwlTurnOffSuppressionDeviceAction::Execute(Event event) { @@ -18,10 +16,12 @@ bool BwlTurnOffSuppressionDeviceAction::Execute(Event event) for (GuidVector::iterator i = gos.begin(); i != gos.end(); i++) { GameObject* go = botAI->GetGameObject(*i); - if (!go) { + if (!go) + { continue; } - if (go->GetEntry() != 179784 || go->GetDistance(bot) >= 15.0f || go->GetGoState() != GO_STATE_READY) { + if (go->GetEntry() != 179784 || go->GetDistance(bot) >= 15.0f || go->GetGoState() != GO_STATE_READY) + { continue; } go->SetGoState(GO_STATE_ACTIVE); diff --git a/src/strategy/raids/blackwinglair/RaidBwlActions.h b/src/strategy/raids/blackwinglair/RaidBwlActions.h index 56f94089..1822ebde 100644 --- a/src/strategy/raids/blackwinglair/RaidBwlActions.h +++ b/src/strategy/raids/blackwinglair/RaidBwlActions.h @@ -2,25 +2,25 @@ #define _PLAYERBOT_RAIDBWLACTIONS_H #include "Action.h" -#include "MovementActions.h" #include "AttackAction.h" #include "GenericActions.h" +#include "MovementActions.h" #include "PlayerbotAI.h" #include "Playerbots.h" class BwlOnyxiaScaleCloakAuraCheckAction : public Action { - public: - BwlOnyxiaScaleCloakAuraCheckAction(PlayerbotAI* botAI) : Action(botAI, "bwl onyxia scale cloak aura check") {} - bool Execute(Event event) override; - bool isUseful() override; +public: + BwlOnyxiaScaleCloakAuraCheckAction(PlayerbotAI* botAI) : Action(botAI, "bwl onyxia scale cloak aura check") {} + bool Execute(Event event) override; + bool isUseful() override; }; class BwlTurnOffSuppressionDeviceAction : public Action { - public: - BwlTurnOffSuppressionDeviceAction(PlayerbotAI* botAI) : Action(botAI, "bwl turn off suppression device") {} - bool Execute(Event event) override; +public: + BwlTurnOffSuppressionDeviceAction(PlayerbotAI* botAI) : Action(botAI, "bwl turn off suppression device") {} + bool Execute(Event event) override; }; #endif \ No newline at end of file diff --git a/src/strategy/raids/blackwinglair/RaidBwlStrategy.cpp b/src/strategy/raids/blackwinglair/RaidBwlStrategy.cpp index f9e98e52..6c7d79e5 100644 --- a/src/strategy/raids/blackwinglair/RaidBwlStrategy.cpp +++ b/src/strategy/raids/blackwinglair/RaidBwlStrategy.cpp @@ -1,13 +1,13 @@ #include "RaidBwlStrategy.h" + #include "Strategy.h" -void RaidBwlStrategy::InitTriggers(std::vector &triggers) +void RaidBwlStrategy::InitTriggers(std::vector& triggers) { triggers.push_back(new TriggerNode( - "often", - NextAction::array(0, new NextAction("bwl check onyxia scale cloak", ACTION_RAID), NULL))); + "often", NextAction::array(0, new NextAction("bwl check onyxia scale cloak", ACTION_RAID), NULL))); - triggers.push_back(new TriggerNode( - "bwl suppression device", - NextAction::array(0, new NextAction("bwl turn off suppression device", ACTION_RAID), NULL))); + triggers.push_back( + new TriggerNode("bwl suppression device", + NextAction::array(0, new NextAction("bwl turn off suppression device", ACTION_RAID), NULL))); } \ No newline at end of file diff --git a/src/strategy/raids/blackwinglair/RaidBwlStrategy.h b/src/strategy/raids/blackwinglair/RaidBwlStrategy.h index 98c60c53..27bced8e 100644 --- a/src/strategy/raids/blackwinglair/RaidBwlStrategy.h +++ b/src/strategy/raids/blackwinglair/RaidBwlStrategy.h @@ -2,8 +2,8 @@ #ifndef _PLAYERBOT_RAIDBWLSTRATEGY_H #define _PLAYERBOT_RAIDBWLSTRATEGY_H -#include "Multiplier.h" #include "AiObjectContext.h" +#include "Multiplier.h" #include "Strategy.h" class RaidBwlStrategy : public Strategy @@ -11,9 +11,8 @@ class RaidBwlStrategy : public Strategy public: RaidBwlStrategy(PlayerbotAI* ai) : Strategy(ai) {} virtual std::string const getName() override { return "bwl"; } - virtual void InitTriggers(std::vector &triggers) override; + virtual void InitTriggers(std::vector& triggers) override; // virtual void InitMultipliers(std::vector &multipliers) override; }; - #endif \ No newline at end of file diff --git a/src/strategy/raids/blackwinglair/RaidBwlTriggers.cpp b/src/strategy/raids/blackwinglair/RaidBwlTriggers.cpp index 1b303bb7..089a3f11 100644 --- a/src/strategy/raids/blackwinglair/RaidBwlTriggers.cpp +++ b/src/strategy/raids/blackwinglair/RaidBwlTriggers.cpp @@ -1,15 +1,19 @@ #include "RaidBwlTriggers.h" + #include "SharedDefines.h" -bool BwlSuppressionDeviceTrigger::IsActive() { +bool BwlSuppressionDeviceTrigger::IsActive() +{ GuidVector gos = AI_VALUE(GuidVector, "nearest game objects"); for (GuidVector::iterator i = gos.begin(); i != gos.end(); i++) { GameObject* go = botAI->GetGameObject(*i); - if (!go) { + if (!go) + { continue; } - if (go->GetEntry() != 179784 || go->GetDistance(bot) >= 15.0f || go->GetGoState() != GO_STATE_READY) { + if (go->GetEntry() != 179784 || go->GetDistance(bot) >= 15.0f || go->GetGoState() != GO_STATE_READY) + { continue; } return true; diff --git a/src/strategy/raids/blackwinglair/RaidBwlTriggers.h b/src/strategy/raids/blackwinglair/RaidBwlTriggers.h index d1aedb6f..8f26ad7b 100644 --- a/src/strategy/raids/blackwinglair/RaidBwlTriggers.h +++ b/src/strategy/raids/blackwinglair/RaidBwlTriggers.h @@ -1,15 +1,15 @@ #ifndef _PLAYERBOT_RAIDBWLTRIGGERS_H #define _PLAYERBOT_RAIDBWLTRIGGERS_H -#include "Trigger.h" #include "PlayerbotAI.h" #include "Playerbots.h" +#include "Trigger.h" -class BwlSuppressionDeviceTrigger : public Trigger +class BwlSuppressionDeviceTrigger : public Trigger { - public: - BwlSuppressionDeviceTrigger(PlayerbotAI* botAI) : Trigger(botAI, "bwl suppression device") {} - bool IsActive() override; +public: + BwlSuppressionDeviceTrigger(PlayerbotAI* botAI) : Trigger(botAI, "bwl suppression device") {} + bool IsActive() override; }; #endif \ No newline at end of file diff --git a/src/strategy/raids/naxxramas/RaidNaxxActionContext.h b/src/strategy/raids/naxxramas/RaidNaxxActionContext.h index fe2c8366..f323106f 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxActionContext.h +++ b/src/strategy/raids/naxxramas/RaidNaxxActionContext.h @@ -1,5 +1,6 @@ // /* -// * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. +// * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it +// and/or modify it under version 2 of the License, or (at your option), any later version. // */ #ifndef _PLAYERBOT_RAIDNAXXACTIONCONTEXT_H @@ -11,70 +12,79 @@ class RaidNaxxActionContext : public NamedObjectContext { - public: - RaidNaxxActionContext() { - creators["grobbulus go behind the boss"] = &RaidNaxxActionContext::go_behind_the_boss; - creators["rotate grobbulus"] = &RaidNaxxActionContext::rotate_grobbulus; - creators["grobbulus move center"] = &RaidNaxxActionContext::grobbulus_move_center; +public: + RaidNaxxActionContext() + { + creators["grobbulus go behind the boss"] = &RaidNaxxActionContext::go_behind_the_boss; + creators["rotate grobbulus"] = &RaidNaxxActionContext::rotate_grobbulus; + creators["grobbulus move center"] = &RaidNaxxActionContext::grobbulus_move_center; - creators["heigan dance melee"] = &RaidNaxxActionContext::heigan_dance_melee; - creators["heigan dance ranged"] = &RaidNaxxActionContext::heigan_dance_ranged; - creators["thaddius attack nearest pet"] = &RaidNaxxActionContext::thaddius_attack_nearest_pet; - // creators["thaddius melee to place"] = &RaidNaxxActionContext::thaddius_tank_to_place; - // creators["thaddius ranged to place"] = &RaidNaxxActionContext::thaddius_ranged_to_place; - creators["thaddius move to platform"] = &RaidNaxxActionContext::thaddius_move_to_platform; - creators["thaddius move polarity"] = &RaidNaxxActionContext::thaddius_move_polarity; + creators["heigan dance melee"] = &RaidNaxxActionContext::heigan_dance_melee; + creators["heigan dance ranged"] = &RaidNaxxActionContext::heigan_dance_ranged; + creators["thaddius attack nearest pet"] = &RaidNaxxActionContext::thaddius_attack_nearest_pet; + // creators["thaddius melee to place"] = &RaidNaxxActionContext::thaddius_tank_to_place; + // creators["thaddius ranged to place"] = &RaidNaxxActionContext::thaddius_ranged_to_place; + creators["thaddius move to platform"] = &RaidNaxxActionContext::thaddius_move_to_platform; + creators["thaddius move polarity"] = &RaidNaxxActionContext::thaddius_move_polarity; - creators["razuvious use obedience crystal"] = &RaidNaxxActionContext::razuvious_use_obedience_crystal; - creators["razuvious target"] = &RaidNaxxActionContext::razuvious_target; + creators["razuvious use obedience crystal"] = &RaidNaxxActionContext::razuvious_use_obedience_crystal; + creators["razuvious target"] = &RaidNaxxActionContext::razuvious_target; - creators["horseman attract alternatively"] = &RaidNaxxActionContext::horseman_attract_alternatively; - creators["horseman attack in order"] = &RaidNaxxActionContext::horseman_attack_in_order; - - creators["sapphiron ground position"] = &RaidNaxxActionContext::sapphiron_ground_position; - creators["sapphiron flight position"] = &RaidNaxxActionContext::sapphiron_flight_position; + creators["horseman attract alternatively"] = &RaidNaxxActionContext::horseman_attract_alternatively; + creators["horseman attack in order"] = &RaidNaxxActionContext::horseman_attack_in_order; - creators["kel'thuzad choose target"] = &RaidNaxxActionContext::kelthuzad_choose_target; - creators["kel'thuzad position"] = &RaidNaxxActionContext::kelthuzad_position; + creators["sapphiron ground position"] = &RaidNaxxActionContext::sapphiron_ground_position; + creators["sapphiron flight position"] = &RaidNaxxActionContext::sapphiron_flight_position; - creators["anub'rekhan choose target"] = &RaidNaxxActionContext::anubrekhan_choose_target; - creators["anub'rekhan position"] = &RaidNaxxActionContext::anubrekhan_position; + creators["kel'thuzad choose target"] = &RaidNaxxActionContext::kelthuzad_choose_target; + creators["kel'thuzad position"] = &RaidNaxxActionContext::kelthuzad_position; - creators["gluth choose target"] = &RaidNaxxActionContext::gluth_choose_target; - creators["gluth position"] = &RaidNaxxActionContext::gluth_position; - creators["gluth slowdown"] = &RaidNaxxActionContext::gluth_slowdown; + creators["anub'rekhan choose target"] = &RaidNaxxActionContext::anubrekhan_choose_target; + creators["anub'rekhan position"] = &RaidNaxxActionContext::anubrekhan_position; - creators["loatheb position"] = &RaidNaxxActionContext::loatheb_position; - creators["loatheb choose target"] = &RaidNaxxActionContext::loatheb_choose_target; - } - private: - static Action* go_behind_the_boss(PlayerbotAI* ai) { return new GrobbulusGoBehindAction(ai); } - static Action* rotate_grobbulus(PlayerbotAI* ai) { return new GrobbulusRotateAction(ai); } - static Action* grobbulus_move_center(PlayerbotAI* ai) { return new GrobblulusMoveCenterAction(ai); } - static Action* heigan_dance_melee(PlayerbotAI* ai) { return new HeiganDanceMeleeAction(ai); } - static Action* heigan_dance_ranged(PlayerbotAI* ai) { return new HeiganDanceRangedAction(ai); } - static Action* thaddius_attack_nearest_pet(PlayerbotAI* ai) { return new ThaddiusAttackNearestPetAction(ai); } - // static Action* thaddius_tank_to_place(PlayerbotAI* ai) { return new ThaddiusMeleeToPlaceAction(ai); } - // static Action* thaddius_ranged_to_place(PlayerbotAI* ai) { return new ThaddiusRangedToPlaceAction(ai); } - static Action* thaddius_move_to_platform(PlayerbotAI* ai) { return new ThaddiusMoveToPlatformAction(ai); } - static Action* thaddius_move_polarity(PlayerbotAI* ai) { return new ThaddiusMovePolarityAction(ai); } - static Action* razuvious_target(PlayerbotAI* ai) { return new RazuviousTargetAction(ai); } - static Action* razuvious_use_obedience_crystal(PlayerbotAI* ai) { return new RazuviousUseObedienceCrystalAction(ai); } - static Action* horseman_attract_alternatively(PlayerbotAI* ai) { return new HorsemanAttractAlternativelyAction(ai); } - static Action* horseman_attack_in_order(PlayerbotAI* ai) { return new HorsemanAttactInOrderAction(ai); } - // static Action* sapphiron_ground_main_tank_position(PlayerbotAI* ai) { return new SapphironGroundMainTankPositionAction(ai); } - static Action* sapphiron_ground_position(PlayerbotAI* ai) { return new SapphironGroundPositionAction(ai); } - static Action* sapphiron_flight_position(PlayerbotAI* ai) { return new SapphironFlightPositionAction(ai); } - // static Action* sapphiron_avoid_chill(PlayerbotAI* ai) { return new SapphironAvoidChillAction(ai); } - static Action* kelthuzad_choose_target(PlayerbotAI* ai) { return new KelthuzadChooseTargetAction(ai); } - static Action* kelthuzad_position(PlayerbotAI* ai) { return new KelthuzadPositionAction(ai); } - static Action* anubrekhan_choose_target(PlayerbotAI* ai) { return new AnubrekhanChooseTargetAction(ai); } - static Action* anubrekhan_position(PlayerbotAI* ai) { return new AnubrekhanPositionAction(ai); } - static Action* gluth_choose_target(PlayerbotAI* ai) { return new GluthChooseTargetAction(ai); } - static Action* gluth_position(PlayerbotAI* ai) { return new GluthPositionAction(ai); } - static Action* gluth_slowdown(PlayerbotAI* ai) { return new GluthSlowdownAction(ai); } - static Action* loatheb_position(PlayerbotAI* ai) { return new LoathebPositionAction(ai); } - static Action* loatheb_choose_target(PlayerbotAI* ai) { return new LoathebChooseTargetAction(ai); } + creators["gluth choose target"] = &RaidNaxxActionContext::gluth_choose_target; + creators["gluth position"] = &RaidNaxxActionContext::gluth_position; + creators["gluth slowdown"] = &RaidNaxxActionContext::gluth_slowdown; + + creators["loatheb position"] = &RaidNaxxActionContext::loatheb_position; + creators["loatheb choose target"] = &RaidNaxxActionContext::loatheb_choose_target; + } + +private: + static Action* go_behind_the_boss(PlayerbotAI* ai) { return new GrobbulusGoBehindAction(ai); } + static Action* rotate_grobbulus(PlayerbotAI* ai) { return new GrobbulusRotateAction(ai); } + static Action* grobbulus_move_center(PlayerbotAI* ai) { return new GrobblulusMoveCenterAction(ai); } + static Action* heigan_dance_melee(PlayerbotAI* ai) { return new HeiganDanceMeleeAction(ai); } + static Action* heigan_dance_ranged(PlayerbotAI* ai) { return new HeiganDanceRangedAction(ai); } + static Action* thaddius_attack_nearest_pet(PlayerbotAI* ai) { return new ThaddiusAttackNearestPetAction(ai); } + // static Action* thaddius_tank_to_place(PlayerbotAI* ai) { return new ThaddiusMeleeToPlaceAction(ai); } + // static Action* thaddius_ranged_to_place(PlayerbotAI* ai) { return new ThaddiusRangedToPlaceAction(ai); } + static Action* thaddius_move_to_platform(PlayerbotAI* ai) { return new ThaddiusMoveToPlatformAction(ai); } + static Action* thaddius_move_polarity(PlayerbotAI* ai) { return new ThaddiusMovePolarityAction(ai); } + static Action* razuvious_target(PlayerbotAI* ai) { return new RazuviousTargetAction(ai); } + static Action* razuvious_use_obedience_crystal(PlayerbotAI* ai) + { + return new RazuviousUseObedienceCrystalAction(ai); + } + static Action* horseman_attract_alternatively(PlayerbotAI* ai) + { + return new HorsemanAttractAlternativelyAction(ai); + } + static Action* horseman_attack_in_order(PlayerbotAI* ai) { return new HorsemanAttactInOrderAction(ai); } + // static Action* sapphiron_ground_main_tank_position(PlayerbotAI* ai) { return new + // SapphironGroundMainTankPositionAction(ai); } + static Action* sapphiron_ground_position(PlayerbotAI* ai) { return new SapphironGroundPositionAction(ai); } + static Action* sapphiron_flight_position(PlayerbotAI* ai) { return new SapphironFlightPositionAction(ai); } + // static Action* sapphiron_avoid_chill(PlayerbotAI* ai) { return new SapphironAvoidChillAction(ai); } + static Action* kelthuzad_choose_target(PlayerbotAI* ai) { return new KelthuzadChooseTargetAction(ai); } + static Action* kelthuzad_position(PlayerbotAI* ai) { return new KelthuzadPositionAction(ai); } + static Action* anubrekhan_choose_target(PlayerbotAI* ai) { return new AnubrekhanChooseTargetAction(ai); } + static Action* anubrekhan_position(PlayerbotAI* ai) { return new AnubrekhanPositionAction(ai); } + static Action* gluth_choose_target(PlayerbotAI* ai) { return new GluthChooseTargetAction(ai); } + static Action* gluth_position(PlayerbotAI* ai) { return new GluthPositionAction(ai); } + static Action* gluth_slowdown(PlayerbotAI* ai) { return new GluthSlowdownAction(ai); } + static Action* loatheb_position(PlayerbotAI* ai) { return new LoathebPositionAction(ai); } + static Action* loatheb_choose_target(PlayerbotAI* ai) { return new LoathebChooseTargetAction(ai); } }; #endif \ No newline at end of file diff --git a/src/strategy/raids/naxxramas/RaidNaxxActions.cpp b/src/strategy/raids/naxxramas/RaidNaxxActions.cpp index 152f0ae1..5d75e31a 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxActions.cpp +++ b/src/strategy/raids/naxxramas/RaidNaxxActions.cpp @@ -1,18 +1,19 @@ +#include "RaidNaxxActions.h" + #include "ObjectGuid.h" #include "PlayerbotAIConfig.h" #include "Playerbots.h" -#include "RaidNaxxActions.h" +#include "RaidNaxxBossHelper.h" #include "RaidNaxxStrategy.h" #include "ScriptedCreature.h" #include "SharedDefines.h" -#include "RaidNaxxBossHelper.h" - bool GrobbulusGoBehindAction::Execute(Event event) { Unit* boss = AI_VALUE(Unit*, "boss target"); - if (!boss) { + if (!boss) + { return false; } // Position* pos = boss->GetPosition(); @@ -29,10 +30,12 @@ uint32 RotateAroundTheCenterPointAction::FindNearestWaypoint() { float minDistance = 0; int ret = -1; - for (int i = 0; i < intervals; i++) { + for (int i = 0; i < intervals; i++) + { float w_x = waypoints[i].first, w_y = waypoints[i].second; float dis = bot->GetDistance2d(w_x, w_y); - if (ret == -1 || dis < minDistance) { + if (ret == -1 || dis < minDistance) + { ret = i; minDistance = dis; } @@ -43,7 +46,8 @@ uint32 RotateAroundTheCenterPointAction::FindNearestWaypoint() uint32 GrobbulusRotateAction::GetCurrWaypoint() { Unit* boss = AI_VALUE(Unit*, "boss target"); - if (!boss) { + if (!boss) + { return false; } auto* boss_ai = dynamic_cast(boss->GetAI()); @@ -52,9 +56,11 @@ uint32 GrobbulusRotateAction::GetCurrWaypoint() return (event_time / 15000) % intervals; } -bool HeiganDanceAction::CalculateSafe() { +bool HeiganDanceAction::CalculateSafe() +{ Unit* boss = AI_VALUE2(Unit*, "find target", "heigan the unclean"); - if (!boss) { + if (!boss) + { return false; } auto* boss_ai = dynamic_cast(boss->GetAI()); @@ -63,9 +69,12 @@ bool HeiganDanceAction::CalculateSafe() { uint32 curr_erupt = eventMap->GetNextEventTime(3); uint32 curr_dance = eventMap->GetNextEventTime(4); uint32 curr_timer = eventMap->GetTimer(); - if ((curr_phase == 0 && curr_dance - curr_timer >= 85000) || (curr_phase == 1 && curr_dance - curr_timer >= 40000)) { + if ((curr_phase == 0 && curr_dance - curr_timer >= 85000) || (curr_phase == 1 && curr_dance - curr_timer >= 40000)) + { ResetSafe(); - } else if (curr_erupt != prev_erupt) { + } + else if (curr_erupt != prev_erupt) + { NextSafe(); } prev_phase = curr_phase; @@ -73,18 +82,23 @@ bool HeiganDanceAction::CalculateSafe() { return true; } -bool HeiganDanceMeleeAction::Execute(Event event) { +bool HeiganDanceMeleeAction::Execute(Event event) +{ CalculateSafe(); - if (prev_phase == 0 && botAI->IsMainTank(bot) && !AI_VALUE2(bool, "has aggro", "boss target")) { + if (prev_phase == 0 && botAI->IsMainTank(bot) && !AI_VALUE2(bool, "has aggro", "boss target")) + { return false; } assert(curr_safe >= 0 && curr_safe <= 3); - return MoveInside(bot->GetMapId(), waypoints[curr_safe].first, waypoints[curr_safe].second, bot->GetPositionZ(), botAI->IsMainTank(bot) ? 0 : 0); + return MoveInside(bot->GetMapId(), waypoints[curr_safe].first, waypoints[curr_safe].second, bot->GetPositionZ(), + botAI->IsMainTank(bot) ? 0 : 0); } -bool HeiganDanceRangedAction::Execute(Event event) { +bool HeiganDanceRangedAction::Execute(Event event) +{ CalculateSafe(); - if (prev_phase != 1) { + if (prev_phase != 1) + { return MoveTo(bot->GetMapId(), platform.first, platform.second, 276.54f); } botAI->InterruptSpell(); @@ -93,44 +107,50 @@ bool HeiganDanceRangedAction::Execute(Event event) { bool ThaddiusAttackNearestPetAction::isUseful() { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } - if (!helper.IsPhasePet()) { + if (!helper.IsPhasePet()) + { return false; } Unit* target = helper.GetNearestPet(); - if (bot->GetDistance(target) > 50.0f) { + if (bot->GetDistance(target) > 50.0f) + { return false; } return true; } -bool ThaddiusAttackNearestPetAction::Execute(Event event) { +bool ThaddiusAttackNearestPetAction::Execute(Event event) +{ Unit* target = helper.GetNearestPet(); - if (!bot->IsWithinLOSInMap(target)) { + if (!bot->IsWithinLOSInMap(target)) + { return MoveTo(target); } - if (AI_VALUE(Unit*, "current target") != target) { + if (AI_VALUE(Unit*, "current target") != target) + { return Attack(target); } - if (botAI->IsTank(bot) && AI_VALUE2(bool, "has aggro", "current target")) { + if (botAI->IsTank(bot) && AI_VALUE2(bool, "has aggro", "current target")) + { std::pair posForTank = helper.PetPhaseGetPosForTank(); return MoveTo(533, posForTank.first, posForTank.second, helper.tankPosZ); } - if (botAI->IsRanged(bot)) { + if (botAI->IsRanged(bot)) + { std::pair posForRanged = helper.PetPhaseGetPosForRanged(); return MoveTo(533, posForRanged.first, posForRanged.second, helper.tankPosZ); } return false; } -bool ThaddiusMoveToPlatformAction::isUseful() -{ - return true; -} +bool ThaddiusMoveToPlatformAction::isUseful() { return true; } -bool ThaddiusMoveToPlatformAction::Execute(Event event) { +bool ThaddiusMoveToPlatformAction::Execute(Event event) +{ std::vector> position = { // high left {3462.99f, -2918.90f}, @@ -144,28 +164,39 @@ bool ThaddiusMoveToPlatformAction::Execute(Event event) { {3512.19f, -2928.58f}, }; float high_z = 312.00f, low_z = 304.02f; - bool is_left = bot->GetDistance2d(position[0].first, position[0].second) < bot->GetDistance2d(position[1].first, position[1].second); - if (bot->GetPositionZ() >= (high_z - 3.0f)) { - if (is_left) { - if (!MoveTo(bot->GetMapId(), position[0].first, position[0].second, high_z)) { + bool is_left = bot->GetDistance2d(position[0].first, position[0].second) < + bot->GetDistance2d(position[1].first, position[1].second); + if (bot->GetPositionZ() >= (high_z - 3.0f)) + { + if (is_left) + { + if (!MoveTo(bot->GetMapId(), position[0].first, position[0].second, high_z)) + { bot->TeleportTo(bot->GetMapId(), position[2].first, position[2].second, low_z, bot->GetOrientation()); } - } else { - if (!MoveTo(bot->GetMapId(), position[1].first, position[1].second, high_z)) { + } + else + { + if (!MoveTo(bot->GetMapId(), position[1].first, position[1].second, high_z)) + { bot->TeleportTo(bot->GetMapId(), position[3].first, position[3].second, low_z, bot->GetOrientation()); } } - } else { + } + else + { return MoveTo(bot->GetMapId(), position[4].first, position[4].second, low_z); } return true; } -bool ThaddiusMovePolarityAction::isUseful() { +bool ThaddiusMovePolarityAction::isUseful() +{ return !botAI->IsMainTank(bot) || AI_VALUE2(bool, "has aggro", "current target"); } -bool ThaddiusMovePolarityAction::Execute(Event event) { +bool ThaddiusMovePolarityAction::Execute(Event event) +{ std::vector> position = { // left melee {3508.29f, -2920.12f}, @@ -181,11 +212,16 @@ bool ThaddiusMovePolarityAction::Execute(Event event) { {3504.68f, -2936.68f}, }; uint32 idx; - if (botAI->HasAura("negative charge", bot, false, false, -1, true)) { + if (botAI->HasAura("negative charge", bot, false, false, -1, true)) + { idx = 0; - } else if (botAI->HasAura("positive charge", bot, false, false, -1, true)) { + } + else if (botAI->HasAura("positive charge", bot, false, false, -1, true)) + { idx = 1; - } else { + } + else + { idx = 2; } idx = idx * 2 + botAI->IsRanged(bot); @@ -194,48 +230,63 @@ bool ThaddiusMovePolarityAction::Execute(Event event) { bool RazuviousUseObedienceCrystalAction::Execute(Event event) { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } // bot->GetCharm - if (Unit* charm = bot->GetCharm()) { + if (Unit* charm = bot->GetCharm()) + { Unit* target = AI_VALUE2(Unit*, "find target", "instructor razuvious"); - if (!target) { + if (!target) + { return false; } - if (charm->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_ACTIVE) == NULL_MOTION_TYPE) { + if (charm->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_ACTIVE) == NULL_MOTION_TYPE) + { charm->GetMotionMaster()->Clear(); charm->GetMotionMaster()->MoveChase(target); charm->GetAI()->AttackStart(target); } Aura* forceObedience = botAI->GetAura("force obedience", charm); uint32 duration_time; - if (!forceObedience) { + if (!forceObedience) + { forceObedience = botAI->GetAura("mind control", charm); duration_time = 60000; - } else { + } + else + { duration_time = 90000; } - if (!forceObedience) { + if (!forceObedience) + { return false; } - if (charm->GetDistance(target) <= 0.51f) { + if (charm->GetDistance(target) <= 0.51f) + { // taunt bool tauntUseful = true; - if (forceObedience->GetDuration() <= (duration_time - 5000)) { - if (target->GetVictim() && botAI->HasAura(29061, target->GetVictim())) { + if (forceObedience->GetDuration() <= (duration_time - 5000)) + { + if (target->GetVictim() && botAI->HasAura(29061, target->GetVictim())) + { tauntUseful = false; } - if (forceObedience->GetDuration() <= 3000) { + if (forceObedience->GetDuration() <= 3000) + { tauntUseful = false; } } - if (forceObedience->GetDuration() >= (duration_time - 500)) { + if (forceObedience->GetDuration() >= (duration_time - 500)) + { tauntUseful = false; } - if ( tauntUseful && !charm->HasSpellCooldown(29060) ) { + if (tauntUseful && !charm->HasSpellCooldown(29060)) + { // shield - if (!charm->HasSpellCooldown(29061)) { + if (!charm->HasSpellCooldown(29061)) + { charm->CastSpell(charm, 29061, true); charm->AddSpellCooldown(29061, 0, 30 * 1000); } @@ -243,52 +294,68 @@ bool RazuviousUseObedienceCrystalAction::Execute(Event event) charm->AddSpellCooldown(29060, 0, 20 * 1000); } // strike - if (!charm->HasSpellCooldown(61696)) { + if (!charm->HasSpellCooldown(61696)) + { charm->CastSpell(target, 61696, true); charm->AddSpellCooldown(61696, 0, 4 * 1000); } } - } else { + } + else + { Difficulty diff = bot->GetRaidDifficulty(); - if (diff == RAID_DIFFICULTY_10MAN_NORMAL) { + if (diff == RAID_DIFFICULTY_10MAN_NORMAL) + { GuidVector npcs = AI_VALUE(GuidVector, "nearest npcs"); for (auto i = npcs.begin(); i != npcs.end(); i++) { Creature* unit = botAI->GetCreature(*i); - if (!unit) { + if (!unit) + { continue; } - if (botAI->IsMainTank(bot) && unit->GetSpawnId() != 128352) { + if (botAI->IsMainTank(bot) && unit->GetSpawnId() != 128352) + { continue; } - if (!botAI->IsMainTank(bot) && unit->GetSpawnId() != 128353) { + if (!botAI->IsMainTank(bot) && unit->GetSpawnId() != 128353) + { continue; } - if (MoveTo(unit)) { + if (MoveTo(unit)) + { return true; } - Creature *creature = bot->GetNPCIfCanInteractWith(*i, UNIT_NPC_FLAG_SPELLCLICK); + Creature* creature = bot->GetNPCIfCanInteractWith(*i, UNIT_NPC_FLAG_SPELLCLICK); if (!creature) continue; creature->HandleSpellClick(bot); return true; } - } else { + } + else + { GuidVector attackers = context->GetValue("attackers")->Get(); Unit* target = nullptr; - for (auto i = attackers.begin(); i != attackers.end(); ++i) { + for (auto i = attackers.begin(); i != attackers.end(); ++i) + { Unit* unit = botAI->GetUnit(*i); if (!unit) continue; - if (botAI->EqualLowercaseName(unit->GetName(), "death knight understudy")) { + if (botAI->EqualLowercaseName(unit->GetName(), "death knight understudy")) + { target = unit; break; } } - if (target) { - if (bot->GetDistance2d(target) > sPlayerbotAIConfig->spellDistance) { + if (target) + { + if (bot->GetDistance2d(target) > sPlayerbotAIConfig->spellDistance) + { return MoveNear(target, sPlayerbotAIConfig->spellDistance); - } else { + } + else + { return botAI->CastSpell("mind control", target); } } @@ -299,18 +366,23 @@ bool RazuviousUseObedienceCrystalAction::Execute(Event event) bool RazuviousTargetAction::Execute(Event event) { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } Unit* razuvious = AI_VALUE2(Unit*, "find target", "instructor razuvious"); Unit* understudy = AI_VALUE2(Unit*, "find target", "death knight understudy"); Unit* target = nullptr; - if (botAI->IsTank(bot)) { + if (botAI->IsTank(bot)) + { target = understudy; - } else { + } + else + { target = razuvious; } - if (AI_VALUE(Unit*, "current target") == target) { + if (AI_VALUE(Unit*, "current target") == target) + { return false; } return Attack(target); @@ -318,16 +390,19 @@ bool RazuviousTargetAction::Execute(Event event) bool HorsemanAttractAlternativelyAction::Execute(Event event) { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } helper.CalculatePosToGo(bot); auto [posX, posY] = helper.CurrentAttractPos(); - if (MoveTo(bot->GetMapId(), posX, posY, helper.posZ)) { + if (MoveTo(bot->GetMapId(), posX, posY, helper.posZ)) + { return true; } Unit* attackTarget = helper.CurrentAttackTarget(); - if (context->GetValue("current target")->Get() != attackTarget) { + if (context->GetValue("current target")->Get() != attackTarget) + { return Attack(attackTarget); } return false; @@ -335,7 +410,8 @@ bool HorsemanAttractAlternativelyAction::Execute(Event event) bool HorsemanAttactInOrderAction::Execute(Event event) { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } Unit* target = nullptr; @@ -344,22 +420,30 @@ bool HorsemanAttactInOrderAction::Execute(Event event) Unit* lady = AI_VALUE2(Unit*, "find target", "lady blaumeux"); Unit* sir = AI_VALUE2(Unit*, "find target", "sir zeliek"); std::vector attack_order; - if (botAI->IsAssistTank(bot)) { + if (botAI->IsAssistTank(bot)) + { attack_order = {baron, thane, lady, sir}; - } else { + } + else + { attack_order = {thane, baron, lady, sir}; } - for (Unit* t : attack_order) { - if (t && t->IsAlive()) { + for (Unit* t : attack_order) + { + if (t && t->IsAlive()) + { target = t; break; } } - if (target) { - if (context->GetValue("current target")->Get() == target && botAI->GetState() == BOT_STATE_COMBAT) { + if (target) + { + if (context->GetValue("current target")->Get() == target && botAI->GetState() == BOT_STATE_COMBAT) + { return false; } - if (!bot->IsWithinLOSInMap(target)) { + if (!bot->IsWithinLOSInMap(target)) + { return MoveNear(target, 22.0f); } return Attack(target); @@ -369,32 +453,45 @@ bool HorsemanAttactInOrderAction::Execute(Event event) bool SapphironGroundPositionAction::Execute(Event event) { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } - if (botAI->IsMainTank(bot)) { - if (AI_VALUE2(bool, "has aggro", "current target")) { + if (botAI->IsMainTank(bot)) + { + if (AI_VALUE2(bool, "has aggro", "current target")) + { return MoveTo(NAXX_MAP_ID, helper.mainTankPos.first, helper.mainTankPos.second, helper.GENERIC_HEIGHT); } return false; - } - if (helper.JustLanded()) { + } + if (helper.JustLanded()) + { uint32 index = botAI->GetGroupSlotIndex(bot); float start_angle = 0.85 * M_PI; float offset_angle = M_PI * 0.02 * index; float angle = start_angle + offset_angle; float distance; - if (botAI->IsRanged(bot)) { + if (botAI->IsRanged(bot)) + { distance = 35.0f; - } else if (botAI->IsHeal(bot)) { + } + else if (botAI->IsHeal(bot)) + { distance = 30.0f; - } else { + } + else + { distance = 5.0f; } - return MoveTo(NAXX_MAP_ID, helper.center.first + cos(angle) * distance, helper.center.second + sin(angle) * distance, helper.GENERIC_HEIGHT); - } else { + return MoveTo(NAXX_MAP_ID, helper.center.first + cos(angle) * distance, + helper.center.second + sin(angle) * distance, helper.GENERIC_HEIGHT); + } + else + { std::vector dest; - if (helper.FindPosToAvoidChill(dest)) { + if (helper.FindPosToAvoidChill(dest)) + { return MoveTo(NAXX_MAP_ID, dest[0], dest[1], dest[2]); } } @@ -403,14 +500,19 @@ bool SapphironGroundPositionAction::Execute(Event event) bool SapphironFlightPositionAction::Execute(Event event) { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } - if (helper.WaitForExplosion()) { + if (helper.WaitForExplosion()) + { return MoveToNearestIcebolt(); - } else { + } + else + { std::vector dest; - if (helper.FindPosToAvoidChill(dest)) { + if (helper.FindPosToAvoidChill(dest)) + { return MoveTo(NAXX_MAP_ID, dest[0], dest[1], dest[2]); } } @@ -420,26 +522,33 @@ bool SapphironFlightPositionAction::Execute(Event event) bool SapphironFlightPositionAction::MoveToNearestIcebolt() { Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { return false; } Group::MemberSlotList const& slots = group->GetMemberSlots(); Player* playerWithIcebolt = nullptr; float minDistance; - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { Player* member = ref->GetSource(); - if (botAI->HasAura("icebolt", member, false, false, -1, true)) { - if (!playerWithIcebolt || minDistance > bot->GetDistance(member)) { + if (botAI->HasAura("icebolt", member, false, false, -1, true)) + { + if (!playerWithIcebolt || minDistance > bot->GetDistance(member)) + { playerWithIcebolt = member; minDistance = bot->GetDistance(member); } } } - if (playerWithIcebolt) { + if (playerWithIcebolt) + { Unit* boss = AI_VALUE2(Unit*, "find target", "sapphiron"); - if (boss) { + if (boss) + { float angle = boss->GetAngle(playerWithIcebolt); - return MoveTo(NAXX_MAP_ID, playerWithIcebolt->GetPositionX() + cos(angle) * 3.0f, playerWithIcebolt->GetPositionY() + sin(angle) * 3.0f, helper.GENERIC_HEIGHT); + return MoveTo(NAXX_MAP_ID, playerWithIcebolt->GetPositionX() + cos(angle) * 3.0f, + playerWithIcebolt->GetPositionY() + sin(angle) * 3.0f, helper.GENERIC_HEIGHT); } } return false; @@ -447,83 +556,114 @@ bool SapphironFlightPositionAction::MoveToNearestIcebolt() bool KelthuzadChooseTargetAction::Execute(Event event) { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } GuidVector attackers = context->GetValue("attackers")->Get(); Unit* target = nullptr; - Unit *target_soldier = nullptr, *target_weaver = nullptr, *target_abomination = nullptr, *target_kelthuzad = nullptr, *target_guardian = nullptr; + Unit *target_soldier = nullptr, *target_weaver = nullptr, *target_abomination = nullptr, + *target_kelthuzad = nullptr, *target_guardian = nullptr; for (auto i = attackers.begin(); i != attackers.end(); ++i) { Unit* unit = botAI->GetUnit(*i); if (!unit) continue; - if (botAI->EqualLowercaseName(unit->GetName(), "guardian of icecrown")) { - if (!target_guardian) { + if (botAI->EqualLowercaseName(unit->GetName(), "guardian of icecrown")) + { + if (!target_guardian) + { target_guardian = unit; - } else if (unit->GetVictim() && target_guardian->GetVictim() && - unit->GetVictim()->ToPlayer() && target_guardian->GetVictim()->ToPlayer() && - !botAI->IsAssistTank(unit->GetVictim()->ToPlayer()) && botAI->IsAssistTank(target_guardian->GetVictim()->ToPlayer())) { + } + else if (unit->GetVictim() && target_guardian->GetVictim() && unit->GetVictim()->ToPlayer() && + target_guardian->GetVictim()->ToPlayer() && !botAI->IsAssistTank(unit->GetVictim()->ToPlayer()) && + botAI->IsAssistTank(target_guardian->GetVictim()->ToPlayer())) + { target_guardian = unit; - } else if (unit->GetVictim() && target_guardian->GetVictim() && - unit->GetVictim()->ToPlayer() && target_guardian->GetVictim()->ToPlayer() && - !botAI->IsAssistTank(unit->GetVictim()->ToPlayer()) && !botAI->IsAssistTank(target_guardian->GetVictim()->ToPlayer()) && - target_guardian->GetDistance2d(helper.center.first, helper.center.second) > bot->GetDistance2d(unit)) { + } + else if (unit->GetVictim() && target_guardian->GetVictim() && unit->GetVictim()->ToPlayer() && + target_guardian->GetVictim()->ToPlayer() && !botAI->IsAssistTank(unit->GetVictim()->ToPlayer()) && + !botAI->IsAssistTank(target_guardian->GetVictim()->ToPlayer()) && + target_guardian->GetDistance2d(helper.center.first, helper.center.second) > + bot->GetDistance2d(unit)) + { target_guardian = unit; } } - - if (unit->GetDistance2d(helper.center.first, helper.center.second) > 30.0f) { + + if (unit->GetDistance2d(helper.center.first, helper.center.second) > 30.0f) + { continue; } - if (bot->GetDistance2d(unit) > sPlayerbotAIConfig->spellDistance) { + if (bot->GetDistance2d(unit) > sPlayerbotAIConfig->spellDistance) + { continue; } - if (botAI->EqualLowercaseName(unit->GetName(), "unstoppable abomination")) { - if (target_abomination == nullptr || - target_abomination->GetDistance2d(helper.center.first, helper.center.second) > unit->GetDistance2d(helper.center.first, helper.center.second)) { + if (botAI->EqualLowercaseName(unit->GetName(), "unstoppable abomination")) + { + if (target_abomination == nullptr || + target_abomination->GetDistance2d(helper.center.first, helper.center.second) > + unit->GetDistance2d(helper.center.first, helper.center.second)) + { target_abomination = unit; } } - if (botAI->EqualLowercaseName(unit->GetName(), "soldier of the frozen wastes")) { - if (target_soldier == nullptr || - target_soldier->GetDistance2d(helper.center.first, helper.center.second) > unit->GetDistance2d(helper.center.first, helper.center.second)) { + if (botAI->EqualLowercaseName(unit->GetName(), "soldier of the frozen wastes")) + { + if (target_soldier == nullptr || target_soldier->GetDistance2d(helper.center.first, helper.center.second) > + unit->GetDistance2d(helper.center.first, helper.center.second)) + { target_soldier = unit; } } - if (botAI->EqualLowercaseName(unit->GetName(), "soul weaver")) { - if (target_weaver == nullptr || - target_weaver->GetDistance2d(helper.center.first, helper.center.second) > unit->GetDistance2d(helper.center.first, helper.center.second)) { + if (botAI->EqualLowercaseName(unit->GetName(), "soul weaver")) + { + if (target_weaver == nullptr || target_weaver->GetDistance2d(helper.center.first, helper.center.second) > + unit->GetDistance2d(helper.center.first, helper.center.second)) + { target_weaver = unit; } } - if (botAI->EqualLowercaseName(unit->GetName(), "kel'thuzad")) { + if (botAI->EqualLowercaseName(unit->GetName(), "kel'thuzad")) + { target_kelthuzad = unit; } } std::vector targets; - if (botAI->IsRanged(bot)) { - if (botAI->GetRangedDpsIndex(bot) <= 1) { + if (botAI->IsRanged(bot)) + { + if (botAI->GetRangedDpsIndex(bot) <= 1) + { targets = {target_soldier, target_weaver, target_abomination, target_kelthuzad}; - } else { + } + else + { targets = {target_weaver, target_soldier, target_abomination, target_kelthuzad}; } - } else if (botAI->IsAssistTank(bot)) { + } + else if (botAI->IsAssistTank(bot)) + { targets = {target_abomination, target_guardian, target_kelthuzad}; - } else { + } + else + { targets = {target_abomination, target_kelthuzad}; } - for (Unit* t : targets) { - if (t) { + for (Unit* t : targets) + { + if (t) + { target = t; break; } } - if (context->GetValue("current target")->Get() == target) { + if (context->GetValue("current target")->Get() == target) + { return false; } - if (target_kelthuzad && target == target_kelthuzad) { + if (target_kelthuzad && target == target_kelthuzad) + { return Attack(target, true); } return Attack(target, false); @@ -531,29 +671,44 @@ bool KelthuzadChooseTargetAction::Execute(Event event) bool KelthuzadPositionAction::Execute(Event event) { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } - if (helper.IsPhaseOne()) { - if (AI_VALUE(Unit*, "current target") == nullptr) { + if (helper.IsPhaseOne()) + { + if (AI_VALUE(Unit*, "current target") == nullptr) + { return MoveInside(NAXX_MAP_ID, helper.center.first, helper.center.second, bot->GetPositionZ(), 3.0f); } - } else if (helper.IsPhaseTwo()) { + } + else if (helper.IsPhaseTwo()) + { Unit* shadow_fissure = helper.GetAnyShadowFissure(); - if (!shadow_fissure || bot->GetDistance2d(shadow_fissure) > 10.0f) { + if (!shadow_fissure || bot->GetDistance2d(shadow_fissure) > 10.0f) + { float distance, angle; - if (botAI->IsMainTank(bot)) { - if (AI_VALUE2(bool, "has aggro", "current target")) { + if (botAI->IsMainTank(bot)) + { + if (AI_VALUE2(bool, "has aggro", "current target")) + { return MoveTo(NAXX_MAP_ID, helper.tank_pos.first, helper.tank_pos.second, bot->GetPositionZ()); - } else { + } + else + { return false; } - } else if (botAI->IsRanged(bot)) { + } + else if (botAI->IsRanged(bot)) + { uint32 index = botAI->GetRangedIndex(bot); - if (index < 8) { + if (index < 8) + { distance = 20.0f; angle = index * M_PI / 4; - } else { + } + else + { distance = 32.0f; angle = (index - 8) * M_PI / 4; } @@ -561,22 +716,33 @@ bool KelthuzadPositionAction::Execute(Event event) dx = helper.center.first + cos(angle) * distance; dy = helper.center.second + sin(angle) * distance; return MoveTo(NAXX_MAP_ID, dx, dy, bot->GetPositionZ()); - } else if (botAI->IsTank(bot)) { + } + else if (botAI->IsTank(bot)) + { Unit* cur_tar = AI_VALUE(Unit*, "current target"); - if (cur_tar && cur_tar->GetVictim() && cur_tar->GetVictim()->ToPlayer() && - botAI->EqualLowercaseName(cur_tar->GetName(), "guardian of icecrown") && - botAI->IsAssistTank(cur_tar->GetVictim()->ToPlayer()) ) { - return MoveTo(NAXX_MAP_ID, helper.assist_tank_pos.first, helper.assist_tank_pos.second, bot->GetPositionZ()); - } else { + if (cur_tar && cur_tar->GetVictim() && cur_tar->GetVictim()->ToPlayer() && + botAI->EqualLowercaseName(cur_tar->GetName(), "guardian of icecrown") && + botAI->IsAssistTank(cur_tar->GetVictim()->ToPlayer())) + { + return MoveTo(NAXX_MAP_ID, helper.assist_tank_pos.first, helper.assist_tank_pos.second, + bot->GetPositionZ()); + } + else + { return false; } } - } else { + } + else + { float dx, dy; float angle; - if (!botAI->IsRanged(bot)) { + if (!botAI->IsRanged(bot)) + { angle = shadow_fissure->GetAngle(helper.center.first, helper.center.second); - } else { + } + else + { angle = bot->GetAngle(shadow_fissure) + M_PI; } dx = shadow_fissure->GetPositionX() + cos(angle) * 10.0f; @@ -589,44 +755,61 @@ bool KelthuzadPositionAction::Execute(Event event) bool AnubrekhanChooseTargetAction::Execute(Event event) { - GuidVector attackers = context->GetValue("attackers")->Get(); + GuidVector attackers = context->GetValue("attackers")->Get(); Unit* target = nullptr; - Unit *target_boss = nullptr; + Unit* target_boss = nullptr; std::vector target_guards; for (ObjectGuid const guid : attackers) { Unit* unit = botAI->GetUnit(guid); if (!unit) continue; - if (botAI->EqualLowercaseName(unit->GetName(), "crypt guard")) { + if (botAI->EqualLowercaseName(unit->GetName(), "crypt guard")) + { target_guards.push_back(unit); } - if (botAI->EqualLowercaseName(unit->GetName(), "anub'rekhan")) { + if (botAI->EqualLowercaseName(unit->GetName(), "anub'rekhan")) + { target_boss = unit; } } - if (botAI->IsMainTank(bot)) { + if (botAI->IsMainTank(bot)) + { target = target_boss; - } else { - if (target_guards.size() == 0) { + } + else + { + if (target_guards.size() == 0) + { target = target_boss; - } else { - if (botAI->IsAssistTank(bot)) { - for (Unit* t : target_guards) { - if (target == nullptr || (target->GetVictim() && target->GetVictim()->ToPlayer() && botAI->IsTank(target->GetVictim()->ToPlayer()))) { + } + else + { + if (botAI->IsAssistTank(bot)) + { + for (Unit* t : target_guards) + { + if (target == nullptr || (target->GetVictim() && target->GetVictim()->ToPlayer() && + botAI->IsTank(target->GetVictim()->ToPlayer()))) + { target = t; } } - } else { - for (Unit* t : target_guards) { - if (target == nullptr || target->GetHealthPct() > t->GetHealthPct()) { + } + else + { + for (Unit* t : target_guards) + { + if (target == nullptr || target->GetHealthPct() > t->GetHealthPct()) + { target = t; } } } } } - if (context->GetValue("current target")->Get() == target) { + if (context->GetValue("current target")->Get() == target) + { return false; } return Attack(target); @@ -635,28 +818,38 @@ bool AnubrekhanChooseTargetAction::Execute(Event event) bool AnubrekhanPositionAction::Execute(Event event) { Unit* boss = AI_VALUE2(Unit*, "find target", "anub'rekhan"); - if (!boss) { + if (!boss) + { return false; } auto* boss_ai = dynamic_cast(boss->GetAI()); - if (!boss_ai) { + if (!boss_ai) + { return false; } - EventMap *eventMap = &boss_ai->events; + EventMap* eventMap = &boss_ai->events; uint32 locust = eventMap->GetNextEventTime(2); uint32 timer = eventMap->GetTimer(); bool inPhase = botAI->HasAura("locust swarm", boss) || boss->GetCurrentSpell(CURRENT_GENERIC_SPELL); - if (inPhase || (locust && locust - timer <= 8000)) { - if (botAI->IsMainTank(bot)) { + if (inPhase || (locust && locust - timer <= 8000)) + { + if (botAI->IsMainTank(bot)) + { uint32 nearest = FindNearestWaypoint(); uint32 next_point; - if (inPhase || (locust && locust - timer <= 3000)) { + if (inPhase || (locust && locust - timer <= 3000)) + { next_point = (nearest + 1) % intervals; - } else { + } + else + { next_point = nearest; } - return MoveTo(bot->GetMapId(), waypoints[next_point].first, waypoints[next_point].second, bot->GetPositionZ()); - } else { + return MoveTo(bot->GetMapId(), waypoints[next_point].first, waypoints[next_point].second, + bot->GetPositionZ()); + } + else + { return MoveInside(533, 3272.49f, -3476.27f, bot->GetPositionZ(), 3.0f); } } @@ -665,65 +858,90 @@ bool AnubrekhanPositionAction::Execute(Event event) bool GluthChooseTargetAction::Execute(Event event) { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } GuidVector attackers = context->GetValue("possible targets")->Get(); Unit* target = nullptr; - Unit *target_boss = nullptr; + Unit* target_boss = nullptr; std::vector target_zombies; for (GuidVector::iterator i = attackers.begin(); i != attackers.end(); ++i) { Unit* unit = botAI->GetUnit(*i); if (!unit) continue; - if (!unit->IsAlive()) { + if (!unit->IsAlive()) + { continue; } - if (botAI->EqualLowercaseName(unit->GetName(), "zombie chow")) { + if (botAI->EqualLowercaseName(unit->GetName(), "zombie chow")) + { target_zombies.push_back(unit); } - if (botAI->EqualLowercaseName(unit->GetName(), "gluth")) { + if (botAI->EqualLowercaseName(unit->GetName(), "gluth")) + { target_boss = unit; } } - if (botAI->IsMainTank(bot) || botAI->IsAssistTankOfIndex(bot, 0)) { + if (botAI->IsMainTank(bot) || botAI->IsAssistTankOfIndex(bot, 0)) + { target = target_boss; - } else if (botAI->IsAssistTankOfIndex(bot, 1)) { - for (Unit* t : target_zombies) { - if (t->GetHealthPct() > helper.decimatedZombiePct && t->GetVictim() != bot && t->GetDistance2d(bot) <= 10.0f) { - if (!target || t->GetDistance2d(bot) < target->GetDistance2d(bot)) { + } + else if (botAI->IsAssistTankOfIndex(bot, 1)) + { + for (Unit* t : target_zombies) + { + if (t->GetHealthPct() > helper.decimatedZombiePct && t->GetVictim() != bot && + t->GetDistance2d(bot) <= 10.0f) + { + if (!target || t->GetDistance2d(bot) < target->GetDistance2d(bot)) + { target = t; } } } - } else if (botAI->GetClassIndex(bot, CLASS_HUNTER) == 0 || botAI->GetClassIndex(bot, CLASS_HUNTER) == 1) { + } + else if (botAI->GetClassIndex(bot, CLASS_HUNTER) == 0 || botAI->GetClassIndex(bot, CLASS_HUNTER) == 1) + { // prevent zombie go straight to gluth - for (Unit* t : target_zombies) { - if (t->GetHealthPct() > helper.decimatedZombiePct && t->GetVictim() == target_boss && t->GetDistance2d(bot) <= sPlayerbotAIConfig->spellDistance) { - if (!target || t->GetDistance2d(bot) < target->GetDistance2d(bot)) { + for (Unit* t : target_zombies) + { + if (t->GetHealthPct() > helper.decimatedZombiePct && t->GetVictim() == target_boss && + t->GetDistance2d(bot) <= sPlayerbotAIConfig->spellDistance) + { + if (!target || t->GetDistance2d(bot) < target->GetDistance2d(bot)) + { target = t; } } } - if (!target) { - target = target_boss; - } - } else { - for (Unit* t : target_zombies) { - if (t->GetHealthPct() <= helper.decimatedZombiePct) { - if (target == nullptr || - target->GetDistance2d(helper.mainTankPos25.first, helper.mainTankPos25.second) > - t->GetDistance2d(helper.mainTankPos25.first, helper.mainTankPos25.second)) { - target = t; - } - } - } - if (target == nullptr) { + if (!target) + { target = target_boss; } } - if (!target || context->GetValue("current target")->Get() == target) { + else + { + for (Unit* t : target_zombies) + { + if (t->GetHealthPct() <= helper.decimatedZombiePct) + { + if (target == nullptr || + target->GetDistance2d(helper.mainTankPos25.first, helper.mainTankPos25.second) > + t->GetDistance2d(helper.mainTankPos25.first, helper.mainTankPos25.second)) + { + target = t; + } + } + } + if (target == nullptr) + { + target = target_boss; + } + } + if (!target || context->GetValue("current target")->Get() == target) + { return false; } if (target_boss && target == target_boss) @@ -734,57 +952,85 @@ bool GluthChooseTargetAction::Execute(Event event) bool GluthPositionAction::Execute(Event event) { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } bool raid25 = bot->GetRaidDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL; - if (botAI->IsMainTank(bot) || botAI->IsAssistTankOfIndex(bot, 0)) { - if (AI_VALUE2(bool, "has aggro", "boss target")) { - if (raid25) { - return MoveTo(NAXX_MAP_ID, helper.mainTankPos25.first, helper.mainTankPos25.second, bot->GetPositionZ()); - } else { - return MoveTo(NAXX_MAP_ID, helper.mainTankPos10.first, helper.mainTankPos10.second, bot->GetPositionZ()); + if (botAI->IsMainTank(bot) || botAI->IsAssistTankOfIndex(bot, 0)) + { + if (AI_VALUE2(bool, "has aggro", "boss target")) + { + if (raid25) + { + return MoveTo(NAXX_MAP_ID, helper.mainTankPos25.first, helper.mainTankPos25.second, + bot->GetPositionZ()); + } + else + { + return MoveTo(NAXX_MAP_ID, helper.mainTankPos10.first, helper.mainTankPos10.second, + bot->GetPositionZ()); } } - } else if (botAI->IsAssistTankOfIndex(bot, 1)) { - if (helper.BeforeDecimate()) { - return MoveTo(bot->GetMapId(), helper.beforeDecimatePos.first, helper.beforeDecimatePos.second, bot->GetPositionZ()); - } else { - if (AI_VALUE2(bool, "has aggro", "current target")) { + } + else if (botAI->IsAssistTankOfIndex(bot, 1)) + { + if (helper.BeforeDecimate()) + { + return MoveTo(bot->GetMapId(), helper.beforeDecimatePos.first, helper.beforeDecimatePos.second, + bot->GetPositionZ()); + } + else + { + if (AI_VALUE2(bool, "has aggro", "current target")) + { uint32 nearest = FindNearestWaypoint(); uint32 next_point = (nearest + 1) % intervals; - return MoveTo(bot->GetMapId(), waypoints[next_point].first, waypoints[next_point].second, bot->GetPositionZ()); + return MoveTo(bot->GetMapId(), waypoints[next_point].first, waypoints[next_point].second, + bot->GetPositionZ()); } } - } else if (botAI->IsRangedDps(bot)) { - if (raid25) { - if (botAI->GetClassIndex(bot, CLASS_HUNTER) == 0) { - return MoveInside(NAXX_MAP_ID, helper.leftSlowDownPos.first, helper.leftSlowDownPos.second, bot->GetPositionZ(), 0.0f); + } + else if (botAI->IsRangedDps(bot)) + { + if (raid25) + { + if (botAI->GetClassIndex(bot, CLASS_HUNTER) == 0) + { + return MoveInside(NAXX_MAP_ID, helper.leftSlowDownPos.first, helper.leftSlowDownPos.second, + bot->GetPositionZ(), 0.0f); } - if (botAI->GetClassIndex(bot, CLASS_HUNTER) == 1) { - return MoveInside(NAXX_MAP_ID, helper.rightSlowDownPos.first, helper.rightSlowDownPos.second, bot->GetPositionZ(), 0.0f); + if (botAI->GetClassIndex(bot, CLASS_HUNTER) == 1) + { + return MoveInside(NAXX_MAP_ID, helper.rightSlowDownPos.first, helper.rightSlowDownPos.second, + bot->GetPositionZ(), 0.0f); } } return MoveInside(NAXX_MAP_ID, helper.rangedPos.first, helper.rangedPos.second, bot->GetPositionZ(), 3.0f); - } else if (botAI->IsHeal(bot)) { + } + else if (botAI->IsHeal(bot)) + { return MoveInside(NAXX_MAP_ID, helper.healPos.first, helper.healPos.second, bot->GetPositionZ(), 0.0f); } return false; } bool GluthSlowdownAction::Execute(Event event) -{ - if (!helper.UpdateBossAI()) { +{ + if (!helper.UpdateBossAI()) + { return false; } bool raid25 = bot->GetRaidDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL; - if (!raid25) { + if (!raid25) + { return false; } - if (helper.JustStartCombat()) { + if (helper.JustStartCombat()) + { return false; } - switch (bot->getClass()) + switch (bot->getClass()) { case CLASS_HUNTER: return botAI->CastSpell("frost trap", bot); @@ -797,14 +1043,19 @@ bool GluthSlowdownAction::Execute(Event event) bool LoathebPositionAction::Execute(Event event) { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } - if (botAI->IsTank(bot)) { - if (AI_VALUE2(bool, "has aggro", "boss target")) { + if (botAI->IsTank(bot)) + { + if (AI_VALUE2(bool, "has aggro", "boss target")) + { return MoveTo(533, helper.mainTankPos.first, helper.mainTankPos.second, bot->GetPositionZ()); } - } else if (botAI->IsRanged(bot)) { + } + else if (botAI->IsRanged(bot)) + { return MoveInside(533, helper.rangePos.first, helper.rangePos.second, bot->GetPositionZ(), 1.0f); } return false; @@ -812,34 +1063,42 @@ bool LoathebPositionAction::Execute(Event event) bool LoathebChooseTargetAction::Execute(Event event) { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } GuidVector attackers = context->GetValue("attackers")->Get(); Unit* target = nullptr; - Unit *target_boss = nullptr; - Unit *target_spore = nullptr; + Unit* target_boss = nullptr; + Unit* target_spore = nullptr; for (auto i = attackers.begin(); i != attackers.end(); ++i) { Unit* unit = botAI->GetUnit(*i); if (!unit) continue; - if (!unit->IsAlive()) { + if (!unit->IsAlive()) + { continue; } - if (botAI->EqualLowercaseName(unit->GetName(), "spore")) { + if (botAI->EqualLowercaseName(unit->GetName(), "spore")) + { target_spore = unit; } - if (botAI->EqualLowercaseName(unit->GetName(), "loatheb")) { + if (botAI->EqualLowercaseName(unit->GetName(), "loatheb")) + { target_boss = unit; } } - if (target_spore && bot->GetDistance2d(target_spore) <= 1.0f) { + if (target_spore && bot->GetDistance2d(target_spore) <= 1.0f) + { target = target_spore; - } else { + } + else + { target = target_boss; } - if (!target || context->GetValue("current target")->Get() == target) { + if (!target || context->GetValue("current target")->Get() == target) + { return false; } return Attack(target); diff --git a/src/strategy/raids/naxxramas/RaidNaxxActions.h b/src/strategy/raids/naxxramas/RaidNaxxActions.h index 702d8839..4c877510 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxActions.h +++ b/src/strategy/raids/naxxramas/RaidNaxxActions.h @@ -2,18 +2,18 @@ #define _PLAYERBOT_RAIDNAXXACTIONS_H #include "Action.h" -#include "MovementActions.h" #include "AttackAction.h" #include "GenericActions.h" +#include "MovementActions.h" #include "PlayerbotAI.h" #include "Playerbots.h" -#include "RaidNaxxScripts.h" #include "RaidNaxxBossHelper.h" +#include "RaidNaxxScripts.h" // just for test // class TryToGetBossAIAction : public Action // { -// public: +// public: // TryToGetBossAIAction(PlayerbotAI* ai) : Action(ai, "try to get boss ai") {} // public: @@ -23,11 +23,14 @@ class GrobbulusGoBehindAction : public MovementAction { public: - GrobbulusGoBehindAction(PlayerbotAI* ai, float distance = 24.0f, float delta_angle = M_PI / 8) : MovementAction(ai, "grobbulus go behind") { + GrobbulusGoBehindAction(PlayerbotAI* ai, float distance = 24.0f, float delta_angle = M_PI / 8) + : MovementAction(ai, "grobbulus go behind") + { this->distance = distance; this->delta_angle = delta_angle; } virtual bool Execute(Event event); + protected: float distance, delta_angle; }; @@ -35,9 +38,14 @@ protected: class GrobbulusRotateAction : public RotateAroundTheCenterPointAction { public: - GrobbulusRotateAction(PlayerbotAI* botAI): RotateAroundTheCenterPointAction(botAI, "rotate grobbulus", 3281.23f, -3310.38f, 35.0f, 8, true, M_PI) {} - virtual bool isUseful() override { - return RotateAroundTheCenterPointAction::isUseful() && botAI->IsMainTank(bot) && AI_VALUE2(bool, "has aggro", "boss target"); + GrobbulusRotateAction(PlayerbotAI* botAI) + : RotateAroundTheCenterPointAction(botAI, "rotate grobbulus", 3281.23f, -3310.38f, 35.0f, 8, true, M_PI) + { + } + virtual bool isUseful() override + { + return RotateAroundTheCenterPointAction::isUseful() && botAI->IsMainTank(bot) && + AI_VALUE2(bool, "has aggro", "boss target"); } uint32 GetCurrWaypoint() override; }; @@ -51,7 +59,8 @@ public: class HeiganDanceAction : public MovementAction { public: - HeiganDanceAction(PlayerbotAI* ai) : MovementAction(ai, "heigan dance") { + HeiganDanceAction(PlayerbotAI* ai) : MovementAction(ai, "heigan dance") + { this->prev_phase = 0; this->prev_erupt = 0; this->prev_timer = 0; @@ -60,10 +69,22 @@ public: waypoints.push_back(std::make_pair(2762.30f, -3684.59f)); waypoints.push_back(std::make_pair(2755.99f, -3703.96f)); } + protected: bool CalculateSafe(); - void ResetSafe() { curr_safe = 0; curr_dir = 1; } - void NextSafe() { curr_safe += curr_dir; if (curr_safe == 3 || curr_safe == 0) { curr_dir = -curr_dir; } } + void ResetSafe() + { + curr_safe = 0; + curr_dir = 1; + } + void NextSafe() + { + curr_safe += curr_dir; + if (curr_safe == 3 || curr_safe == 0) + { + curr_dir = -curr_dir; + } + } uint32 prev_phase, prev_erupt, prev_timer; uint32 curr_safe, curr_dir; std::vector> waypoints; @@ -79,22 +100,22 @@ public: class HeiganDanceRangedAction : public HeiganDanceAction { public: - HeiganDanceRangedAction(PlayerbotAI* ai) : HeiganDanceAction(ai) { - platform = std::make_pair(2794.26f, -3706.67f); - } + HeiganDanceRangedAction(PlayerbotAI* ai) : HeiganDanceAction(ai) { platform = std::make_pair(2794.26f, -3706.67f); } virtual bool Execute(Event event); + protected: std::pair platform; }; class ThaddiusAttackNearestPetAction : public AttackAction { - public: - ThaddiusAttackNearestPetAction(PlayerbotAI* ai) : AttackAction(ai, "thaddius attack nearest pet"), helper(ai) {} - virtual bool Execute(Event event); - virtual bool isUseful(); - private: - ThaddiusBossHelper helper; +public: + ThaddiusAttackNearestPetAction(PlayerbotAI* ai) : AttackAction(ai, "thaddius attack nearest pet"), helper(ai) {} + virtual bool Execute(Event event); + virtual bool isUseful(); + +private: + ThaddiusBossHelper helper; }; // class ThaddiusMeleeToPlaceAction : public MovementAction @@ -115,80 +136,91 @@ class ThaddiusAttackNearestPetAction : public AttackAction class ThaddiusMoveToPlatformAction : public MovementAction { - public: - ThaddiusMoveToPlatformAction(PlayerbotAI* ai) : MovementAction(ai, "thaddius move to platform") {} - virtual bool Execute(Event event); - virtual bool isUseful(); +public: + ThaddiusMoveToPlatformAction(PlayerbotAI* ai) : MovementAction(ai, "thaddius move to platform") {} + virtual bool Execute(Event event); + virtual bool isUseful(); }; class ThaddiusMovePolarityAction : public MovementAction { - public: - ThaddiusMovePolarityAction(PlayerbotAI* ai) : MovementAction(ai, "thaddius move polarity") {} - virtual bool Execute(Event event); - virtual bool isUseful(); +public: + ThaddiusMovePolarityAction(PlayerbotAI* ai) : MovementAction(ai, "thaddius move polarity") {} + virtual bool Execute(Event event); + virtual bool isUseful(); }; class RazuviousUseObedienceCrystalAction : public MovementAction { - public: - RazuviousUseObedienceCrystalAction(PlayerbotAI* ai) : MovementAction(ai, "razuvious use obedience crystal"), helper(ai) {} - bool Execute(Event event) override; - private: - RazuviousBossHelper helper; +public: + RazuviousUseObedienceCrystalAction(PlayerbotAI* ai) + : MovementAction(ai, "razuvious use obedience crystal"), helper(ai) + { + } + bool Execute(Event event) override; + +private: + RazuviousBossHelper helper; }; class RazuviousTargetAction : public AttackAction { - public: - RazuviousTargetAction(PlayerbotAI* ai) : AttackAction(ai, "razuvious target"), helper(ai) {} - bool Execute(Event event) override; - private: - RazuviousBossHelper helper; +public: + RazuviousTargetAction(PlayerbotAI* ai) : AttackAction(ai, "razuvious target"), helper(ai) {} + bool Execute(Event event) override; + +private: + RazuviousBossHelper helper; }; class HorsemanAttractAlternativelyAction : public AttackAction { - public: - HorsemanAttractAlternativelyAction(PlayerbotAI* ai) : AttackAction(ai, "horseman attract alternatively"), helper(ai) {} - bool Execute(Event event) override; - protected: - FourhorsemanBossHelper helper; +public: + HorsemanAttractAlternativelyAction(PlayerbotAI* ai) : AttackAction(ai, "horseman attract alternatively"), helper(ai) + { + } + bool Execute(Event event) override; + +protected: + FourhorsemanBossHelper helper; }; class HorsemanAttactInOrderAction : public AttackAction { - public: - HorsemanAttactInOrderAction(PlayerbotAI* ai) : AttackAction(ai, "horseman attact in order"), helper(ai) {} - bool Execute(Event event) override; - protected: - FourhorsemanBossHelper helper; +public: + HorsemanAttactInOrderAction(PlayerbotAI* ai) : AttackAction(ai, "horseman attact in order"), helper(ai) {} + bool Execute(Event event) override; + +protected: + FourhorsemanBossHelper helper; }; // class SapphironGroundMainTankPositionAction : public MovementAction // { // public: -// SapphironGroundMainTankPositionAction(PlayerbotAI* ai) : MovementAction(ai, "sapphiron ground main tank position") {} -// virtual bool Execute(Event event); +// SapphironGroundMainTankPositionAction(PlayerbotAI* ai) : MovementAction(ai, "sapphiron ground main tank +// position") {} virtual bool Execute(Event event); // }; class SapphironGroundPositionAction : public MovementAction { - public: - SapphironGroundPositionAction(PlayerbotAI* ai) : MovementAction(ai, "sapphiron ground position"), helper(ai) {} - bool Execute(Event event) override; - protected: - SapphironBossHelper helper; +public: + SapphironGroundPositionAction(PlayerbotAI* ai) : MovementAction(ai, "sapphiron ground position"), helper(ai) {} + bool Execute(Event event) override; + +protected: + SapphironBossHelper helper; }; class SapphironFlightPositionAction : public MovementAction { - public: - SapphironFlightPositionAction(PlayerbotAI* ai) : MovementAction(ai, "sapphiron flight position"), helper(ai) {} - bool Execute(Event event) override; - protected: - SapphironBossHelper helper; - bool MoveToNearestIcebolt(); +public: + SapphironFlightPositionAction(PlayerbotAI* ai) : MovementAction(ai, "sapphiron flight position"), helper(ai) {} + bool Execute(Event event) override; + +protected: + SapphironBossHelper helper; + bool MoveToNearestIcebolt(); }; // class SapphironAvoidChillAction : public MovementAction @@ -200,80 +232,92 @@ class SapphironFlightPositionAction : public MovementAction class KelthuzadChooseTargetAction : public AttackAction { - public: - KelthuzadChooseTargetAction(PlayerbotAI* ai) : AttackAction(ai, "kel'thuzad choose target"), helper(ai) {} - virtual bool Execute(Event event); - private: - KelthuzadBossHelper helper; +public: + KelthuzadChooseTargetAction(PlayerbotAI* ai) : AttackAction(ai, "kel'thuzad choose target"), helper(ai) {} + virtual bool Execute(Event event); + +private: + KelthuzadBossHelper helper; }; class KelthuzadPositionAction : public MovementAction { - public: - KelthuzadPositionAction(PlayerbotAI* ai) : MovementAction(ai, "kel'thuzad position"), helper(ai) {} - virtual bool Execute(Event event); - private: - KelthuzadBossHelper helper; +public: + KelthuzadPositionAction(PlayerbotAI* ai) : MovementAction(ai, "kel'thuzad position"), helper(ai) {} + virtual bool Execute(Event event); + +private: + KelthuzadBossHelper helper; }; class AnubrekhanChooseTargetAction : public AttackAction { - public: - AnubrekhanChooseTargetAction(PlayerbotAI* ai) : AttackAction(ai, "anub'rekhan choose target") {} - bool Execute(Event event) override; +public: + AnubrekhanChooseTargetAction(PlayerbotAI* ai) : AttackAction(ai, "anub'rekhan choose target") {} + bool Execute(Event event) override; }; class AnubrekhanPositionAction : public RotateAroundTheCenterPointAction { - public: - AnubrekhanPositionAction(PlayerbotAI* ai) : RotateAroundTheCenterPointAction(ai, "anub'rekhan position", 3272.49f, -3476.27f, 45.0f, 16) {} - bool Execute(Event event) override; +public: + AnubrekhanPositionAction(PlayerbotAI* ai) + : RotateAroundTheCenterPointAction(ai, "anub'rekhan position", 3272.49f, -3476.27f, 45.0f, 16) + { + } + bool Execute(Event event) override; }; class GluthChooseTargetAction : public AttackAction { - public: - GluthChooseTargetAction(PlayerbotAI* ai) : AttackAction(ai, "gluth choose target"), helper(ai) {} - bool Execute(Event event) override; - private: - GluthBossHelper helper; +public: + GluthChooseTargetAction(PlayerbotAI* ai) : AttackAction(ai, "gluth choose target"), helper(ai) {} + bool Execute(Event event) override; + +private: + GluthBossHelper helper; }; class GluthPositionAction : public RotateAroundTheCenterPointAction { - public: - GluthPositionAction(PlayerbotAI* ai) : RotateAroundTheCenterPointAction(ai, "gluth position", 3293.61f, -3149.01f, 12.0f, 12), helper(ai) {} - bool Execute(Event event) override; - private: - GluthBossHelper helper; +public: + GluthPositionAction(PlayerbotAI* ai) + : RotateAroundTheCenterPointAction(ai, "gluth position", 3293.61f, -3149.01f, 12.0f, 12), helper(ai) + { + } + bool Execute(Event event) override; + +private: + GluthBossHelper helper; }; class GluthSlowdownAction : public Action { - public: - GluthSlowdownAction(PlayerbotAI* ai) : Action(ai, "gluth slowdown"), helper(ai) {} - bool Execute(Event event) override; - private: - GluthBossHelper helper; +public: + GluthSlowdownAction(PlayerbotAI* ai) : Action(ai, "gluth slowdown"), helper(ai) {} + bool Execute(Event event) override; + +private: + GluthBossHelper helper; }; class LoathebPositionAction : public MovementAction { - public: - LoathebPositionAction(PlayerbotAI* ai) : MovementAction(ai, "loatheb position"), helper(ai) {} - virtual bool Execute(Event event); - private: - LoathebBossHelper helper; +public: + LoathebPositionAction(PlayerbotAI* ai) : MovementAction(ai, "loatheb position"), helper(ai) {} + virtual bool Execute(Event event); + +private: + LoathebBossHelper helper; }; class LoathebChooseTargetAction : public AttackAction { - public: - LoathebChooseTargetAction(PlayerbotAI* ai) : AttackAction(ai, "loatheb choose target"), helper(ai) {} - virtual bool Execute(Event event); - private: - LoathebBossHelper helper; +public: + LoathebChooseTargetAction(PlayerbotAI* ai) : AttackAction(ai, "loatheb choose target"), helper(ai) {} + virtual bool Execute(Event event); + +private: + LoathebBossHelper helper; }; - #endif \ No newline at end of file diff --git a/src/strategy/raids/naxxramas/RaidNaxxBossHelper.h b/src/strategy/raids/naxxramas/RaidNaxxBossHelper.h index 671d30c9..b0781ebb 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxBossHelper.h +++ b/src/strategy/raids/naxxramas/RaidNaxxBossHelper.h @@ -1,6 +1,8 @@ #ifndef _PLAYERBOT_RAIDNAXXBOSSHELPER_H #define _PLAYERBOT_RAIDNAXXBOSSHELPER_H +#include + #include "AiObject.h" #include "AiObjectContext.h" #include "EventMap.h" @@ -10,347 +12,408 @@ #include "Player.h" #include "PlayerbotAI.h" #include "Playerbots.h" -#include "ScriptedCreature.h" #include "RaidNaxxScripts.h" +#include "ScriptedCreature.h" #include "SharedDefines.h" -#include - const uint32 NAXX_MAP_ID = 533; -template -class GenericBossHelper : public AiObject { - public: - GenericBossHelper(PlayerbotAI* botAI, std::string name): AiObject(botAI), _name(name) {} - virtual bool UpdateBossAI() { - if (!bot->IsInCombat()) { - _unit = nullptr; - } - if(_unit && (!_unit->IsInWorld() || !_unit->IsAlive())) { - _unit = nullptr; - } - if (!_unit) { - _unit = AI_VALUE2(Unit*, "find target", _name); - if (!_unit) { - return false; - } - _target = _unit->ToCreature(); - if (!_target) { - return false; - } - _ai = dynamic_cast(_target->GetAI()); - if (!_ai) { - return false; - } - _event_map = &_ai->events; - if (!_event_map) { - return false; - } - } - if (!_event_map) { - return false; - } - _timer = _event_map->GetTimer(); - return true; - } - virtual void Reset() { +template +class GenericBossHelper : public AiObject +{ +public: + GenericBossHelper(PlayerbotAI* botAI, std::string name) : AiObject(botAI), _name(name) {} + virtual bool UpdateBossAI() + { + if (!bot->IsInCombat()) + { _unit = nullptr; - _target = nullptr; - _ai = nullptr; - _event_map = nullptr; - _timer = 0; } - protected: - std::string _name; - Unit* _unit = nullptr; - Creature* _target = nullptr; - BossAiType *_ai = nullptr; - EventMap* _event_map = nullptr; - uint32 _timer = 0; -}; - -class KelthuzadBossHelper: public GenericBossHelper { - public: - KelthuzadBossHelper(PlayerbotAI *botAI): GenericBossHelper(botAI, "kel'thuzad") {} - const std::pair center = {3716.19f, -5106.58f}; - const std::pair tank_pos = {3709.19f, -5104.86f}; - const std::pair assist_tank_pos = {3746.05f, -5112.74f}; - bool IsPhaseOne() { - return _event_map->GetNextEventTime(Kelthuzad::EVENT_PHASE_2) != 0; + if (_unit && (!_unit->IsInWorld() || !_unit->IsAlive())) + { + _unit = nullptr; } - bool IsPhaseTwo() { - return !IsPhaseOne(); - } - Unit* GetAnyShadowFissure() { - Unit* shadow_fissure = nullptr; - GuidVector units = *context->GetValue("nearest triggers"); - for (auto i = units.begin(); i != units.end(); i++) + if (!_unit) + { + _unit = AI_VALUE2(Unit*, "find target", _name); + if (!_unit) { - Unit* unit = botAI->GetUnit(*i); - if (!unit) - continue; - if (botAI->EqualLowercaseName(unit->GetName(), "shadow fissure")) { - shadow_fissure = unit; + return false; + } + _target = _unit->ToCreature(); + if (!_target) + { + return false; + } + _ai = dynamic_cast(_target->GetAI()); + if (!_ai) + { + return false; + } + _event_map = &_ai->events; + if (!_event_map) + { + return false; + } + } + if (!_event_map) + { + return false; + } + _timer = _event_map->GetTimer(); + return true; + } + virtual void Reset() + { + _unit = nullptr; + _target = nullptr; + _ai = nullptr; + _event_map = nullptr; + _timer = 0; + } + +protected: + std::string _name; + Unit* _unit = nullptr; + Creature* _target = nullptr; + BossAiType* _ai = nullptr; + EventMap* _event_map = nullptr; + uint32 _timer = 0; +}; + +class KelthuzadBossHelper : public GenericBossHelper +{ +public: + KelthuzadBossHelper(PlayerbotAI* botAI) : GenericBossHelper(botAI, "kel'thuzad") {} + const std::pair center = {3716.19f, -5106.58f}; + const std::pair tank_pos = {3709.19f, -5104.86f}; + const std::pair assist_tank_pos = {3746.05f, -5112.74f}; + bool IsPhaseOne() { return _event_map->GetNextEventTime(Kelthuzad::EVENT_PHASE_2) != 0; } + bool IsPhaseTwo() { return !IsPhaseOne(); } + Unit* GetAnyShadowFissure() + { + Unit* shadow_fissure = nullptr; + GuidVector units = *context->GetValue("nearest triggers"); + for (auto i = units.begin(); i != units.end(); i++) + { + Unit* unit = botAI->GetUnit(*i); + if (!unit) + continue; + if (botAI->EqualLowercaseName(unit->GetName(), "shadow fissure")) + { + shadow_fissure = unit; + } + } + return shadow_fissure; + } +}; + +class RazuviousBossHelper : public GenericBossHelper +{ +public: + RazuviousBossHelper(PlayerbotAI* botAI) : GenericBossHelper(botAI, "instructor razuvious") {} +}; + +class SapphironBossHelper : public GenericBossHelper +{ +public: + const std::pair mainTankPos = {3512.07f, -5274.06f}; + const std::pair center = {3517.31f, -5253.74f}; + const float GENERIC_HEIGHT = 137.29f; + SapphironBossHelper(PlayerbotAI* botAI) : GenericBossHelper(botAI, "sapphiron") {} + bool UpdateBossAI() override + { + if (!GenericBossHelper::UpdateBossAI()) + { + return false; + } + uint32 nextEventGround = _event_map->GetNextEventTime(Sapphiron::EVENT_GROUND); + if (nextEventGround && nextEventGround != lastEventGround) + lastEventGround = nextEventGround; + return true; + } + bool IsPhaseGround() { return _target->GetReactState() == REACT_AGGRESSIVE; } + bool IsPhaseFlight() { return !IsPhaseGround(); } + bool JustLanded() + { + return (_event_map->GetNextEventTime(Sapphiron::EVENT_FLIGHT_START) - _timer) >= + EVENT_FLIGHT_INTERVAL - POSITION_TIME_AFTER_LANDED; + } + bool WaitForExplosion() { return _event_map->GetNextEventTime(Sapphiron::EVENT_FLIGHT_SPELL_EXPLOSION); } + bool FindPosToAvoidChill(std::vector& dest) + { + Aura* aura = botAI->GetAura("chill", bot); + if (!aura) + { + return false; + } + DynamicObject* dyn_obj = aura->GetDynobjOwner(); + if (!dyn_obj) + { + return false; + } + Unit* currentTarget = AI_VALUE(Unit*, "current target"); + float angle = 0; + uint32 index = botAI->GetGroupSlotIndex(bot); + if (currentTarget) + { + if (botAI->IsRanged(bot)) + { + if (bot->GetExactDist2d(currentTarget) <= 45.0f) + { + angle = bot->GetAngle(dyn_obj) - M_PI + (rand_norm() - 0.5) * M_PI / 2; } - } - return shadow_fissure; - } -}; - -class RazuviousBossHelper: public GenericBossHelper { - public: - RazuviousBossHelper(PlayerbotAI *botAI): GenericBossHelper(botAI, "instructor razuvious") {} -}; - -class SapphironBossHelper: public GenericBossHelper { - public: - const std::pair mainTankPos = {3512.07f, -5274.06f}; - const std::pair center = {3517.31f, -5253.74f}; - const float GENERIC_HEIGHT = 137.29f; - SapphironBossHelper(PlayerbotAI *botAI): GenericBossHelper(botAI, "sapphiron") {} - bool UpdateBossAI() override { - if (!GenericBossHelper::UpdateBossAI()) { - return false; - } - uint32 nextEventGround = _event_map->GetNextEventTime(Sapphiron::EVENT_GROUND); - if (nextEventGround && nextEventGround != lastEventGround) - lastEventGround = nextEventGround; - return true; - } - bool IsPhaseGround() { - return _target->GetReactState() == REACT_AGGRESSIVE; - } - bool IsPhaseFlight() { - return !IsPhaseGround(); - } - bool JustLanded() { - return (_event_map->GetNextEventTime(Sapphiron::EVENT_FLIGHT_START) - _timer) >= EVENT_FLIGHT_INTERVAL - POSITION_TIME_AFTER_LANDED; - } - bool WaitForExplosion() { - return _event_map->GetNextEventTime(Sapphiron::EVENT_FLIGHT_SPELL_EXPLOSION); - } - bool FindPosToAvoidChill(std::vector &dest) { - Aura* aura = botAI->GetAura("chill", bot); - if (!aura) { - return false; - } - DynamicObject* dyn_obj = aura->GetDynobjOwner(); - if (!dyn_obj) { - return false; - } - Unit* currentTarget = AI_VALUE(Unit*, "current target"); - float angle = 0; - uint32 index = botAI->GetGroupSlotIndex(bot); - if (currentTarget) { - if (botAI->IsRanged(bot)) { - if (bot->GetExactDist2d(currentTarget) <= 45.0f) { - angle = bot->GetAngle(dyn_obj) - M_PI + (rand_norm() - 0.5) * M_PI / 2; - } else { - if (index % 2 == 0) { - angle = bot->GetAngle(currentTarget) + M_PI / 2; - } else { - angle = bot->GetAngle(currentTarget) - M_PI / 2; - } - } - } else { - if (index % 3 == 0) { - angle = bot->GetAngle(currentTarget); - } else if (index % 3 == 1) { + else + { + if (index % 2 == 0) + { angle = bot->GetAngle(currentTarget) + M_PI / 2; - } else { + } + else + { angle = bot->GetAngle(currentTarget) - M_PI / 2; } } - } else { - angle = bot->GetAngle(dyn_obj) - M_PI + (rand_norm() - 0.5) * M_PI / 2; } - dest = {bot->GetPositionX() + cos(angle) * 5.0f, bot->GetPositionY() + sin(angle) * 5.0f, bot->GetPositionZ()}; + else + { + if (index % 3 == 0) + { + angle = bot->GetAngle(currentTarget); + } + else if (index % 3 == 1) + { + angle = bot->GetAngle(currentTarget) + M_PI / 2; + } + else + { + angle = bot->GetAngle(currentTarget) - M_PI / 2; + } + } + } + else + { + angle = bot->GetAngle(dyn_obj) - M_PI + (rand_norm() - 0.5) * M_PI / 2; + } + dest = {bot->GetPositionX() + cos(angle) * 5.0f, bot->GetPositionY() + sin(angle) * 5.0f, bot->GetPositionZ()}; + return true; + } + +private: + const uint32 POSITION_TIME_AFTER_LANDED = 5000; + const uint32 EVENT_FLIGHT_INTERVAL = 45000; + uint32 lastEventGround = 0; +}; + +class GluthBossHelper : public GenericBossHelper +{ +public: + const std::pair mainTankPos25 = {3331.48f, -3109.06f}; + const std::pair mainTankPos10 = {3278.29f, -3162.06f}; + const std::pair beforeDecimatePos = {3267.34f, -3175.68f}; + const std::pair leftSlowDownPos = {3290.68f, -3141.65f}; + const std::pair rightSlowDownPos = {3300.78f, -3151.98f}; + const std::pair rangedPos = {3301.45f, -3139.29f}; + const std::pair healPos = {3303.09f, -3135.24f}; + + const float decimatedZombiePct = 10.0f; + GluthBossHelper(PlayerbotAI* botAI) : GenericBossHelper(botAI, "gluth") {} + bool BeforeDecimate() + { + uint32 decimate = _event_map->GetNextEventTime(Gluth::EVENT_DECIMATE); + return decimate && decimate - _timer <= 3000; + } + bool JustStartCombat() { return _timer < 10000; } +}; + +class LoathebBossHelper : public GenericBossHelper +{ +public: + const std::pair mainTankPos = {2877.57f, -3967.00f}; + const std::pair rangePos = {2896.96f, -3980.61f}; + LoathebBossHelper(PlayerbotAI* botAI) : GenericBossHelper(botAI, "loatheb") {} +}; + +class FourhorsemanBossHelper : public GenericBossHelper +{ +public: + const float posZ = 241.27f; + const std::pair attractPos[2] = {{2502.03f, -2910.90f}, + {2484.61f, -2947.07f}}; // left (sir zeliek), right (lady blaumeux) + FourhorsemanBossHelper(PlayerbotAI* botAI) : GenericBossHelper(botAI, "sir zeliek") {} + bool UpdateBossAI() override + { + if (!GenericBossHelper::UpdateBossAI()) + { + return false; + } + if (!bot->IsInCombat()) + { + Reset(); + } + sir = _unit; + lady = AI_VALUE2(Unit*, "find target", "lady blaumeux"); + if (!lady) + { return true; } - private: - const uint32 POSITION_TIME_AFTER_LANDED = 5000; - const uint32 EVENT_FLIGHT_INTERVAL = 45000; - uint32 lastEventGround = 0; -}; - -class GluthBossHelper: public GenericBossHelper { - public: - const std::pair mainTankPos25 = {3331.48f, -3109.06f}; - const std::pair mainTankPos10 = {3278.29f, -3162.06f}; - const std::pair beforeDecimatePos = {3267.34f, -3175.68f}; - const std::pair leftSlowDownPos = {3290.68f, -3141.65f}; - const std::pair rightSlowDownPos = {3300.78f, -3151.98f}; - const std::pair rangedPos = {3301.45f, -3139.29f}; - const std::pair healPos = {3303.09f, -3135.24f}; - - const float decimatedZombiePct = 10.0f; - GluthBossHelper(PlayerbotAI *botAI): GenericBossHelper(botAI, "gluth") {} - bool BeforeDecimate() { - uint32 decimate = _event_map->GetNextEventTime(Gluth::EVENT_DECIMATE); - return decimate && decimate - _timer <= 3000; - } - bool JustStartCombat() { - return _timer < 10000; - } -}; - -class LoathebBossHelper: public GenericBossHelper { - public: - const std::pair mainTankPos = {2877.57f, -3967.00f}; - const std::pair rangePos = {2896.96f, -3980.61f}; - LoathebBossHelper(PlayerbotAI *botAI): GenericBossHelper(botAI, "loatheb") {} -}; - -class FourhorsemanBossHelper: public GenericBossHelper { - public: - const float posZ = 241.27f; - const std::pair attractPos[2] = {{2502.03f, -2910.90f}, {2484.61f, -2947.07f}}; // left (sir zeliek), right (lady blaumeux) - FourhorsemanBossHelper(PlayerbotAI *botAI): GenericBossHelper(botAI, "sir zeliek") {} - bool UpdateBossAI() override { - if (!GenericBossHelper::UpdateBossAI()) { - return false; - } - if (!bot->IsInCombat()) { - Reset(); - } - sir = _unit; - lady = AI_VALUE2(Unit*, "find target", "lady blaumeux"); - if (!lady) { - return true; - } - ladyAI = dynamic_cast(lady->GetAI()); - if (!ladyAI) { - return true; - } - ladyEvent = &ladyAI->events; - const uint32 voidZone = ladyEvent->GetNextEventTime(FourHorsemen::EVENT_SECONDARY_SPELL); - if (voidZone && lastEventVoidZone != voidZone) { - voidZoneCounter++; - voidZoneCounter %= 8; - lastEventVoidZone = voidZone; - } + ladyAI = dynamic_cast(lady->GetAI()); + if (!ladyAI) + { return true; } - void Reset() override { - GenericBossHelper::Reset(); - sir = nullptr; - lady = nullptr; - ladyAI = nullptr; - ladyEvent = nullptr; - lastEventVoidZone = 0; - voidZoneCounter = 0; + ladyEvent = &ladyAI->events; + const uint32 voidZone = ladyEvent->GetNextEventTime(FourHorsemen::EVENT_SECONDARY_SPELL); + if (voidZone && lastEventVoidZone != voidZone) + { + voidZoneCounter++; + voidZoneCounter %= 8; + lastEventVoidZone = voidZone; + } + return true; + } + void Reset() override + { + GenericBossHelper::Reset(); + sir = nullptr; + lady = nullptr; + ladyAI = nullptr; + ladyEvent = nullptr; + lastEventVoidZone = 0; + voidZoneCounter = 0; + posToGo = 0; + } + bool IsAttracter(Player* bot) + { + Difficulty diff = bot->GetRaidDifficulty(); + if (diff == RAID_DIFFICULTY_25MAN_NORMAL) + { + return botAI->IsRangedDpsAssistantOfIndex(bot, 0) || botAI->IsHealAssistantOfIndex(bot, 0) || + botAI->IsHealAssistantOfIndex(bot, 1) || botAI->IsHealAssistantOfIndex(bot, 2); + } + return botAI->IsRangedDpsAssistantOfIndex(bot, 0) || botAI->IsHealAssistantOfIndex(bot, 0); + } + void CalculatePosToGo(Player* bot) + { + bool raid25 = bot->GetRaidDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL; + if (!lady) + { posToGo = 0; } - bool IsAttracter(Player* bot) { - Difficulty diff = bot->GetRaidDifficulty(); - if (diff == RAID_DIFFICULTY_25MAN_NORMAL) { - return botAI->IsRangedDpsAssistantOfIndex(bot, 0) || botAI->IsHealAssistantOfIndex(bot, 0) || - botAI->IsHealAssistantOfIndex(bot, 1) || botAI->IsHealAssistantOfIndex(bot, 2); - } - return botAI->IsRangedDpsAssistantOfIndex(bot, 0) || botAI->IsHealAssistantOfIndex(bot, 0); - } - void CalculatePosToGo(Player* bot) { - bool raid25 = bot->GetRaidDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL; - if (!lady) { - posToGo = 0; - } else { - // Interval: 24s - 15s - 15s - ... - posToGo = !(_timer <= 9000 || ((_timer - 9000) / 67500) % 2 == 0); - if (botAI->IsRangedDpsAssistantOfIndex(bot, 0) || (raid25 && botAI->IsHealAssistantOfIndex(bot, 1))) { - posToGo = 1 - posToGo; - } - } - } - std::pair CurrentAttractPos() + else { - float posX = attractPos[posToGo].first, posY = attractPos[posToGo].second; - if (posToGo == 1) { - float offset_x; - float offset_y; - if (voidZoneCounter < 4) { - offset_x = voidZoneCounter * (-4.5f); - offset_y = voidZoneCounter * (4.5f); - } - if (voidZoneCounter >= 4) { - offset_x = (7 - voidZoneCounter) * (-4.5f); - offset_y = (7 - voidZoneCounter) * (4.5f); - offset_x += 4.5f; - offset_y += 4.5f; - } - posX += offset_x; - posY += offset_y; + // Interval: 24s - 15s - 15s - ... + posToGo = !(_timer <= 9000 || ((_timer - 9000) / 67500) % 2 == 0); + if (botAI->IsRangedDpsAssistantOfIndex(bot, 0) || (raid25 && botAI->IsHealAssistantOfIndex(bot, 1))) + { + posToGo = 1 - posToGo; } - return {posX, posY}; } - Unit* CurrentAttackTarget() + } + std::pair CurrentAttractPos() + { + float posX = attractPos[posToGo].first, posY = attractPos[posToGo].second; + if (posToGo == 1) { - if (posToGo == 0) { - return sir; + float offset_x; + float offset_y; + if (voidZoneCounter < 4) + { + offset_x = voidZoneCounter * (-4.5f); + offset_y = voidZoneCounter * (4.5f); } - return lady; + if (voidZoneCounter >= 4) + { + offset_x = (7 - voidZoneCounter) * (-4.5f); + offset_y = (7 - voidZoneCounter) * (4.5f); + offset_x += 4.5f; + offset_y += 4.5f; + } + posX += offset_x; + posY += offset_y; } - protected: - Unit* sir = nullptr; - Unit* lady = nullptr; - FourHorsemen::boss_four_horsemen::boss_four_horsemenAI* ladyAI = nullptr; - EventMap* ladyEvent = nullptr; - uint32 lastEventVoidZone = 0; - uint32 voidZoneCounter = 0; - int posToGo = 0; + return {posX, posY}; + } + Unit* CurrentAttackTarget() + { + if (posToGo == 0) + { + return sir; + } + return lady; + } + +protected: + Unit* sir = nullptr; + Unit* lady = nullptr; + FourHorsemen::boss_four_horsemen::boss_four_horsemenAI* ladyAI = nullptr; + EventMap* ladyEvent = nullptr; + uint32 lastEventVoidZone = 0; + uint32 voidZoneCounter = 0; + int posToGo = 0; }; -class ThaddiusBossHelper: public GenericBossHelper { - public: - const std::pair tankPosFeugen = {3522.94f, -3002.60f}; - const std::pair tankPosStalagg = {3436.14f, -2919.98f}; - const std::pair rangedPosFeugen = {3500.45f, -2997.92f}; - const std::pair rangedPosStalagg = {3441.01f, -2942.04f}; - const float tankPosZ = 312.61f; - ThaddiusBossHelper(PlayerbotAI *botAI): GenericBossHelper(botAI, "thaddius") {} - bool UpdateBossAI() override { - if (!GenericBossHelper::UpdateBossAI()) { - return false; - } - feugen = AI_VALUE2(Unit*, "find target", "feugen"); - stalagg = AI_VALUE2(Unit*, "find target", "stalagg"); - return true; +class ThaddiusBossHelper : public GenericBossHelper +{ +public: + const std::pair tankPosFeugen = {3522.94f, -3002.60f}; + const std::pair tankPosStalagg = {3436.14f, -2919.98f}; + const std::pair rangedPosFeugen = {3500.45f, -2997.92f}; + const std::pair rangedPosStalagg = {3441.01f, -2942.04f}; + const float tankPosZ = 312.61f; + ThaddiusBossHelper(PlayerbotAI* botAI) : GenericBossHelper(botAI, "thaddius") {} + bool UpdateBossAI() override + { + if (!GenericBossHelper::UpdateBossAI()) + { + return false; } - bool IsPhasePet() { - return (feugen && feugen->IsAlive()) || (stalagg && stalagg->IsAlive()); + feugen = AI_VALUE2(Unit*, "find target", "feugen"); + stalagg = AI_VALUE2(Unit*, "find target", "stalagg"); + return true; + } + bool IsPhasePet() { return (feugen && feugen->IsAlive()) || (stalagg && stalagg->IsAlive()); } + bool IsPhaseTransition() + { + if (IsPhasePet()) + { + return false; } - bool IsPhaseTransition() { - if (IsPhasePet()) { - return false; - } - return _unit->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE); + return _unit->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE); + } + bool IsPhaseThaddius() { return !IsPhasePet() && !IsPhaseTransition(); } + Unit* GetNearestPet() + { + Unit* unit = nullptr; + if (feugen && feugen->IsAlive()) + { + unit = feugen; } - bool IsPhaseThaddius() { - return !IsPhasePet() && !IsPhaseTransition(); + if (stalagg && stalagg->IsAlive() && (!feugen || bot->GetDistance(stalagg) < bot->GetDistance(feugen))) + { + unit = stalagg; } - Unit* GetNearestPet() { - Unit* unit = nullptr; - if (feugen && feugen->IsAlive()) { - unit = feugen; - } - if (stalagg && stalagg->IsAlive() && (!feugen || bot->GetDistance(stalagg) < bot->GetDistance(feugen))) { - unit = stalagg; - } - return unit; + return unit; + } + std::pair PetPhaseGetPosForTank() + { + if (GetNearestPet() == feugen) + { + return tankPosFeugen; } - std::pair PetPhaseGetPosForTank() { - if (GetNearestPet() == feugen) { - return tankPosFeugen; - } - return tankPosStalagg; + return tankPosStalagg; + } + std::pair PetPhaseGetPosForRanged() + { + if (GetNearestPet() == feugen) + { + return rangedPosFeugen; } - std::pair PetPhaseGetPosForRanged() { - if (GetNearestPet() == feugen) { - return rangedPosFeugen; - } - return rangedPosStalagg; - } - protected: - Unit* feugen = nullptr; - Unit* stalagg = nullptr; + return rangedPosStalagg; + } + +protected: + Unit* feugen = nullptr; + Unit* stalagg = nullptr; }; #endif diff --git a/src/strategy/raids/naxxramas/RaidNaxxMultipliers.cpp b/src/strategy/raids/naxxramas/RaidNaxxMultipliers.cpp index 72ea08dd..bdf5831e 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxMultipliers.cpp +++ b/src/strategy/raids/naxxramas/RaidNaxxMultipliers.cpp @@ -1,234 +1,253 @@ #include "RaidNaxxMultipliers.h" -#include "GenericActions.h" -#include "MovementActions.h" -#include "ScriptedCreature.h" -#include "RaidNaxxActions.h" -#include "GenericSpellActions.h" + #include "ChooseTargetActions.h" -#include "ReachTargetActions.h" -#include "UseMeetingStoneAction.h" -#include "FollowActions.h" -#include "ShamanActions.h" -#include "PriestActions.h" #include "DKActions.h" +#include "DruidActions.h" +#include "DruidBearActions.h" +#include "FollowActions.h" +#include "GenericActions.h" +#include "GenericSpellActions.h" #include "HunterActions.h" #include "MageActions.h" -#include "RogueActions.h" -#include "DruidActions.h" +#include "MovementActions.h" #include "PaladinActions.h" +#include "PriestActions.h" +#include "RaidNaxxActions.h" +#include "ReachTargetActions.h" +#include "RogueActions.h" +#include "ScriptedCreature.h" +#include "ShamanActions.h" +#include "UseMeetingStoneAction.h" #include "WarriorActions.h" -#include "DruidBearActions.h" float GrobbulusMultiplier::GetValue(Action* action) { - Unit* boss = AI_VALUE2(Unit*, "find target", "grobbulus"); - if (!boss) { + Unit* boss = AI_VALUE2(Unit*, "find target", "grobbulus"); + if (!boss) + { return 1.0f; } - if (dynamic_cast(action)) { - return 0.0f; - } - return 1.0f; + if (dynamic_cast(action)) + { + return 0.0f; + } + return 1.0f; } float HeiganDanceMultiplier::GetValue(Action* action) { - Unit* boss = AI_VALUE2(Unit*, "find target", "heigan the unclean"); - if (!boss) { + Unit* boss = AI_VALUE2(Unit*, "find target", "heigan the unclean"); + if (!boss) + { return 1.0f; } - + auto* boss_ai = dynamic_cast(boss->GetAI()); EventMap* eventMap = &boss_ai->events; uint32 curr_phase = boss_ai->currentPhase; - uint32 curr_dance = eventMap->GetNextEventTime(4); - uint32 curr_timer = eventMap->GetTimer(); - uint32 curr_erupt = eventMap->GetNextEventTime(3); - if (dynamic_cast(action)) { - return 0.0f; - } - if (curr_phase != 1 && (int32)curr_dance - curr_timer >= 3000) { - return 1.0f; - } - if (dynamic_cast(action) || dynamic_cast(action)) { - return 1.0f; - } - if (dynamic_cast(action) && !dynamic_cast(action)) + uint32 curr_dance = eventMap->GetNextEventTime(4); + uint32 curr_timer = eventMap->GetTimer(); + uint32 curr_erupt = eventMap->GetNextEventTime(3); + if (dynamic_cast(action)) + { + return 0.0f; + } + if (curr_phase != 1 && (int32)curr_dance - curr_timer >= 3000) + { + return 1.0f; + } + if (dynamic_cast(action) || dynamic_cast(action)) + { + return 1.0f; + } + if (dynamic_cast(action) && !dynamic_cast(action)) { uint32 spellId = AI_VALUE2(uint32, "spell id", action->getName()); SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); - if (!spellInfo) { + if (!spellInfo) + { return 0.0f; - } + } uint32 castTime = spellInfo->CalcCastTime(); - if (castTime == 0 && !spellInfo->IsChanneled()) { - return 1.0f; - } + if (castTime == 0 && !spellInfo->IsChanneled()) + { + return 1.0f; + } } - return 0.0f; + return 0.0f; } float LoathebGenericMultiplier::GetValue(Action* action) { - Unit* boss = AI_VALUE2(Unit*, "find target", "loatheb"); - if (!boss) { + Unit* boss = AI_VALUE2(Unit*, "find target", "loatheb"); + if (!boss) + { return 1.0f; } - context->GetValue("neglect threat")->Set(true); - if (botAI->GetState() == BOT_STATE_COMBAT && - (dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action))) { - return 0.0f; - } - if (!dynamic_cast(action)) { - return 1.0f; - } - Aura* aura = botAI->GetAura("necrotic aura", bot); - if (!aura || aura->GetDuration() <= 1500) { - return 1.0f; - } - return 0.0f; + context->GetValue("neglect threat")->Set(true); + if (botAI->GetState() == BOT_STATE_COMBAT && + (dynamic_cast(action) || dynamic_cast(action) || + dynamic_cast(action) || dynamic_cast(action))) + { + return 0.0f; + } + if (!dynamic_cast(action)) + { + return 1.0f; + } + Aura* aura = botAI->GetAura("necrotic aura", bot); + if (!aura || aura->GetDuration() <= 1500) + { + return 1.0f; + } + return 0.0f; } float ThaddiusGenericMultiplier::GetValue(Action* action) { - if (!helper.UpdateBossAI()) { - return 1.0f; - } - // pet phase - if (helper.IsPhasePet() && - (dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action))) { - return 0.0f; - } - // die at the same time - Unit* target = AI_VALUE(Unit*, "current target"); - Unit* feugen = AI_VALUE2(Unit*, "find target", "feugen"); + if (!helper.UpdateBossAI()) + { + return 1.0f; + } + // pet phase + if (helper.IsPhasePet() && + (dynamic_cast(action) || dynamic_cast(action) || + dynamic_cast(action) || + dynamic_cast(action) || dynamic_cast(action))) + { + return 0.0f; + } + // die at the same time + Unit* target = AI_VALUE(Unit*, "current target"); + Unit* feugen = AI_VALUE2(Unit*, "find target", "feugen"); Unit* stalagg = AI_VALUE2(Unit*, "find target", "stalagg"); - if (helper.IsPhasePet() && target && feugen && stalagg && target->GetHealthPct() <= 40 && - (feugen->GetHealthPct() >= target->GetHealthPct() + 3 || stalagg->GetHealthPct() >= target->GetHealthPct() + 3)) { - if (dynamic_cast(action) && !dynamic_cast(action)) { - return 0.0f; - } - } - // magnetic pull - // uint32 curr_timer = eventMap->GetTimer(); - // // if (curr_phase == 2 && bot->GetPositionZ() > 312.5f && dynamic_cast(action)) { - // if (curr_phase == 2 && (curr_timer % 20000 >= 18000 || curr_timer % 20000 <= 2000) && dynamic_cast(action)) { - // // MotionMaster *mm = bot->GetMotionMaster(); - // // mm->Clear(); - // return 0.0f; - // } - // thaddius phase - // if (curr_phase == 8 && dynamic_cast(action)) { - // return 0.0f; - // } - return 1.0f; + if (helper.IsPhasePet() && target && feugen && stalagg && target->GetHealthPct() <= 40 && + (feugen->GetHealthPct() >= target->GetHealthPct() + 3 || stalagg->GetHealthPct() >= target->GetHealthPct() + 3)) + { + if (dynamic_cast(action) && !dynamic_cast(action)) + { + return 0.0f; + } + } + // magnetic pull + // uint32 curr_timer = eventMap->GetTimer(); + // // if (curr_phase == 2 && bot->GetPositionZ() > 312.5f && dynamic_cast(action)) { + // if (curr_phase == 2 && (curr_timer % 20000 >= 18000 || curr_timer % 20000 <= 2000) && + // dynamic_cast(action)) { + // // MotionMaster *mm = bot->GetMotionMaster(); + // // mm->Clear(); + // return 0.0f; + // } + // thaddius phase + // if (curr_phase == 8 && dynamic_cast(action)) { + // return 0.0f; + // } + return 1.0f; } float SapphironGenericMultiplier::GetValue(Action* action) { - if (!helper.UpdateBossAI()) { - return 1.0f; - } - if (dynamic_cast(action) || - dynamic_cast(action)) { - return 0.0f; - } - return 1.0f; + if (!helper.UpdateBossAI()) + { + return 1.0f; + } + if (dynamic_cast(action) || dynamic_cast(action)) + { + return 0.0f; + } + return 1.0f; } float InstructorRazuviousGenericMultiplier::GetValue(Action* action) { - if (!helper.UpdateBossAI()) { - return 1.0f; - } - context->GetValue("neglect threat")->Set(true); - if (botAI->GetState() == BOT_STATE_COMBAT && - (dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action))) { - return 0.0f; - } - return 1.0f; + if (!helper.UpdateBossAI()) + { + return 1.0f; + } + context->GetValue("neglect threat")->Set(true); + if (botAI->GetState() == BOT_STATE_COMBAT && + (dynamic_cast(action) || dynamic_cast(action) || + dynamic_cast(action) || dynamic_cast(action) || + dynamic_cast(action) || dynamic_cast(action))) + { + return 0.0f; + } + return 1.0f; } float KelthuzadGenericMultiplier::GetValue(Action* action) { - if (!helper.UpdateBossAI()) { - return 1.0f; - } - if ((dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action))) { - return 0.0f; - } - if (helper.IsPhaseOne()) { - if (dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action)) { - return 0.0f; - } - } - if (helper.IsPhaseTwo()) { - if (dynamic_cast(action) || - dynamic_cast(action)) { - return 0.0f; - } - } - return 1.0f; + if (!helper.UpdateBossAI()) + { + return 1.0f; + } + if ((dynamic_cast(action) || dynamic_cast(action) || + dynamic_cast(action) || dynamic_cast(action) || + dynamic_cast(action))) + { + return 0.0f; + } + if (helper.IsPhaseOne()) + { + if (dynamic_cast(action) || dynamic_cast(action) || + dynamic_cast(action) || dynamic_cast(action) || + dynamic_cast(action) || dynamic_cast(action) || + dynamic_cast(action)) + { + return 0.0f; + } + } + if (helper.IsPhaseTwo()) + { + if (dynamic_cast(action) || dynamic_cast(action)) + { + return 0.0f; + } + } + return 1.0f; } float AnubrekhanGenericMultiplier::GetValue(Action* action) { - Unit* boss = AI_VALUE2(Unit*, "find target", "anub'rekhan"); - if (!boss) { + Unit* boss = AI_VALUE2(Unit*, "find target", "anub'rekhan"); + if (!boss) + { return 1.0f; } - if ( - // (dynamic_cast(action) || - // dynamic_cast(action) || - // dynamic_cast(action) || - dynamic_cast(action)) { - return 0.0f; - } - // BossAI* boss_ai = dynamic_cast(boss->GetAI()); - // EventMap* eventMap = boss_ai->GetEvents(); + if ( + // (dynamic_cast(action) || + // dynamic_cast(action) || + // dynamic_cast(action) || + dynamic_cast(action)) + { + return 0.0f; + } + // BossAI* boss_ai = dynamic_cast(boss->GetAI()); + // EventMap* eventMap = boss_ai->GetEvents(); // uint32 curr_phase = eventMap->GetPhaseMask(); - if (botAI->HasAura("locust swarm", boss)) { - if (dynamic_cast(action)) { - return 0.0f; - } - } - return 1.0f; + if (botAI->HasAura("locust swarm", boss)) + { + if (dynamic_cast(action)) + { + return 0.0f; + } + } + return 1.0f; } float FourhorsemanGenericMultiplier::GetValue(Action* action) { - Unit* boss = AI_VALUE2(Unit*, "find target", "sir zeliek"); - if (!boss) { + Unit* boss = AI_VALUE2(Unit*, "find target", "sir zeliek"); + if (!boss) + { return 1.0f; } - context->GetValue("neglect threat")->Set(true); - if ((dynamic_cast(action) || - dynamic_cast(action))) { - return 0.0f; - } - return 1.0f; + context->GetValue("neglect threat")->Set(true); + if ((dynamic_cast(action) || dynamic_cast(action))) + { + return 0.0f; + } + return 1.0f; } // float GothikGenericMultiplier::GetValue(Action* action) @@ -254,33 +273,36 @@ float FourhorsemanGenericMultiplier::GetValue(Action* action) float GluthGenericMultiplier::GetValue(Action* action) { - if (!helper.UpdateBossAI()) { - return 1.0f; - } - if ((dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action))) { - return 0.0f; - } - - if (botAI->IsMainTank(bot)) { - Aura* aura = botAI->GetAura("mortal wound", bot, false, true); - if (aura && aura->GetStackAmount() >= 5) { - if (dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action) || - dynamic_cast(action)) { - return 0.0f; - } - } - } - if (dynamic_cast(action)) { - Unit* target = AI_VALUE(Unit*, "current target"); - if (target && target->GetEntry() == Gluth::NPC_ZOMBIE_CHOW) { - return 0.0f; - } - } - return 1.0f; + if (!helper.UpdateBossAI()) + { + return 1.0f; + } + if ((dynamic_cast(action) || dynamic_cast(action) || + dynamic_cast(action) || dynamic_cast(action) || + dynamic_cast(action))) + { + return 0.0f; + } + + if (botAI->IsMainTank(bot)) + { + Aura* aura = botAI->GetAura("mortal wound", bot, false, true); + if (aura && aura->GetStackAmount() >= 5) + { + if (dynamic_cast(action) || dynamic_cast(action) || + dynamic_cast(action) || dynamic_cast(action)) + { + return 0.0f; + } + } + } + if (dynamic_cast(action)) + { + Unit* target = AI_VALUE(Unit*, "current target"); + if (target && target->GetEntry() == Gluth::NPC_ZOMBIE_CHOW) + { + return 0.0f; + } + } + return 1.0f; } diff --git a/src/strategy/raids/naxxramas/RaidNaxxMultipliers.h b/src/strategy/raids/naxxramas/RaidNaxxMultipliers.h index 8ac9e071..2b2723ea 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxMultipliers.h +++ b/src/strategy/raids/naxxramas/RaidNaxxMultipliers.h @@ -7,67 +7,73 @@ class GrobbulusMultiplier : public Multiplier { - public: - GrobbulusMultiplier(PlayerbotAI* ai) : Multiplier(ai, "grobbulus") {} +public: + GrobbulusMultiplier(PlayerbotAI* ai) : Multiplier(ai, "grobbulus") {} - public: - virtual float GetValue(Action* action); +public: + virtual float GetValue(Action* action); }; class HeiganDanceMultiplier : public Multiplier { - public: - HeiganDanceMultiplier(PlayerbotAI* ai) : Multiplier(ai, "helgan dance") {} +public: + HeiganDanceMultiplier(PlayerbotAI* ai) : Multiplier(ai, "helgan dance") {} - public: - virtual float GetValue(Action* action); +public: + virtual float GetValue(Action* action); }; class LoathebGenericMultiplier : public Multiplier { - public: - LoathebGenericMultiplier(PlayerbotAI* ai) : Multiplier(ai, "loatheb generic") {} +public: + LoathebGenericMultiplier(PlayerbotAI* ai) : Multiplier(ai, "loatheb generic") {} - public: - virtual float GetValue(Action* action); +public: + virtual float GetValue(Action* action); }; class ThaddiusGenericMultiplier : public Multiplier { - public: - ThaddiusGenericMultiplier(PlayerbotAI* ai) : Multiplier(ai, "thaddius generic"), helper(ai) {} +public: + ThaddiusGenericMultiplier(PlayerbotAI* ai) : Multiplier(ai, "thaddius generic"), helper(ai) {} - public: - virtual float GetValue(Action* action); - private: - ThaddiusBossHelper helper; +public: + virtual float GetValue(Action* action); + +private: + ThaddiusBossHelper helper; }; class SapphironGenericMultiplier : public Multiplier { - public: - SapphironGenericMultiplier(PlayerbotAI* ai) : Multiplier(ai, "sapphiron generic"), helper(ai) {} +public: + SapphironGenericMultiplier(PlayerbotAI* ai) : Multiplier(ai, "sapphiron generic"), helper(ai) {} - virtual float GetValue(Action* action); - private: - SapphironBossHelper helper; + virtual float GetValue(Action* action); + +private: + SapphironBossHelper helper; }; class InstructorRazuviousGenericMultiplier : public Multiplier { - public: - InstructorRazuviousGenericMultiplier(PlayerbotAI* ai) : Multiplier(ai, "instructor razuvious generic"), helper(ai) {} - virtual float GetValue(Action* action); - private: - RazuviousBossHelper helper; +public: + InstructorRazuviousGenericMultiplier(PlayerbotAI* ai) : Multiplier(ai, "instructor razuvious generic"), helper(ai) + { + } + virtual float GetValue(Action* action); + +private: + RazuviousBossHelper helper; }; class KelthuzadGenericMultiplier : public Multiplier { - public: - KelthuzadGenericMultiplier(PlayerbotAI* ai) : Multiplier(ai, "kelthuzad generic"), helper(ai) {} - virtual float GetValue(Action* action); - private: - KelthuzadBossHelper helper; +public: + KelthuzadGenericMultiplier(PlayerbotAI* ai) : Multiplier(ai, "kelthuzad generic"), helper(ai) {} + virtual float GetValue(Action* action); + +private: + KelthuzadBossHelper helper; }; class AnubrekhanGenericMultiplier : public Multiplier @@ -99,11 +105,12 @@ public: class GluthGenericMultiplier : public Multiplier { - public: - GluthGenericMultiplier(PlayerbotAI* ai) : Multiplier(ai, "gluth generic"), helper(ai) {} - float GetValue(Action* action) override; - private: - GluthBossHelper helper; +public: + GluthGenericMultiplier(PlayerbotAI* ai) : Multiplier(ai, "gluth generic"), helper(ai) {} + float GetValue(Action* action) override; + +private: + GluthBossHelper helper; }; #endif \ No newline at end of file diff --git a/src/strategy/raids/naxxramas/RaidNaxxScripts.h b/src/strategy/raids/naxxramas/RaidNaxxScripts.h index c0edcc67..b7c5e8ac 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxScripts.h +++ b/src/strategy/raids/naxxramas/RaidNaxxScripts.h @@ -3,22 +3,18 @@ #include "../../../../src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.h" #include "../../../../src/server/scripts/Northrend/Naxxramas/boss_faerlina.h" -#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_maexxna.h" - -#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_noth.h" -#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_heigan.h" -#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_loatheb.h" - -#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_patchwerk.h" -#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_grobbulus.h" +#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.h" #include "../../../../src/server/scripts/Northrend/Naxxramas/boss_gluth.h" +#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_gothik.h" +#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_grobbulus.h" +#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_heigan.h" +#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.h" +#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_loatheb.h" +#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_maexxna.h" +#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_noth.h" +#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_patchwerk.h" +#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_razuvious.h" +#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_sapphiron.h" #include "../../../../src/server/scripts/Northrend/Naxxramas/boss_thaddius.h" -#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_razuvious.h" -#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_gothik.h" -#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.h" - -#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_sapphiron.h" -#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.h" - #endif diff --git a/src/strategy/raids/naxxramas/RaidNaxxStrategy.cpp b/src/strategy/raids/naxxramas/RaidNaxxStrategy.cpp index 0d640273..a4f7f42e 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxStrategy.cpp +++ b/src/strategy/raids/naxxramas/RaidNaxxStrategy.cpp @@ -1,126 +1,105 @@ #include "RaidNaxxStrategy.h" + #include "RaidNaxxMultipliers.h" - -void RaidNaxxStrategy::InitTriggers(std::vector &triggers) +void RaidNaxxStrategy::InitTriggers(std::vector& triggers) { - // Grobbulus - triggers.push_back(new TriggerNode( - "mutating injection", - NextAction::array(0, new NextAction("grobbulus go behind the boss", ACTION_RAID + 2), nullptr))); - - triggers.push_back(new TriggerNode( - "mutating injection removed", - NextAction::array(0, new NextAction("grobbulus move center", ACTION_RAID + 1), nullptr))); + // Grobbulus + triggers.push_back(new TriggerNode( + "mutating injection", + NextAction::array(0, new NextAction("grobbulus go behind the boss", ACTION_RAID + 2), nullptr))); - triggers.push_back(new TriggerNode( - "grobbulus cloud", - NextAction::array(0, new NextAction("rotate grobbulus", ACTION_RAID + 1), nullptr))); + triggers.push_back( + new TriggerNode("mutating injection removed", + NextAction::array(0, new NextAction("grobbulus move center", ACTION_RAID + 1), nullptr))); - // Heigan the Unclean - triggers.push_back(new TriggerNode( - "heigan melee", - NextAction::array(0, new NextAction("heigan dance melee", ACTION_RAID + 1), nullptr))); + triggers.push_back(new TriggerNode( + "grobbulus cloud", NextAction::array(0, new NextAction("rotate grobbulus", ACTION_RAID + 1), nullptr))); - triggers.push_back(new TriggerNode( - "heigan ranged", - NextAction::array(0, new NextAction("heigan dance ranged", ACTION_RAID + 1), nullptr))); + // Heigan the Unclean + triggers.push_back(new TriggerNode( + "heigan melee", NextAction::array(0, new NextAction("heigan dance melee", ACTION_RAID + 1), nullptr))); - // Kel'Thuzad - triggers.push_back(new TriggerNode( - "kel'thuzad", - NextAction::array(0, - new NextAction("kel'thuzad position", ACTION_RAID + 2), - new NextAction("kel'thuzad choose target", ACTION_RAID + 1), - nullptr))); + triggers.push_back(new TriggerNode( + "heigan ranged", NextAction::array(0, new NextAction("heigan dance ranged", ACTION_RAID + 1), nullptr))); - // Anub'Rekhan - triggers.push_back(new TriggerNode( - "anub'rekhan", - NextAction::array(0, - new NextAction("anub'rekhan position", ACTION_RAID + 1), - nullptr))); + // Kel'Thuzad + triggers.push_back(new TriggerNode( + "kel'thuzad", NextAction::array(0, new NextAction("kel'thuzad position", ACTION_RAID + 2), + new NextAction("kel'thuzad choose target", ACTION_RAID + 1), nullptr))); - // Thaddius - triggers.push_back(new TriggerNode( - "thaddius phase pet", - NextAction::array(0, - new NextAction("thaddius attack nearest pet", ACTION_RAID + 1), - nullptr))); + // Anub'Rekhan + triggers.push_back(new TriggerNode( + "anub'rekhan", NextAction::array(0, new NextAction("anub'rekhan position", ACTION_RAID + 1), nullptr))); - triggers.push_back(new TriggerNode( - "thaddius phase pet lose aggro", - NextAction::array(0, new NextAction("taunt spell", ACTION_RAID + 2), nullptr))); + // Thaddius + triggers.push_back( + new TriggerNode("thaddius phase pet", + NextAction::array(0, new NextAction("thaddius attack nearest pet", ACTION_RAID + 1), nullptr))); - triggers.push_back(new TriggerNode( - "thaddius phase transition", - NextAction::array(0, new NextAction("thaddius move to platform", ACTION_RAID + 1), nullptr))); + triggers.push_back(new TriggerNode("thaddius phase pet lose aggro", + NextAction::array(0, new NextAction("taunt spell", ACTION_RAID + 2), nullptr))); - triggers.push_back(new TriggerNode( - "thaddius phase thaddius", - NextAction::array(0, new NextAction("thaddius move polarity", ACTION_RAID + 1), nullptr))); + triggers.push_back( + new TriggerNode("thaddius phase transition", + NextAction::array(0, new NextAction("thaddius move to platform", ACTION_RAID + 1), nullptr))); - // Instructor Razuvious - triggers.push_back(new TriggerNode( - "razuvious tank", - NextAction::array(0, new NextAction("razuvious use obedience crystal", ACTION_RAID + 1), nullptr))); - - triggers.push_back(new TriggerNode( - "razuvious nontank", - NextAction::array(0, new NextAction("razuvious target", ACTION_RAID + 1), nullptr))); + triggers.push_back( + new TriggerNode("thaddius phase thaddius", + NextAction::array(0, new NextAction("thaddius move polarity", ACTION_RAID + 1), nullptr))); - // four horseman - triggers.push_back(new TriggerNode( - "horseman attractors", - NextAction::array(0, new NextAction("horseman attract alternatively", ACTION_RAID + 1), nullptr))); - - triggers.push_back(new TriggerNode( - "horseman except attractors", - NextAction::array(0, new NextAction("horseman attack in order", ACTION_RAID + 1), nullptr))); + // Instructor Razuvious + triggers.push_back(new TriggerNode( + "razuvious tank", + NextAction::array(0, new NextAction("razuvious use obedience crystal", ACTION_RAID + 1), nullptr))); - // sapphiron - triggers.push_back(new TriggerNode( - "sapphiron ground", - NextAction::array(0, new NextAction("sapphiron ground position", ACTION_RAID + 1), nullptr))); + triggers.push_back(new TriggerNode( + "razuvious nontank", NextAction::array(0, new NextAction("razuvious target", ACTION_RAID + 1), nullptr))); - triggers.push_back(new TriggerNode( - "sapphiron flight", - NextAction::array(0, new NextAction("sapphiron flight position", ACTION_RAID + 1), nullptr))); - - // Gluth - triggers.push_back(new TriggerNode( - "gluth", - NextAction::array(0, - new NextAction("gluth choose target", ACTION_RAID + 1), - new NextAction("gluth position", ACTION_RAID + 1), - new NextAction("gluth slowdown", ACTION_RAID), - nullptr))); - - triggers.push_back(new TriggerNode( - "gluth main tank mortal wound", - NextAction::array(0, - new NextAction("taunt spell", ACTION_RAID + 1), nullptr))); + // four horseman + triggers.push_back(new TriggerNode( + "horseman attractors", + NextAction::array(0, new NextAction("horseman attract alternatively", ACTION_RAID + 1), nullptr))); - // Loatheb - triggers.push_back(new TriggerNode( - "loatheb", - NextAction::array(0, - new NextAction("loatheb position", ACTION_RAID + 1), - new NextAction("loatheb choose target", ACTION_RAID + 1), - nullptr))); + triggers.push_back( + new TriggerNode("horseman except attractors", + NextAction::array(0, new NextAction("horseman attack in order", ACTION_RAID + 1), nullptr))); + + // sapphiron + triggers.push_back( + new TriggerNode("sapphiron ground", + NextAction::array(0, new NextAction("sapphiron ground position", ACTION_RAID + 1), nullptr))); + + triggers.push_back( + new TriggerNode("sapphiron flight", + NextAction::array(0, new NextAction("sapphiron flight position", ACTION_RAID + 1), nullptr))); + + // Gluth + triggers.push_back( + new TriggerNode("gluth", NextAction::array(0, new NextAction("gluth choose target", ACTION_RAID + 1), + new NextAction("gluth position", ACTION_RAID + 1), + new NextAction("gluth slowdown", ACTION_RAID), nullptr))); + + triggers.push_back(new TriggerNode("gluth main tank mortal wound", + NextAction::array(0, new NextAction("taunt spell", ACTION_RAID + 1), nullptr))); + + // Loatheb + triggers.push_back(new TriggerNode( + "loatheb", NextAction::array(0, new NextAction("loatheb position", ACTION_RAID + 1), + new NextAction("loatheb choose target", ACTION_RAID + 1), nullptr))); } -void RaidNaxxStrategy::InitMultipliers(std::vector &multipliers) +void RaidNaxxStrategy::InitMultipliers(std::vector& multipliers) { - multipliers.push_back(new GrobbulusMultiplier(botAI)); - multipliers.push_back(new HeiganDanceMultiplier(botAI)); - multipliers.push_back(new LoathebGenericMultiplier(botAI)); - multipliers.push_back(new ThaddiusGenericMultiplier(botAI)); - multipliers.push_back(new SapphironGenericMultiplier(botAI)); - multipliers.push_back(new InstructorRazuviousGenericMultiplier(botAI)); - multipliers.push_back(new KelthuzadGenericMultiplier(botAI)); - multipliers.push_back(new AnubrekhanGenericMultiplier(botAI)); - multipliers.push_back(new FourhorsemanGenericMultiplier(botAI)); - // multipliers.push_back(new GothikGenericMultiplier(botAI)); - multipliers.push_back(new GluthGenericMultiplier(botAI)); + multipliers.push_back(new GrobbulusMultiplier(botAI)); + multipliers.push_back(new HeiganDanceMultiplier(botAI)); + multipliers.push_back(new LoathebGenericMultiplier(botAI)); + multipliers.push_back(new ThaddiusGenericMultiplier(botAI)); + multipliers.push_back(new SapphironGenericMultiplier(botAI)); + multipliers.push_back(new InstructorRazuviousGenericMultiplier(botAI)); + multipliers.push_back(new KelthuzadGenericMultiplier(botAI)); + multipliers.push_back(new AnubrekhanGenericMultiplier(botAI)); + multipliers.push_back(new FourhorsemanGenericMultiplier(botAI)); + // multipliers.push_back(new GothikGenericMultiplier(botAI)); + multipliers.push_back(new GluthGenericMultiplier(botAI)); } diff --git a/src/strategy/raids/naxxramas/RaidNaxxStrategy.h b/src/strategy/raids/naxxramas/RaidNaxxStrategy.h index c2b55a59..4603f4ee 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxStrategy.h +++ b/src/strategy/raids/naxxramas/RaidNaxxStrategy.h @@ -2,20 +2,18 @@ #ifndef _PLAYERBOT_RAIDNAXXSTRATEGY_H #define _PLAYERBOT_RAIDNAXXSTRATEGY_H -#include "Multiplier.h" #include "AiObjectContext.h" -#include "Strategy.h" +#include "Multiplier.h" #include "RaidNaxxScripts.h" - +#include "Strategy.h" class RaidNaxxStrategy : public Strategy { public: RaidNaxxStrategy(PlayerbotAI* ai) : Strategy(ai) {} virtual std::string const getName() override { return "naxx"; } - virtual void InitTriggers(std::vector &triggers) override; - virtual void InitMultipliers(std::vector &multipliers) override; + virtual void InitTriggers(std::vector& triggers) override; + virtual void InitMultipliers(std::vector& multipliers) override; }; - #endif \ No newline at end of file diff --git a/src/strategy/raids/naxxramas/RaidNaxxTriggerContext.h b/src/strategy/raids/naxxramas/RaidNaxxTriggerContext.h index 342f58e6..9f12369a 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxTriggerContext.h +++ b/src/strategy/raids/naxxramas/RaidNaxxTriggerContext.h @@ -1,72 +1,74 @@ // /* -// * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. +// * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it +// and/or modify it under version 2 of the License, or (at your option), any later version. // */ #ifndef _PLAYERBOT_RAIDNAXXTRIGGERCONTEXT_H #define _PLAYERBOT_RAIDNAXXTRIGGERCONTEXT_H -#include "NamedObjectContext.h" #include "AiObjectContext.h" +#include "NamedObjectContext.h" #include "RaidNaxxTriggers.h" -class RaidNaxxTriggerContext : public NamedObjectContext +class RaidNaxxTriggerContext : public NamedObjectContext { - public: - RaidNaxxTriggerContext() - { - creators["mutating injection"] = &RaidNaxxTriggerContext::mutating_injection; - creators["mutating injection removed"] = &RaidNaxxTriggerContext::mutating_injection_removed; - creators["grobbulus cloud"] = &RaidNaxxTriggerContext::grobbulus_cloud; - creators["heigan melee"] = &RaidNaxxTriggerContext::heigan_melee; - creators["heigan ranged"] = &RaidNaxxTriggerContext::heigan_ranged; +public: + RaidNaxxTriggerContext() + { + creators["mutating injection"] = &RaidNaxxTriggerContext::mutating_injection; + creators["mutating injection removed"] = &RaidNaxxTriggerContext::mutating_injection_removed; + creators["grobbulus cloud"] = &RaidNaxxTriggerContext::grobbulus_cloud; + creators["heigan melee"] = &RaidNaxxTriggerContext::heigan_melee; + creators["heigan ranged"] = &RaidNaxxTriggerContext::heigan_ranged; - creators["thaddius phase pet"] = &RaidNaxxTriggerContext::thaddius_phase_pet; - creators["thaddius phase pet lose aggro"] = &RaidNaxxTriggerContext::thaddius_phase_pet_lose_aggro; - creators["thaddius phase transition"] = &RaidNaxxTriggerContext::thaddius_phase_transition; - creators["thaddius phase thaddius"] = &RaidNaxxTriggerContext::thaddius_phase_thaddius; + creators["thaddius phase pet"] = &RaidNaxxTriggerContext::thaddius_phase_pet; + creators["thaddius phase pet lose aggro"] = &RaidNaxxTriggerContext::thaddius_phase_pet_lose_aggro; + creators["thaddius phase transition"] = &RaidNaxxTriggerContext::thaddius_phase_transition; + creators["thaddius phase thaddius"] = &RaidNaxxTriggerContext::thaddius_phase_thaddius; - creators["razuvious tank"] = &RaidNaxxTriggerContext::razuvious_tank; - creators["razuvious nontank"] = &RaidNaxxTriggerContext::razuvious_nontank; + creators["razuvious tank"] = &RaidNaxxTriggerContext::razuvious_tank; + creators["razuvious nontank"] = &RaidNaxxTriggerContext::razuvious_nontank; - creators["horseman attractors"] = &RaidNaxxTriggerContext::horseman_attractors; - creators["horseman except attractors"] = &RaidNaxxTriggerContext::horseman_except_attractors; + creators["horseman attractors"] = &RaidNaxxTriggerContext::horseman_attractors; + creators["horseman except attractors"] = &RaidNaxxTriggerContext::horseman_except_attractors; - creators["sapphiron ground"] = &RaidNaxxTriggerContext::sapphiron_ground; - creators["sapphiron flight"] = &RaidNaxxTriggerContext::sapphiron_flight; - - creators["kel'thuzad"] = &RaidNaxxTriggerContext::kelthuzad; + creators["sapphiron ground"] = &RaidNaxxTriggerContext::sapphiron_ground; + creators["sapphiron flight"] = &RaidNaxxTriggerContext::sapphiron_flight; - creators["anub'rekhan"] = &RaidNaxxTriggerContext::anubrekhan; + creators["kel'thuzad"] = &RaidNaxxTriggerContext::kelthuzad; - creators["gluth"] = &RaidNaxxTriggerContext::gluth; - creators["gluth main tank mortal wound"] = &RaidNaxxTriggerContext::gluth_main_tank_mortal_wound; - - creators["loatheb"] = &RaidNaxxTriggerContext::loatheb; - } - private: - static Trigger* mutating_injection(PlayerbotAI* ai) { return new MutatingInjectionTrigger(ai); } - static Trigger* mutating_injection_removed(PlayerbotAI* ai) { return new MutatingInjectionRemovedTrigger(ai); } - static Trigger* grobbulus_cloud(PlayerbotAI* ai) { return new GrobbulusCloudTrigger(ai); } - static Trigger* heigan_melee(PlayerbotAI* ai) { return new HeiganMeleeTrigger(ai); } - static Trigger* heigan_ranged(PlayerbotAI* ai) { return new HeiganRangedTrigger(ai); } + creators["anub'rekhan"] = &RaidNaxxTriggerContext::anubrekhan; - static Trigger* thaddius_phase_pet(PlayerbotAI* ai) { return new ThaddiusPhasePetTrigger(ai); } - static Trigger* thaddius_phase_pet_lose_aggro(PlayerbotAI* ai) { return new ThaddiusPhasePetLoseAggroTrigger(ai); } - static Trigger* thaddius_phase_transition(PlayerbotAI* ai) { return new ThaddiusPhaseTransitionTrigger(ai); } - static Trigger* thaddius_phase_thaddius(PlayerbotAI* ai) { return new ThaddiusPhaseThaddiusTrigger(ai); } - static Trigger* razuvious_tank(PlayerbotAI* ai) { return new RazuviousTankTrigger(ai); } - static Trigger* razuvious_nontank(PlayerbotAI* ai) { return new RazuviousNontankTrigger(ai); } - - static Trigger* horseman_attractors(PlayerbotAI* ai) { return new HorsemanAttractorsTrigger(ai); } - static Trigger* horseman_except_attractors(PlayerbotAI* ai) { return new HorsemanExceptAttractorsTrigger(ai); } - - static Trigger* sapphiron_ground(PlayerbotAI* ai) { return new SapphironGroundTrigger(ai); } - static Trigger* sapphiron_flight(PlayerbotAI* ai) { return new SapphironFlightTrigger(ai); } - static Trigger* kelthuzad(PlayerbotAI* ai) { return new KelthuzadTrigger(ai); } - static Trigger* anubrekhan(PlayerbotAI* ai) { return new AnubrekhanTrigger(ai); } - static Trigger* gluth(PlayerbotAI* ai) { return new GluthTrigger(ai); } - static Trigger* gluth_main_tank_mortal_wound(PlayerbotAI* ai) { return new GluthMainTankMortalWoundTrigger(ai); } - static Trigger* loatheb(PlayerbotAI* ai) { return new LoathebTrigger(ai); } + creators["gluth"] = &RaidNaxxTriggerContext::gluth; + creators["gluth main tank mortal wound"] = &RaidNaxxTriggerContext::gluth_main_tank_mortal_wound; + + creators["loatheb"] = &RaidNaxxTriggerContext::loatheb; + } + +private: + static Trigger* mutating_injection(PlayerbotAI* ai) { return new MutatingInjectionTrigger(ai); } + static Trigger* mutating_injection_removed(PlayerbotAI* ai) { return new MutatingInjectionRemovedTrigger(ai); } + static Trigger* grobbulus_cloud(PlayerbotAI* ai) { return new GrobbulusCloudTrigger(ai); } + static Trigger* heigan_melee(PlayerbotAI* ai) { return new HeiganMeleeTrigger(ai); } + static Trigger* heigan_ranged(PlayerbotAI* ai) { return new HeiganRangedTrigger(ai); } + + static Trigger* thaddius_phase_pet(PlayerbotAI* ai) { return new ThaddiusPhasePetTrigger(ai); } + static Trigger* thaddius_phase_pet_lose_aggro(PlayerbotAI* ai) { return new ThaddiusPhasePetLoseAggroTrigger(ai); } + static Trigger* thaddius_phase_transition(PlayerbotAI* ai) { return new ThaddiusPhaseTransitionTrigger(ai); } + static Trigger* thaddius_phase_thaddius(PlayerbotAI* ai) { return new ThaddiusPhaseThaddiusTrigger(ai); } + static Trigger* razuvious_tank(PlayerbotAI* ai) { return new RazuviousTankTrigger(ai); } + static Trigger* razuvious_nontank(PlayerbotAI* ai) { return new RazuviousNontankTrigger(ai); } + + static Trigger* horseman_attractors(PlayerbotAI* ai) { return new HorsemanAttractorsTrigger(ai); } + static Trigger* horseman_except_attractors(PlayerbotAI* ai) { return new HorsemanExceptAttractorsTrigger(ai); } + + static Trigger* sapphiron_ground(PlayerbotAI* ai) { return new SapphironGroundTrigger(ai); } + static Trigger* sapphiron_flight(PlayerbotAI* ai) { return new SapphironFlightTrigger(ai); } + static Trigger* kelthuzad(PlayerbotAI* ai) { return new KelthuzadTrigger(ai); } + static Trigger* anubrekhan(PlayerbotAI* ai) { return new AnubrekhanTrigger(ai); } + static Trigger* gluth(PlayerbotAI* ai) { return new GluthTrigger(ai); } + static Trigger* gluth_main_tank_mortal_wound(PlayerbotAI* ai) { return new GluthMainTankMortalWoundTrigger(ai); } + static Trigger* loatheb(PlayerbotAI* ai) { return new LoathebTrigger(ai); } }; #endif \ No newline at end of file diff --git a/src/strategy/raids/naxxramas/RaidNaxxTriggers.cpp b/src/strategy/raids/naxxramas/RaidNaxxTriggers.cpp index dbfa6545..0ce93564 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxTriggers.cpp +++ b/src/strategy/raids/naxxramas/RaidNaxxTriggers.cpp @@ -1,13 +1,16 @@ +#include "RaidNaxxTriggers.h" + #include "EventMap.h" #include "Playerbots.h" -#include "RaidNaxxTriggers.h" #include "ScriptedCreature.h" #include "Trigger.h" -bool AuraRemovedTrigger::IsActive() { +bool AuraRemovedTrigger::IsActive() +{ bool check = botAI->HasAura(name, bot, false, false, -1, true); bool ret = false; - if (prev_check && !check) { + if (prev_check && !check) + { ret = true; } prev_check = check; @@ -17,67 +20,77 @@ bool AuraRemovedTrigger::IsActive() { bool MutatingInjectionRemovedTrigger::IsActive() { Unit* boss = AI_VALUE2(Unit*, "find target", "grobbulus"); - if (!boss) { + if (!boss) + { return false; } return HasNoAuraTrigger::IsActive() && botAI->GetState() == BOT_STATE_COMBAT && botAI->IsRanged(bot); } -template +template bool BossEventTrigger::IsActive() { Unit* boss = AI_VALUE(Unit*, "boss target"); - if (!boss || boss->GetEntry() != boss_entry) { + if (!boss || boss->GetEntry() != boss_entry) + { return false; } T* ai = dynamic_cast(boss->GetAI()); - EventMap *eventMap = &ai->events; - if (!eventMap) { + EventMap* eventMap = &ai->events; + if (!eventMap) + { return false; } const uint32 event_time = eventMap->GetNextEventTime(event_id); - if (event_time != last_event_time) { + if (event_time != last_event_time) + { last_event_time = event_time; return true; } return false; } -template +template bool BossPhaseTrigger::IsActive() { Unit* boss = AI_VALUE2(Unit*, "find target", boss_name); - if (!boss) { + if (!boss) + { return false; } - if (this->phase_mask == 0) { + if (this->phase_mask == 0) + { return true; } T* boss_ai = dynamic_cast(boss->GetAI()); EventMap* eventMap = &boss_ai->events; uint8 phase_mask = eventMap->GetPhaseMask(); - // bot->Yell("phase mask detected: " + to_string(phase_mask) + " compare with " + to_string(this->phase_mask), LANG_UNIVERSAL); + // bot->Yell("phase mask detected: " + to_string(phase_mask) + " compare with " + to_string(this->phase_mask), + // LANG_UNIVERSAL); return phase_mask == this->phase_mask; } bool GrobbulusCloudTrigger::IsActive() { Unit* boss = AI_VALUE(Unit*, "boss target"); - if (!boss || boss->GetEntry() != boss_entry) { + if (!boss || boss->GetEntry() != boss_entry) + { return false; } - if (!botAI->IsMainTank(bot)) { + if (!botAI->IsMainTank(bot)) + { return false; } - // bot->Yell("has aggro on " + boss->GetName() + " : " + to_string(AI_VALUE2(bool, "has aggro", "boss target")), LANG_UNIVERSAL); + // bot->Yell("has aggro on " + boss->GetName() + " : " + to_string(AI_VALUE2(bool, "has aggro", "boss target")), + // LANG_UNIVERSAL); return AI_VALUE2(bool, "has aggro", "boss target"); } bool HeiganMeleeTrigger::IsActive() { - Unit* heigan = AI_VALUE2(Unit*, "find target", "heigan the unclean"); - if (!heigan) { + if (!heigan) + { return false; } return !botAI->IsRanged(bot); @@ -86,7 +99,8 @@ bool HeiganMeleeTrigger::IsActive() bool HeiganRangedTrigger::IsActive() { Unit* heigan = AI_VALUE2(Unit*, "find target", "heigan the unclean"); - if (!heigan) { + if (!heigan) + { return false; } return botAI->IsRanged(bot); @@ -95,7 +109,8 @@ bool HeiganRangedTrigger::IsActive() bool RazuviousTankTrigger::IsActive() { Difficulty diff = bot->GetRaidDifficulty(); - if (diff == RAID_DIFFICULTY_10MAN_NORMAL) { + if (diff == RAID_DIFFICULTY_10MAN_NORMAL) + { return helper.UpdateBossAI() && botAI->IsTank(bot); } return helper.UpdateBossAI() && bot->getClass() == CLASS_PRIEST; @@ -104,7 +119,8 @@ bool RazuviousTankTrigger::IsActive() bool RazuviousNontankTrigger::IsActive() { Difficulty diff = bot->GetRaidDifficulty(); - if (diff == RAID_DIFFICULTY_10MAN_NORMAL) { + if (diff == RAID_DIFFICULTY_10MAN_NORMAL) + { return helper.UpdateBossAI() && !(botAI->IsTank(bot)); } return helper.UpdateBossAI() && !(bot->getClass() == CLASS_PRIEST); @@ -112,7 +128,8 @@ bool RazuviousNontankTrigger::IsActive() bool HorsemanAttractorsTrigger::IsActive() { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } return helper.IsAttracter(bot); @@ -120,7 +137,8 @@ bool HorsemanAttractorsTrigger::IsActive() bool HorsemanExceptAttractorsTrigger::IsActive() { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } return !helper.IsAttracter(bot); @@ -128,7 +146,8 @@ bool HorsemanExceptAttractorsTrigger::IsActive() bool SapphironGroundTrigger::IsActive() { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } return helper.IsPhaseGround(); @@ -136,7 +155,8 @@ bool SapphironGroundTrigger::IsActive() bool SapphironFlightTrigger::IsActive() { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } return helper.IsPhaseFlight(); @@ -157,43 +177,39 @@ bool SapphironFlightTrigger::IsActive() // return BossPhaseTrigger::IsActive() && !botAI->IsMainTank(bot) && botAI->HasAura("chill", bot); // } -bool GluthTrigger::IsActive() -{ - return helper.UpdateBossAI(); -} +bool GluthTrigger::IsActive() { return helper.UpdateBossAI(); } bool GluthMainTankMortalWoundTrigger::IsActive() { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } - if (!botAI->IsAssistTankOfIndex(bot, 0)) { + if (!botAI->IsAssistTankOfIndex(bot, 0)) + { return false; } Unit* mt = AI_VALUE(Unit*, "main tank"); - if (!mt) { + if (!mt) + { return false; } Aura* aura = botAI->GetAura("mortal wound", mt, false, true); - if (!aura || aura->GetStackAmount() < 5) { + if (!aura || aura->GetStackAmount() < 5) + { return false; } return true; } -bool KelthuzadTrigger::IsActive() -{ - return helper.UpdateBossAI(); -} +bool KelthuzadTrigger::IsActive() { return helper.UpdateBossAI(); } -bool LoathebTrigger::IsActive() -{ - return helper.UpdateBossAI(); -} +bool LoathebTrigger::IsActive() { return helper.UpdateBossAI(); } bool ThaddiusPhasePetTrigger::IsActive() { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } return helper.IsPhasePet(); @@ -201,7 +217,8 @@ bool ThaddiusPhasePetTrigger::IsActive() bool ThaddiusPhaseTransitionTrigger::IsActive() { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } return helper.IsPhaseTransition(); @@ -209,7 +226,8 @@ bool ThaddiusPhaseTransitionTrigger::IsActive() bool ThaddiusPhaseThaddiusTrigger::IsActive() { - if (!helper.UpdateBossAI()) { + if (!helper.UpdateBossAI()) + { return false; } return helper.IsPhaseThaddius(); diff --git a/src/strategy/raids/naxxramas/RaidNaxxTriggers.h b/src/strategy/raids/naxxramas/RaidNaxxTriggers.h index 3c8e983e..3ad498a3 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxTriggers.h +++ b/src/strategy/raids/naxxramas/RaidNaxxTriggers.h @@ -3,25 +3,24 @@ #define _PLAYERBOT_RAIDNAXXTRIGGERS_H #include "EventMap.h" -#include "Trigger.h" -#include "PlayerbotAIConfig.h" #include "GenericTriggers.h" -#include "RaidNaxxScripts.h" +#include "PlayerbotAIConfig.h" #include "RaidNaxxBossHelper.h" +#include "RaidNaxxScripts.h" +#include "Trigger.h" class MutatingInjectionTrigger : public HasAuraTrigger { public: - MutatingInjectionTrigger(PlayerbotAI* ai): HasAuraTrigger(ai, "mutating injection", 1) {} + MutatingInjectionTrigger(PlayerbotAI* ai) : HasAuraTrigger(ai, "mutating injection", 1) {} }; class AuraRemovedTrigger : public Trigger { public: - AuraRemovedTrigger(PlayerbotAI* botAI, std::string name): Trigger(botAI, name, 1) { - this->prev_check = false; - } + AuraRemovedTrigger(PlayerbotAI* botAI, std::string name) : Trigger(botAI, name, 1) { this->prev_check = false; } virtual bool IsActive() override; + protected: bool prev_check; }; @@ -29,33 +28,39 @@ protected: class MutatingInjectionRemovedTrigger : public HasNoAuraTrigger { public: - MutatingInjectionRemovedTrigger(PlayerbotAI* ai): HasNoAuraTrigger(ai, "mutating injection") {} + MutatingInjectionRemovedTrigger(PlayerbotAI* ai) : HasNoAuraTrigger(ai, "mutating injection") {} virtual bool IsActive(); }; -template +template class BossEventTrigger : public Trigger { public: - BossEventTrigger(PlayerbotAI* ai, uint32 boss_entry, uint32 event_id, std::string name = "boss event"): Trigger(ai, name, 1) { + BossEventTrigger(PlayerbotAI* ai, uint32 boss_entry, uint32 event_id, std::string name = "boss event") + : Trigger(ai, name, 1) + { this->boss_entry = boss_entry; this->event_id = event_id; this->last_event_time = -1; } virtual bool IsActive(); + protected: uint32 boss_entry, event_id, last_event_time; }; -template +template class BossPhaseTrigger : public Trigger { public: - BossPhaseTrigger(PlayerbotAI* ai, std::string boss_name, uint32 phase_mask, std::string name = "boss event"): Trigger(ai, name, 1) { + BossPhaseTrigger(PlayerbotAI* ai, std::string boss_name, uint32 phase_mask, std::string name = "boss event") + : Trigger(ai, name, 1) + { this->boss_name = boss_name; this->phase_mask = phase_mask; } virtual bool IsActive(); + protected: std::string boss_name; uint32 phase_mask; @@ -64,49 +69,52 @@ protected: class GrobbulusCloudTrigger : public BossEventTrigger { public: - GrobbulusCloudTrigger(PlayerbotAI* ai): BossEventTrigger(ai, 15931, 2, "grobbulus cloud event") { } + GrobbulusCloudTrigger(PlayerbotAI* ai) : BossEventTrigger(ai, 15931, 2, "grobbulus cloud event") {} virtual bool IsActive(); }; class HeiganMeleeTrigger : public Trigger { public: - HeiganMeleeTrigger(PlayerbotAI* ai): Trigger(ai, "heigan melee") {} + HeiganMeleeTrigger(PlayerbotAI* ai) : Trigger(ai, "heigan melee") {} virtual bool IsActive(); }; class HeiganRangedTrigger : public Trigger { - public: - HeiganRangedTrigger(PlayerbotAI* ai): Trigger(ai, "heigan ranged") {} - bool IsActive() override; +public: + HeiganRangedTrigger(PlayerbotAI* ai) : Trigger(ai, "heigan ranged") {} + bool IsActive() override; }; class RazuviousTankTrigger : public Trigger { - public: - RazuviousTankTrigger(PlayerbotAI* ai) : Trigger(ai, "instructor razuvious tank"), helper(ai) {} - bool IsActive() override; - private: - RazuviousBossHelper helper; +public: + RazuviousTankTrigger(PlayerbotAI* ai) : Trigger(ai, "instructor razuvious tank"), helper(ai) {} + bool IsActive() override; + +private: + RazuviousBossHelper helper; }; class RazuviousNontankTrigger : public Trigger { - public: - RazuviousNontankTrigger(PlayerbotAI* ai) : Trigger(ai, "instructor razuvious non-tank"), helper(ai) {} - bool IsActive() override; - private: - RazuviousBossHelper helper; +public: + RazuviousNontankTrigger(PlayerbotAI* ai) : Trigger(ai, "instructor razuvious non-tank"), helper(ai) {} + bool IsActive() override; + +private: + RazuviousBossHelper helper; }; class KelthuzadTrigger : public Trigger { - public: - KelthuzadTrigger(PlayerbotAI* ai) : Trigger(ai, "kel'thuzad trigger"), helper(ai) {} - bool IsActive() override; - private: - KelthuzadBossHelper helper; +public: + KelthuzadTrigger(PlayerbotAI* ai) : Trigger(ai, "kel'thuzad trigger"), helper(ai) {} + bool IsActive() override; + +private: + KelthuzadBossHelper helper; }; class AnubrekhanTrigger : public BossPhaseTrigger @@ -117,18 +125,20 @@ public: class ThaddiusPhasePetTrigger : public Trigger { - public: - ThaddiusPhasePetTrigger(PlayerbotAI* ai) : Trigger(ai, "thaddius phase pet"), helper(ai) {} - bool IsActive() override; - private: - ThaddiusBossHelper helper; +public: + ThaddiusPhasePetTrigger(PlayerbotAI* ai) : Trigger(ai, "thaddius phase pet"), helper(ai) {} + bool IsActive() override; + +private: + ThaddiusBossHelper helper; }; class ThaddiusPhasePetLoseAggroTrigger : public ThaddiusPhasePetTrigger { public: ThaddiusPhasePetLoseAggroTrigger(PlayerbotAI* ai) : ThaddiusPhasePetTrigger(ai) {} - virtual bool IsActive() { + virtual bool IsActive() + { Unit* target = AI_VALUE(Unit*, "current target"); return ThaddiusPhasePetTrigger::IsActive() && botAI->IsTank(bot) && target && target->GetVictim() != bot; } @@ -136,63 +146,69 @@ public: class ThaddiusPhaseTransitionTrigger : public Trigger { - public: - ThaddiusPhaseTransitionTrigger(PlayerbotAI* ai) : Trigger(ai, "thaddius phase transition"), helper(ai) {} - bool IsActive() override; - private: - ThaddiusBossHelper helper; +public: + ThaddiusPhaseTransitionTrigger(PlayerbotAI* ai) : Trigger(ai, "thaddius phase transition"), helper(ai) {} + bool IsActive() override; + +private: + ThaddiusBossHelper helper; }; class ThaddiusPhaseThaddiusTrigger : public Trigger { - public: - ThaddiusPhaseThaddiusTrigger(PlayerbotAI* ai) : Trigger(ai, "thaddius phase thaddius"), helper(ai) {} - bool IsActive() override; - private: - ThaddiusBossHelper helper; +public: + ThaddiusPhaseThaddiusTrigger(PlayerbotAI* ai) : Trigger(ai, "thaddius phase thaddius"), helper(ai) {} + bool IsActive() override; + +private: + ThaddiusBossHelper helper; }; class HorsemanAttractorsTrigger : public Trigger { - public: - HorsemanAttractorsTrigger(PlayerbotAI* ai) : Trigger(ai, "fourhorsemen attractors"), helper(ai) {} - bool IsActive() override; - private: - FourhorsemanBossHelper helper; +public: + HorsemanAttractorsTrigger(PlayerbotAI* ai) : Trigger(ai, "fourhorsemen attractors"), helper(ai) {} + bool IsActive() override; + +private: + FourhorsemanBossHelper helper; }; class HorsemanExceptAttractorsTrigger : public Trigger { - public: - HorsemanExceptAttractorsTrigger(PlayerbotAI* ai) : Trigger(ai, "fourhorsemen except attractors"), helper(ai) {} - bool IsActive() override; - private: - FourhorsemanBossHelper helper; +public: + HorsemanExceptAttractorsTrigger(PlayerbotAI* ai) : Trigger(ai, "fourhorsemen except attractors"), helper(ai) {} + bool IsActive() override; + +private: + FourhorsemanBossHelper helper; }; class SapphironGroundTrigger : public Trigger { - public: - SapphironGroundTrigger(PlayerbotAI* ai) : Trigger(ai, "sapphiron ground"), helper(ai) {} - bool IsActive() override; - private: - SapphironBossHelper helper; +public: + SapphironGroundTrigger(PlayerbotAI* ai) : Trigger(ai, "sapphiron ground"), helper(ai) {} + bool IsActive() override; + +private: + SapphironBossHelper helper; }; // class SapphironGroundExceptMainTankTrigger : public BossPhaseTrigger // { // public: -// SapphironGroundExceptMainTankTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "sapphiron", (1 << (2 - 1)), "sapphiron ground except main tank") {} -// virtual bool IsActive(); +// SapphironGroundExceptMainTankTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "sapphiron", (1 << (2 - 1)), +// "sapphiron ground except main tank") {} virtual bool IsActive(); // }; class SapphironFlightTrigger : public Trigger { - public: - SapphironFlightTrigger(PlayerbotAI* ai) : Trigger(ai, "sapphiron flight"), helper(ai) {} - bool IsActive() override; - private: - SapphironBossHelper helper; +public: + SapphironFlightTrigger(PlayerbotAI* ai) : Trigger(ai, "sapphiron flight"), helper(ai) {} + bool IsActive() override; + +private: + SapphironBossHelper helper; }; // class SapphironGroundChillTrigger : public BossPhaseTrigger @@ -202,41 +218,44 @@ class SapphironFlightTrigger : public Trigger // virtual bool IsActive(); // }; - - // class KelthuzadPhaseTwoTrigger : public BossPhaseTrigger // { // public: -// KelthuzadPhaseTwoTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "kel'thuzad", 1 << (2 - 1), "kel'thuzad trigger") {} +// KelthuzadPhaseTwoTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "kel'thuzad", 1 << (2 - 1), "kel'thuzad +// trigger") {} // }; class GluthTrigger : public Trigger { - public: - GluthTrigger(PlayerbotAI* ai) : Trigger(ai, "gluth trigger"), helper(ai) {} - bool IsActive() override; - private: - GluthBossHelper helper; +public: + GluthTrigger(PlayerbotAI* ai) : Trigger(ai, "gluth trigger"), helper(ai) {} + bool IsActive() override; + +private: + GluthBossHelper helper; }; class GluthMainTankMortalWoundTrigger : public Trigger { - public: - GluthMainTankMortalWoundTrigger(PlayerbotAI* ai) : Trigger(ai, "gluth main tank mortal wound trigger"), helper(ai) {} - bool IsActive() override; - private: - GluthBossHelper helper; +public: + GluthMainTankMortalWoundTrigger(PlayerbotAI* ai) : Trigger(ai, "gluth main tank mortal wound trigger"), helper(ai) + { + } + bool IsActive() override; + +private: + GluthBossHelper helper; }; class LoathebTrigger : public Trigger { - public: - LoathebTrigger(PlayerbotAI* ai) : Trigger(ai, "loatheb"), helper(ai) {} - bool IsActive() override; - private: - LoathebBossHelper helper; +public: + LoathebTrigger(PlayerbotAI* ai) : Trigger(ai, "loatheb"), helper(ai) {} + bool IsActive() override; + +private: + LoathebBossHelper helper; }; - // template BossEventTrigger; #endif \ No newline at end of file diff --git a/src/strategy/raids/ulduar/RaidUlduarActionContext.h b/src/strategy/raids/ulduar/RaidUlduarActionContext.h index e907a07f..591e8fbd 100644 --- a/src/strategy/raids/ulduar/RaidUlduarActionContext.h +++ b/src/strategy/raids/ulduar/RaidUlduarActionContext.h @@ -1,5 +1,6 @@ // /* -// * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. +// * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it +// and/or modify it under version 2 of the License, or (at your option), any later version. // */ #ifndef _PLAYERBOT_RAIDULDUARACTIONCONTEXT_H @@ -11,12 +12,10 @@ class RaidUlduarActionContext : public NamedObjectContext { - public: - RaidUlduarActionContext() { - - } - private: +public: + RaidUlduarActionContext() {} +private: }; #endif \ No newline at end of file diff --git a/src/strategy/raids/ulduar/RaidUlduarActions.cpp b/src/strategy/raids/ulduar/RaidUlduarActions.cpp index f678bee8..66828cae 100644 --- a/src/strategy/raids/ulduar/RaidUlduarActions.cpp +++ b/src/strategy/raids/ulduar/RaidUlduarActions.cpp @@ -1,21 +1,24 @@ +#include "RaidUlduarActions.h" + #include "ObjectGuid.h" #include "PlayerbotAIConfig.h" #include "Playerbots.h" -#include "RaidUlduarActions.h" +#include "RaidUlduarBossHelper.h" #include "RaidUlduarStrategy.h" #include "ScriptedCreature.h" #include "SharedDefines.h" -#include "RaidUlduarBossHelper.h" uint32 RotateAroundTheCenterPointAction::FindNearestWaypoint() { float minDistance = 0; int ret = -1; - for (int i = 0; i < intervals; i++) { + for (int i = 0; i < intervals; i++) + { float w_x = waypoints[i].first, w_y = waypoints[i].second; float dis = bot->GetDistance2d(w_x, w_y); - if (ret == -1 || dis < minDistance) { + if (ret == -1 || dis < minDistance) + { ret = i; minDistance = dis; } diff --git a/src/strategy/raids/ulduar/RaidUlduarActions.h b/src/strategy/raids/ulduar/RaidUlduarActions.h index 314d4370..c2fec2d8 100644 --- a/src/strategy/raids/ulduar/RaidUlduarActions.h +++ b/src/strategy/raids/ulduar/RaidUlduarActions.h @@ -2,18 +2,18 @@ #define _PLAYERBOT_RAIDULDUARACTIONS_H #include "Action.h" -#include "MovementActions.h" #include "AttackAction.h" #include "GenericActions.h" +#include "MovementActions.h" #include "PlayerbotAI.h" #include "Playerbots.h" -#include "RaidUlduarScripts.h" #include "RaidUlduarBossHelper.h" +#include "RaidUlduarScripts.h" // just for test // class TryToGetBossAIAction : public Action // { -// public: +// public: // TryToGetBossAIAction(PlayerbotAI* ai) : Action(ai, "try to get boss ai") {} // public: diff --git a/src/strategy/raids/ulduar/RaidUlduarBossHelper.h b/src/strategy/raids/ulduar/RaidUlduarBossHelper.h index 36360524..a1585ade 100644 --- a/src/strategy/raids/ulduar/RaidUlduarBossHelper.h +++ b/src/strategy/raids/ulduar/RaidUlduarBossHelper.h @@ -1,6 +1,8 @@ #ifndef _PLAYERBOT_RAIDULDUARBOSSHELPER_H #define _PLAYERBOT_RAIDULDUARBOSSHELPER_H +#include + #include "AiObject.h" #include "AiObjectContext.h" #include "EventMap.h" @@ -9,63 +11,73 @@ #include "Player.h" #include "PlayerbotAI.h" #include "Playerbots.h" -#include "ScriptedCreature.h" #include "RaidUlduarScripts.h" +#include "ScriptedCreature.h" #include "SharedDefines.h" -#include - const uint32 ULDUAR_MAP_ID = 603; -template -class GenericBossHelper : public AiObject { - public: - GenericBossHelper(PlayerbotAI* botAI, std::string name): AiObject(botAI), _name(name) {} - virtual bool UpdateBossAI() { - if (!bot->IsInCombat()) { - _unit = nullptr; - } - if(_unit && (!_unit->IsInWorld() || !_unit->IsAlive())) { - _unit = nullptr; - } - if (!_unit) { - _unit = AI_VALUE2(Unit*, "find target", _name); - if (!_unit) { - return false; - } - _target = _unit->ToCreature(); - if (!_target) { - return false; - } - _ai = dynamic_cast(_target->GetAI()); - if (!_ai) { - return false; - } - _event_map = &_ai->events; - if (!_event_map) { - return false; - } - } - if (!_event_map) { +template +class GenericBossHelper : public AiObject +{ +public: + GenericBossHelper(PlayerbotAI* botAI, std::string name) : AiObject(botAI), _name(name) {} + virtual bool UpdateBossAI() + { + if (!bot->IsInCombat()) + { + _unit = nullptr; + } + if (_unit && (!_unit->IsInWorld() || !_unit->IsAlive())) + { + _unit = nullptr; + } + if (!_unit) + { + _unit = AI_VALUE2(Unit*, "find target", _name); + if (!_unit) + { + return false; + } + _target = _unit->ToCreature(); + if (!_target) + { + return false; + } + _ai = dynamic_cast(_target->GetAI()); + if (!_ai) + { + return false; + } + _event_map = &_ai->events; + if (!_event_map) + { return false; } - _timer = _event_map->GetTimer(); - return true; } - virtual void Reset() { - _unit = nullptr; - _target = nullptr; - _ai = nullptr; - _event_map = nullptr; - _timer = 0; + if (!_event_map) + { + return false; } - protected: - std::string _name; - Unit* _unit = nullptr; - Creature* _target = nullptr; - BossAiType *_ai = nullptr; - EventMap* _event_map = nullptr; - uint32 _timer = 0; + _timer = _event_map->GetTimer(); + return true; + } + virtual void Reset() + { + _unit = nullptr; + _target = nullptr; + _ai = nullptr; + _event_map = nullptr; + _timer = 0; + } + +protected: + std::string _name; + Unit* _unit = nullptr; + Creature* _target = nullptr; + BossAiType* _ai = nullptr; + EventMap* _event_map = nullptr; + uint32 _timer = 0; }; #endif diff --git a/src/strategy/raids/ulduar/RaidUlduarMultipliers.cpp b/src/strategy/raids/ulduar/RaidUlduarMultipliers.cpp index 8801c322..760e3547 100644 --- a/src/strategy/raids/ulduar/RaidUlduarMultipliers.cpp +++ b/src/strategy/raids/ulduar/RaidUlduarMultipliers.cpp @@ -1,21 +1,21 @@ #include "RaidUlduarMultipliers.h" -#include "GenericActions.h" -#include "MovementActions.h" -#include "ScriptedCreature.h" -#include "RaidUlduarActions.h" -#include "GenericSpellActions.h" + #include "ChooseTargetActions.h" -#include "ReachTargetActions.h" -#include "UseMeetingStoneAction.h" -#include "FollowActions.h" -#include "ShamanActions.h" -#include "PriestActions.h" #include "DKActions.h" +#include "DruidActions.h" +#include "DruidBearActions.h" +#include "FollowActions.h" +#include "GenericActions.h" +#include "GenericSpellActions.h" #include "HunterActions.h" #include "MageActions.h" -#include "RogueActions.h" -#include "DruidActions.h" +#include "MovementActions.h" #include "PaladinActions.h" +#include "PriestActions.h" +#include "RaidUlduarActions.h" +#include "ReachTargetActions.h" +#include "RogueActions.h" +#include "ScriptedCreature.h" +#include "ShamanActions.h" +#include "UseMeetingStoneAction.h" #include "WarriorActions.h" -#include "DruidBearActions.h" - diff --git a/src/strategy/raids/ulduar/RaidUlduarScripts.h b/src/strategy/raids/ulduar/RaidUlduarScripts.h index 382177de..a5085309 100644 --- a/src/strategy/raids/ulduar/RaidUlduarScripts.h +++ b/src/strategy/raids/ulduar/RaidUlduarScripts.h @@ -1,7 +1,7 @@ #ifndef _PLAYERBOT_RAIDULDUARSCRIPTS_H #define _PLAYERBOT_RAIDULDUARSCRIPTS_H -//There are no header files for bosses in Ulduar directory +// There are no header files for bosses in Ulduar directory //#include "../../../../src/server/scripts/Northrend/Ulduar/Ulduar/" #endif diff --git a/src/strategy/raids/ulduar/RaidUlduarStrategy.cpp b/src/strategy/raids/ulduar/RaidUlduarStrategy.cpp index 3e3cd8e2..c0693cdc 100644 --- a/src/strategy/raids/ulduar/RaidUlduarStrategy.cpp +++ b/src/strategy/raids/ulduar/RaidUlduarStrategy.cpp @@ -1,12 +1,7 @@ #include "RaidUlduarStrategy.h" + #include "RaidUlduarMultipliers.h" +void RaidUlduarStrategy::InitTriggers(std::vector& triggers) {} -void RaidUlduarStrategy::InitTriggers(std::vector &triggers) -{ - -} - -void RaidUlduarStrategy::InitMultipliers(std::vector &multipliers) -{ -} +void RaidUlduarStrategy::InitMultipliers(std::vector& multipliers) {} diff --git a/src/strategy/raids/ulduar/RaidUlduarStrategy.h b/src/strategy/raids/ulduar/RaidUlduarStrategy.h index 207cec7d..e523d4b6 100644 --- a/src/strategy/raids/ulduar/RaidUlduarStrategy.h +++ b/src/strategy/raids/ulduar/RaidUlduarStrategy.h @@ -2,20 +2,18 @@ #ifndef _PLAYERBOT_RAIDULDUARSTRATEGY_H #define _PLAYERBOT_RAIDULDUARSTRATEGY_H -#include "Multiplier.h" #include "AiObjectContext.h" -#include "Strategy.h" +#include "Multiplier.h" #include "RaidUlduarScripts.h" - +#include "Strategy.h" class RaidUlduarStrategy : public Strategy { public: RaidUlduarStrategy(PlayerbotAI* ai) : Strategy(ai) {} virtual std::string const getName() override { return "ulduar"; } - virtual void InitTriggers(std::vector &triggers) override; - virtual void InitMultipliers(std::vector &multipliers) override; + virtual void InitTriggers(std::vector& triggers) override; + virtual void InitMultipliers(std::vector& multipliers) override; }; - #endif \ No newline at end of file diff --git a/src/strategy/raids/ulduar/RaidUlduarTriggerContext.h b/src/strategy/raids/ulduar/RaidUlduarTriggerContext.h index e086d2c6..aed35cf8 100644 --- a/src/strategy/raids/ulduar/RaidUlduarTriggerContext.h +++ b/src/strategy/raids/ulduar/RaidUlduarTriggerContext.h @@ -1,23 +1,21 @@ // /* -// * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. +// * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it +// and/or modify it under version 2 of the License, or (at your option), any later version. // */ #ifndef _PLAYERBOT_RAIDULDUARTRIGGERCONTEXT_H #define _PLAYERBOT_RAIDULDUARTRIGGERCONTEXT_H -#include "NamedObjectContext.h" #include "AiObjectContext.h" +#include "NamedObjectContext.h" #include "RaidUlduarTriggers.h" -class RaidUlduarTriggerContext : public NamedObjectContext +class RaidUlduarTriggerContext : public NamedObjectContext { - public: - RaidUlduarTriggerContext() - { - - } - private: +public: + RaidUlduarTriggerContext() {} +private: }; #endif \ No newline at end of file diff --git a/src/strategy/raids/ulduar/RaidUlduarTriggers.cpp b/src/strategy/raids/ulduar/RaidUlduarTriggers.cpp index 9255b19f..8ee3d799 100644 --- a/src/strategy/raids/ulduar/RaidUlduarTriggers.cpp +++ b/src/strategy/raids/ulduar/RaidUlduarTriggers.cpp @@ -1,5 +1,6 @@ +#include "RaidUlduarTriggers.h" + #include "EventMap.h" #include "Playerbots.h" -#include "RaidUlduarTriggers.h" #include "ScriptedCreature.h" #include "Trigger.h" diff --git a/src/strategy/raids/ulduar/RaidUlduarTriggers.h b/src/strategy/raids/ulduar/RaidUlduarTriggers.h index fa4b62c0..7337706a 100644 --- a/src/strategy/raids/ulduar/RaidUlduarTriggers.h +++ b/src/strategy/raids/ulduar/RaidUlduarTriggers.h @@ -2,12 +2,10 @@ #define _PLAYERBOT_RAIDULDUARTRIGGERS_H #include "EventMap.h" -#include "Trigger.h" -#include "PlayerbotAIConfig.h" #include "GenericTriggers.h" -#include "RaidUlduarScripts.h" +#include "PlayerbotAIConfig.h" #include "RaidUlduarBossHelper.h" - - +#include "RaidUlduarScripts.h" +#include "Trigger.h" #endif \ No newline at end of file diff --git a/src/strategy/rogue/AssassinationRogueStrategy.cpp b/src/strategy/rogue/AssassinationRogueStrategy.cpp index 306b323a..c0eafa69 100644 --- a/src/strategy/rogue/AssassinationRogueStrategy.cpp +++ b/src/strategy/rogue/AssassinationRogueStrategy.cpp @@ -1,5 +1,6 @@ #include "AssassinationRogueStrategy.h" + #include "Playerbots.h" class AssassinationRogueStrategyActionNodeFactory : public NamedObjectFactory @@ -10,20 +11,21 @@ public: creators["mutilate"] = &mutilate; creators["envenom"] = &envenom; } -private: + +private: static ActionNode* mutilate(PlayerbotAI* ai) { - return new ActionNode ("mutilate", - /*P*/ NULL, - /*A*/ NextAction::array(0, new NextAction("sinister strike"), NULL), - /*C*/ NULL); + return new ActionNode("mutilate", + /*P*/ NULL, + /*A*/ NextAction::array(0, new NextAction("sinister strike"), NULL), + /*C*/ NULL); } static ActionNode* envenom(PlayerbotAI* ai) { - return new ActionNode ("envenom", - /*P*/ NULL, - /*A*/ NextAction::array(0, new NextAction("eviscerate"), NULL), - /*C*/ NULL); + return new ActionNode("envenom", + /*P*/ NULL, + /*A*/ NextAction::array(0, new NextAction("eviscerate"), NULL), + /*C*/ NULL); } }; @@ -34,70 +36,55 @@ AssassinationRogueStrategy::AssassinationRogueStrategy(PlayerbotAI* ai) : MeleeC NextAction** AssassinationRogueStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("melee", ACTION_DEFAULT), - NULL); + return NextAction::array(0, new NextAction("melee", ACTION_DEFAULT), NULL); } -void AssassinationRogueStrategy::InitTriggers(std::vector &triggers) +void AssassinationRogueStrategy::InitTriggers(std::vector& triggers) { MeleeCombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode( - "high energy available", - NextAction::array(0, - new NextAction("garrote", ACTION_HIGH + 7), - new NextAction("ambush", ACTION_HIGH + 6), nullptr))); + triggers.push_back(new TriggerNode("high energy available", + NextAction::array(0, new NextAction("garrote", ACTION_HIGH + 7), + new NextAction("ambush", ACTION_HIGH + 6), nullptr))); + + triggers.push_back(new TriggerNode("high energy available", + NextAction::array(0, new NextAction("mutilate", ACTION_NORMAL + 3), NULL))); triggers.push_back(new TriggerNode( - "high energy available", - NextAction::array(0, new NextAction("mutilate", ACTION_NORMAL + 3), NULL))); + "hunger for blood", NextAction::array(0, new NextAction("hunger for blood", ACTION_HIGH + 6), NULL))); + + triggers.push_back(new TriggerNode("slice and dice", + NextAction::array(0, new NextAction("slice and dice", ACTION_HIGH + 5), NULL))); + + triggers.push_back(new TriggerNode("combo points 3 available", + NextAction::array(0, new NextAction("envenom", ACTION_HIGH + 4), NULL))); + + triggers.push_back( + new TriggerNode("expose armor", NextAction::array(0, new NextAction("expose armor", ACTION_HIGH + 3), NULL))); + + triggers.push_back( + new TriggerNode("medium threat", NextAction::array(0, new NextAction("vanish", ACTION_HIGH), NULL))); + + triggers.push_back( + new TriggerNode("low health", NextAction::array(0, new NextAction("evasion", ACTION_EMERGENCY), + new NextAction("feint", ACTION_EMERGENCY), NULL))); + + triggers.push_back( + new TriggerNode("kick", NextAction::array(0, new NextAction("kick", ACTION_INTERRUPT + 2), NULL))); + + triggers.push_back( + new TriggerNode("kick on enemy healer", + NextAction::array(0, new NextAction("kick on enemy healer", ACTION_INTERRUPT + 1), NULL))); + + triggers.push_back( + new TriggerNode("medium aoe", NextAction::array(0, new NextAction("fan of knives", ACTION_NORMAL + 5), NULL))); triggers.push_back(new TriggerNode( - "hunger for blood", - NextAction::array(0, new NextAction("hunger for blood", ACTION_HIGH + 6), NULL))); + "tricks of the trade on main tank", + NextAction::array(0, new NextAction("tricks of the trade on main tank", ACTION_HIGH + 7), NULL))); triggers.push_back(new TriggerNode( - "slice and dice", - NextAction::array(0, new NextAction("slice and dice", ACTION_HIGH + 5), NULL))); - - triggers.push_back(new TriggerNode( - "combo points 3 available", - NextAction::array(0, new NextAction("envenom", ACTION_HIGH + 4), NULL))); - - triggers.push_back(new TriggerNode( - "expose armor", - NextAction::array(0, new NextAction("expose armor", ACTION_HIGH + 3), NULL))); - - triggers.push_back(new TriggerNode( - "medium threat", - NextAction::array(0, new NextAction("vanish", ACTION_HIGH), NULL))); - - triggers.push_back(new TriggerNode( - "low health", - NextAction::array(0, new NextAction("evasion", ACTION_EMERGENCY), new NextAction("feint", ACTION_EMERGENCY), NULL))); - - triggers.push_back(new TriggerNode( - "kick", - NextAction::array(0, new NextAction("kick", ACTION_INTERRUPT + 2), NULL))); - - triggers.push_back(new TriggerNode( - "kick on enemy healer", - NextAction::array(0, new NextAction("kick on enemy healer", ACTION_INTERRUPT + 1), NULL))); - - triggers.push_back(new TriggerNode( - "medium aoe", - NextAction::array(0, new NextAction("fan of knives", ACTION_NORMAL + 5), NULL))); - - triggers.push_back(new TriggerNode( - "tricks of the trade on main tank", - NextAction::array(0, new NextAction("tricks of the trade on main tank", ACTION_HIGH + 7), NULL))); - - triggers.push_back(new TriggerNode( - "enemy out of melee", - NextAction::array(0, - new NextAction("stealth", ACTION_NORMAL + 9), - new NextAction("sprint", ACTION_NORMAL + 8), - new NextAction("reach melee", ACTION_NORMAL + 7), - NULL))); + "enemy out of melee", + NextAction::array(0, new NextAction("stealth", ACTION_NORMAL + 9), new NextAction("sprint", ACTION_NORMAL + 8), + new NextAction("reach melee", ACTION_NORMAL + 7), NULL))); } diff --git a/src/strategy/rogue/AssassinationRogueStrategy.h b/src/strategy/rogue/AssassinationRogueStrategy.h index b6aa26b5..ae36d272 100644 --- a/src/strategy/rogue/AssassinationRogueStrategy.h +++ b/src/strategy/rogue/AssassinationRogueStrategy.h @@ -10,7 +10,7 @@ public: AssassinationRogueStrategy(PlayerbotAI* ai); public: - virtual void InitTriggers(std::vector &triggers) override; + virtual void InitTriggers(std::vector& triggers) override; virtual std::string const getName() override { return "melee"; } virtual NextAction** getDefaultActions() override; uint32 GetType() const override { return MeleeCombatStrategy::GetType() | STRATEGY_TYPE_DPS; } diff --git a/src/strategy/rogue/DpsRogueStrategy.cpp b/src/strategy/rogue/DpsRogueStrategy.cpp index ad5ef8e6..f3b2ab1c 100644 --- a/src/strategy/rogue/DpsRogueStrategy.cpp +++ b/src/strategy/rogue/DpsRogueStrategy.cpp @@ -1,75 +1,76 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DpsRogueStrategy.h" + #include "Playerbots.h" class DpsRogueStrategyActionNodeFactory : public NamedObjectFactory { - public: - DpsRogueStrategyActionNodeFactory() - { - creators["mutilate"] = &mutilate; - creators["sinister strike"] = &sinister_strike; - creators["kick"] = &kick; - creators["kidney shot"] = &kidney_shot; - creators["backstab"] = &backstab; - creators["melee"] = &melee; - creators["rupture"] = &rupture; - } +public: + DpsRogueStrategyActionNodeFactory() + { + creators["mutilate"] = &mutilate; + creators["sinister strike"] = &sinister_strike; + creators["kick"] = &kick; + creators["kidney shot"] = &kidney_shot; + creators["backstab"] = &backstab; + creators["melee"] = &melee; + creators["rupture"] = &rupture; + } - private: - static ActionNode* melee(PlayerbotAI* botAI) - { - return new ActionNode ("melee", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("mutilate"), nullptr), - /*C*/ nullptr); - } - static ActionNode* mutilate(PlayerbotAI* botAI) - { - return new ActionNode ("mutilate", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("sinister strike"), nullptr), - /*C*/ nullptr); - } - static ActionNode* sinister_strike(PlayerbotAI* botAI) - { - return new ActionNode ("sinister strike", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), - /*C*/ nullptr); - } - static ActionNode* kick(PlayerbotAI* botAI) - { - return new ActionNode ("kick", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("kidney shot"), nullptr), - /*C*/ nullptr); - } - static ActionNode* kidney_shot(PlayerbotAI* botAI) - { - return new ActionNode ("kidney shot", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } - static ActionNode* backstab(PlayerbotAI* botAI) - { - return new ActionNode ("backstab", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("mutilate"), nullptr), - /*C*/ nullptr); - } - static ActionNode* rupture(PlayerbotAI* botAI) - { - return new ActionNode ("rupture", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("eviscerate"), nullptr), - /*C*/ nullptr); - } - +private: + static ActionNode* melee(PlayerbotAI* botAI) + { + return new ActionNode("melee", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("mutilate"), nullptr), + /*C*/ nullptr); + } + static ActionNode* mutilate(PlayerbotAI* botAI) + { + return new ActionNode("mutilate", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("sinister strike"), nullptr), + /*C*/ nullptr); + } + static ActionNode* sinister_strike(PlayerbotAI* botAI) + { + return new ActionNode("sinister strike", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), + /*C*/ nullptr); + } + static ActionNode* kick(PlayerbotAI* botAI) + { + return new ActionNode("kick", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("kidney shot"), nullptr), + /*C*/ nullptr); + } + static ActionNode* kidney_shot(PlayerbotAI* botAI) + { + return new ActionNode("kidney shot", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } + static ActionNode* backstab(PlayerbotAI* botAI) + { + return new ActionNode("backstab", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("mutilate"), nullptr), + /*C*/ nullptr); + } + static ActionNode* rupture(PlayerbotAI* botAI) + { + return new ActionNode("rupture", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("eviscerate"), nullptr), + /*C*/ nullptr); + } }; DpsRogueStrategy::DpsRogueStrategy(PlayerbotAI* botAI) : MeleeCombatStrategy(botAI) @@ -79,132 +80,116 @@ DpsRogueStrategy::DpsRogueStrategy(PlayerbotAI* botAI) : MeleeCombatStrategy(bot NextAction** DpsRogueStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("killing spree", ACTION_DEFAULT + 0.1f), - new NextAction("melee", ACTION_DEFAULT), nullptr); + return NextAction::array(0, new NextAction("killing spree", ACTION_DEFAULT + 0.1f), + new NextAction("melee", ACTION_DEFAULT), nullptr); } void DpsRogueStrategy::InitTriggers(std::vector& triggers) { MeleeCombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode( - "high energy available", - NextAction::array(0, - new NextAction("garrote", ACTION_HIGH + 7), - new NextAction("ambush", ACTION_HIGH + 6), nullptr))); + triggers.push_back(new TriggerNode("high energy available", + NextAction::array(0, new NextAction("garrote", ACTION_HIGH + 7), + new NextAction("ambush", ACTION_HIGH + 6), nullptr))); triggers.push_back(new TriggerNode( - "high energy available", - NextAction::array(0, new NextAction("sinister strike", ACTION_NORMAL + 3), nullptr))); + "high energy available", NextAction::array(0, new NextAction("sinister strike", ACTION_NORMAL + 3), nullptr))); triggers.push_back(new TriggerNode( - "slice and dice", - NextAction::array(0, new NextAction("slice and dice", ACTION_HIGH + 2), nullptr))); + "slice and dice", NextAction::array(0, new NextAction("slice and dice", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode( - "combo points available", - NextAction::array(0, - new NextAction("rupture", ACTION_HIGH + 1), nullptr))); + triggers.push_back(new TriggerNode("combo points available", + NextAction::array(0, new NextAction("rupture", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode( - "target with combo points almost dead", - NextAction::array(0, - new NextAction("eviscerate", ACTION_HIGH + 1), nullptr))); + triggers.push_back(new TriggerNode("target with combo points almost dead", + NextAction::array(0, new NextAction("eviscerate", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode( - "medium threat", - NextAction::array(0, new NextAction("vanish", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("medium threat", NextAction::array(0, new NextAction("vanish", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode( - "low health", - NextAction::array(0, new NextAction("evasion", ACTION_EMERGENCY), new NextAction("feint", ACTION_EMERGENCY), nullptr))); + triggers.push_back( + new TriggerNode("low health", NextAction::array(0, new NextAction("evasion", ACTION_EMERGENCY), + new NextAction("feint", ACTION_EMERGENCY), nullptr))); - triggers.push_back(new TriggerNode( - "kick", - NextAction::array(0, new NextAction("kick", ACTION_INTERRUPT + 2), nullptr))); + triggers.push_back( + new TriggerNode("kick", NextAction::array(0, new NextAction("kick", ACTION_INTERRUPT + 2), nullptr))); - triggers.push_back(new TriggerNode( - "kick on enemy healer", - NextAction::array(0, new NextAction("kick on enemy healer", ACTION_INTERRUPT + 1), nullptr))); + triggers.push_back( + new TriggerNode("kick on enemy healer", + NextAction::array(0, new NextAction("kick on enemy healer", ACTION_INTERRUPT + 1), nullptr))); // triggers.push_back(new TriggerNode( // "behind target", // NextAction::array(0, new NextAction("backstab", ACTION_NORMAL), nullptr))); - triggers.push_back(new TriggerNode( - "light aoe", - NextAction::array(0, new NextAction("blade flurry", ACTION_HIGH + 3), nullptr))); - - triggers.push_back(new TriggerNode( - "enemy out of melee", - NextAction::array(0, - new NextAction("stealth", ACTION_NORMAL + 9), - new NextAction("sprint", ACTION_NORMAL + 8), - new NextAction("reach melee", ACTION_NORMAL + 7), - nullptr))); + triggers.push_back( + new TriggerNode("light aoe", NextAction::array(0, new NextAction("blade flurry", ACTION_HIGH + 3), nullptr))); triggers.push_back(new TriggerNode( - "expose armor", - NextAction::array(0, new NextAction("expose armor", ACTION_HIGH + 3), nullptr))); - + "enemy out of melee", + NextAction::array(0, new NextAction("stealth", ACTION_NORMAL + 9), new NextAction("sprint", ACTION_NORMAL + 8), + new NextAction("reach melee", ACTION_NORMAL + 7), nullptr))); + + triggers.push_back(new TriggerNode("expose armor", + NextAction::array(0, new NextAction("expose armor", ACTION_HIGH + 3), nullptr))); + triggers.push_back(new TriggerNode( - "tricks of the trade on main tank", - NextAction::array(0, new NextAction("tricks of the trade on main tank", ACTION_HIGH + 7), nullptr))); + "tricks of the trade on main tank", + NextAction::array(0, new NextAction("tricks of the trade on main tank", ACTION_HIGH + 7), nullptr))); } class StealthedRogueStrategyActionNodeFactory : public NamedObjectFactory { - public: - StealthedRogueStrategyActionNodeFactory() - { - creators["ambush"] = &ambush; - creators["cheap shot"] = &cheap_shot; - creators["garrote"] = &garrote; - creators["sap"] = &sap; - creators["sinister strike"] = &sinister_strike; - } +public: + StealthedRogueStrategyActionNodeFactory() + { + creators["ambush"] = &ambush; + creators["cheap shot"] = &cheap_shot; + creators["garrote"] = &garrote; + creators["sap"] = &sap; + creators["sinister strike"] = &sinister_strike; + } - private: - static ActionNode* ambush(PlayerbotAI* botAI) - { - return new ActionNode("ambush", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("garrote"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* ambush(PlayerbotAI* botAI) + { + return new ActionNode("ambush", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("garrote"), nullptr), + /*C*/ nullptr); + } - static ActionNode* cheap_shot(PlayerbotAI* botAI) - { - return new ActionNode("cheap shot", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* cheap_shot(PlayerbotAI* botAI) + { + return new ActionNode("cheap shot", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* garrote(PlayerbotAI* botAI) - { - return new ActionNode("garrote", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* garrote(PlayerbotAI* botAI) + { + return new ActionNode("garrote", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* sap(PlayerbotAI* botAI) - { - return new ActionNode("sap", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* sap(PlayerbotAI* botAI) + { + return new ActionNode("sap", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ nullptr); + } - static ActionNode* sinister_strike(PlayerbotAI* botAI) - { - return new ActionNode("sinister strike", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("cheap shot"), nullptr), - /*C*/ nullptr); - } + static ActionNode* sinister_strike(PlayerbotAI* botAI) + { + return new ActionNode("sinister strike", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("cheap shot"), nullptr), + /*C*/ nullptr); + } }; StealthedRogueStrategy::StealthedRogueStrategy(PlayerbotAI* botAI) : Strategy(botAI) @@ -214,44 +199,58 @@ StealthedRogueStrategy::StealthedRogueStrategy(PlayerbotAI* botAI) : Strategy(bo NextAction** StealthedRogueStrategy::getDefaultActions() { - return NextAction::array(0, new NextAction("ambush", ACTION_NORMAL + 4), new NextAction("backstab", ACTION_NORMAL + 3), new NextAction("cheap shot", ACTION_NORMAL + 2), - new NextAction("sinister strike", ACTION_NORMAL + 1), new NextAction("melee", ACTION_NORMAL), nullptr); + return NextAction::array( + 0, new NextAction("ambush", ACTION_NORMAL + 4), new NextAction("backstab", ACTION_NORMAL + 3), + new NextAction("cheap shot", ACTION_NORMAL + 2), new NextAction("sinister strike", ACTION_NORMAL + 1), + new NextAction("melee", ACTION_NORMAL), nullptr); } void StealthedRogueStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("combo points available", NextAction::array(0, new NextAction("eviscerate", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("kick", NextAction::array(0, new NextAction("cheap shot", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("kick on enemy healer", NextAction::array(0, new NextAction("cheap shot", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("behind target", NextAction::array(0, new NextAction("ambush", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("not behind target", NextAction::array(0, new NextAction("cheap shot", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("enemy flagcarrier near", NextAction::array(0, new NextAction("sprint", ACTION_EMERGENCY + 1), nullptr))); - triggers.push_back(new TriggerNode("unstealth", NextAction::array(0, new NextAction("unstealth", ACTION_NORMAL), nullptr))); - /*triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("food", ACTION_EMERGENCY + 1), nullptr)));*/ - triggers.push_back(new TriggerNode("no stealth", NextAction::array(0, new NextAction("check stealth", ACTION_EMERGENCY), nullptr))); - triggers.push_back(new TriggerNode("sprint", NextAction::array(0, new NextAction("sprint", ACTION_INTERRUPT), nullptr))); - + triggers.push_back(new TriggerNode("combo points available", + NextAction::array(0, new NextAction("eviscerate", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("kick", NextAction::array(0, new NextAction("cheap shot", ACTION_INTERRUPT), nullptr))); + triggers.push_back(new TriggerNode("kick on enemy healer", + NextAction::array(0, new NextAction("cheap shot", ACTION_INTERRUPT), nullptr))); + triggers.push_back( + new TriggerNode("behind target", NextAction::array(0, new NextAction("ambush", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("not behind target", NextAction::array(0, new NextAction("cheap shot", ACTION_HIGH), nullptr))); + triggers.push_back(new TriggerNode("enemy flagcarrier near", + NextAction::array(0, new NextAction("sprint", ACTION_EMERGENCY + 1), nullptr))); + triggers.push_back( + new TriggerNode("unstealth", NextAction::array(0, new NextAction("unstealth", ACTION_NORMAL), nullptr))); + /*triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("food", ACTION_EMERGENCY + + * 1), nullptr)));*/ + triggers.push_back(new TriggerNode( + "no stealth", NextAction::array(0, new NextAction("check stealth", ACTION_EMERGENCY), nullptr))); + triggers.push_back( + new TriggerNode("sprint", NextAction::array(0, new NextAction("sprint", ACTION_INTERRUPT), nullptr))); } void StealthStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("stealth", NextAction::array(0, new NextAction("stealth", ACTION_INTERRUPT), nullptr))); + triggers.push_back( + new TriggerNode("stealth", NextAction::array(0, new NextAction("stealth", ACTION_INTERRUPT), nullptr))); } void RogueAoeStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("light aoe", NextAction::array(0, new NextAction("blade flurry", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("light aoe", NextAction::array(0, new NextAction("blade flurry", ACTION_HIGH), nullptr))); triggers.push_back(new TriggerNode( - "medium aoe", - NextAction::array(0, new NextAction("fan of knives", ACTION_NORMAL + 5), nullptr))); + "medium aoe", NextAction::array(0, new NextAction("fan of knives", ACTION_NORMAL + 5), nullptr))); } void RogueBoostStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("adrenaline rush", NextAction::array(0, new NextAction("adrenaline rush", ACTION_HIGH + 2), nullptr))); + triggers.push_back(new TriggerNode( + "adrenaline rush", NextAction::array(0, new NextAction("adrenaline rush", ACTION_HIGH + 2), nullptr))); } void RogueCcStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("sap", NextAction::array(0, new NextAction("stealth", ACTION_INTERRUPT), new NextAction("sap", ACTION_INTERRUPT), nullptr))); + triggers.push_back(new TriggerNode("sap", NextAction::array(0, new NextAction("stealth", ACTION_INTERRUPT), + new NextAction("sap", ACTION_INTERRUPT), nullptr))); } diff --git a/src/strategy/rogue/DpsRogueStrategy.h b/src/strategy/rogue/DpsRogueStrategy.h index 4baf789b..39aee91f 100644 --- a/src/strategy/rogue/DpsRogueStrategy.h +++ b/src/strategy/rogue/DpsRogueStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DPSROGUESTRATEGY_H @@ -12,60 +13,60 @@ class PlayerbotAI; class DpsRogueStrategy : public MeleeCombatStrategy { - public: - DpsRogueStrategy(PlayerbotAI* botAI); +public: + DpsRogueStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "dps"; } - NextAction** getDefaultActions() override; - uint32 GetType() const override { return MeleeCombatStrategy::GetType() | STRATEGY_TYPE_DPS; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "dps"; } + NextAction** getDefaultActions() override; + uint32 GetType() const override { return MeleeCombatStrategy::GetType() | STRATEGY_TYPE_DPS; } }; class StealthedRogueStrategy : public Strategy { - public: - StealthedRogueStrategy(PlayerbotAI* botAI); +public: + StealthedRogueStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "stealthed"; } - NextAction** getDefaultActions() override; + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "stealthed"; } + NextAction** getDefaultActions() override; }; class StealthStrategy : public Strategy { - public: - StealthStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + StealthStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - //virtual int GetType() { return STRATEGY_TYPE_NONCOMBAT; } - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "stealth"; } + // virtual int GetType() { return STRATEGY_TYPE_NONCOMBAT; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "stealth"; } }; class RogueAoeStrategy : public Strategy { - public: - RogueAoeStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + RogueAoeStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "aoe"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "aoe"; } }; class RogueBoostStrategy : public Strategy { - public: - RogueBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + RogueBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "boost"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "boost"; } }; class RogueCcStrategy : public Strategy { - public: - RogueCcStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + RogueCcStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "cc"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cc"; } }; #endif diff --git a/src/strategy/rogue/GenericRogueNonCombatStrategy.cpp b/src/strategy/rogue/GenericRogueNonCombatStrategy.cpp index b28da727..029b0d7e 100644 --- a/src/strategy/rogue/GenericRogueNonCombatStrategy.cpp +++ b/src/strategy/rogue/GenericRogueNonCombatStrategy.cpp @@ -1,55 +1,58 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericRogueNonCombatStrategy.h" -#include "Playerbots.h" +#include "Playerbots.h" class GenericRogueNonCombatStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericRogueNonCombatStrategyActionNodeFactory() - { - creators["use deadly poison on off hand"] = &use_deadly_poison_on_off_hand; - } +public: + GenericRogueNonCombatStrategyActionNodeFactory() + { + creators["use deadly poison on off hand"] = &use_deadly_poison_on_off_hand; + } - private: - static ActionNode* use_deadly_poison_on_off_hand(PlayerbotAI* botAI) - { - return new ActionNode ("use deadly poison on off hand", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("use instant poison on off hand"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* use_deadly_poison_on_off_hand(PlayerbotAI* botAI) + { + return new ActionNode("use deadly poison on off hand", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("use instant poison on off hand"), nullptr), + /*C*/ nullptr); + } }; -GenericRogueNonCombatStrategy::GenericRogueNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { - actionNodeFactories.Add(new GenericRogueNonCombatStrategyActionNodeFactory()); +GenericRogueNonCombatStrategy::GenericRogueNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) +{ + actionNodeFactories.Add(new GenericRogueNonCombatStrategyActionNodeFactory()); } void GenericRogueNonCombatStrategy::InitTriggers(std::vector& triggers) { NonCombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("player has flag", NextAction::array(0, new NextAction("sprint", ACTION_EMERGENCY + 1), nullptr))); - triggers.push_back(new TriggerNode("enemy flagcarrier near", NextAction::array(0, new NextAction("sprint", ACTION_EMERGENCY + 2), nullptr))); - // triggers.push_back(new TriggerNode("unstealth", NextAction::array(0, new NextAction("unstealth", 1.0f), nullptr))); - // triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("apply poison", 1.0f), nullptr))); + triggers.push_back(new TriggerNode("player has flag", + NextAction::array(0, new NextAction("sprint", ACTION_EMERGENCY + 1), nullptr))); + triggers.push_back(new TriggerNode("enemy flagcarrier near", + NextAction::array(0, new NextAction("sprint", ACTION_EMERGENCY + 2), nullptr))); + // triggers.push_back(new TriggerNode("unstealth", NextAction::array(0, new NextAction("unstealth", 1.0f), + // nullptr))); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("apply + // poison", 1.0f), nullptr))); - triggers.push_back(new TriggerNode( - "main hand weapon no enchant", - NextAction::array(0, new NextAction("use instant poison on main hand", 20.0f), NULL))); - - triggers.push_back(new TriggerNode( - "off hand weapon no enchant", - NextAction::array(0, new NextAction("use deadly poison on off hand", 19.0f), NULL))); + triggers.push_back( + new TriggerNode("main hand weapon no enchant", + NextAction::array(0, new NextAction("use instant poison on main hand", 20.0f), NULL))); - // triggers.push_back(new TriggerNode( - // "off hand weapon no enchant", - // NextAction::array(0, new NextAction("use instant poison", 18.0f), NULL))); + triggers.push_back( + new TriggerNode("off hand weapon no enchant", + NextAction::array(0, new NextAction("use deadly poison on off hand", 19.0f), NULL))); - triggers.push_back(new TriggerNode( - "often", - NextAction::array(0, new NextAction("unstealth", 30.0f), NULL))); + // triggers.push_back(new TriggerNode( + // "off hand weapon no enchant", + // NextAction::array(0, new NextAction("use instant poison", 18.0f), NULL))); + + triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("unstealth", 30.0f), NULL))); } diff --git a/src/strategy/rogue/GenericRogueNonCombatStrategy.h b/src/strategy/rogue/GenericRogueNonCombatStrategy.h index a7d2a6c6..2bcfbefd 100644 --- a/src/strategy/rogue/GenericRogueNonCombatStrategy.h +++ b/src/strategy/rogue/GenericRogueNonCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICROGUENONCOMBATSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class GenericRogueNonCombatStrategy : public NonCombatStrategy { - public: - GenericRogueNonCombatStrategy(PlayerbotAI* botAI); +public: + GenericRogueNonCombatStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "nc"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "nc"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/rogue/RogueActions.cpp b/src/strategy/rogue/RogueActions.cpp index 18df897c..54733caa 100644 --- a/src/strategy/rogue/RogueActions.cpp +++ b/src/strategy/rogue/RogueActions.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RogueActions.h" + #include "Event.h" #include "ObjectGuid.h" #include "Player.h" @@ -42,101 +44,123 @@ bool CastVanishAction::isUseful() return !botAI->HasAura(23333, bot) && !botAI->HasAura(23335, bot) && !botAI->HasAura(34976, bot); } -bool CastTricksOfTheTradeOnMainTankAction::isUseful() { +bool CastTricksOfTheTradeOnMainTankAction::isUseful() +{ return CastSpellAction::isUseful() && AI_VALUE2(float, "distance", GetTargetName()) < 20.0f; } -bool UseDeadlyPoisonAction::Execute(Event event) { +bool UseDeadlyPoisonAction::Execute(Event event) +{ std::vector poison_suffixs = {" IX", " VIII", " VII", " VI", " V", " IV", " III", " II", ""}; std::vector items; std::string poison_name; - for (std::string& suffix: poison_suffixs) { + for (std::string& suffix : poison_suffixs) + { poison_name = "Deadly Poison" + suffix; items = AI_VALUE2(std::vector, "inventory items", poison_name); - if (!items.empty()) { + if (!items.empty()) + { break; } } - if (items.empty()) { + if (items.empty()) + { return false; } - Item* const itemForSpell = bot->GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND ); + Item* const itemForSpell = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); return UseItem(*items.begin(), ObjectGuid::Empty, itemForSpell); // return UseItemAuto(*items.begin()); } -bool UseDeadlyPoisonAction::isPossible() { +bool UseDeadlyPoisonAction::isPossible() +{ std::vector poison_suffixs = {" IX", " VIII", " VII", " VI", " V", " IV", " III", " II", ""}; std::vector items; std::string poison_name; - for (std::string& suffix: poison_suffixs) { + for (std::string& suffix : poison_suffixs) + { poison_name = "Deadly Poison" + suffix; items = AI_VALUE2(std::vector, "inventory items", poison_name); - if (!items.empty()) { + if (!items.empty()) + { break; } } return !items.empty(); } -bool UseInstantPoisonAction::Execute(Event event) { +bool UseInstantPoisonAction::Execute(Event event) +{ std::vector poison_suffixs = {" IX", " VIII", " VII", " VI", " V", " IV", " III", " II", ""}; std::vector items; std::string poison_name; - for (std::string& suffix: poison_suffixs) { + for (std::string& suffix : poison_suffixs) + { poison_name = "Instant Poison" + suffix; items = AI_VALUE2(std::vector, "inventory items", poison_name); - if (!items.empty()) { + if (!items.empty()) + { break; } } - if (items.empty()) { + if (items.empty()) + { return false; } - Item* const itemForSpell = bot->GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND ); + Item* const itemForSpell = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); return UseItem(*items.begin(), ObjectGuid::Empty, itemForSpell); } -bool UseInstantPoisonAction::isPossible() { +bool UseInstantPoisonAction::isPossible() +{ std::vector poison_suffixs = {" IX", " VIII", " VII", " VI", " V", " IV", " III", " II", ""}; std::vector items; std::string poison_name; - for (std::string& suffix: poison_suffixs) { + for (std::string& suffix : poison_suffixs) + { poison_name = "Instant Poison" + suffix; items = AI_VALUE2(std::vector, "inventory items", poison_name); - if (!items.empty()) { + if (!items.empty()) + { break; } } return !items.empty(); } -bool UseInstantPoisonOffHandAction::Execute(Event event) { +bool UseInstantPoisonOffHandAction::Execute(Event event) +{ std::vector poison_suffixs = {" IX", " VIII", " VII", " VI", " V", " IV", " III", " II", ""}; std::vector items; std::string poison_name; - for (std::string& suffix: poison_suffixs) { + for (std::string& suffix : poison_suffixs) + { poison_name = "Instant Poison" + suffix; items = AI_VALUE2(std::vector, "inventory items", poison_name); - if (!items.empty()) { + if (!items.empty()) + { break; } } - if (items.empty()) { + if (items.empty()) + { return false; } - Item* const itemForSpell = bot->GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND ); + Item* const itemForSpell = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); return UseItem(*items.begin(), ObjectGuid::Empty, itemForSpell); } -bool UseInstantPoisonOffHandAction::isPossible() { +bool UseInstantPoisonOffHandAction::isPossible() +{ std::vector poison_suffixs = {" IX", " VIII", " VII", " VI", " V", " IV", " III", " II", ""}; std::vector items; std::string poison_name; - for (std::string& suffix: poison_suffixs) { + for (std::string& suffix : poison_suffixs) + { poison_name = "Instant Poison" + suffix; items = AI_VALUE2(std::vector, "inventory items", poison_name); - if (!items.empty()) { + if (!items.empty()) + { break; } } diff --git a/src/strategy/rogue/RogueActions.h b/src/strategy/rogue/RogueActions.h index b6f34972..f68fb676 100644 --- a/src/strategy/rogue/RogueActions.h +++ b/src/strategy/rogue/RogueActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ROGUEACTIONS_H @@ -12,156 +13,156 @@ class PlayerbotAI; class CastEvasionAction : public CastBuffSpellAction { - public: - CastEvasionAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "evasion") { } +public: + CastEvasionAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "evasion") {} }; class CastHungerForBloodAction : public CastBuffSpellAction { - public: - CastHungerForBloodAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "hunger for blood") { } - std::string const GetTargetName() override { return "current target"; } +public: + CastHungerForBloodAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "hunger for blood") {} + std::string const GetTargetName() override { return "current target"; } }; class CastSprintAction : public CastBuffSpellAction { - public: - CastSprintAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "sprint") { } +public: + CastSprintAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "sprint") {} - std::string const GetTargetName() override { return "self target"; } + std::string const GetTargetName() override { return "self target"; } }; class CastStealthAction : public CastBuffSpellAction { - public: - CastStealthAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "stealth") { } +public: + CastStealthAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "stealth") {} - std::string const GetTargetName() override { return "self target"; } + std::string const GetTargetName() override { return "self target"; } - bool isPossible() override; + bool isPossible() override; }; class UnstealthAction : public Action { - public: - UnstealthAction(PlayerbotAI* botAI) : Action(botAI, "unstealth") { } +public: + UnstealthAction(PlayerbotAI* botAI) : Action(botAI, "unstealth") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; class CheckStealthAction : public Action { - public: - CheckStealthAction(PlayerbotAI* botAI) : Action(botAI, "check stealth") { } +public: + CheckStealthAction(PlayerbotAI* botAI) : Action(botAI, "check stealth") {} - bool isPossible() override { return true; } - bool Execute(Event event) override; + bool isPossible() override { return true; } + bool Execute(Event event) override; }; class CastKickAction : public CastSpellAction { - public: - CastKickAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "kick") { } +public: + CastKickAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "kick") {} }; class CastFeintAction : public CastBuffSpellAction { - public: - CastFeintAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "feint") { } +public: + CastFeintAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "feint") {} }; class CastDismantleAction : public CastSpellAction { - public: - CastDismantleAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "dismantle") { } +public: + CastDismantleAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "dismantle") {} }; class CastDistractAction : public CastSpellAction { - public: - CastDistractAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "distract") { } +public: + CastDistractAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "distract") {} }; class CastVanishAction : public CastBuffSpellAction { - public: - CastVanishAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "vanish") { } +public: + CastVanishAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "vanish") {} - bool isUseful() override; + bool isUseful() override; }; class CastBlindAction : public CastDebuffSpellAction { - public: - CastBlindAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "blind") { } +public: + CastBlindAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "blind") {} }; class CastBladeFlurryAction : public CastBuffSpellAction { - public: - CastBladeFlurryAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "blade flurry") { } +public: + CastBladeFlurryAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "blade flurry") {} }; class CastAdrenalineRushAction : public CastBuffSpellAction { - public: - CastAdrenalineRushAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "adrenaline rush") { } +public: + CastAdrenalineRushAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "adrenaline rush") {} }; class CastKillingSpreeAction : public CastMeleeSpellAction { - public: - CastKillingSpreeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "killing spree") { } +public: + CastKillingSpreeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "killing spree") {} }; class CastKickOnEnemyHealerAction : public CastSpellOnEnemyHealerAction { - public: - CastKickOnEnemyHealerAction(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, "kick") { } +public: + CastKickOnEnemyHealerAction(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, "kick") {} }; class EnvenomAction : public CastMeleeSpellAction { - public: - EnvenomAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "envenom") {} +public: + EnvenomAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "envenom") {} }; class CastTricksOfTheTradeOnMainTankAction : public BuffOnMainTankAction { - public: - CastTricksOfTheTradeOnMainTankAction(PlayerbotAI* ai) : BuffOnMainTankAction(ai, "tricks of the trade", true) {} - virtual bool isUseful() override; +public: + CastTricksOfTheTradeOnMainTankAction(PlayerbotAI* ai) : BuffOnMainTankAction(ai, "tricks of the trade", true) {} + virtual bool isUseful() override; }; class UseDeadlyPoisonAction : public UseItemAction { - public: - UseDeadlyPoisonAction(PlayerbotAI* ai) : UseItemAction(ai, "Deadly Poison") {} - virtual bool Execute(Event event) override; - virtual bool isPossible() override; +public: + UseDeadlyPoisonAction(PlayerbotAI* ai) : UseItemAction(ai, "Deadly Poison") {} + virtual bool Execute(Event event) override; + virtual bool isPossible() override; }; class UseInstantPoisonAction : public UseItemAction { - public: - UseInstantPoisonAction(PlayerbotAI* ai) : UseItemAction(ai, "Instant Poison") {} - virtual bool Execute(Event event) override; - virtual bool isPossible() override; +public: + UseInstantPoisonAction(PlayerbotAI* ai) : UseItemAction(ai, "Instant Poison") {} + virtual bool Execute(Event event) override; + virtual bool isPossible() override; }; class UseInstantPoisonOffHandAction : public UseItemAction { - public: - UseInstantPoisonOffHandAction(PlayerbotAI* ai) : UseItemAction(ai, "Instant Poison Off Hand") {} - virtual bool Execute(Event event) override; - virtual bool isPossible() override; +public: + UseInstantPoisonOffHandAction(PlayerbotAI* ai) : UseItemAction(ai, "Instant Poison Off Hand") {} + virtual bool Execute(Event event) override; + virtual bool isPossible() override; }; class FanOfKnivesAction : public CastMeleeSpellAction { - public: - FanOfKnivesAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "fan of knives") {} - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } +public: + FanOfKnivesAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "fan of knives") {} + ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } }; #endif diff --git a/src/strategy/rogue/RogueAiObjectContext.cpp b/src/strategy/rogue/RogueAiObjectContext.cpp index 469ab00e..e4f88909 100644 --- a/src/strategy/rogue/RogueAiObjectContext.cpp +++ b/src/strategy/rogue/RogueAiObjectContext.cpp @@ -1,178 +1,190 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RogueAiObjectContext.h" + +#include "AssassinationRogueStrategy.h" #include "DpsRogueStrategy.h" #include "GenericRogueNonCombatStrategy.h" +#include "NamedObjectContext.h" +#include "Playerbots.h" +#include "PullStrategy.h" #include "RogueActions.h" #include "RogueComboActions.h" #include "RogueFinishingActions.h" #include "RogueOpeningActions.h" #include "RogueTriggers.h" -#include "NamedObjectContext.h" -#include "PullStrategy.h" -#include "Playerbots.h" -#include "AssassinationRogueStrategy.h" class RogueStrategyFactoryInternal : public NamedObjectContext { - public: - RogueStrategyFactoryInternal() - { - creators["nc"] = &RogueStrategyFactoryInternal::nc; - creators["pull"] = &RogueStrategyFactoryInternal::pull; - creators["aoe"] = &RogueStrategyFactoryInternal::aoe; - creators["boost"] = &RogueStrategyFactoryInternal::boost; - creators["stealthed"] = &RogueStrategyFactoryInternal::stealthed; - creators["stealth"] = &RogueStrategyFactoryInternal::stealth; - creators["cc"] = &RogueStrategyFactoryInternal::cc; - } +public: + RogueStrategyFactoryInternal() + { + creators["nc"] = &RogueStrategyFactoryInternal::nc; + creators["pull"] = &RogueStrategyFactoryInternal::pull; + creators["aoe"] = &RogueStrategyFactoryInternal::aoe; + creators["boost"] = &RogueStrategyFactoryInternal::boost; + creators["stealthed"] = &RogueStrategyFactoryInternal::stealthed; + creators["stealth"] = &RogueStrategyFactoryInternal::stealth; + creators["cc"] = &RogueStrategyFactoryInternal::cc; + } - private: - static Strategy* boost(PlayerbotAI* botAI) { return new RogueBoostStrategy(botAI); } - static Strategy* aoe(PlayerbotAI* botAI) { return new RogueAoeStrategy(botAI); } - static Strategy* nc(PlayerbotAI* botAI) { return new GenericRogueNonCombatStrategy(botAI); } - static Strategy* pull(PlayerbotAI* botAI) { return new PullStrategy(botAI, "shoot"); } - static Strategy* stealthed(PlayerbotAI* botAI) { return new StealthedRogueStrategy(botAI); } - static Strategy* stealth(PlayerbotAI* botAI) { return new StealthStrategy(botAI); } - static Strategy* cc(PlayerbotAI* botAI) { return new RogueCcStrategy(botAI); } +private: + static Strategy* boost(PlayerbotAI* botAI) { return new RogueBoostStrategy(botAI); } + static Strategy* aoe(PlayerbotAI* botAI) { return new RogueAoeStrategy(botAI); } + static Strategy* nc(PlayerbotAI* botAI) { return new GenericRogueNonCombatStrategy(botAI); } + static Strategy* pull(PlayerbotAI* botAI) { return new PullStrategy(botAI, "shoot"); } + static Strategy* stealthed(PlayerbotAI* botAI) { return new StealthedRogueStrategy(botAI); } + static Strategy* stealth(PlayerbotAI* botAI) { return new StealthStrategy(botAI); } + static Strategy* cc(PlayerbotAI* botAI) { return new RogueCcStrategy(botAI); } }; class RogueCombatStrategyFactoryInternal : public NamedObjectContext { - public: - RogueCombatStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["dps"] = &RogueCombatStrategyFactoryInternal::dps; - creators["melee"] = &RogueCombatStrategyFactoryInternal::melee; - } +public: + RogueCombatStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["dps"] = &RogueCombatStrategyFactoryInternal::dps; + creators["melee"] = &RogueCombatStrategyFactoryInternal::melee; + } - private: - static Strategy* dps(PlayerbotAI* botAI) { return new DpsRogueStrategy(botAI); } - static Strategy* melee(PlayerbotAI* botAI) { return new AssassinationRogueStrategy(botAI); } +private: + static Strategy* dps(PlayerbotAI* botAI) { return new DpsRogueStrategy(botAI); } + static Strategy* melee(PlayerbotAI* botAI) { return new AssassinationRogueStrategy(botAI); } }; class RogueTriggerFactoryInternal : public NamedObjectContext { - public: - RogueTriggerFactoryInternal() - { - creators["kick"] = &RogueTriggerFactoryInternal::kick; - creators["rupture"] = &RogueTriggerFactoryInternal::rupture; - creators["slice and dice"] = &RogueTriggerFactoryInternal::slice_and_dice; - creators["hunger for blood"] = &RogueTriggerFactoryInternal::hunger_for_blood; - creators["expose armor"] = &RogueTriggerFactoryInternal::expose_armor; - creators["kick on enemy healer"] = &RogueTriggerFactoryInternal::kick_on_enemy_healer; - creators["unstealth"] = &RogueTriggerFactoryInternal::unstealth; - creators["sap"] = &RogueTriggerFactoryInternal::sap; - creators["in stealth"] = &RogueTriggerFactoryInternal::in_stealth; - creators["no stealth"] = &RogueTriggerFactoryInternal::no_stealth; - creators["stealth"] = &RogueTriggerFactoryInternal::stealth; - creators["sprint"] = &RogueTriggerFactoryInternal::sprint; - creators["main hand weapon no enchant"] = &RogueTriggerFactoryInternal::main_hand_weapon_no_enchant; - creators["off hand weapon no enchant"] = &RogueTriggerFactoryInternal::off_hand_weapon_no_enchant; - creators["tricks of the trade on main tank"] = &RogueTriggerFactoryInternal::tricks_of_the_trade_on_main_tank; - creators["adrenaline rush"] = &RogueTriggerFactoryInternal::adrenaline_rush; - creators["target with combo points almost dead"] =&RogueTriggerFactoryInternal::target_with_combo_points_almost_dead; - } +public: + RogueTriggerFactoryInternal() + { + creators["kick"] = &RogueTriggerFactoryInternal::kick; + creators["rupture"] = &RogueTriggerFactoryInternal::rupture; + creators["slice and dice"] = &RogueTriggerFactoryInternal::slice_and_dice; + creators["hunger for blood"] = &RogueTriggerFactoryInternal::hunger_for_blood; + creators["expose armor"] = &RogueTriggerFactoryInternal::expose_armor; + creators["kick on enemy healer"] = &RogueTriggerFactoryInternal::kick_on_enemy_healer; + creators["unstealth"] = &RogueTriggerFactoryInternal::unstealth; + creators["sap"] = &RogueTriggerFactoryInternal::sap; + creators["in stealth"] = &RogueTriggerFactoryInternal::in_stealth; + creators["no stealth"] = &RogueTriggerFactoryInternal::no_stealth; + creators["stealth"] = &RogueTriggerFactoryInternal::stealth; + creators["sprint"] = &RogueTriggerFactoryInternal::sprint; + creators["main hand weapon no enchant"] = &RogueTriggerFactoryInternal::main_hand_weapon_no_enchant; + creators["off hand weapon no enchant"] = &RogueTriggerFactoryInternal::off_hand_weapon_no_enchant; + creators["tricks of the trade on main tank"] = &RogueTriggerFactoryInternal::tricks_of_the_trade_on_main_tank; + creators["adrenaline rush"] = &RogueTriggerFactoryInternal::adrenaline_rush; + creators["target with combo points almost dead"] = + &RogueTriggerFactoryInternal::target_with_combo_points_almost_dead; + } - private: - static Trigger* adrenaline_rush(PlayerbotAI* botAI) { return new AdrenalineRushTrigger(botAI); } - static Trigger* kick(PlayerbotAI* botAI) { return new KickInterruptSpellTrigger(botAI); } - static Trigger* rupture(PlayerbotAI* botAI) { return new RuptureTrigger(botAI); } - static Trigger* slice_and_dice(PlayerbotAI* botAI) { return new SliceAndDiceTrigger(botAI); } - static Trigger* hunger_for_blood(PlayerbotAI* botAI) { return new HungerForBloodTrigger(botAI); } - static Trigger* expose_armor(PlayerbotAI* botAI) { return new ExposeArmorTrigger(botAI); } - static Trigger* kick_on_enemy_healer(PlayerbotAI* botAI) { return new KickInterruptEnemyHealerSpellTrigger(botAI); } - static Trigger* unstealth(PlayerbotAI* botAI) { return new UnstealthTrigger(botAI); } - static Trigger* sap(PlayerbotAI* botAI) { return new SapTrigger(botAI); } - static Trigger* in_stealth(PlayerbotAI* botAI) { return new InStealthTrigger(botAI); } - static Trigger* no_stealth(PlayerbotAI* botAI) { return new NoStealthTrigger(botAI); } - static Trigger* stealth(PlayerbotAI* botAI) { return new StealthTrigger(botAI); } - static Trigger* sprint(PlayerbotAI* botAI) { return new SprintTrigger(botAI); } - static Trigger* main_hand_weapon_no_enchant(PlayerbotAI* ai) { return new MainHandWeaponNoEnchantTrigger(ai); } - static Trigger* off_hand_weapon_no_enchant(PlayerbotAI* ai) { return new OffHandWeaponNoEnchantTrigger(ai); } - static Trigger* tricks_of_the_trade_on_main_tank(PlayerbotAI* ai) { return new TricksOfTheTradeOnMainTankTrigger(ai); } - static Trigger* target_with_combo_points_almost_dead(PlayerbotAI* ai) { return new TargetWithComboPointsLowerHealTrigger(ai, 3, 3.0f); } +private: + static Trigger* adrenaline_rush(PlayerbotAI* botAI) { return new AdrenalineRushTrigger(botAI); } + static Trigger* kick(PlayerbotAI* botAI) { return new KickInterruptSpellTrigger(botAI); } + static Trigger* rupture(PlayerbotAI* botAI) { return new RuptureTrigger(botAI); } + static Trigger* slice_and_dice(PlayerbotAI* botAI) { return new SliceAndDiceTrigger(botAI); } + static Trigger* hunger_for_blood(PlayerbotAI* botAI) { return new HungerForBloodTrigger(botAI); } + static Trigger* expose_armor(PlayerbotAI* botAI) { return new ExposeArmorTrigger(botAI); } + static Trigger* kick_on_enemy_healer(PlayerbotAI* botAI) { return new KickInterruptEnemyHealerSpellTrigger(botAI); } + static Trigger* unstealth(PlayerbotAI* botAI) { return new UnstealthTrigger(botAI); } + static Trigger* sap(PlayerbotAI* botAI) { return new SapTrigger(botAI); } + static Trigger* in_stealth(PlayerbotAI* botAI) { return new InStealthTrigger(botAI); } + static Trigger* no_stealth(PlayerbotAI* botAI) { return new NoStealthTrigger(botAI); } + static Trigger* stealth(PlayerbotAI* botAI) { return new StealthTrigger(botAI); } + static Trigger* sprint(PlayerbotAI* botAI) { return new SprintTrigger(botAI); } + static Trigger* main_hand_weapon_no_enchant(PlayerbotAI* ai) { return new MainHandWeaponNoEnchantTrigger(ai); } + static Trigger* off_hand_weapon_no_enchant(PlayerbotAI* ai) { return new OffHandWeaponNoEnchantTrigger(ai); } + static Trigger* tricks_of_the_trade_on_main_tank(PlayerbotAI* ai) + { + return new TricksOfTheTradeOnMainTankTrigger(ai); + } + static Trigger* target_with_combo_points_almost_dead(PlayerbotAI* ai) + { + return new TargetWithComboPointsLowerHealTrigger(ai, 3, 3.0f); + } }; class RogueAiObjectContextInternal : public NamedObjectContext { - public: - RogueAiObjectContextInternal() - { - creators["riposte"] = &RogueAiObjectContextInternal::riposte; - creators["mutilate"] = &RogueAiObjectContextInternal::mutilate; - creators["sinister strike"] = &RogueAiObjectContextInternal::sinister_strike; - creators["gouge"] = &RogueAiObjectContextInternal::gouge; - creators["kidney shot"] = &RogueAiObjectContextInternal::kidney_shot; - creators["rupture"] = &RogueAiObjectContextInternal::rupture; - creators["slice and dice"] = &RogueAiObjectContextInternal::slice_and_dice; - creators["hunger for blood"] = &RogueAiObjectContextInternal::hunger_for_blood; - creators["eviscerate"] = &RogueAiObjectContextInternal::eviscerate; - creators["vanish"] = &RogueAiObjectContextInternal::vanish; - creators["evasion"] = &RogueAiObjectContextInternal::evasion; - creators["kick"] = &RogueAiObjectContextInternal::kick; - creators["feint"] = &RogueAiObjectContextInternal::feint; - creators["backstab"] = &RogueAiObjectContextInternal::backstab; - creators["expose armor"] = &RogueAiObjectContextInternal::expose_armor; - creators["kick on enemy healer"] = &RogueAiObjectContextInternal::kick_on_enemy_healer; - creators["blade flurry"] = &RogueAiObjectContextInternal::blade_flurry; - creators["adrenaline rush"] = &RogueAiObjectContextInternal::adrenaline_rush; - creators["ambush"] = &RogueAiObjectContextInternal::ambush; - creators["stealth"] = &RogueAiObjectContextInternal::stealth; - creators["sprint"] = &RogueAiObjectContextInternal::sprint; - creators["garrote"] = &RogueAiObjectContextInternal::garrote; - creators["cheap shot"] = &RogueAiObjectContextInternal::cheap_shot; - creators["blind"] = &RogueAiObjectContextInternal::blind; - creators["unstealth"] = &RogueAiObjectContextInternal::unstealth; - creators["sap"] = &RogueAiObjectContextInternal::sap; - creators["check stealth"] = &RogueAiObjectContextInternal::check_stealth; - creators["envenom"] = &RogueAiObjectContextInternal::envenom; - creators["tricks of the trade on main tank"] = &RogueAiObjectContextInternal::tricks_of_the_trade_on_main_tank; - creators["use instant poison on main hand"] = &RogueAiObjectContextInternal::use_instant_poison; - creators["use deadly poison on off hand"] = &RogueAiObjectContextInternal::use_deadly_poison; - creators["use instant poison on off hand"] = &RogueAiObjectContextInternal::use_instant_poison_off_hand; - creators["fan of knives"] = &RogueAiObjectContextInternal::fan_of_knives; - creators["killing spree"] = &RogueAiObjectContextInternal::killing_spree; - } +public: + RogueAiObjectContextInternal() + { + creators["riposte"] = &RogueAiObjectContextInternal::riposte; + creators["mutilate"] = &RogueAiObjectContextInternal::mutilate; + creators["sinister strike"] = &RogueAiObjectContextInternal::sinister_strike; + creators["gouge"] = &RogueAiObjectContextInternal::gouge; + creators["kidney shot"] = &RogueAiObjectContextInternal::kidney_shot; + creators["rupture"] = &RogueAiObjectContextInternal::rupture; + creators["slice and dice"] = &RogueAiObjectContextInternal::slice_and_dice; + creators["hunger for blood"] = &RogueAiObjectContextInternal::hunger_for_blood; + creators["eviscerate"] = &RogueAiObjectContextInternal::eviscerate; + creators["vanish"] = &RogueAiObjectContextInternal::vanish; + creators["evasion"] = &RogueAiObjectContextInternal::evasion; + creators["kick"] = &RogueAiObjectContextInternal::kick; + creators["feint"] = &RogueAiObjectContextInternal::feint; + creators["backstab"] = &RogueAiObjectContextInternal::backstab; + creators["expose armor"] = &RogueAiObjectContextInternal::expose_armor; + creators["kick on enemy healer"] = &RogueAiObjectContextInternal::kick_on_enemy_healer; + creators["blade flurry"] = &RogueAiObjectContextInternal::blade_flurry; + creators["adrenaline rush"] = &RogueAiObjectContextInternal::adrenaline_rush; + creators["ambush"] = &RogueAiObjectContextInternal::ambush; + creators["stealth"] = &RogueAiObjectContextInternal::stealth; + creators["sprint"] = &RogueAiObjectContextInternal::sprint; + creators["garrote"] = &RogueAiObjectContextInternal::garrote; + creators["cheap shot"] = &RogueAiObjectContextInternal::cheap_shot; + creators["blind"] = &RogueAiObjectContextInternal::blind; + creators["unstealth"] = &RogueAiObjectContextInternal::unstealth; + creators["sap"] = &RogueAiObjectContextInternal::sap; + creators["check stealth"] = &RogueAiObjectContextInternal::check_stealth; + creators["envenom"] = &RogueAiObjectContextInternal::envenom; + creators["tricks of the trade on main tank"] = &RogueAiObjectContextInternal::tricks_of_the_trade_on_main_tank; + creators["use instant poison on main hand"] = &RogueAiObjectContextInternal::use_instant_poison; + creators["use deadly poison on off hand"] = &RogueAiObjectContextInternal::use_deadly_poison; + creators["use instant poison on off hand"] = &RogueAiObjectContextInternal::use_instant_poison_off_hand; + creators["fan of knives"] = &RogueAiObjectContextInternal::fan_of_knives; + creators["killing spree"] = &RogueAiObjectContextInternal::killing_spree; + } - private: - static Action* adrenaline_rush(PlayerbotAI* botAI) { return new CastAdrenalineRushAction(botAI); } - static Action* blade_flurry(PlayerbotAI* botAI) { return new CastBladeFlurryAction(botAI); } - static Action* riposte(PlayerbotAI* botAI) { return new CastRiposteAction(botAI); } - static Action* mutilate(PlayerbotAI* botAI) { return new CastMutilateAction(botAI); } - static Action* sinister_strike(PlayerbotAI* botAI) { return new CastSinisterStrikeAction(botAI); } - static Action* gouge(PlayerbotAI* botAI) { return new CastGougeAction(botAI); } - static Action* kidney_shot(PlayerbotAI* botAI) { return new CastKidneyShotAction(botAI); } - static Action* rupture(PlayerbotAI* botAI) { return new CastRuptureAction(botAI); } - static Action* slice_and_dice(PlayerbotAI* botAI) { return new CastSliceAndDiceAction(botAI); } - static Action* hunger_for_blood(PlayerbotAI* botAI) { return new CastHungerForBloodAction(botAI); } - static Action* eviscerate(PlayerbotAI* botAI) { return new CastEviscerateAction(botAI); } - static Action* vanish(PlayerbotAI* botAI) { return new CastVanishAction(botAI); } - static Action* evasion(PlayerbotAI* botAI) { return new CastEvasionAction(botAI); } - static Action* kick(PlayerbotAI* botAI) { return new CastKickAction(botAI); } - static Action* feint(PlayerbotAI* botAI) { return new CastFeintAction(botAI); } - static Action* backstab(PlayerbotAI* botAI) { return new CastBackstabAction(botAI); } - static Action* expose_armor(PlayerbotAI* botAI) { return new CastExposeArmorAction(botAI); } - static Action* kick_on_enemy_healer(PlayerbotAI* botAI) { return new CastKickOnEnemyHealerAction(botAI); } - static Action* ambush(PlayerbotAI* botAI) { return new CastAmbushAction(botAI); } - static Action* stealth(PlayerbotAI* botAI) { return new CastStealthAction(botAI); } - static Action* sprint(PlayerbotAI* botAI) { return new CastSprintAction(botAI); } - static Action* garrote(PlayerbotAI* botAI) { return new CastGarroteAction(botAI); } - static Action* cheap_shot(PlayerbotAI* botAI) { return new CastCheapShotAction(botAI); } - static Action* blind(PlayerbotAI* botAI) { return new CastBlindAction(botAI); } - static Action* check_stealth(PlayerbotAI* botAI) { return new CheckStealthAction(botAI); } - static Action* sap(PlayerbotAI* botAI) { return new CastSapAction(botAI); } - static Action* unstealth(PlayerbotAI* botAI) { return new UnstealthAction(botAI); } - static Action* envenom(PlayerbotAI* ai) { return new EnvenomAction(ai); } - static Action* tricks_of_the_trade_on_main_tank(PlayerbotAI* ai) { return new CastTricksOfTheTradeOnMainTankAction(ai); } - static Action* use_instant_poison(PlayerbotAI* ai) { return new UseInstantPoisonAction(ai); } - static Action* use_deadly_poison(PlayerbotAI* ai) { return new UseDeadlyPoisonAction(ai); } - static Action* use_instant_poison_off_hand(PlayerbotAI* ai) { return new UseInstantPoisonOffHandAction(ai); } - static Action* fan_of_knives(PlayerbotAI* ai) { return new FanOfKnivesAction(ai); } - static Action* killing_spree(PlayerbotAI* ai) { return new CastKillingSpreeAction(ai); } +private: + static Action* adrenaline_rush(PlayerbotAI* botAI) { return new CastAdrenalineRushAction(botAI); } + static Action* blade_flurry(PlayerbotAI* botAI) { return new CastBladeFlurryAction(botAI); } + static Action* riposte(PlayerbotAI* botAI) { return new CastRiposteAction(botAI); } + static Action* mutilate(PlayerbotAI* botAI) { return new CastMutilateAction(botAI); } + static Action* sinister_strike(PlayerbotAI* botAI) { return new CastSinisterStrikeAction(botAI); } + static Action* gouge(PlayerbotAI* botAI) { return new CastGougeAction(botAI); } + static Action* kidney_shot(PlayerbotAI* botAI) { return new CastKidneyShotAction(botAI); } + static Action* rupture(PlayerbotAI* botAI) { return new CastRuptureAction(botAI); } + static Action* slice_and_dice(PlayerbotAI* botAI) { return new CastSliceAndDiceAction(botAI); } + static Action* hunger_for_blood(PlayerbotAI* botAI) { return new CastHungerForBloodAction(botAI); } + static Action* eviscerate(PlayerbotAI* botAI) { return new CastEviscerateAction(botAI); } + static Action* vanish(PlayerbotAI* botAI) { return new CastVanishAction(botAI); } + static Action* evasion(PlayerbotAI* botAI) { return new CastEvasionAction(botAI); } + static Action* kick(PlayerbotAI* botAI) { return new CastKickAction(botAI); } + static Action* feint(PlayerbotAI* botAI) { return new CastFeintAction(botAI); } + static Action* backstab(PlayerbotAI* botAI) { return new CastBackstabAction(botAI); } + static Action* expose_armor(PlayerbotAI* botAI) { return new CastExposeArmorAction(botAI); } + static Action* kick_on_enemy_healer(PlayerbotAI* botAI) { return new CastKickOnEnemyHealerAction(botAI); } + static Action* ambush(PlayerbotAI* botAI) { return new CastAmbushAction(botAI); } + static Action* stealth(PlayerbotAI* botAI) { return new CastStealthAction(botAI); } + static Action* sprint(PlayerbotAI* botAI) { return new CastSprintAction(botAI); } + static Action* garrote(PlayerbotAI* botAI) { return new CastGarroteAction(botAI); } + static Action* cheap_shot(PlayerbotAI* botAI) { return new CastCheapShotAction(botAI); } + static Action* blind(PlayerbotAI* botAI) { return new CastBlindAction(botAI); } + static Action* check_stealth(PlayerbotAI* botAI) { return new CheckStealthAction(botAI); } + static Action* sap(PlayerbotAI* botAI) { return new CastSapAction(botAI); } + static Action* unstealth(PlayerbotAI* botAI) { return new UnstealthAction(botAI); } + static Action* envenom(PlayerbotAI* ai) { return new EnvenomAction(ai); } + static Action* tricks_of_the_trade_on_main_tank(PlayerbotAI* ai) + { + return new CastTricksOfTheTradeOnMainTankAction(ai); + } + static Action* use_instant_poison(PlayerbotAI* ai) { return new UseInstantPoisonAction(ai); } + static Action* use_deadly_poison(PlayerbotAI* ai) { return new UseDeadlyPoisonAction(ai); } + static Action* use_instant_poison_off_hand(PlayerbotAI* ai) { return new UseInstantPoisonOffHandAction(ai); } + static Action* fan_of_knives(PlayerbotAI* ai) { return new FanOfKnivesAction(ai); } + static Action* killing_spree(PlayerbotAI* ai) { return new CastKillingSpreeAction(ai); } }; RogueAiObjectContext::RogueAiObjectContext(PlayerbotAI* botAI) : AiObjectContext(botAI) diff --git a/src/strategy/rogue/RogueAiObjectContext.h b/src/strategy/rogue/RogueAiObjectContext.h index 3f60e77c..e641623f 100644 --- a/src/strategy/rogue/RogueAiObjectContext.h +++ b/src/strategy/rogue/RogueAiObjectContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ROGUEAIOBJECTCONTEXT_H @@ -11,8 +12,8 @@ class PlayerbotAI; class RogueAiObjectContext : public AiObjectContext { - public: - RogueAiObjectContext(PlayerbotAI* botAI); +public: + RogueAiObjectContext(PlayerbotAI* botAI); }; #endif diff --git a/src/strategy/rogue/RogueComboActions.cpp b/src/strategy/rogue/RogueComboActions.cpp index 61abf9b1..21f0ea54 100644 --- a/src/strategy/rogue/RogueComboActions.cpp +++ b/src/strategy/rogue/RogueComboActions.cpp @@ -1,11 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RogueComboActions.h" + #include "Playerbots.h" bool CastComboAction::isUseful() { - return CastMeleeSpellAction::isUseful() && AI_VALUE2(uint8, "combo", "current target") < 5; + return CastMeleeSpellAction::isUseful() && AI_VALUE2(uint8, "combo", "current target") < 5; } diff --git a/src/strategy/rogue/RogueComboActions.h b/src/strategy/rogue/RogueComboActions.h index 657ccf50..171d0b7d 100644 --- a/src/strategy/rogue/RogueComboActions.h +++ b/src/strategy/rogue/RogueComboActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ROGUECOMBOACTIONS_H @@ -11,40 +12,40 @@ class PlayerbotAI; class CastComboAction : public CastMeleeSpellAction { - public: - CastComboAction(PlayerbotAI* botAI, std::string const name) : CastMeleeSpellAction(botAI, name) { } +public: + CastComboAction(PlayerbotAI* botAI, std::string const name) : CastMeleeSpellAction(botAI, name) {} - bool isUseful() override; + bool isUseful() override; }; class CastSinisterStrikeAction : public CastComboAction { - public: - CastSinisterStrikeAction(PlayerbotAI* botAI) : CastComboAction(botAI, "sinister strike") { } +public: + CastSinisterStrikeAction(PlayerbotAI* botAI) : CastComboAction(botAI, "sinister strike") {} }; class CastMutilateAction : public CastComboAction { - public: - CastMutilateAction(PlayerbotAI* botAI) : CastComboAction(botAI, "mutilate") { } +public: + CastMutilateAction(PlayerbotAI* botAI) : CastComboAction(botAI, "mutilate") {} }; class CastRiposteAction : public CastComboAction { - public: - CastRiposteAction(PlayerbotAI* botAI) : CastComboAction(botAI, "riposte") { } +public: + CastRiposteAction(PlayerbotAI* botAI) : CastComboAction(botAI, "riposte") {} }; class CastGougeAction : public CastComboAction { - public: - CastGougeAction(PlayerbotAI* botAI) : CastComboAction(botAI, "gouge") { } +public: + CastGougeAction(PlayerbotAI* botAI) : CastComboAction(botAI, "gouge") {} }; class CastBackstabAction : public CastComboAction { - public: - CastBackstabAction(PlayerbotAI* botAI) : CastComboAction(botAI, "backstab") { } +public: + CastBackstabAction(PlayerbotAI* botAI) : CastComboAction(botAI, "backstab") {} }; #endif diff --git a/src/strategy/rogue/RogueFinishingActions.h b/src/strategy/rogue/RogueFinishingActions.h index fdc606dd..464c35a1 100644 --- a/src/strategy/rogue/RogueFinishingActions.h +++ b/src/strategy/rogue/RogueFinishingActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ROGUEFINISHINGACTIONS_H @@ -11,32 +12,32 @@ class PlayerbotAI; class CastEviscerateAction : public CastMeleeSpellAction { - public: - CastEviscerateAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "eviscerate") { } +public: + CastEviscerateAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "eviscerate") {} }; class CastSliceAndDiceAction : public CastMeleeSpellAction { - public: - CastSliceAndDiceAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "slice and dice") { } +public: + CastSliceAndDiceAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "slice and dice") {} }; class CastExposeArmorAction : public CastDebuffSpellAction { - public: - CastExposeArmorAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "expose armor", false, 25.0f) { } +public: + CastExposeArmorAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "expose armor", false, 25.0f) {} }; class CastRuptureAction : public CastDebuffSpellAction { - public: - CastRuptureAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "rupture", true, 6.0f) { } +public: + CastRuptureAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "rupture", true, 6.0f) {} }; class CastKidneyShotAction : public CastMeleeSpellAction { - public: - CastKidneyShotAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "kidney shot") { } +public: + CastKidneyShotAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "kidney shot") {} }; #endif diff --git a/src/strategy/rogue/RogueOpeningActions.cpp b/src/strategy/rogue/RogueOpeningActions.cpp index 1c3aa6f3..f4beb13c 100644 --- a/src/strategy/rogue/RogueOpeningActions.cpp +++ b/src/strategy/rogue/RogueOpeningActions.cpp @@ -1,11 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RogueOpeningActions.h" + #include "Playerbots.h" -Value* CastSapAction::GetTargetValue() -{ - return context->GetValue("cc target", getName()); -} +Value* CastSapAction::GetTargetValue() { return context->GetValue("cc target", getName()); } diff --git a/src/strategy/rogue/RogueOpeningActions.h b/src/strategy/rogue/RogueOpeningActions.h index ae527eb0..8a564fc9 100644 --- a/src/strategy/rogue/RogueOpeningActions.h +++ b/src/strategy/rogue/RogueOpeningActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ROGUEOPENINGACTIONS_H @@ -12,29 +13,29 @@ class Unit; class CastSapAction : public CastMeleeSpellAction { - public: - CastSapAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "sap") { } +public: + CastSapAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "sap") {} - Value* GetTargetValue() override; - bool isUseful() override { return true; } + Value* GetTargetValue() override; + bool isUseful() override { return true; } }; class CastGarroteAction : public CastDebuffSpellAction { - public: - CastGarroteAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "garrote", true, 8.0f) { } +public: + CastGarroteAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "garrote", true, 8.0f) {} }; class CastCheapShotAction : public CastMeleeSpellAction { - public: - CastCheapShotAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "cheap shot") { } +public: + CastCheapShotAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "cheap shot") {} }; class CastAmbushAction : public CastMeleeSpellAction { - public: - CastAmbushAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "ambush") { } +public: + CastAmbushAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "ambush") {} }; #endif diff --git a/src/strategy/rogue/RogueTriggers.cpp b/src/strategy/rogue/RogueTriggers.cpp index be652f6c..31e1a390 100644 --- a/src/strategy/rogue/RogueTriggers.cpp +++ b/src/strategy/rogue/RogueTriggers.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RogueTriggers.h" + #include "GenericTriggers.h" #include "Playerbots.h" #include "ServerFacade.h" @@ -17,9 +19,12 @@ bool UnstealthTrigger::IsActive() if (!botAI->HasAura("stealth", bot)) return false; - return botAI->HasAura("stealth", bot) && !AI_VALUE(uint8, "attacker count") && (AI_VALUE2(bool, "moving", "self target") && ((botAI->GetMaster() && - sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "master target"), 10.0f) && AI_VALUE2(bool, "moving", "master target")) || - !AI_VALUE(uint8, "attacker count"))); + return botAI->HasAura("stealth", bot) && !AI_VALUE(uint8, "attacker count") && + (AI_VALUE2(bool, "moving", "self target") && + ((botAI->GetMaster() && + sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "master target"), 10.0f) && + AI_VALUE2(bool, "moving", "master target")) || + !AI_VALUE(uint8, "attacker count"))); } bool StealthTrigger::IsActive() @@ -30,7 +35,8 @@ bool StealthTrigger::IsActive() float distance = 30.f; Unit* target = AI_VALUE(Unit*, "enemy player target"); - if (target && !target->IsInWorld()) { + if (target && !target->IsInWorld()) + { return false; } if (!target) @@ -57,15 +63,9 @@ bool StealthTrigger::IsActive() return target && sServerFacade->GetDistance2d(bot, target) < distance; } -bool SapTrigger::IsPossible() -{ - return bot->GetLevel() > 10 && bot->HasSpell(6770) && !bot->IsInCombat(); -} +bool SapTrigger::IsPossible() { return bot->GetLevel() > 10 && bot->HasSpell(6770) && !bot->IsInCombat(); } -bool SprintTrigger::IsPossible() -{ - return bot->HasSpell(2983); -} +bool SprintTrigger::IsPossible() { return bot->HasSpell(2983); } bool SprintTrigger::IsActive() { @@ -81,7 +81,8 @@ bool SprintTrigger::IsActive() Unit* dps = AI_VALUE(Unit*, "dps target"); Unit* enemyPlayer = AI_VALUE(Unit*, "enemy player target"); - if (enemyPlayer && !enemyPlayer->IsInWorld()) { + if (enemyPlayer && !enemyPlayer->IsInWorld()) + { return false; } if (dps) @@ -96,33 +97,41 @@ bool SprintTrigger::IsActive() if ((dps && dps->IsInCombat()) || enemyPlayer) distance -= 10; - return AI_VALUE2(bool, "moving", "self target") && (AI_VALUE2(bool, "moving", "dps target") || AI_VALUE2(bool, "moving", "enemy player target")) && - targeted && (sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "dps target"), distance) || + return AI_VALUE2(bool, "moving", "self target") && + (AI_VALUE2(bool, "moving", "dps target") || AI_VALUE2(bool, "moving", "enemy player target")) && targeted && + (sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "dps target"), distance) || sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), distance)); } -bool ExposeArmorTrigger::IsActive() { - return DebuffTrigger::IsActive() && !botAI->HasAura("sunder armor", bot, false, false, -1, true) && AI_VALUE2(uint8, "combo", "current target") <= 3; +bool ExposeArmorTrigger::IsActive() +{ + return DebuffTrigger::IsActive() && !botAI->HasAura("sunder armor", bot, false, false, -1, true) && + AI_VALUE2(uint8, "combo", "current target") <= 3; } -bool MainHandWeaponNoEnchantTrigger::IsActive() { - Item* const itemForSpell = bot->GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND ); +bool MainHandWeaponNoEnchantTrigger::IsActive() +{ + Item* const itemForSpell = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); if (!itemForSpell || itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) return false; return true; } -bool OffHandWeaponNoEnchantTrigger::IsActive() { - Item* const itemForSpell = bot->GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND ); +bool OffHandWeaponNoEnchantTrigger::IsActive() +{ + Item* const itemForSpell = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); if (!itemForSpell || itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) return false; return true; } -bool TargetWithComboPointsLowerHealTrigger::IsActive() { +bool TargetWithComboPointsLowerHealTrigger::IsActive() +{ Unit* target = AI_VALUE(Unit*, "current target"); - if (!target || !target->IsAlive() || !target->IsInWorld()) { + if (!target || !target->IsAlive() || !target->IsInWorld()) + { return false; } - return ComboPointsAvailableTrigger::IsActive() && (target->GetHealth() / AI_VALUE(float, "expected group dps")) <= lifeTime; + return ComboPointsAvailableTrigger::IsActive() && + (target->GetHealth() / AI_VALUE(float, "expected group dps")) <= lifeTime; } \ No newline at end of file diff --git a/src/strategy/rogue/RogueTriggers.h b/src/strategy/rogue/RogueTriggers.h index 94cf199f..30ca4105 100644 --- a/src/strategy/rogue/RogueTriggers.h +++ b/src/strategy/rogue/RogueTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ROGUETRIGGERS_H @@ -11,121 +12,125 @@ class PlayerbotAI; class KickInterruptSpellTrigger : public InterruptSpellTrigger { - public: - KickInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "kick") { } +public: + KickInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "kick") {} }; class SliceAndDiceTrigger : public BuffTrigger { - public: - SliceAndDiceTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "slice and dice") { } +public: + SliceAndDiceTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "slice and dice") {} }; class HungerForBloodTrigger : public BuffTrigger { - public: - HungerForBloodTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "hunger for blood") { } +public: + HungerForBloodTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "hunger for blood") {} }; class AdrenalineRushTrigger : public BoostTrigger { - public: - AdrenalineRushTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "adrenaline rush") { } +public: + AdrenalineRushTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "adrenaline rush") {} - // bool isPossible(); + // bool isPossible(); }; class RuptureTrigger : public DebuffTrigger { - public: - RuptureTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "rupture", 1, true) { } +public: + RuptureTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "rupture", 1, true) {} }; class ExposeArmorTrigger : public DebuffTrigger { - public: - ExposeArmorTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "expose armor") { } - virtual bool IsActive() override; +public: + ExposeArmorTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "expose armor") {} + virtual bool IsActive() override; }; class KickInterruptEnemyHealerSpellTrigger : public InterruptEnemyHealerTrigger { - public: - KickInterruptEnemyHealerSpellTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "kick") { } +public: + KickInterruptEnemyHealerSpellTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "kick") {} }; class InStealthTrigger : public HasAuraTrigger { - public: - InStealthTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "stealth") { } +public: + InStealthTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "stealth") {} }; class NoStealthTrigger : public HasNoAuraTrigger { - public: - NoStealthTrigger(PlayerbotAI* botAI) : HasNoAuraTrigger(botAI, "stealth") { } +public: + NoStealthTrigger(PlayerbotAI* botAI) : HasNoAuraTrigger(botAI, "stealth") {} }; class UnstealthTrigger : public BuffTrigger { - public: - UnstealthTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "stealth", 3) { } +public: + UnstealthTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "stealth", 3) {} - bool IsActive() override; + bool IsActive() override; }; class StealthTrigger : public Trigger { - public: - StealthTrigger(PlayerbotAI* botAI) : Trigger(botAI, "stealth") { } +public: + StealthTrigger(PlayerbotAI* botAI) : Trigger(botAI, "stealth") {} - bool IsActive() override; + bool IsActive() override; }; class SapTrigger : public HasCcTargetTrigger { - public: - SapTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "sap") { } +public: + SapTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "sap") {} - bool IsPossible(); + bool IsPossible(); }; class SprintTrigger : public BuffTrigger { - public: - SprintTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "sprint", 3) { } +public: + SprintTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "sprint", 3) {} - bool IsPossible(); - bool IsActive() override; + bool IsPossible(); + bool IsActive() override; }; class MainHandWeaponNoEnchantTrigger : public BuffTrigger { - public: - MainHandWeaponNoEnchantTrigger(PlayerbotAI* ai) : BuffTrigger(ai, "main hand", 1) {} - virtual bool IsActive(); +public: + MainHandWeaponNoEnchantTrigger(PlayerbotAI* ai) : BuffTrigger(ai, "main hand", 1) {} + virtual bool IsActive(); }; class OffHandWeaponNoEnchantTrigger : public BuffTrigger { - public: - OffHandWeaponNoEnchantTrigger(PlayerbotAI* ai) : BuffTrigger(ai, "off hand", 1) {} - virtual bool IsActive(); +public: + OffHandWeaponNoEnchantTrigger(PlayerbotAI* ai) : BuffTrigger(ai, "off hand", 1) {} + virtual bool IsActive(); }; class TricksOfTheTradeOnMainTankTrigger : public BuffOnMainTankTrigger { - public: - TricksOfTheTradeOnMainTankTrigger(PlayerbotAI* ai) : BuffOnMainTankTrigger(ai, "tricks of the trade", true) {} +public: + TricksOfTheTradeOnMainTankTrigger(PlayerbotAI* ai) : BuffOnMainTankTrigger(ai, "tricks of the trade", true) {} }; class TargetWithComboPointsLowerHealTrigger : public ComboPointsAvailableTrigger { - public: - TargetWithComboPointsLowerHealTrigger(PlayerbotAI* ai, int32 combo_point = 5, float lifeTime = 8.0f) : ComboPointsAvailableTrigger(ai, combo_point), lifeTime(lifeTime) {} - bool IsActive() override; - private: - float lifeTime; +public: + TargetWithComboPointsLowerHealTrigger(PlayerbotAI* ai, int32 combo_point = 5, float lifeTime = 8.0f) + : ComboPointsAvailableTrigger(ai, combo_point), lifeTime(lifeTime) + { + } + bool IsActive() override; + +private: + float lifeTime; }; #endif diff --git a/src/strategy/shaman/CasterShamanStrategy.cpp b/src/strategy/shaman/CasterShamanStrategy.cpp index 381e7070..050be6f1 100644 --- a/src/strategy/shaman/CasterShamanStrategy.cpp +++ b/src/strategy/shaman/CasterShamanStrategy.cpp @@ -1,34 +1,36 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CasterShamanStrategy.h" + #include "Playerbots.h" class CasterShamanStrategyActionNodeFactory : public NamedObjectFactory { - public: - CasterShamanStrategyActionNodeFactory() - { - creators["magma totem"] = &magma_totem; - creators["totem of wrath"] = &totem_of_wrath; - } +public: + CasterShamanStrategyActionNodeFactory() + { + creators["magma totem"] = &magma_totem; + creators["totem of wrath"] = &totem_of_wrath; + } - private: - static ActionNode* magma_totem([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("magma totem", - /*P*/ nullptr, - /*A*/ nullptr, - /*C*/ NextAction::array(0, new NextAction("fire nova"), nullptr)); - } - static ActionNode* totem_of_wrath(PlayerbotAI* botAI) - { - return new ActionNode ("totem of wrath", - /*P*/ NULL, - /*A*/ NextAction::array(0, new NextAction("flametongue totem"), NULL), - /*C*/ NULL); - } +private: + static ActionNode* magma_totem([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("magma totem", + /*P*/ nullptr, + /*A*/ nullptr, + /*C*/ NextAction::array(0, new NextAction("fire nova"), nullptr)); + } + static ActionNode* totem_of_wrath(PlayerbotAI* botAI) + { + return new ActionNode("totem of wrath", + /*P*/ NULL, + /*A*/ NextAction::array(0, new NextAction("flametongue totem"), NULL), + /*C*/ NULL); + } }; CasterShamanStrategy::CasterShamanStrategy(PlayerbotAI* botAI) : GenericShamanStrategy(botAI) @@ -38,35 +40,41 @@ CasterShamanStrategy::CasterShamanStrategy(PlayerbotAI* botAI) : GenericShamanSt NextAction** CasterShamanStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("lava burst", ACTION_DEFAULT + 0.2f), - new NextAction("lightning bolt", ACTION_DEFAULT), - NULL); + return NextAction::array(0, new NextAction("lava burst", ACTION_DEFAULT + 0.2f), + new NextAction("lightning bolt", ACTION_DEFAULT), NULL); } void CasterShamanStrategy::InitTriggers(std::vector& triggers) { GenericShamanStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", ACTION_NORMAL + 9), nullptr))); - // triggers.push_back(new TriggerNode("shaman weapon", NextAction::array(0, new NextAction("flametongue weapon", 23.0f), nullptr))); - triggers.push_back(new TriggerNode("main hand weapon no imbue", NextAction::array(0, new NextAction("flametongue weapon", 22.0f), nullptr))); - // triggers.push_back(new TriggerNode("searing totem", NextAction::array(0, new NextAction("searing totem", 19.0f), nullptr))); - triggers.push_back(new TriggerNode("flame shock", NextAction::array(0, new NextAction("flame shock", 20.0f), nullptr))); - triggers.push_back(new TriggerNode("elemental mastery", NextAction::array(0, new NextAction("elemental mastery", 27.0f), nullptr))); - // triggers.push_back(new TriggerNode("frost shock snare", NextAction::array(0, new NextAction("frost shock", 21.0f), nullptr))); - triggers.push_back(new TriggerNode( - "no fire totem", - NextAction::array(0, - new NextAction("totem of wrath", 15.0f), NULL))); + // triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", + // ACTION_NORMAL + 9), nullptr))); triggers.push_back(new TriggerNode("shaman weapon", NextAction::array(0, new + // NextAction("flametongue weapon", 23.0f), nullptr))); + triggers.push_back(new TriggerNode("main hand weapon no imbue", + NextAction::array(0, new NextAction("flametongue weapon", 22.0f), nullptr))); + // triggers.push_back(new TriggerNode("searing totem", NextAction::array(0, new NextAction("searing totem", 19.0f), + // nullptr))); + triggers.push_back( + new TriggerNode("flame shock", NextAction::array(0, new NextAction("flame shock", 20.0f), nullptr))); + triggers.push_back(new TriggerNode("elemental mastery", + NextAction::array(0, new NextAction("elemental mastery", 27.0f), nullptr))); + // triggers.push_back(new TriggerNode("frost shock snare", NextAction::array(0, new NextAction("frost + // shock", 21.0f), nullptr))); + triggers.push_back( + new TriggerNode("no fire totem", NextAction::array(0, new NextAction("totem of wrath", 15.0f), NULL))); - triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new NextAction("thunderstorm", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new NextAction("thunderstorm", ACTION_HIGH + 1), nullptr))); + triggers.push_back(new TriggerNode("enemy is close", + NextAction::array(0, new NextAction("thunderstorm", ACTION_HIGH + 1), nullptr))); + triggers.push_back( + new TriggerNode("medium mana", NextAction::array(0, new NextAction("thunderstorm", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("enemy too close for spell", NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); + triggers.push_back(new TriggerNode("enemy too close for spell", + NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); } void CasterAoeShamanStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("light aoe", NextAction::array(0, new NextAction("chain lightning", 25.0f), nullptr))); + triggers.push_back( + new TriggerNode("light aoe", NextAction::array(0, new NextAction("chain lightning", 25.0f), nullptr))); } diff --git a/src/strategy/shaman/CasterShamanStrategy.h b/src/strategy/shaman/CasterShamanStrategy.h index 2e45e399..dd568290 100644 --- a/src/strategy/shaman/CasterShamanStrategy.h +++ b/src/strategy/shaman/CasterShamanStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CASTSHAMANSTRATEGY_H @@ -11,22 +12,22 @@ class PlayerbotAI; class CasterShamanStrategy : public GenericShamanStrategy { - public: - CasterShamanStrategy(PlayerbotAI* botAI); +public: + CasterShamanStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - NextAction** getDefaultActions() override; - std::string const getName() override { return "caster"; } - uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_RANGED; } + void InitTriggers(std::vector& triggers) override; + NextAction** getDefaultActions() override; + std::string const getName() override { return "caster"; } + uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_RANGED; } }; class CasterAoeShamanStrategy : public CombatStrategy { - public: - CasterAoeShamanStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + CasterAoeShamanStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "caster aoe"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "caster aoe"; } }; #endif diff --git a/src/strategy/shaman/GenericShamanStrategy.cpp b/src/strategy/shaman/GenericShamanStrategy.cpp index eb4958fd..7110036d 100644 --- a/src/strategy/shaman/GenericShamanStrategy.cpp +++ b/src/strategy/shaman/GenericShamanStrategy.cpp @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HealShamanStrategy.h" @@ -8,93 +9,93 @@ class GenericShamanStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericShamanStrategyActionNodeFactory() - { - creators["flametongue weapon"] = &flametongue_weapon; - creators["frostbrand weapon"] = &frostbrand_weapon; - creators["windfury weapon"] = &windfury_weapon; - creators["lesser healing wave"] = &lesser_healing_wave; - creators["lesser healing wave on party"] = &lesser_healing_wave_on_party; - creators["chain heal"] = &chain_heal; - creators["riptide"] = &riptide; - creators["riptide on party"] = &riptide_on_party; - creators["earth shock"] = &earth_shock; - } +public: + GenericShamanStrategyActionNodeFactory() + { + creators["flametongue weapon"] = &flametongue_weapon; + creators["frostbrand weapon"] = &frostbrand_weapon; + creators["windfury weapon"] = &windfury_weapon; + creators["lesser healing wave"] = &lesser_healing_wave; + creators["lesser healing wave on party"] = &lesser_healing_wave_on_party; + creators["chain heal"] = &chain_heal; + creators["riptide"] = &riptide; + creators["riptide on party"] = &riptide_on_party; + creators["earth shock"] = &earth_shock; + } - private: - static ActionNode* earth_shock([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("earth shock", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("flame shock"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* earth_shock([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("earth shock", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("flame shock"), nullptr), + /*C*/ nullptr); + } - static ActionNode* flametongue_weapon([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("flametongue weapon", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("rockbiter weapon"), nullptr), - /*C*/ nullptr); - } + static ActionNode* flametongue_weapon([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("flametongue weapon", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("rockbiter weapon"), nullptr), + /*C*/ nullptr); + } - static ActionNode* frostbrand_weapon([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("frostbrand weapon", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("flametongue weapon"), nullptr), - /*C*/ nullptr); - } + static ActionNode* frostbrand_weapon([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("frostbrand weapon", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("flametongue weapon"), nullptr), + /*C*/ nullptr); + } - static ActionNode* windfury_weapon([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("windfury weapon", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("flametongue weapon"), nullptr), - /*C*/ nullptr); - } + static ActionNode* windfury_weapon([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("windfury weapon", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("flametongue weapon"), nullptr), + /*C*/ nullptr); + } - static ActionNode* lesser_healing_wave([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("lesser healing wave", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("healing wave"), nullptr), - /*C*/ nullptr); - } + static ActionNode* lesser_healing_wave([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("lesser healing wave", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("healing wave"), nullptr), + /*C*/ nullptr); + } - static ActionNode* lesser_healing_wave_on_party([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("lesser healing wave on party", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("healing wave on party"), nullptr), - /*C*/ nullptr); - } + static ActionNode* lesser_healing_wave_on_party([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("lesser healing wave on party", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("healing wave on party"), nullptr), + /*C*/ nullptr); + } - static ActionNode* chain_heal([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("chain heal", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("lesser healing wave"), nullptr), - /*C*/ nullptr); - } + static ActionNode* chain_heal([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("chain heal", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("lesser healing wave"), nullptr), + /*C*/ nullptr); + } - static ActionNode* riptide([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("riptide", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("healing wave"), nullptr), - /*C*/ nullptr); - } + static ActionNode* riptide([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("riptide", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("healing wave"), nullptr), + /*C*/ nullptr); + } - static ActionNode* riptide_on_party([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("riptide on party", - /*P*/ nullptr, - // /*A*/ NextAction::array(0, new NextAction("healing wave on party"), nullptr), - /*A*/ nullptr, - /*C*/ nullptr); - } + static ActionNode* riptide_on_party([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("riptide on party", + /*P*/ nullptr, + // /*A*/ NextAction::array(0, new NextAction("healing wave on party"), nullptr), + /*A*/ nullptr, + /*C*/ nullptr); + } }; GenericShamanStrategy::GenericShamanStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) @@ -106,39 +107,58 @@ void GenericShamanStrategy::InitTriggers(std::vector& triggers) { CombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("wind shear", NextAction::array(0, new NextAction("wind shear", 23.0f), nullptr))); - triggers.push_back(new TriggerNode("wind shear on enemy healer", NextAction::array(0, new NextAction("wind shear on enemy healer", 23.0f), nullptr))); - triggers.push_back(new TriggerNode("purge", NextAction::array(0, new NextAction("purge", ACTION_DISPEL), nullptr))); - // triggers.push_back(new TriggerNode("party member medium health", NextAction::array(0, new NextAction("lesser healing wave on party", 25.0f), nullptr))); - // triggers.push_back(new TriggerNode("party member low health", NextAction::array(0, new NextAction("riptide on party", 25.0f), nullptr))); - // triggers.push_back(new TriggerNode("medium aoe heal", NextAction::array(0, new NextAction("chain heal", 27.0f), nullptr))); - // triggers.push_back(new TriggerNode("medium health", NextAction::array(0, new NextAction("lesser healing wave", 26.0f), nullptr))); - // triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("riptide", 26.0f), nullptr))); - triggers.push_back(new TriggerNode("heroism", NextAction::array(0, new NextAction("heroism", 31.0f), nullptr))); - triggers.push_back(new TriggerNode("bloodlust", NextAction::array(0, new NextAction("bloodlust", 30.0f), nullptr))); - + triggers.push_back( + new TriggerNode("wind shear", NextAction::array(0, new NextAction("wind shear", 23.0f), nullptr))); + triggers.push_back( + new TriggerNode("wind shear on enemy healer", + NextAction::array(0, new NextAction("wind shear on enemy healer", 23.0f), nullptr))); + triggers.push_back(new TriggerNode("purge", NextAction::array(0, new NextAction("purge", ACTION_DISPEL), nullptr))); + // triggers.push_back(new TriggerNode("party member medium health", NextAction::array(0, new NextAction("lesser + // healing wave on party", 25.0f), nullptr))); triggers.push_back(new TriggerNode("party member low health", + // NextAction::array(0, new NextAction("riptide on party", 25.0f), nullptr))); triggers.push_back(new + // TriggerNode("medium aoe heal", NextAction::array(0, new NextAction("chain heal", 27.0f), nullptr))); + // triggers.push_back(new TriggerNode("medium health", NextAction::array(0, new NextAction("lesser healing + // wave", 26.0f), nullptr))); triggers.push_back(new TriggerNode("low health", NextAction::array(0, new + // NextAction("riptide", 26.0f), nullptr))); + triggers.push_back(new TriggerNode("heroism", NextAction::array(0, new NextAction("heroism", 31.0f), nullptr))); + triggers.push_back(new TriggerNode("bloodlust", NextAction::array(0, new NextAction("bloodlust", 30.0f), nullptr))); } void ShamanBuffDpsStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("lightning shield", NextAction::array(0, new NextAction("lightning shield", 22.0f), nullptr))); + triggers.push_back( + new TriggerNode("lightning shield", NextAction::array(0, new NextAction("lightning shield", 22.0f), nullptr))); } void ShamanBuffManaStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("water shield", NextAction::array(0, new NextAction("water shield", 22.0f), nullptr))); + triggers.push_back( + new TriggerNode("water shield", NextAction::array(0, new NextAction("water shield", 22.0f), nullptr))); } void ShamanCureStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("cure poison", NextAction::array(0, new NextAction("cure poison", 21.0f), nullptr))); - triggers.push_back(new TriggerNode("party member cure poison", NextAction::array(0, new NextAction("cure poison on party", 21.0f), nullptr))); - triggers.push_back(new TriggerNode("cleanse spirit poison", NextAction::array(0, new NextAction("cleanse spirit", 24.0f), nullptr))); - triggers.push_back(new TriggerNode("party member cleanse spirit poison", NextAction::array(0, new NextAction("cleanse spirit poison on party", 23.0f), nullptr))); - triggers.push_back(new TriggerNode("cure disease", NextAction::array(0, new NextAction("cure disease", 31.0f), nullptr))); - triggers.push_back(new TriggerNode("party member cure disease", NextAction::array(0, new NextAction("cure disease on party", 30.0f), nullptr))); - triggers.push_back(new TriggerNode("cleanse spirit disease", NextAction::array(0, new NextAction("cleanse spirit", 24.0f), nullptr))); - triggers.push_back(new TriggerNode("party member cleanse spirit disease", NextAction::array(0, new NextAction("cleanse spirit disease on party", 23.0f), nullptr))); - triggers.push_back(new TriggerNode("cleanse spirit curse", NextAction::array(0, new NextAction("cleanse spirit", 24.0f), nullptr))); - triggers.push_back(new TriggerNode("party member cleanse spirit curse", NextAction::array(0, new NextAction("cleanse spirit curse on party", 23.0f), nullptr))); + triggers.push_back( + new TriggerNode("cure poison", NextAction::array(0, new NextAction("cure poison", 21.0f), nullptr))); + triggers.push_back(new TriggerNode("party member cure poison", + NextAction::array(0, new NextAction("cure poison on party", 21.0f), nullptr))); + triggers.push_back(new TriggerNode("cleanse spirit poison", + NextAction::array(0, new NextAction("cleanse spirit", 24.0f), nullptr))); + triggers.push_back( + new TriggerNode("party member cleanse spirit poison", + NextAction::array(0, new NextAction("cleanse spirit poison on party", 23.0f), nullptr))); + triggers.push_back( + new TriggerNode("cure disease", NextAction::array(0, new NextAction("cure disease", 31.0f), nullptr))); + triggers.push_back(new TriggerNode("party member cure disease", + NextAction::array(0, new NextAction("cure disease on party", 30.0f), nullptr))); + triggers.push_back(new TriggerNode("cleanse spirit disease", + NextAction::array(0, new NextAction("cleanse spirit", 24.0f), nullptr))); + triggers.push_back( + new TriggerNode("party member cleanse spirit disease", + NextAction::array(0, new NextAction("cleanse spirit disease on party", 23.0f), nullptr))); + triggers.push_back(new TriggerNode("cleanse spirit curse", + NextAction::array(0, new NextAction("cleanse spirit", 24.0f), nullptr))); + triggers.push_back( + new TriggerNode("party member cleanse spirit curse", + NextAction::array(0, new NextAction("cleanse spirit curse on party", 23.0f), nullptr))); } diff --git a/src/strategy/shaman/GenericShamanStrategy.h b/src/strategy/shaman/GenericShamanStrategy.h index 7969aba9..49753e7b 100644 --- a/src/strategy/shaman/GenericShamanStrategy.h +++ b/src/strategy/shaman/GenericShamanStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICSHAMANSTRATEGY_H @@ -11,37 +12,37 @@ class PlayerbotAI; class GenericShamanStrategy : public CombatStrategy { - public: - GenericShamanStrategy(PlayerbotAI* botAI); +public: + GenericShamanStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; + void InitTriggers(std::vector& triggers) override; }; class ShamanBuffDpsStrategy : public Strategy { - public: - ShamanBuffDpsStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + ShamanBuffDpsStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "bdps"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bdps"; } }; class ShamanBuffManaStrategy : public Strategy { - public: - ShamanBuffManaStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + ShamanBuffManaStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "bmana"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "bmana"; } }; class ShamanCureStrategy : public Strategy { - public: - ShamanCureStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + ShamanCureStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "cure"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cure"; } }; #endif diff --git a/src/strategy/shaman/HealShamanStrategy.cpp b/src/strategy/shaman/HealShamanStrategy.cpp index d451e55b..7fda4651 100644 --- a/src/strategy/shaman/HealShamanStrategy.cpp +++ b/src/strategy/shaman/HealShamanStrategy.cpp @@ -1,35 +1,37 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HealShamanStrategy.h" + #include "Playerbots.h" class HealShamanStrategyActionNodeFactory : public NamedObjectFactory { - public: - HealShamanStrategyActionNodeFactory() - { - creators["earthliving weapon"] = &earthliving_weapon; - creators["mana tide totem"] = &mana_tide_totem; - } +public: + HealShamanStrategyActionNodeFactory() + { + creators["earthliving weapon"] = &earthliving_weapon; + creators["mana tide totem"] = &mana_tide_totem; + } - private: - static ActionNode* earthliving_weapon([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("earthliving weapon", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("flametongue weapon"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* earthliving_weapon([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("earthliving weapon", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("flametongue weapon"), nullptr), + /*C*/ nullptr); + } - static ActionNode* mana_tide_totem([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("mana tide totem", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("mana potion"), nullptr), - /*C*/ nullptr); - } + static ActionNode* mana_tide_totem([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("mana tide totem", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("mana potion"), nullptr), + /*C*/ nullptr); + } }; HealShamanStrategy::HealShamanStrategy(PlayerbotAI* botAI) : GenericShamanStrategy(botAI) @@ -41,42 +43,44 @@ void HealShamanStrategy::InitTriggers(std::vector& triggers) { GenericShamanStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", ACTION_NORMAL + 9), nullptr))); - // triggers.push_back(new TriggerNode("shaman weapon", NextAction::array(0, new NextAction("earthliving weapon", 22.0f), nullptr))); - triggers.push_back(new TriggerNode("main hand weapon no imbue", NextAction::array(0, new NextAction("earthliving weapon", 22.0f), nullptr))); + // triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", + // ACTION_NORMAL + 9), nullptr))); triggers.push_back(new TriggerNode("shaman weapon", NextAction::array(0, new + // NextAction("earthliving weapon", 22.0f), nullptr))); + triggers.push_back(new TriggerNode("main hand weapon no imbue", + NextAction::array(0, new NextAction("earthliving weapon", 22.0f), nullptr))); triggers.push_back(new TriggerNode( - "group heal occasion", - NextAction::array(0, new NextAction("riptide on party", 23.0f), new NextAction("chain heal", 22.0f), NULL))); - + "group heal occasion", + NextAction::array(0, new NextAction("riptide on party", 23.0f), new NextAction("chain heal", 22.0f), NULL))); + triggers.push_back(new TriggerNode( "party member critical health", - NextAction::array(0, new NextAction("riptide on party", 25.0f), new NextAction("healing wave on party", 24.0f), new NextAction("lesser healing wave on party", 23.0f), nullptr))); + NextAction::array(0, new NextAction("riptide on party", 25.0f), new NextAction("healing wave on party", 24.0f), + new NextAction("lesser healing wave on party", 23.0f), nullptr))); triggers.push_back(new TriggerNode( "party member low health", - NextAction::array(0, new NextAction("riptide on party", 19.0f), new NextAction("healing wave on party", 18.0f), new NextAction("lesser healing wave on party", 17.0f), nullptr))); + NextAction::array(0, new NextAction("riptide on party", 19.0f), new NextAction("healing wave on party", 18.0f), + new NextAction("lesser healing wave on party", 17.0f), nullptr))); - triggers.push_back(new TriggerNode( + triggers.push_back(new TriggerNode( "party member medium health", - NextAction::array(0, new NextAction("riptide on party", 16.0f), new NextAction("healing wave on party", 15.0f), new NextAction("lesser healing wave on party", 14.0f), nullptr))); - - triggers.push_back(new TriggerNode( - "party member almost full health", - NextAction::array(0, new NextAction("riptide on party", 12.0f), new NextAction("lesser healing wave on party", 11.0f), nullptr))); - - triggers.push_back(new TriggerNode( - "party member cleanse spirit poison", - NextAction::array(0, - new NextAction("cleanse spirit poison on party", ACTION_DISPEL + 2), - new NextAction("cleansing totem", ACTION_DISPEL + 2), - NULL))); + NextAction::array(0, new NextAction("riptide on party", 16.0f), new NextAction("healing wave on party", 15.0f), + new NextAction("lesser healing wave on party", 14.0f), nullptr))); - triggers.push_back(new TriggerNode( - "party member cleanse spirit disease", - NextAction::array(0, - new NextAction("cleanse spirit disease on party", ACTION_DISPEL + 2), - new NextAction("cleansing totem", ACTION_DISPEL + 1), - NULL))); + triggers.push_back( + new TriggerNode("party member almost full health", + NextAction::array(0, new NextAction("riptide on party", 12.0f), + new NextAction("lesser healing wave on party", 11.0f), nullptr))); + + triggers.push_back( + new TriggerNode("party member cleanse spirit poison", + NextAction::array(0, new NextAction("cleanse spirit poison on party", ACTION_DISPEL + 2), + new NextAction("cleansing totem", ACTION_DISPEL + 2), NULL))); + + triggers.push_back( + new TriggerNode("party member cleanse spirit disease", + NextAction::array(0, new NextAction("cleanse spirit disease on party", ACTION_DISPEL + 2), + new NextAction("cleansing totem", ACTION_DISPEL + 1), NULL))); triggers.push_back(new TriggerNode( "party member cleanse spirit curse", @@ -89,16 +93,18 @@ void HealShamanStrategy::InitTriggers(std::vector& triggers) // triggers.push_back(new TriggerNode( // "no water totem", // NextAction::array(0, new NextAction("healing stream totem", 13.0f), NULL))); - - triggers.push_back(new TriggerNode( - "earth shield on main tank", - NextAction::array(0, new NextAction("earth shield on main tank", ACTION_HIGH + 7), NULL))); - triggers.push_back(new TriggerNode("enemy too close for spell", NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); + triggers.push_back( + new TriggerNode("earth shield on main tank", + NextAction::array(0, new NextAction("earth shield on main tank", ACTION_HIGH + 7), NULL))); + + triggers.push_back(new TriggerNode("enemy too close for spell", + NextAction::array(0, new NextAction("flee", ACTION_MOVE + 9), nullptr))); + + triggers.push_back( + new TriggerNode("medium mana", NextAction::array(0, new NextAction("mana tide totem", ACTION_HIGH + 5), NULL))); triggers.push_back(new TriggerNode( - "medium mana", - NextAction::array(0, new NextAction("mana tide totem", ACTION_HIGH + 5), NULL))); - - triggers.push_back(new TriggerNode("party member to heal out of spell range", NextAction::array(0, new NextAction("reach party member to heal", ACTION_CRITICAL_HEAL + 1), nullptr))); + "party member to heal out of spell range", + NextAction::array(0, new NextAction("reach party member to heal", ACTION_CRITICAL_HEAL + 1), nullptr))); } diff --git a/src/strategy/shaman/HealShamanStrategy.h b/src/strategy/shaman/HealShamanStrategy.h index e41cc2e1..b4068f0f 100644 --- a/src/strategy/shaman/HealShamanStrategy.h +++ b/src/strategy/shaman/HealShamanStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HEALSHAMANSTRATEGY_H @@ -12,12 +13,12 @@ class PlayerbotAI; class HealShamanStrategy : public GenericShamanStrategy { - public: - HealShamanStrategy(PlayerbotAI* botAI); +public: + HealShamanStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "heal"; } - uint32 GetType() const override { return STRATEGY_TYPE_RANGED | STRATEGY_TYPE_HEAL; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "heal"; } + uint32 GetType() const override { return STRATEGY_TYPE_RANGED | STRATEGY_TYPE_HEAL; } }; #endif diff --git a/src/strategy/shaman/MeleeShamanStrategy.cpp b/src/strategy/shaman/MeleeShamanStrategy.cpp index 6b8bce24..a840a9e8 100644 --- a/src/strategy/shaman/MeleeShamanStrategy.cpp +++ b/src/strategy/shaman/MeleeShamanStrategy.cpp @@ -1,45 +1,47 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "MeleeShamanStrategy.h" + #include "Playerbots.h" class MeleeShamanStrategyActionNodeFactory : public NamedObjectFactory { - public: - MeleeShamanStrategyActionNodeFactory() - { - creators["stormstrike"] = &stormstrike; - creators["lava lash"] = &lava_lash; - creators["magma totem"] = &magma_totem; - } +public: + MeleeShamanStrategyActionNodeFactory() + { + creators["stormstrike"] = &stormstrike; + creators["lava lash"] = &lava_lash; + creators["magma totem"] = &magma_totem; + } - private: - static ActionNode* stormstrike([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("stormstrike", - /*P*/ nullptr, - // /*A*/ NextAction::array(0, new NextAction("lava lash"), nullptr), - nullptr, - /*C*/ nullptr); - } +private: + static ActionNode* stormstrike([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("stormstrike", + /*P*/ nullptr, + // /*A*/ NextAction::array(0, new NextAction("lava lash"), nullptr), + nullptr, + /*C*/ nullptr); + } - static ActionNode* lava_lash([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("lava lash", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), - /*C*/ nullptr); - } + static ActionNode* lava_lash([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("lava lash", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("melee"), nullptr), + /*C*/ nullptr); + } - static ActionNode* magma_totem([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("magma totem", - /*P*/ NULL, - /*A*/ NextAction::array(0, new NextAction("searing totem"), NULL), - /*C*/ NULL); - } + static ActionNode* magma_totem([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("magma totem", + /*P*/ NULL, + /*A*/ NextAction::array(0, new NextAction("searing totem"), NULL), + /*C*/ NULL); + } }; MeleeShamanStrategy::MeleeShamanStrategy(PlayerbotAI* botAI) : GenericShamanStrategy(botAI) @@ -49,57 +51,56 @@ MeleeShamanStrategy::MeleeShamanStrategy(PlayerbotAI* botAI) : GenericShamanStra NextAction** MeleeShamanStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("stormstrike", ACTION_DEFAULT + 0.5f), - new NextAction("earth shock", ACTION_DEFAULT + 0.4f), - new NextAction("feral spirit", ACTION_DEFAULT + 0.3f), - new NextAction("fire nova", ACTION_DEFAULT + 0.2f), - new NextAction("lava lash", ACTION_DEFAULT + 0.1f), - new NextAction("melee", ACTION_DEFAULT), - NULL); + return NextAction::array( + 0, new NextAction("stormstrike", ACTION_DEFAULT + 0.5f), new NextAction("earth shock", ACTION_DEFAULT + 0.4f), + new NextAction("feral spirit", ACTION_DEFAULT + 0.3f), new NextAction("fire nova", ACTION_DEFAULT + 0.2f), + new NextAction("lava lash", ACTION_DEFAULT + 0.1f), new NextAction("melee", ACTION_DEFAULT), NULL); } void MeleeShamanStrategy::InitTriggers(std::vector& triggers) { GenericShamanStrategy::InitTriggers(triggers); - //triggers.push_back(new TriggerNode("shaman weapon", NextAction::array(0, new NextAction("flametongue weapon", 22.0f), nullptr))); - triggers.push_back(new TriggerNode("main hand weapon no imbue", NextAction::array(0, new NextAction("windfury weapon", 22.0f), nullptr))); - triggers.push_back(new TriggerNode("off hand weapon no imbue", NextAction::array(0, new NextAction("flametongue weapon", 21.0f), nullptr))); - // triggers.push_back(new TriggerNode("searing totem", NextAction::array(0, new NextAction("reach melee", 22.0f), new NextAction("searing totem", 22.0f), nullptr))); - triggers.push_back(new TriggerNode("flame shock", NextAction::array(0, new NextAction("flame shock", 20.0f), nullptr))); + // triggers.push_back(new TriggerNode("shaman weapon", NextAction::array(0, new NextAction("flametongue + // weapon", 22.0f), nullptr))); + triggers.push_back(new TriggerNode("main hand weapon no imbue", + NextAction::array(0, new NextAction("windfury weapon", 22.0f), nullptr))); + triggers.push_back(new TriggerNode("off hand weapon no imbue", + NextAction::array(0, new NextAction("flametongue weapon", 21.0f), nullptr))); + // triggers.push_back(new TriggerNode("searing totem", NextAction::array(0, new NextAction("reach melee", 22.0f), + // new NextAction("searing totem", 22.0f), nullptr))); + triggers.push_back( + new TriggerNode("flame shock", NextAction::array(0, new NextAction("flame shock", 20.0f), nullptr))); + triggers.push_back( + new TriggerNode("maelstrom weapon", NextAction::array(0, new NextAction("lightning bolt", 25.0f), nullptr))); + triggers.push_back(new TriggerNode("not facing target", + NextAction::array(0, new NextAction("set facing", ACTION_NORMAL + 7), nullptr))); + // triggers.push_back(new TriggerNode("enemy too close for melee", NextAction::array(0, new NextAction("move out of + // enemy contact", ACTION_NORMAL + 8), nullptr))); triggers.push_back(new TriggerNode( - "maelstrom weapon", - NextAction::array(0, new NextAction("lightning bolt", 25.0f), nullptr))); - triggers.push_back(new TriggerNode("not facing target", NextAction::array(0, new NextAction("set facing", ACTION_NORMAL + 7), nullptr))); - // triggers.push_back(new TriggerNode("enemy too close for melee", NextAction::array(0, new NextAction("move out of enemy contact", ACTION_NORMAL + 8), nullptr))); - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("strength of earth totem", ACTION_LIGHT_HEAL), nullptr))); - triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("reach melee", ACTION_NORMAL + 8), nullptr))); + "medium aoe", NextAction::array(0, new NextAction("strength of earth totem", ACTION_LIGHT_HEAL), nullptr))); + triggers.push_back(new TriggerNode( + "enemy out of melee", NextAction::array(0, new NextAction("reach melee", ACTION_NORMAL + 8), nullptr))); triggers.push_back(new TriggerNode( "no fire totem", - NextAction::array(0, - new NextAction("reach melee", 23.0f), - new NextAction("magma totem", 22.0f), nullptr))); + NextAction::array(0, new NextAction("reach melee", 23.0f), new NextAction("magma totem", 22.0f), nullptr))); - triggers.push_back(new TriggerNode("fire elemental totem", - NextAction::array(0, - new NextAction("reach melee", 33.0f), - new NextAction("fire elemental totem", 32.0f), - nullptr))); + triggers.push_back(new TriggerNode("fire elemental totem", + NextAction::array(0, new NextAction("reach melee", 33.0f), + new NextAction("fire elemental totem", 32.0f), nullptr))); - triggers.push_back(new TriggerNode( - "no air totem", - NextAction::array(0, new NextAction("windfury totem", 20.0f), nullptr))); + triggers.push_back( + new TriggerNode("no air totem", NextAction::array(0, new NextAction("windfury totem", 20.0f), nullptr))); - triggers.push_back(new TriggerNode( - "medium mana", - NextAction::array(0, new NextAction("shamanistic rage", 23.0f), nullptr))); + triggers.push_back( + new TriggerNode("medium mana", NextAction::array(0, new NextAction("shamanistic rage", 23.0f), nullptr))); } void MeleeAoeShamanStrategy::InitTriggers(std::vector& triggers) { - - // triggers.push_back(new TriggerNode("magma totem", NextAction::array(0, new NextAction("magma totem", 26.0f), nullptr))); - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("fire nova", 25.0f), nullptr))); + // triggers.push_back(new TriggerNode("magma totem", NextAction::array(0, new NextAction("magma totem", 26.0f), + // nullptr))); + triggers.push_back( + new TriggerNode("medium aoe", NextAction::array(0, new NextAction("fire nova", 25.0f), nullptr))); } diff --git a/src/strategy/shaman/MeleeShamanStrategy.h b/src/strategy/shaman/MeleeShamanStrategy.h index 20e444f0..dd324f85 100644 --- a/src/strategy/shaman/MeleeShamanStrategy.h +++ b/src/strategy/shaman/MeleeShamanStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MELEESHAMANSTRATEGY_H @@ -11,22 +12,22 @@ class PlayerbotAI; class MeleeShamanStrategy : public GenericShamanStrategy { - public: - MeleeShamanStrategy(PlayerbotAI* botAI); +public: + MeleeShamanStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - NextAction** getDefaultActions() override; - std::string const getName() override { return "melee"; } - uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_MELEE; } + void InitTriggers(std::vector& triggers) override; + NextAction** getDefaultActions() override; + std::string const getName() override { return "melee"; } + uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_MELEE; } }; class MeleeAoeShamanStrategy : public CombatStrategy { - public: - MeleeAoeShamanStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + MeleeAoeShamanStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "melee aoe"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "melee aoe"; } }; #endif diff --git a/src/strategy/shaman/ShamanActions.cpp b/src/strategy/shaman/ShamanActions.cpp index 61e3e52a..ee6e3bea 100644 --- a/src/strategy/shaman/ShamanActions.cpp +++ b/src/strategy/shaman/ShamanActions.cpp @@ -1,19 +1,24 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ShamanActions.h" + #include "Playerbots.h" bool CastTotemAction::isUseful() { - if (needLifeTime > 0.1f) { + if (needLifeTime > 0.1f) + { Unit* target = AI_VALUE(Unit*, "current target"); - if (!target) { + if (!target) + { return false; } float dps = AI_VALUE(float, "expected group dps"); - if (target->GetHealth() / dps < needLifeTime) { + if (target->GetHealth() / dps < needLifeTime) + { return false; } } @@ -27,7 +32,8 @@ bool CastManaSpringTotemAction::isUseful() bool CastFlametongueTotemAction::isUseful() { - return CastTotemAction::isUseful() && !AI_VALUE2(bool, "has totem", "magma totem") && !botAI->HasAura("totem of wrath", bot); + return CastTotemAction::isUseful() && !AI_VALUE2(bool, "has totem", "magma totem") && + !botAI->HasAura("totem of wrath", bot); } bool CastSearingTotemAction::isUseful() @@ -35,12 +41,9 @@ bool CastSearingTotemAction::isUseful() return CastTotemAction::isUseful() && !AI_VALUE2(bool, "has totem", "flametongue totem"); } -bool CastMagmaTotemAction::isUseful() -{ - return CastTotemAction::isUseful() && !AI_VALUE2(bool, "has totem", name); -} +bool CastMagmaTotemAction::isUseful() { return CastTotemAction::isUseful() && !AI_VALUE2(bool, "has totem", name); } -bool CastCleansingTotemAction::isUseful() -{ - return CastTotemAction::isUseful() && !AI_VALUE2(bool, "has totem", "mana tide totem"); +bool CastCleansingTotemAction::isUseful() +{ + return CastTotemAction::isUseful() && !AI_VALUE2(bool, "has totem", "mana tide totem"); } \ No newline at end of file diff --git a/src/strategy/shaman/ShamanActions.h b/src/strategy/shaman/ShamanActions.h index 1b8d0101..0356a144 100644 --- a/src/strategy/shaman/ShamanActions.h +++ b/src/strategy/shaman/ShamanActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SHAMANACTIONS_H @@ -12,352 +13,382 @@ class PlayerbotAI; class CastLesserHealingWaveAction : public CastHealingSpellAction { - public: - CastLesserHealingWaveAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "lesser healing wave") { } +public: + CastLesserHealingWaveAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "lesser healing wave") {} }; class CastLesserHealingWaveOnPartyAction : public HealPartyMemberAction { - public: - CastLesserHealingWaveOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "lesser healing wave", 25.0f, HealingManaEfficiency::LOW) { } +public: + CastLesserHealingWaveOnPartyAction(PlayerbotAI* botAI) + : HealPartyMemberAction(botAI, "lesser healing wave", 25.0f, HealingManaEfficiency::LOW) + { + } }; class CastHealingWaveAction : public CastHealingSpellAction { - public: - CastHealingWaveAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "healing wave") { } +public: + CastHealingWaveAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "healing wave") {} }; class CastHealingWaveOnPartyAction : public HealPartyMemberAction { - public: - CastHealingWaveOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "healing wave", 50.0f, HealingManaEfficiency::MEDIUM) { } +public: + CastHealingWaveOnPartyAction(PlayerbotAI* botAI) + : HealPartyMemberAction(botAI, "healing wave", 50.0f, HealingManaEfficiency::MEDIUM) + { + } }; class CastChainHealAction : public CastAoeHealSpellAction { - public: - CastChainHealAction(PlayerbotAI* botAI) : CastAoeHealSpellAction(botAI, "chain heal", 15.0f, HealingManaEfficiency::HIGH) { } +public: + CastChainHealAction(PlayerbotAI* botAI) + : CastAoeHealSpellAction(botAI, "chain heal", 15.0f, HealingManaEfficiency::HIGH) + { + } }; class CastRiptideAction : public CastHealingSpellAction { - public: - CastRiptideAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "riptide") { } +public: + CastRiptideAction(PlayerbotAI* botAI) : CastHealingSpellAction(botAI, "riptide") {} }; class CastRiptideOnPartyAction : public HealPartyMemberAction { - public: - CastRiptideOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "riptide", 15.0f, HealingManaEfficiency::VERY_HIGH) { } +public: + CastRiptideOnPartyAction(PlayerbotAI* botAI) + : HealPartyMemberAction(botAI, "riptide", 15.0f, HealingManaEfficiency::VERY_HIGH) + { + } }; class CastEarthShieldAction : public CastBuffSpellAction { - public: - CastEarthShieldAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "earth shield") { } +public: + CastEarthShieldAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "earth shield") {} }; class CastEarthShieldOnPartyAction : public BuffOnPartyAction { - public: - CastEarthShieldOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "earth shield") { } +public: + CastEarthShieldOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "earth shield") {} }; class CastWaterShieldAction : public CastBuffSpellAction { - public: - CastWaterShieldAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "water shield") { } +public: + CastWaterShieldAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "water shield") {} }; class CastLightningShieldAction : public CastBuffSpellAction { - public: - CastLightningShieldAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "lightning shield") { } +public: + CastLightningShieldAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "lightning shield") {} }; class CastEarthlivingWeaponAction : public CastEnchantItemAction { - public: - CastEarthlivingWeaponAction(PlayerbotAI* botAI) : CastEnchantItemAction(botAI, "earthliving weapon") { } +public: + CastEarthlivingWeaponAction(PlayerbotAI* botAI) : CastEnchantItemAction(botAI, "earthliving weapon") {} }; class CastRockbiterWeaponAction : public CastEnchantItemAction { - public: - CastRockbiterWeaponAction(PlayerbotAI* botAI) : CastEnchantItemAction(botAI, "rockbiter weapon") { } +public: + CastRockbiterWeaponAction(PlayerbotAI* botAI) : CastEnchantItemAction(botAI, "rockbiter weapon") {} }; class CastFlametongueWeaponAction : public CastEnchantItemAction { - public: - CastFlametongueWeaponAction(PlayerbotAI* botAI) : CastEnchantItemAction(botAI, "flametongue weapon") { } +public: + CastFlametongueWeaponAction(PlayerbotAI* botAI) : CastEnchantItemAction(botAI, "flametongue weapon") {} }; class CastFrostbrandWeaponAction : public CastEnchantItemAction { - public: - CastFrostbrandWeaponAction(PlayerbotAI* botAI) : CastEnchantItemAction(botAI, "frostbrand weapon") { } +public: + CastFrostbrandWeaponAction(PlayerbotAI* botAI) : CastEnchantItemAction(botAI, "frostbrand weapon") {} }; class CastWindfuryWeaponAction : public CastEnchantItemAction { - public: - CastWindfuryWeaponAction(PlayerbotAI* botAI) : CastEnchantItemAction(botAI, "windfury weapon") { } +public: + CastWindfuryWeaponAction(PlayerbotAI* botAI) : CastEnchantItemAction(botAI, "windfury weapon") {} }; class CastTotemAction : public CastBuffSpellAction { - public: - CastTotemAction(PlayerbotAI* botAI, std::string const spell, std::string const buffName = "", float needLifeTime = 8.0f) - : CastBuffSpellAction(botAI, spell), needLifeTime(needLifeTime) { - if (buffName == "") { - buff = spell; - } else { - buff = buffName; - } +public: + CastTotemAction(PlayerbotAI* botAI, std::string const spell, std::string const buffName = "", + float needLifeTime = 8.0f) + : CastBuffSpellAction(botAI, spell), needLifeTime(needLifeTime) + { + if (buffName == "") + { + buff = spell; } + else + { + buff = buffName; + } + } - bool isUseful() override; - protected: - float needLifeTime; - std::string buff; + bool isUseful() override; + +protected: + float needLifeTime; + std::string buff; }; class CastStoneskinTotemAction : public CastTotemAction { - public: - CastStoneskinTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "stoneskin totem") { } +public: + CastStoneskinTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "stoneskin totem") {} }; class CastEarthbindTotemAction : public CastTotemAction { - public: - CastEarthbindTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "earthbind totem") { } +public: + CastEarthbindTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "earthbind totem") {} }; class CastStrengthOfEarthTotemAction : public CastTotemAction { - public: - CastStrengthOfEarthTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "strength of earth totem", "strength of earth", 20.0f) { } +public: + CastStrengthOfEarthTotemAction(PlayerbotAI* botAI) + : CastTotemAction(botAI, "strength of earth totem", "strength of earth", 20.0f) + { + } }; class CastManaSpringTotemAction : public CastTotemAction { - public: - CastManaSpringTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "mana spring totem", "mana spring", 0.0f) { } +public: + CastManaSpringTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "mana spring totem", "mana spring", 0.0f) {} - bool isUseful() override; + bool isUseful() override; }; class CastManaTideTotemAction : public CastTotemAction { - public: - CastManaTideTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "mana tide totem") { } +public: + CastManaTideTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "mana tide totem") {} - std::string const GetTargetName() override { return "self target"; } + std::string const GetTargetName() override { return "self target"; } }; class CastHealingStreamTotemAction : public CastTotemAction { - public: - CastHealingStreamTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "healing stream totem") { } +public: + CastHealingStreamTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "healing stream totem") {} }; class CastCleansingTotemAction : public CastTotemAction { - public: - CastCleansingTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "cleansing totem") { } - virtual bool isUseful(); +public: + CastCleansingTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "cleansing totem") {} + virtual bool isUseful(); }; class CastFlametongueTotemAction : public CastTotemAction { - public: - CastFlametongueTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "flametongue totem", "", 20.0f) { } +public: + CastFlametongueTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "flametongue totem", "", 20.0f) {} - bool isUseful() override; + bool isUseful() override; }; class CastWindfuryTotemAction : public CastTotemAction { - public: - CastWindfuryTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "windfury totem") { } +public: + CastWindfuryTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "windfury totem") {} }; class CastGraceOfAirTotemAction : public CastTotemAction { - public: - CastGraceOfAirTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "grace of air totem") { } +public: + CastGraceOfAirTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "grace of air totem") {} }; class CastSearingTotemAction : public CastTotemAction { - public: - CastSearingTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "searing totem", "", 0.0f) { } +public: + CastSearingTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "searing totem", "", 0.0f) {} - std::string const GetTargetName() override { return "self target"; } - bool isUseful() override; + std::string const GetTargetName() override { return "self target"; } + bool isUseful() override; }; class CastMagmaTotemAction : public CastTotemAction { - public: - CastMagmaTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "magma totem", "", 0.0f) { } +public: + CastMagmaTotemAction(PlayerbotAI* botAI) : CastTotemAction(botAI, "magma totem", "", 0.0f) {} - std::string const GetTargetName() override { return "self target"; } - bool isUseful() override; + std::string const GetTargetName() override { return "self target"; } + bool isUseful() override; }; class CastFireNovaAction : public CastSpellAction { - public: - CastFireNovaAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "fire nova") { } +public: + CastFireNovaAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "fire nova") {} }; class CastWindShearAction : public CastSpellAction { - public: - CastWindShearAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "wind shear") { } +public: + CastWindShearAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "wind shear") {} }; class CastAncestralSpiritAction : public ResurrectPartyMemberAction { - public: - CastAncestralSpiritAction(PlayerbotAI* botAI) : ResurrectPartyMemberAction(botAI, "ancestral spirit") { } +public: + CastAncestralSpiritAction(PlayerbotAI* botAI) : ResurrectPartyMemberAction(botAI, "ancestral spirit") {} }; class CastPurgeAction : public CastSpellAction { - public: - CastPurgeAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "purge") { } +public: + CastPurgeAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "purge") {} }; class CastStormstrikeAction : public CastMeleeSpellAction { - public: - CastStormstrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "stormstrike") { } +public: + CastStormstrikeAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "stormstrike") {} }; class CastLavaLashAction : public CastMeleeSpellAction { - public: - CastLavaLashAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "lava lash") { } +public: + CastLavaLashAction(PlayerbotAI* botAI) : CastMeleeSpellAction(botAI, "lava lash") {} }; class CastWaterBreathingAction : public CastBuffSpellAction { - public: - CastWaterBreathingAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "water breathing") { } +public: + CastWaterBreathingAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "water breathing") {} }; class CastWaterWalkingAction : public CastBuffSpellAction { - public: - CastWaterWalkingAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "water walking") { } +public: + CastWaterWalkingAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "water walking") {} }; class CastWaterBreathingOnPartyAction : public BuffOnPartyAction { - public: - CastWaterBreathingOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "water breathing") { } +public: + CastWaterBreathingOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "water breathing") {} }; class CastWaterWalkingOnPartyAction : public BuffOnPartyAction { - public: - CastWaterWalkingOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "water walking") { } +public: + CastWaterWalkingOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "water walking") {} }; class CastCleanseSpiritAction : public CastCureSpellAction { - public: - CastCleanseSpiritAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "cleanse spirit") { } +public: + CastCleanseSpiritAction(PlayerbotAI* botAI) : CastCureSpellAction(botAI, "cleanse spirit") {} }; class CastCleanseSpiritPoisonOnPartyAction : public CurePartyMemberAction { - public: - CastCleanseSpiritPoisonOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "cleanse spirit", DISPEL_POISON) { } +public: + CastCleanseSpiritPoisonOnPartyAction(PlayerbotAI* botAI) + : CurePartyMemberAction(botAI, "cleanse spirit", DISPEL_POISON) + { + } - std::string const getName() override { return "cleanse spirit poison on party"; } + std::string const getName() override { return "cleanse spirit poison on party"; } }; class CastCleanseSpiritCurseOnPartyAction : public CurePartyMemberAction { - public: - CastCleanseSpiritCurseOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "cleanse spirit", DISPEL_CURSE) { } +public: + CastCleanseSpiritCurseOnPartyAction(PlayerbotAI* botAI) + : CurePartyMemberAction(botAI, "cleanse spirit", DISPEL_CURSE) + { + } - std::string const getName() override { return "cleanse spirit curse on party"; } + std::string const getName() override { return "cleanse spirit curse on party"; } }; class CastCleanseSpiritDiseaseOnPartyAction : public CurePartyMemberAction { - public: - CastCleanseSpiritDiseaseOnPartyAction(PlayerbotAI* botAI) : CurePartyMemberAction(botAI, "cleanse spirit", DISPEL_DISEASE) { } +public: + CastCleanseSpiritDiseaseOnPartyAction(PlayerbotAI* botAI) + : CurePartyMemberAction(botAI, "cleanse spirit", DISPEL_DISEASE) + { + } - std::string const getName() override { return "cleanse spirit disease on party"; } + std::string const getName() override { return "cleanse spirit disease on party"; } }; class CastFlameShockAction : public CastDebuffSpellAction { - public: - CastFlameShockAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "flame shock", true) { } +public: + CastFlameShockAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "flame shock", true) {} }; class CastEarthShockAction : public CastSpellAction { - public: - CastEarthShockAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "earth shock") { } +public: + CastEarthShockAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "earth shock") {} }; class CastFrostShockAction : public CastSnareSpellAction { - public: - CastFrostShockAction(PlayerbotAI* botAI) : CastSnareSpellAction(botAI, "frost shock") { } +public: + CastFrostShockAction(PlayerbotAI* botAI) : CastSnareSpellAction(botAI, "frost shock") {} }; class CastChainLightningAction : public CastSpellAction { - public: - CastChainLightningAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "chain lightning") { } - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } +public: + CastChainLightningAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "chain lightning") {} + ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } }; class CastLightningBoltAction : public CastSpellAction { - public: - CastLightningBoltAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "lightning bolt") { } +public: + CastLightningBoltAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "lightning bolt") {} }; class CastThunderstormAction : public CastSpellAction { - public: - CastThunderstormAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "thunderstorm") { } +public: + CastThunderstormAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "thunderstorm") {} }; class CastHeroismAction : public CastBuffSpellAction { - public: - CastHeroismAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "heroism") { } +public: + CastHeroismAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "heroism") {} }; class CastBloodlustAction : public CastBuffSpellAction { - public: - CastBloodlustAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "bloodlust") { } +public: + CastBloodlustAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "bloodlust") {} }; class CastElementalMasteryAction : public CastBuffSpellAction { - public: - CastElementalMasteryAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "elemental mastery") { } +public: + CastElementalMasteryAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "elemental mastery") {} }; class CastWindShearOnEnemyHealerAction : public CastSpellOnEnemyHealerAction { - public: - CastWindShearOnEnemyHealerAction(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, "wind shear") { } +public: + CastWindShearOnEnemyHealerAction(PlayerbotAI* botAI) : CastSpellOnEnemyHealerAction(botAI, "wind shear") {} }; CURE_ACTION(CastCurePoisonActionSham, "cure disease"); @@ -368,47 +399,47 @@ CURE_PARTY_ACTION(CastCureDiseaseOnPartyActionSham, "cure disease", DISPEL_DISEA class CastLavaBurstAction : public CastSpellAction { - public: - CastLavaBurstAction(PlayerbotAI* ai) : CastSpellAction(ai, "lava burst") {} +public: + CastLavaBurstAction(PlayerbotAI* ai) : CastSpellAction(ai, "lava burst") {} }; class CastEarthShieldOnMainTankAction : public BuffOnMainTankAction { - public: - CastEarthShieldOnMainTankAction(PlayerbotAI* ai) : BuffOnMainTankAction(ai, "earth shield", false) {} +public: + CastEarthShieldOnMainTankAction(PlayerbotAI* ai) : BuffOnMainTankAction(ai, "earth shield", false) {} }; class CastTotemOfWrathAction : public CastTotemAction { - public: - CastTotemOfWrathAction(PlayerbotAI* ai) : CastTotemAction(ai, "totem of wrath") {} - virtual std::string const GetTargetName() override { return "self target"; } - virtual bool isUseful() override { return CastTotemAction::isUseful(); } +public: + CastTotemOfWrathAction(PlayerbotAI* ai) : CastTotemAction(ai, "totem of wrath") {} + virtual std::string const GetTargetName() override { return "self target"; } + virtual bool isUseful() override { return CastTotemAction::isUseful(); } }; class CastFireElementalTotemAction : public CastTotemAction { - public: - CastFireElementalTotemAction(PlayerbotAI* ai) : CastTotemAction(ai, "fire elemental totem", "", 0.0f) {} - virtual std::string const GetTargetName() override { return "self target"; } - virtual bool isUseful() override { return CastTotemAction::isUseful(); } +public: + CastFireElementalTotemAction(PlayerbotAI* ai) : CastTotemAction(ai, "fire elemental totem", "", 0.0f) {} + virtual std::string const GetTargetName() override { return "self target"; } + virtual bool isUseful() override { return CastTotemAction::isUseful(); } }; class CastWrathOfAirTotemAction : public CastTotemAction { - public: - CastWrathOfAirTotemAction(PlayerbotAI* ai) : CastTotemAction(ai, "wrath of air totem", "wrath of air totem") {} +public: + CastWrathOfAirTotemAction(PlayerbotAI* ai) : CastTotemAction(ai, "wrath of air totem", "wrath of air totem") {} }; class CastShamanisticRageAction : public CastBuffSpellAction { - public: - CastShamanisticRageAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, "shamanistic rage") {} +public: + CastShamanisticRageAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, "shamanistic rage") {} }; class CastFeralSpiritAction : public CastSpellAction { - public: - CastFeralSpiritAction(PlayerbotAI* ai) : CastSpellAction(ai, "feral spirit") {} +public: + CastFeralSpiritAction(PlayerbotAI* ai) : CastSpellAction(ai, "feral spirit") {} }; #endif diff --git a/src/strategy/shaman/ShamanAiObjectContext.cpp b/src/strategy/shaman/ShamanAiObjectContext.cpp index f7ac2223..f4a821ce 100644 --- a/src/strategy/shaman/ShamanAiObjectContext.cpp +++ b/src/strategy/shaman/ShamanAiObjectContext.cpp @@ -1,295 +1,322 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ShamanAiObjectContext.h" + #include "CasterShamanStrategy.h" #include "HealShamanStrategy.h" #include "MeleeShamanStrategy.h" +#include "NamedObjectContext.h" +#include "Playerbots.h" #include "ShamanActions.h" #include "ShamanNonCombatStrategy.h" #include "ShamanTriggers.h" #include "TotemsShamanStrategy.h" -#include "NamedObjectContext.h" -#include "Playerbots.h" class ShamanStrategyFactoryInternal : public NamedObjectContext { - public: - ShamanStrategyFactoryInternal() - { - creators["nc"] = &ShamanStrategyFactoryInternal::nc; - creators["totems"] = &ShamanStrategyFactoryInternal::totems; - creators["melee aoe"] = &ShamanStrategyFactoryInternal::melee_aoe; - creators["caster aoe"] = &ShamanStrategyFactoryInternal::caster_aoe; - creators["cure"] = &ShamanStrategyFactoryInternal::cure; - } +public: + ShamanStrategyFactoryInternal() + { + creators["nc"] = &ShamanStrategyFactoryInternal::nc; + creators["totems"] = &ShamanStrategyFactoryInternal::totems; + creators["melee aoe"] = &ShamanStrategyFactoryInternal::melee_aoe; + creators["caster aoe"] = &ShamanStrategyFactoryInternal::caster_aoe; + creators["cure"] = &ShamanStrategyFactoryInternal::cure; + } - private: - static Strategy* nc(PlayerbotAI* botAI) { return new ShamanNonCombatStrategy(botAI); } - static Strategy* totems(PlayerbotAI* botAI) { return new TotemsShamanStrategy(botAI); } - static Strategy* melee_aoe(PlayerbotAI* botAI) { return new MeleeAoeShamanStrategy(botAI); } - static Strategy* caster_aoe(PlayerbotAI* botAI) { return new CasterAoeShamanStrategy(botAI); } - static Strategy* cure(PlayerbotAI* botAI) { return new ShamanCureStrategy(botAI); } +private: + static Strategy* nc(PlayerbotAI* botAI) { return new ShamanNonCombatStrategy(botAI); } + static Strategy* totems(PlayerbotAI* botAI) { return new TotemsShamanStrategy(botAI); } + static Strategy* melee_aoe(PlayerbotAI* botAI) { return new MeleeAoeShamanStrategy(botAI); } + static Strategy* caster_aoe(PlayerbotAI* botAI) { return new CasterAoeShamanStrategy(botAI); } + static Strategy* cure(PlayerbotAI* botAI) { return new ShamanCureStrategy(botAI); } }; class ShamanBuffStrategyFactoryInternal : public NamedObjectContext { - public: - ShamanBuffStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["bmana"] = &ShamanBuffStrategyFactoryInternal::bmana; - creators["bdps"] = &ShamanBuffStrategyFactoryInternal::bdps; - } +public: + ShamanBuffStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["bmana"] = &ShamanBuffStrategyFactoryInternal::bmana; + creators["bdps"] = &ShamanBuffStrategyFactoryInternal::bdps; + } - private: - static Strategy* bmana(PlayerbotAI* botAI) { return new ShamanBuffManaStrategy(botAI); } - static Strategy* bdps(PlayerbotAI* botAI) { return new ShamanBuffDpsStrategy(botAI); } +private: + static Strategy* bmana(PlayerbotAI* botAI) { return new ShamanBuffManaStrategy(botAI); } + static Strategy* bdps(PlayerbotAI* botAI) { return new ShamanBuffDpsStrategy(botAI); } }; class ShamanCombatStrategyFactoryInternal : public NamedObjectContext { - public: - ShamanCombatStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["heal"] = &ShamanCombatStrategyFactoryInternal::heal; - creators["melee"] = &ShamanCombatStrategyFactoryInternal::dps; - creators["dps"] = &ShamanCombatStrategyFactoryInternal::dps; - creators["caster"] = &ShamanCombatStrategyFactoryInternal::caster; - } +public: + ShamanCombatStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["heal"] = &ShamanCombatStrategyFactoryInternal::heal; + creators["melee"] = &ShamanCombatStrategyFactoryInternal::dps; + creators["dps"] = &ShamanCombatStrategyFactoryInternal::dps; + creators["caster"] = &ShamanCombatStrategyFactoryInternal::caster; + } - private: - static Strategy* heal(PlayerbotAI* botAI) { return new HealShamanStrategy(botAI); } - static Strategy* dps(PlayerbotAI* botAI) { return new MeleeShamanStrategy(botAI); } - static Strategy* caster(PlayerbotAI* botAI) { return new CasterShamanStrategy(botAI); } +private: + static Strategy* heal(PlayerbotAI* botAI) { return new HealShamanStrategy(botAI); } + static Strategy* dps(PlayerbotAI* botAI) { return new MeleeShamanStrategy(botAI); } + static Strategy* caster(PlayerbotAI* botAI) { return new CasterShamanStrategy(botAI); } }; class ShamanATriggerFactoryInternal : public NamedObjectContext { - public: - ShamanATriggerFactoryInternal() - { - creators["grace of air totem"] = &ShamanATriggerFactoryInternal::grace_of_air_totem; - creators["windfury totem"] = &ShamanATriggerFactoryInternal::windfury_totem; - creators["mana spring totem"] = &ShamanATriggerFactoryInternal::mana_spring_totem; - creators["flametongue totem"] = &ShamanATriggerFactoryInternal::flametongue_totem; - creators["strength of earth totem"] = &ShamanATriggerFactoryInternal::strength_of_earth_totem; - creators["fire elemental totem"] = &ShamanATriggerFactoryInternal::fire_elemental_totem; - creators["magma totem"] = &ShamanATriggerFactoryInternal::magma_totem; - creators["searing totem"] = &ShamanATriggerFactoryInternal::searing_totem; - creators["wind shear"] = &ShamanATriggerFactoryInternal::wind_shear; - creators["purge"] = &ShamanATriggerFactoryInternal::purge; - //creators["shaman weapon"] = &ShamanATriggerFactoryInternal::shaman_weapon; - creators["main hand weapon no imbue"] = &ShamanATriggerFactoryInternal::main_hand_weapon_no_imbue; - creators["off hand weapon no imbue"] = &ShamanATriggerFactoryInternal::off_hand_weapon_no_imbue; - creators["water shield"] = &ShamanATriggerFactoryInternal::water_shield; - creators["lightning shield"] = &ShamanATriggerFactoryInternal::lightning_shield; - creators["water breathing"] = &ShamanATriggerFactoryInternal::water_breathing; - creators["water walking"] = &ShamanATriggerFactoryInternal::water_walking; - creators["water breathing on party"] = &ShamanATriggerFactoryInternal::water_breathing_on_party; - creators["water walking on party"] = &ShamanATriggerFactoryInternal::water_walking_on_party; - creators["cleanse spirit poison"] = &ShamanATriggerFactoryInternal::cleanse_poison; - creators["cleanse spirit curse"] = &ShamanATriggerFactoryInternal::cleanse_curse; - creators["cleanse spirit disease"] = &ShamanATriggerFactoryInternal::cleanse_disease; - creators["party member cleanse spirit poison"] = &ShamanATriggerFactoryInternal::party_member_cleanse_poison; - creators["party member cleanse spirit curse"] = &ShamanATriggerFactoryInternal::party_member_cleanse_curse; - creators["party member cleanse spirit disease"] = &ShamanATriggerFactoryInternal::party_member_cleanse_disease; - creators["shock"] = &ShamanATriggerFactoryInternal::shock; - creators["frost shock snare"] = &ShamanATriggerFactoryInternal::frost_shock_snare; - creators["heroism"] = &ShamanATriggerFactoryInternal::heroism; - creators["bloodlust"] = &ShamanATriggerFactoryInternal::bloodlust; - creators["elemental mastery"] = &ShamanATriggerFactoryInternal::elemental_mastery; - creators["wind shear on enemy healer"] = &ShamanATriggerFactoryInternal::wind_shear_on_enemy_healer; - creators["cure poison"] = &ShamanATriggerFactoryInternal::cure_poison; - creators["party member cure poison"] = &ShamanATriggerFactoryInternal::party_member_cure_poison; - creators["cure disease"] = &ShamanATriggerFactoryInternal::cure_disease; - creators["party member cure disease"] = &ShamanATriggerFactoryInternal::party_member_cure_disease; - creators["no fire totem"] = &ShamanATriggerFactoryInternal::no_fire_totem; - creators["no water totem"] = &ShamanATriggerFactoryInternal::no_water_totem; - creators["no air totem"] = &ShamanATriggerFactoryInternal::no_air_totem; - creators["earth shield on main tank"] = &ShamanATriggerFactoryInternal::earth_shield_on_main_tank; - creators["maelstrom weapon"] = &ShamanATriggerFactoryInternal::maelstrom_weapon; - creators["flame shock"] = &ShamanATriggerFactoryInternal::flame_shock; - creators["wrath of air totem"] = &ShamanATriggerFactoryInternal::wrath_of_air_totem; - } +public: + ShamanATriggerFactoryInternal() + { + creators["grace of air totem"] = &ShamanATriggerFactoryInternal::grace_of_air_totem; + creators["windfury totem"] = &ShamanATriggerFactoryInternal::windfury_totem; + creators["mana spring totem"] = &ShamanATriggerFactoryInternal::mana_spring_totem; + creators["flametongue totem"] = &ShamanATriggerFactoryInternal::flametongue_totem; + creators["strength of earth totem"] = &ShamanATriggerFactoryInternal::strength_of_earth_totem; + creators["fire elemental totem"] = &ShamanATriggerFactoryInternal::fire_elemental_totem; + creators["magma totem"] = &ShamanATriggerFactoryInternal::magma_totem; + creators["searing totem"] = &ShamanATriggerFactoryInternal::searing_totem; + creators["wind shear"] = &ShamanATriggerFactoryInternal::wind_shear; + creators["purge"] = &ShamanATriggerFactoryInternal::purge; + // creators["shaman weapon"] = &ShamanATriggerFactoryInternal::shaman_weapon; + creators["main hand weapon no imbue"] = &ShamanATriggerFactoryInternal::main_hand_weapon_no_imbue; + creators["off hand weapon no imbue"] = &ShamanATriggerFactoryInternal::off_hand_weapon_no_imbue; + creators["water shield"] = &ShamanATriggerFactoryInternal::water_shield; + creators["lightning shield"] = &ShamanATriggerFactoryInternal::lightning_shield; + creators["water breathing"] = &ShamanATriggerFactoryInternal::water_breathing; + creators["water walking"] = &ShamanATriggerFactoryInternal::water_walking; + creators["water breathing on party"] = &ShamanATriggerFactoryInternal::water_breathing_on_party; + creators["water walking on party"] = &ShamanATriggerFactoryInternal::water_walking_on_party; + creators["cleanse spirit poison"] = &ShamanATriggerFactoryInternal::cleanse_poison; + creators["cleanse spirit curse"] = &ShamanATriggerFactoryInternal::cleanse_curse; + creators["cleanse spirit disease"] = &ShamanATriggerFactoryInternal::cleanse_disease; + creators["party member cleanse spirit poison"] = &ShamanATriggerFactoryInternal::party_member_cleanse_poison; + creators["party member cleanse spirit curse"] = &ShamanATriggerFactoryInternal::party_member_cleanse_curse; + creators["party member cleanse spirit disease"] = &ShamanATriggerFactoryInternal::party_member_cleanse_disease; + creators["shock"] = &ShamanATriggerFactoryInternal::shock; + creators["frost shock snare"] = &ShamanATriggerFactoryInternal::frost_shock_snare; + creators["heroism"] = &ShamanATriggerFactoryInternal::heroism; + creators["bloodlust"] = &ShamanATriggerFactoryInternal::bloodlust; + creators["elemental mastery"] = &ShamanATriggerFactoryInternal::elemental_mastery; + creators["wind shear on enemy healer"] = &ShamanATriggerFactoryInternal::wind_shear_on_enemy_healer; + creators["cure poison"] = &ShamanATriggerFactoryInternal::cure_poison; + creators["party member cure poison"] = &ShamanATriggerFactoryInternal::party_member_cure_poison; + creators["cure disease"] = &ShamanATriggerFactoryInternal::cure_disease; + creators["party member cure disease"] = &ShamanATriggerFactoryInternal::party_member_cure_disease; + creators["no fire totem"] = &ShamanATriggerFactoryInternal::no_fire_totem; + creators["no water totem"] = &ShamanATriggerFactoryInternal::no_water_totem; + creators["no air totem"] = &ShamanATriggerFactoryInternal::no_air_totem; + creators["earth shield on main tank"] = &ShamanATriggerFactoryInternal::earth_shield_on_main_tank; + creators["maelstrom weapon"] = &ShamanATriggerFactoryInternal::maelstrom_weapon; + creators["flame shock"] = &ShamanATriggerFactoryInternal::flame_shock; + creators["wrath of air totem"] = &ShamanATriggerFactoryInternal::wrath_of_air_totem; + } - private: - static Trigger* maelstrom_weapon(PlayerbotAI* botAI) { return new MaelstromWeaponTrigger(botAI); } - static Trigger* heroism(PlayerbotAI* botAI) { return new HeroismTrigger(botAI); } - static Trigger* bloodlust(PlayerbotAI* botAI) { return new BloodlustTrigger(botAI); } - static Trigger* elemental_mastery(PlayerbotAI* botAI) { return new ElementalMasteryTrigger(botAI); } - static Trigger* party_member_cleanse_disease(PlayerbotAI* botAI) { return new PartyMemberCleanseSpiritDiseaseTrigger(botAI); } - static Trigger* party_member_cleanse_curse(PlayerbotAI* botAI) { return new PartyMemberCleanseSpiritCurseTrigger(botAI); } - static Trigger* party_member_cleanse_poison(PlayerbotAI* botAI) { return new PartyMemberCleanseSpiritPoisonTrigger(botAI); } - static Trigger* cleanse_disease(PlayerbotAI* botAI) { return new CleanseSpiritDiseaseTrigger(botAI); } - static Trigger* cleanse_curse(PlayerbotAI* botAI) { return new CleanseSpiritCurseTrigger(botAI); } - static Trigger* cleanse_poison(PlayerbotAI* botAI) { return new CleanseSpiritPoisonTrigger(botAI); } - static Trigger* water_breathing(PlayerbotAI* botAI) { return new WaterBreathingTrigger(botAI); } - static Trigger* water_walking(PlayerbotAI* botAI) { return new WaterWalkingTrigger(botAI); } - static Trigger* water_breathing_on_party(PlayerbotAI* botAI) { return new WaterBreathingOnPartyTrigger(botAI); } - static Trigger* water_walking_on_party(PlayerbotAI* botAI) { return new WaterWalkingOnPartyTrigger(botAI); } - static Trigger* windfury_totem(PlayerbotAI* botAI) { return new WindfuryTotemTrigger(botAI); } - static Trigger* grace_of_air_totem(PlayerbotAI* botAI) { return new GraceOfAirTotemTrigger(botAI); } - static Trigger* mana_spring_totem(PlayerbotAI* botAI) { return new ManaSpringTotemTrigger(botAI); } - static Trigger* flametongue_totem(PlayerbotAI* botAI) { return new FlametongueTotemTrigger(botAI); } - static Trigger* strength_of_earth_totem(PlayerbotAI* botAI) { return new StrengthOfEarthTotemTrigger(botAI); } - static Trigger* fire_elemental_totem(PlayerbotAI* botAI) { return new FireElementalTotemTrigger(botAI); } - static Trigger* magma_totem(PlayerbotAI* botAI) { return new MagmaTotemTrigger(botAI); } - static Trigger* searing_totem(PlayerbotAI* botAI) { return new SearingTotemTrigger(botAI); } - static Trigger* wind_shear(PlayerbotAI* botAI) { return new WindShearInterruptSpellTrigger(botAI); } - static Trigger* purge(PlayerbotAI* botAI) { return new PurgeTrigger(botAI); } - //static Trigger* shaman_weapon(PlayerbotAI* botAI) { return new ShamanWeaponTrigger(botAI); } - static Trigger* main_hand_weapon_no_imbue(PlayerbotAI* botAI) { return new MainHandWeaponNoImbueTrigger(botAI); } - static Trigger* off_hand_weapon_no_imbue(PlayerbotAI* botAI) { return new OffHandWeaponNoImbueTrigger(botAI); } - static Trigger* water_shield(PlayerbotAI* botAI) { return new WaterShieldTrigger(botAI); } - static Trigger* lightning_shield(PlayerbotAI* botAI) { return new LightningShieldTrigger(botAI); } - static Trigger* shock(PlayerbotAI* botAI) { return new ShockTrigger(botAI); } - static Trigger* frost_shock_snare(PlayerbotAI* botAI) { return new FrostShockSnareTrigger(botAI); } - static Trigger* wind_shear_on_enemy_healer(PlayerbotAI* botAI) { return new WindShearInterruptEnemyHealerSpellTrigger(botAI); } - static Trigger* cure_poison(PlayerbotAI* botAI) { return new CurePoisonTrigger(botAI); } - static Trigger* party_member_cure_poison(PlayerbotAI* botAI) { return new PartyMemberCurePoisonTrigger(botAI); } - static Trigger* cure_disease(PlayerbotAI* botAI) { return new CureDiseaseTrigger(botAI); } - static Trigger* party_member_cure_disease(PlayerbotAI* botAI) { return new PartyMemberCureDiseaseTrigger(botAI); } - static Trigger* no_fire_totem(PlayerbotAI* ai) { return new NoFireTotemTrigger(ai); } - static Trigger* no_water_totem(PlayerbotAI* ai) { return new NoWaterTotemTrigger(ai); } - static Trigger* no_air_totem(PlayerbotAI* ai) { return new NoAirTotemTrigger(ai); } - static Trigger* earth_shield_on_main_tank(PlayerbotAI* ai) { return new EarthShieldOnMainTankTrigger(ai); } - static Trigger* flame_shock(PlayerbotAI* ai) { return new FlameShockTrigger(ai); } - static Trigger* wrath_of_air_totem(PlayerbotAI* ai) { return new WrathOfAirTotemTrigger(ai); } +private: + static Trigger* maelstrom_weapon(PlayerbotAI* botAI) { return new MaelstromWeaponTrigger(botAI); } + static Trigger* heroism(PlayerbotAI* botAI) { return new HeroismTrigger(botAI); } + static Trigger* bloodlust(PlayerbotAI* botAI) { return new BloodlustTrigger(botAI); } + static Trigger* elemental_mastery(PlayerbotAI* botAI) { return new ElementalMasteryTrigger(botAI); } + static Trigger* party_member_cleanse_disease(PlayerbotAI* botAI) + { + return new PartyMemberCleanseSpiritDiseaseTrigger(botAI); + } + static Trigger* party_member_cleanse_curse(PlayerbotAI* botAI) + { + return new PartyMemberCleanseSpiritCurseTrigger(botAI); + } + static Trigger* party_member_cleanse_poison(PlayerbotAI* botAI) + { + return new PartyMemberCleanseSpiritPoisonTrigger(botAI); + } + static Trigger* cleanse_disease(PlayerbotAI* botAI) { return new CleanseSpiritDiseaseTrigger(botAI); } + static Trigger* cleanse_curse(PlayerbotAI* botAI) { return new CleanseSpiritCurseTrigger(botAI); } + static Trigger* cleanse_poison(PlayerbotAI* botAI) { return new CleanseSpiritPoisonTrigger(botAI); } + static Trigger* water_breathing(PlayerbotAI* botAI) { return new WaterBreathingTrigger(botAI); } + static Trigger* water_walking(PlayerbotAI* botAI) { return new WaterWalkingTrigger(botAI); } + static Trigger* water_breathing_on_party(PlayerbotAI* botAI) { return new WaterBreathingOnPartyTrigger(botAI); } + static Trigger* water_walking_on_party(PlayerbotAI* botAI) { return new WaterWalkingOnPartyTrigger(botAI); } + static Trigger* windfury_totem(PlayerbotAI* botAI) { return new WindfuryTotemTrigger(botAI); } + static Trigger* grace_of_air_totem(PlayerbotAI* botAI) { return new GraceOfAirTotemTrigger(botAI); } + static Trigger* mana_spring_totem(PlayerbotAI* botAI) { return new ManaSpringTotemTrigger(botAI); } + static Trigger* flametongue_totem(PlayerbotAI* botAI) { return new FlametongueTotemTrigger(botAI); } + static Trigger* strength_of_earth_totem(PlayerbotAI* botAI) { return new StrengthOfEarthTotemTrigger(botAI); } + static Trigger* fire_elemental_totem(PlayerbotAI* botAI) { return new FireElementalTotemTrigger(botAI); } + static Trigger* magma_totem(PlayerbotAI* botAI) { return new MagmaTotemTrigger(botAI); } + static Trigger* searing_totem(PlayerbotAI* botAI) { return new SearingTotemTrigger(botAI); } + static Trigger* wind_shear(PlayerbotAI* botAI) { return new WindShearInterruptSpellTrigger(botAI); } + static Trigger* purge(PlayerbotAI* botAI) { return new PurgeTrigger(botAI); } + // static Trigger* shaman_weapon(PlayerbotAI* botAI) { return new ShamanWeaponTrigger(botAI); } + static Trigger* main_hand_weapon_no_imbue(PlayerbotAI* botAI) { return new MainHandWeaponNoImbueTrigger(botAI); } + static Trigger* off_hand_weapon_no_imbue(PlayerbotAI* botAI) { return new OffHandWeaponNoImbueTrigger(botAI); } + static Trigger* water_shield(PlayerbotAI* botAI) { return new WaterShieldTrigger(botAI); } + static Trigger* lightning_shield(PlayerbotAI* botAI) { return new LightningShieldTrigger(botAI); } + static Trigger* shock(PlayerbotAI* botAI) { return new ShockTrigger(botAI); } + static Trigger* frost_shock_snare(PlayerbotAI* botAI) { return new FrostShockSnareTrigger(botAI); } + static Trigger* wind_shear_on_enemy_healer(PlayerbotAI* botAI) + { + return new WindShearInterruptEnemyHealerSpellTrigger(botAI); + } + static Trigger* cure_poison(PlayerbotAI* botAI) { return new CurePoisonTrigger(botAI); } + static Trigger* party_member_cure_poison(PlayerbotAI* botAI) { return new PartyMemberCurePoisonTrigger(botAI); } + static Trigger* cure_disease(PlayerbotAI* botAI) { return new CureDiseaseTrigger(botAI); } + static Trigger* party_member_cure_disease(PlayerbotAI* botAI) { return new PartyMemberCureDiseaseTrigger(botAI); } + static Trigger* no_fire_totem(PlayerbotAI* ai) { return new NoFireTotemTrigger(ai); } + static Trigger* no_water_totem(PlayerbotAI* ai) { return new NoWaterTotemTrigger(ai); } + static Trigger* no_air_totem(PlayerbotAI* ai) { return new NoAirTotemTrigger(ai); } + static Trigger* earth_shield_on_main_tank(PlayerbotAI* ai) { return new EarthShieldOnMainTankTrigger(ai); } + static Trigger* flame_shock(PlayerbotAI* ai) { return new FlameShockTrigger(ai); } + static Trigger* wrath_of_air_totem(PlayerbotAI* ai) { return new WrathOfAirTotemTrigger(ai); } }; class ShamanAiObjectContextInternal : public NamedObjectContext { - public: - ShamanAiObjectContextInternal() - { - creators["water shield"] = &ShamanAiObjectContextInternal::water_shield; - creators["lightning shield"] = &ShamanAiObjectContextInternal::lightning_shield; - creators["strength of earth totem"] = &ShamanAiObjectContextInternal::strength_of_earth_totem; - creators["flametongue totem"] = &ShamanAiObjectContextInternal::flametongue_totem; - creators["searing totem"] = &ShamanAiObjectContextInternal::searing_totem; - creators["magma totem"] = &ShamanAiObjectContextInternal::magma_totem; - creators["windfury totem"] = &ShamanAiObjectContextInternal::windfury_totem; - creators["grace of air totem"] = &ShamanAiObjectContextInternal::grace_of_air_totem; - creators["mana spring totem"] = &ShamanAiObjectContextInternal::mana_spring_totem; - creators["mana tide totem"] = &ShamanAiObjectContextInternal::mana_tide_totem; - creators["earthbind totem"] = &ShamanAiObjectContextInternal::earthbind_totem; - creators["healing stream totem"] = &ShamanAiObjectContextInternal::healing_stream_totem; - creators["wind shear"] = &ShamanAiObjectContextInternal::wind_shear; - creators["wind shear on enemy healer"] = &ShamanAiObjectContextInternal::wind_shear_on_enemy_healer; - creators["rockbiter weapon"] = &ShamanAiObjectContextInternal::rockbiter_weapon; - creators["flametongue weapon"] = &ShamanAiObjectContextInternal::flametongue_weapon; - creators["frostbrand weapon"] = &ShamanAiObjectContextInternal::frostbrand_weapon; - creators["windfury weapon"] = &ShamanAiObjectContextInternal::windfury_weapon; - creators["earthliving weapon"] = &ShamanAiObjectContextInternal::earthliving_weapon; - creators["purge"] = &ShamanAiObjectContextInternal::purge; - creators["healing wave"] = &ShamanAiObjectContextInternal::healing_wave; - creators["lesser healing wave"] = &ShamanAiObjectContextInternal::lesser_healing_wave; - creators["healing wave on party"] = &ShamanAiObjectContextInternal::healing_wave_on_party; - creators["lesser healing wave on party"] = &ShamanAiObjectContextInternal::lesser_healing_wave_on_party; - creators["earth shield"] = &ShamanAiObjectContextInternal::earth_shield; - creators["earth shield on party"] = &ShamanAiObjectContextInternal::earth_shield_on_party; - creators["chain heal"] = &ShamanAiObjectContextInternal::chain_heal; - creators["riptide"] = &ShamanAiObjectContextInternal::riptide; - creators["riptide on party"] = &ShamanAiObjectContextInternal::riptide_on_party; - creators["stormstrike"] = &ShamanAiObjectContextInternal::stormstrike; - creators["lava lash"] = &ShamanAiObjectContextInternal::lava_lash; - creators["fire nova"] = &ShamanAiObjectContextInternal::fire_nova; - creators["ancestral spirit"] = &ShamanAiObjectContextInternal::ancestral_spirit; - creators["water walking"] = &ShamanAiObjectContextInternal::water_walking; - creators["water breathing"] = &ShamanAiObjectContextInternal::water_breathing; - creators["water walking on party"] = &ShamanAiObjectContextInternal::water_walking_on_party; - creators["water breathing on party"] = &ShamanAiObjectContextInternal::water_breathing_on_party; - creators["cleanse spirit"] = &ShamanAiObjectContextInternal::cleanse_spirit; - creators["cleanse spirit poison on party"] = &ShamanAiObjectContextInternal::cleanse_spirit_poison_on_party; - creators["cleanse spirit disease on party"] = &ShamanAiObjectContextInternal::cleanse_spirit_disease_on_party; - creators["cleanse spirit curse on party"] = &ShamanAiObjectContextInternal::cleanse_spirit_curse_on_party; - creators["flame shock"] = &ShamanAiObjectContextInternal::flame_shock; - creators["earth shock"] = &ShamanAiObjectContextInternal::earth_shock; - creators["frost shock"] = &ShamanAiObjectContextInternal::frost_shock; - creators["chain lightning"] = &ShamanAiObjectContextInternal::chain_lightning; - creators["lightning bolt"] = &ShamanAiObjectContextInternal::lightning_bolt; - creators["thunderstorm"] = &ShamanAiObjectContextInternal::thunderstorm; - creators["heroism"] = &ShamanAiObjectContextInternal::heroism; - creators["bloodlust"] = &ShamanAiObjectContextInternal::bloodlust; - creators["elemental mastery"] = &ShamanAiObjectContextInternal::elemental_mastery; - creators["cure disease"] = &ShamanAiObjectContextInternal::cure_disease; - creators["cure disease on party"] = &ShamanAiObjectContextInternal::cure_disease_on_party; - creators["cure poison"] = &ShamanAiObjectContextInternal::cure_poison; - creators["cure poison on party"] = &ShamanAiObjectContextInternal::cure_poison_on_party; - creators["lava burst"] = &ShamanAiObjectContextInternal::lava_burst; - creators["earth shield on main tank"] = &ShamanAiObjectContextInternal::earth_shield_on_main_tank; - creators["fire elemental totem"] = &ShamanAiObjectContextInternal::fire_elemental_totem; - creators["totem of wrath"] = &ShamanAiObjectContextInternal::totem_of_wrath; - creators["wrath of air totem"] = &ShamanAiObjectContextInternal::wrath_of_air_totem; - creators["shamanistic rage"] = &ShamanAiObjectContextInternal::shamanistic_rage; - creators["feral spirit"] = &ShamanAiObjectContextInternal::feral_spirit; - } +public: + ShamanAiObjectContextInternal() + { + creators["water shield"] = &ShamanAiObjectContextInternal::water_shield; + creators["lightning shield"] = &ShamanAiObjectContextInternal::lightning_shield; + creators["strength of earth totem"] = &ShamanAiObjectContextInternal::strength_of_earth_totem; + creators["flametongue totem"] = &ShamanAiObjectContextInternal::flametongue_totem; + creators["searing totem"] = &ShamanAiObjectContextInternal::searing_totem; + creators["magma totem"] = &ShamanAiObjectContextInternal::magma_totem; + creators["windfury totem"] = &ShamanAiObjectContextInternal::windfury_totem; + creators["grace of air totem"] = &ShamanAiObjectContextInternal::grace_of_air_totem; + creators["mana spring totem"] = &ShamanAiObjectContextInternal::mana_spring_totem; + creators["mana tide totem"] = &ShamanAiObjectContextInternal::mana_tide_totem; + creators["earthbind totem"] = &ShamanAiObjectContextInternal::earthbind_totem; + creators["healing stream totem"] = &ShamanAiObjectContextInternal::healing_stream_totem; + creators["wind shear"] = &ShamanAiObjectContextInternal::wind_shear; + creators["wind shear on enemy healer"] = &ShamanAiObjectContextInternal::wind_shear_on_enemy_healer; + creators["rockbiter weapon"] = &ShamanAiObjectContextInternal::rockbiter_weapon; + creators["flametongue weapon"] = &ShamanAiObjectContextInternal::flametongue_weapon; + creators["frostbrand weapon"] = &ShamanAiObjectContextInternal::frostbrand_weapon; + creators["windfury weapon"] = &ShamanAiObjectContextInternal::windfury_weapon; + creators["earthliving weapon"] = &ShamanAiObjectContextInternal::earthliving_weapon; + creators["purge"] = &ShamanAiObjectContextInternal::purge; + creators["healing wave"] = &ShamanAiObjectContextInternal::healing_wave; + creators["lesser healing wave"] = &ShamanAiObjectContextInternal::lesser_healing_wave; + creators["healing wave on party"] = &ShamanAiObjectContextInternal::healing_wave_on_party; + creators["lesser healing wave on party"] = &ShamanAiObjectContextInternal::lesser_healing_wave_on_party; + creators["earth shield"] = &ShamanAiObjectContextInternal::earth_shield; + creators["earth shield on party"] = &ShamanAiObjectContextInternal::earth_shield_on_party; + creators["chain heal"] = &ShamanAiObjectContextInternal::chain_heal; + creators["riptide"] = &ShamanAiObjectContextInternal::riptide; + creators["riptide on party"] = &ShamanAiObjectContextInternal::riptide_on_party; + creators["stormstrike"] = &ShamanAiObjectContextInternal::stormstrike; + creators["lava lash"] = &ShamanAiObjectContextInternal::lava_lash; + creators["fire nova"] = &ShamanAiObjectContextInternal::fire_nova; + creators["ancestral spirit"] = &ShamanAiObjectContextInternal::ancestral_spirit; + creators["water walking"] = &ShamanAiObjectContextInternal::water_walking; + creators["water breathing"] = &ShamanAiObjectContextInternal::water_breathing; + creators["water walking on party"] = &ShamanAiObjectContextInternal::water_walking_on_party; + creators["water breathing on party"] = &ShamanAiObjectContextInternal::water_breathing_on_party; + creators["cleanse spirit"] = &ShamanAiObjectContextInternal::cleanse_spirit; + creators["cleanse spirit poison on party"] = &ShamanAiObjectContextInternal::cleanse_spirit_poison_on_party; + creators["cleanse spirit disease on party"] = &ShamanAiObjectContextInternal::cleanse_spirit_disease_on_party; + creators["cleanse spirit curse on party"] = &ShamanAiObjectContextInternal::cleanse_spirit_curse_on_party; + creators["flame shock"] = &ShamanAiObjectContextInternal::flame_shock; + creators["earth shock"] = &ShamanAiObjectContextInternal::earth_shock; + creators["frost shock"] = &ShamanAiObjectContextInternal::frost_shock; + creators["chain lightning"] = &ShamanAiObjectContextInternal::chain_lightning; + creators["lightning bolt"] = &ShamanAiObjectContextInternal::lightning_bolt; + creators["thunderstorm"] = &ShamanAiObjectContextInternal::thunderstorm; + creators["heroism"] = &ShamanAiObjectContextInternal::heroism; + creators["bloodlust"] = &ShamanAiObjectContextInternal::bloodlust; + creators["elemental mastery"] = &ShamanAiObjectContextInternal::elemental_mastery; + creators["cure disease"] = &ShamanAiObjectContextInternal::cure_disease; + creators["cure disease on party"] = &ShamanAiObjectContextInternal::cure_disease_on_party; + creators["cure poison"] = &ShamanAiObjectContextInternal::cure_poison; + creators["cure poison on party"] = &ShamanAiObjectContextInternal::cure_poison_on_party; + creators["lava burst"] = &ShamanAiObjectContextInternal::lava_burst; + creators["earth shield on main tank"] = &ShamanAiObjectContextInternal::earth_shield_on_main_tank; + creators["fire elemental totem"] = &ShamanAiObjectContextInternal::fire_elemental_totem; + creators["totem of wrath"] = &ShamanAiObjectContextInternal::totem_of_wrath; + creators["wrath of air totem"] = &ShamanAiObjectContextInternal::wrath_of_air_totem; + creators["shamanistic rage"] = &ShamanAiObjectContextInternal::shamanistic_rage; + creators["feral spirit"] = &ShamanAiObjectContextInternal::feral_spirit; + } - private: - static Action* heroism(PlayerbotAI* botAI) { return new CastHeroismAction(botAI); } - static Action* bloodlust(PlayerbotAI* botAI) { return new CastBloodlustAction(botAI); } - static Action* elemental_mastery(PlayerbotAI* botAI) { return new CastElementalMasteryAction(botAI); } - static Action* thunderstorm(PlayerbotAI* botAI) { return new CastThunderstormAction(botAI); } - static Action* lightning_bolt(PlayerbotAI* botAI) { return new CastLightningBoltAction(botAI); } - static Action* chain_lightning(PlayerbotAI* botAI) { return new CastChainLightningAction(botAI); } - static Action* frost_shock(PlayerbotAI* botAI) { return new CastFrostShockAction(botAI); } - static Action* earth_shock(PlayerbotAI* botAI) { return new CastEarthShockAction(botAI); } - static Action* flame_shock(PlayerbotAI* botAI) { return new CastFlameShockAction(botAI); } - static Action* cleanse_spirit_poison_on_party(PlayerbotAI* botAI) { return new CastCleanseSpiritPoisonOnPartyAction(botAI); } - static Action* cleanse_spirit_disease_on_party(PlayerbotAI* botAI) { return new CastCleanseSpiritDiseaseOnPartyAction(botAI); } - static Action* cleanse_spirit_curse_on_party(PlayerbotAI* botAI) { return new CastCleanseSpiritCurseOnPartyAction(botAI); } - static Action* cleanse_spirit(PlayerbotAI* botAI) { return new CastCleanseSpiritAction(botAI); } - static Action* water_walking(PlayerbotAI* botAI) { return new CastWaterWalkingAction(botAI); } - static Action* water_breathing(PlayerbotAI* botAI) { return new CastWaterBreathingAction(botAI); } - static Action* water_walking_on_party(PlayerbotAI* botAI) { return new CastWaterWalkingOnPartyAction(botAI); } - static Action* water_breathing_on_party(PlayerbotAI* botAI) { return new CastWaterBreathingOnPartyAction(botAI); } - static Action* water_shield(PlayerbotAI* botAI) { return new CastWaterShieldAction(botAI); } - static Action* lightning_shield(PlayerbotAI* botAI) { return new CastLightningShieldAction(botAI); } - static Action* strength_of_earth_totem(PlayerbotAI* botAI) { return new CastStrengthOfEarthTotemAction(botAI); } - static Action* flametongue_totem(PlayerbotAI* botAI) { return new CastFlametongueTotemAction(botAI); } - static Action* magma_totem(PlayerbotAI* botAI) { return new CastMagmaTotemAction(botAI); } - static Action* searing_totem(PlayerbotAI* botAI) { return new CastSearingTotemAction(botAI); } - static Action* fire_nova(PlayerbotAI* botAI) { return new CastFireNovaAction(botAI); } - static Action* windfury_totem(PlayerbotAI* botAI) { return new CastWindfuryTotemAction(botAI); } - static Action* grace_of_air_totem(PlayerbotAI* botAI) { return new CastGraceOfAirTotemAction(botAI); } - static Action* mana_spring_totem(PlayerbotAI* botAI) { return new CastManaSpringTotemAction(botAI); } - static Action* mana_tide_totem(PlayerbotAI* botAI) { return new CastManaTideTotemAction(botAI); } - static Action* earthbind_totem(PlayerbotAI* botAI) { return new CastEarthbindTotemAction(botAI); } - static Action* healing_stream_totem(PlayerbotAI* botAI) { return new CastHealingStreamTotemAction(botAI); } - static Action* wind_shear(PlayerbotAI* botAI) { return new CastWindShearAction(botAI); } - static Action* rockbiter_weapon(PlayerbotAI* botAI) { return new CastRockbiterWeaponAction(botAI); } - static Action* flametongue_weapon(PlayerbotAI* botAI) { return new CastFlametongueWeaponAction(botAI); } - static Action* frostbrand_weapon(PlayerbotAI* botAI) { return new CastFrostbrandWeaponAction(botAI); } - static Action* windfury_weapon(PlayerbotAI* botAI) { return new CastWindfuryWeaponAction(botAI); } - static Action* earthliving_weapon(PlayerbotAI* botAI) { return new CastEarthlivingWeaponAction(botAI); } - static Action* purge(PlayerbotAI* botAI) { return new CastPurgeAction(botAI); } - static Action* healing_wave(PlayerbotAI* botAI) { return new CastHealingWaveAction(botAI); } - static Action* lesser_healing_wave(PlayerbotAI* botAI) { return new CastLesserHealingWaveAction(botAI); } - static Action* healing_wave_on_party(PlayerbotAI* botAI) { return new CastHealingWaveOnPartyAction(botAI); } - static Action* lesser_healing_wave_on_party(PlayerbotAI* botAI) { return new CastLesserHealingWaveOnPartyAction(botAI); } - static Action* earth_shield(PlayerbotAI* botAI) { return new CastEarthShieldAction(botAI); } - static Action* earth_shield_on_party(PlayerbotAI* botAI) { return new CastEarthShieldOnPartyAction(botAI); } - static Action* chain_heal(PlayerbotAI* botAI) { return new CastChainHealAction(botAI); } - static Action* riptide(PlayerbotAI* botAI) { return new CastRiptideAction(botAI); } - static Action* riptide_on_party(PlayerbotAI* botAI) { return new CastRiptideOnPartyAction(botAI); } - static Action* stormstrike(PlayerbotAI* botAI) { return new CastStormstrikeAction(botAI); } - static Action* lava_lash(PlayerbotAI* botAI) { return new CastLavaLashAction(botAI); } - static Action* ancestral_spirit(PlayerbotAI* botAI) { return new CastAncestralSpiritAction(botAI); } - static Action* wind_shear_on_enemy_healer(PlayerbotAI* botAI) { return new CastWindShearOnEnemyHealerAction(botAI); } - static Action* cure_poison(PlayerbotAI* botAI) { return new CastCurePoisonActionSham(botAI); } - static Action* cure_poison_on_party(PlayerbotAI* botAI) { return new CastCurePoisonOnPartyActionSham(botAI); } - static Action* cure_disease(PlayerbotAI* botAI) { return new CastCureDiseaseActionSham(botAI); } - static Action* cure_disease_on_party(PlayerbotAI* botAI) { return new CastCureDiseaseOnPartyActionSham(botAI); } - static Action* lava_burst(PlayerbotAI* ai) { return new CastLavaBurstAction(ai); } - static Action* earth_shield_on_main_tank(PlayerbotAI* ai) { return new CastEarthShieldOnMainTankAction(ai); } - static Action* totem_of_wrath(PlayerbotAI* ai) { return new CastTotemOfWrathAction(ai); } - static Action* fire_elemental_totem(PlayerbotAI* ai) { return new CastFireElementalTotemAction(ai); } - static Action* wrath_of_air_totem(PlayerbotAI* ai) { return new CastWrathOfAirTotemAction(ai); } - static Action* shamanistic_rage(PlayerbotAI* ai) { return new CastShamanisticRageAction(ai); } - static Action* feral_spirit(PlayerbotAI* ai) { return new CastFeralSpiritAction(ai); } - - +private: + static Action* heroism(PlayerbotAI* botAI) { return new CastHeroismAction(botAI); } + static Action* bloodlust(PlayerbotAI* botAI) { return new CastBloodlustAction(botAI); } + static Action* elemental_mastery(PlayerbotAI* botAI) { return new CastElementalMasteryAction(botAI); } + static Action* thunderstorm(PlayerbotAI* botAI) { return new CastThunderstormAction(botAI); } + static Action* lightning_bolt(PlayerbotAI* botAI) { return new CastLightningBoltAction(botAI); } + static Action* chain_lightning(PlayerbotAI* botAI) { return new CastChainLightningAction(botAI); } + static Action* frost_shock(PlayerbotAI* botAI) { return new CastFrostShockAction(botAI); } + static Action* earth_shock(PlayerbotAI* botAI) { return new CastEarthShockAction(botAI); } + static Action* flame_shock(PlayerbotAI* botAI) { return new CastFlameShockAction(botAI); } + static Action* cleanse_spirit_poison_on_party(PlayerbotAI* botAI) + { + return new CastCleanseSpiritPoisonOnPartyAction(botAI); + } + static Action* cleanse_spirit_disease_on_party(PlayerbotAI* botAI) + { + return new CastCleanseSpiritDiseaseOnPartyAction(botAI); + } + static Action* cleanse_spirit_curse_on_party(PlayerbotAI* botAI) + { + return new CastCleanseSpiritCurseOnPartyAction(botAI); + } + static Action* cleanse_spirit(PlayerbotAI* botAI) { return new CastCleanseSpiritAction(botAI); } + static Action* water_walking(PlayerbotAI* botAI) { return new CastWaterWalkingAction(botAI); } + static Action* water_breathing(PlayerbotAI* botAI) { return new CastWaterBreathingAction(botAI); } + static Action* water_walking_on_party(PlayerbotAI* botAI) { return new CastWaterWalkingOnPartyAction(botAI); } + static Action* water_breathing_on_party(PlayerbotAI* botAI) { return new CastWaterBreathingOnPartyAction(botAI); } + static Action* water_shield(PlayerbotAI* botAI) { return new CastWaterShieldAction(botAI); } + static Action* lightning_shield(PlayerbotAI* botAI) { return new CastLightningShieldAction(botAI); } + static Action* strength_of_earth_totem(PlayerbotAI* botAI) { return new CastStrengthOfEarthTotemAction(botAI); } + static Action* flametongue_totem(PlayerbotAI* botAI) { return new CastFlametongueTotemAction(botAI); } + static Action* magma_totem(PlayerbotAI* botAI) { return new CastMagmaTotemAction(botAI); } + static Action* searing_totem(PlayerbotAI* botAI) { return new CastSearingTotemAction(botAI); } + static Action* fire_nova(PlayerbotAI* botAI) { return new CastFireNovaAction(botAI); } + static Action* windfury_totem(PlayerbotAI* botAI) { return new CastWindfuryTotemAction(botAI); } + static Action* grace_of_air_totem(PlayerbotAI* botAI) { return new CastGraceOfAirTotemAction(botAI); } + static Action* mana_spring_totem(PlayerbotAI* botAI) { return new CastManaSpringTotemAction(botAI); } + static Action* mana_tide_totem(PlayerbotAI* botAI) { return new CastManaTideTotemAction(botAI); } + static Action* earthbind_totem(PlayerbotAI* botAI) { return new CastEarthbindTotemAction(botAI); } + static Action* healing_stream_totem(PlayerbotAI* botAI) { return new CastHealingStreamTotemAction(botAI); } + static Action* wind_shear(PlayerbotAI* botAI) { return new CastWindShearAction(botAI); } + static Action* rockbiter_weapon(PlayerbotAI* botAI) { return new CastRockbiterWeaponAction(botAI); } + static Action* flametongue_weapon(PlayerbotAI* botAI) { return new CastFlametongueWeaponAction(botAI); } + static Action* frostbrand_weapon(PlayerbotAI* botAI) { return new CastFrostbrandWeaponAction(botAI); } + static Action* windfury_weapon(PlayerbotAI* botAI) { return new CastWindfuryWeaponAction(botAI); } + static Action* earthliving_weapon(PlayerbotAI* botAI) { return new CastEarthlivingWeaponAction(botAI); } + static Action* purge(PlayerbotAI* botAI) { return new CastPurgeAction(botAI); } + static Action* healing_wave(PlayerbotAI* botAI) { return new CastHealingWaveAction(botAI); } + static Action* lesser_healing_wave(PlayerbotAI* botAI) { return new CastLesserHealingWaveAction(botAI); } + static Action* healing_wave_on_party(PlayerbotAI* botAI) { return new CastHealingWaveOnPartyAction(botAI); } + static Action* lesser_healing_wave_on_party(PlayerbotAI* botAI) + { + return new CastLesserHealingWaveOnPartyAction(botAI); + } + static Action* earth_shield(PlayerbotAI* botAI) { return new CastEarthShieldAction(botAI); } + static Action* earth_shield_on_party(PlayerbotAI* botAI) { return new CastEarthShieldOnPartyAction(botAI); } + static Action* chain_heal(PlayerbotAI* botAI) { return new CastChainHealAction(botAI); } + static Action* riptide(PlayerbotAI* botAI) { return new CastRiptideAction(botAI); } + static Action* riptide_on_party(PlayerbotAI* botAI) { return new CastRiptideOnPartyAction(botAI); } + static Action* stormstrike(PlayerbotAI* botAI) { return new CastStormstrikeAction(botAI); } + static Action* lava_lash(PlayerbotAI* botAI) { return new CastLavaLashAction(botAI); } + static Action* ancestral_spirit(PlayerbotAI* botAI) { return new CastAncestralSpiritAction(botAI); } + static Action* wind_shear_on_enemy_healer(PlayerbotAI* botAI) + { + return new CastWindShearOnEnemyHealerAction(botAI); + } + static Action* cure_poison(PlayerbotAI* botAI) { return new CastCurePoisonActionSham(botAI); } + static Action* cure_poison_on_party(PlayerbotAI* botAI) { return new CastCurePoisonOnPartyActionSham(botAI); } + static Action* cure_disease(PlayerbotAI* botAI) { return new CastCureDiseaseActionSham(botAI); } + static Action* cure_disease_on_party(PlayerbotAI* botAI) { return new CastCureDiseaseOnPartyActionSham(botAI); } + static Action* lava_burst(PlayerbotAI* ai) { return new CastLavaBurstAction(ai); } + static Action* earth_shield_on_main_tank(PlayerbotAI* ai) { return new CastEarthShieldOnMainTankAction(ai); } + static Action* totem_of_wrath(PlayerbotAI* ai) { return new CastTotemOfWrathAction(ai); } + static Action* fire_elemental_totem(PlayerbotAI* ai) { return new CastFireElementalTotemAction(ai); } + static Action* wrath_of_air_totem(PlayerbotAI* ai) { return new CastWrathOfAirTotemAction(ai); } + static Action* shamanistic_rage(PlayerbotAI* ai) { return new CastShamanisticRageAction(ai); } + static Action* feral_spirit(PlayerbotAI* ai) { return new CastFeralSpiritAction(ai); } }; ShamanAiObjectContext::ShamanAiObjectContext(PlayerbotAI* botAI) : AiObjectContext(botAI) diff --git a/src/strategy/shaman/ShamanAiObjectContext.h b/src/strategy/shaman/ShamanAiObjectContext.h index 0b803f98..ad1c0af4 100644 --- a/src/strategy/shaman/ShamanAiObjectContext.h +++ b/src/strategy/shaman/ShamanAiObjectContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SHAMANAIOBJECTCONTEXT_H @@ -11,8 +12,8 @@ class PlayerbotAI; class ShamanAiObjectContext : public AiObjectContext { - public: - ShamanAiObjectContext(PlayerbotAI* botAI); +public: + ShamanAiObjectContext(PlayerbotAI* botAI); }; #endif diff --git a/src/strategy/shaman/ShamanNonCombatStrategy.cpp b/src/strategy/shaman/ShamanNonCombatStrategy.cpp index 1670d288..3d544419 100644 --- a/src/strategy/shaman/ShamanNonCombatStrategy.cpp +++ b/src/strategy/shaman/ShamanNonCombatStrategy.cpp @@ -1,47 +1,57 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ShamanNonCombatStrategy.h" + #include "Playerbots.h" void ShamanNonCombatStrategy::InitTriggers(std::vector& triggers) { NonCombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("party member dead", NextAction::array(0, new NextAction("ancestral spirit", ACTION_CRITICAL_HEAL + 10), nullptr))); - triggers.push_back(new TriggerNode("water breathing", NextAction::array(0, new NextAction("water breathing", 12.0f), nullptr))); - triggers.push_back(new TriggerNode("water walking", NextAction::array(0, new NextAction("water walking", 12.0f), nullptr))); - triggers.push_back(new TriggerNode("water breathing on party", NextAction::array(0, new NextAction("water breathing on party", 11.0f), nullptr))); - triggers.push_back(new TriggerNode("water walking on party", NextAction::array(0, new NextAction("water walking on party", 11.0f), nullptr))); + triggers.push_back( + new TriggerNode("party member dead", + NextAction::array(0, new NextAction("ancestral spirit", ACTION_CRITICAL_HEAL + 10), nullptr))); + triggers.push_back( + new TriggerNode("water breathing", NextAction::array(0, new NextAction("water breathing", 12.0f), nullptr))); + triggers.push_back( + new TriggerNode("water walking", NextAction::array(0, new NextAction("water walking", 12.0f), nullptr))); triggers.push_back(new TriggerNode( - "party member critical health", - NextAction::array(0, new NextAction("riptide on party", 31.0f), new NextAction("healing wave on party", 30.0f), NULL))); + "water breathing on party", NextAction::array(0, new NextAction("water breathing on party", 11.0f), nullptr))); + triggers.push_back(new TriggerNode("water walking on party", + NextAction::array(0, new NextAction("water walking on party", 11.0f), nullptr))); + triggers.push_back(new TriggerNode("party member critical health", + NextAction::array(0, new NextAction("riptide on party", 31.0f), + new NextAction("healing wave on party", 30.0f), NULL))); - triggers.push_back(new TriggerNode( - "party member low health", - NextAction::array(0, new NextAction("riptide on party", 29.0f), new NextAction("healing wave on party", 28.0f), NULL))); + triggers.push_back(new TriggerNode("party member low health", + NextAction::array(0, new NextAction("riptide on party", 29.0f), + new NextAction("healing wave on party", 28.0f), NULL))); - triggers.push_back(new TriggerNode( - "party member medium health", - NextAction::array(0, new NextAction("riptide on party", 27.0f), new NextAction("healing wave on party", 26.0f), NULL))); + triggers.push_back(new TriggerNode("party member medium health", + NextAction::array(0, new NextAction("riptide on party", 27.0f), + new NextAction("healing wave on party", 26.0f), NULL))); - triggers.push_back(new TriggerNode( - "party member almost full health", - NextAction::array(0, new NextAction("riptide on party", 25.0f), new NextAction("lesser healing wave on party", 24.0f), NULL))); + triggers.push_back(new TriggerNode("party member almost full health", + NextAction::array(0, new NextAction("riptide on party", 25.0f), + new NextAction("lesser healing wave on party", 24.0f), NULL))); - triggers.push_back(new TriggerNode( - "medium aoe heal", - NextAction::array(0, new NextAction("chain heal", 27.0f), NULL))); - - triggers.push_back(new TriggerNode("cure poison", NextAction::array(0, new NextAction("cure poison", 21.0f), nullptr))); - triggers.push_back(new TriggerNode("party member cure poison", NextAction::array(0, new NextAction("cure poison on party", 21.0f), nullptr))); - triggers.push_back(new TriggerNode("cure disease", NextAction::array(0, new NextAction("cure disease", 31.0f), nullptr))); - triggers.push_back(new TriggerNode("party member cure disease", NextAction::array(0, new NextAction("cure disease on party", 30.0f), nullptr))); + triggers.push_back( + new TriggerNode("medium aoe heal", NextAction::array(0, new NextAction("chain heal", 27.0f), NULL))); + + triggers.push_back( + new TriggerNode("cure poison", NextAction::array(0, new NextAction("cure poison", 21.0f), nullptr))); + triggers.push_back(new TriggerNode("party member cure poison", + NextAction::array(0, new NextAction("cure poison on party", 21.0f), nullptr))); + triggers.push_back( + new TriggerNode("cure disease", NextAction::array(0, new NextAction("cure disease", 31.0f), nullptr))); + triggers.push_back(new TriggerNode("party member cure disease", + NextAction::array(0, new NextAction("cure disease on party", 30.0f), nullptr))); } void ShamanNonCombatStrategy::InitMultipliers(std::vector& multipliers) { NonCombatStrategy::InitMultipliers(multipliers); } - diff --git a/src/strategy/shaman/ShamanNonCombatStrategy.h b/src/strategy/shaman/ShamanNonCombatStrategy.h index 6dfcaf16..93e9b2f0 100644 --- a/src/strategy/shaman/ShamanNonCombatStrategy.h +++ b/src/strategy/shaman/ShamanNonCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SHAMANNONCOMBATSTRATEGY_H @@ -11,12 +12,12 @@ class PlayerbotAI; class ShamanNonCombatStrategy : public NonCombatStrategy { - public: - ShamanNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + ShamanNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - void InitMultipliers(std::vector& multipliers) override; - std::string const getName() override { return "nc"; } + void InitTriggers(std::vector& triggers) override; + void InitMultipliers(std::vector& multipliers) override; + std::string const getName() override { return "nc"; } }; #endif diff --git a/src/strategy/shaman/ShamanTriggers.cpp b/src/strategy/shaman/ShamanTriggers.cpp index 12c0e499..5f74e901 100644 --- a/src/strategy/shaman/ShamanTriggers.cpp +++ b/src/strategy/shaman/ShamanTriggers.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ShamanTriggers.h" + #include "Playerbots.h" /* @@ -33,16 +35,19 @@ bool ShamanWeaponTrigger::IsActive() } */ -bool MainHandWeaponNoImbueTrigger::IsActive() { +bool MainHandWeaponNoImbueTrigger::IsActive() +{ Item* const itemForSpell = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); if (!itemForSpell || itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) return false; return true; } -bool OffHandWeaponNoImbueTrigger::IsActive() { +bool OffHandWeaponNoImbueTrigger::IsActive() +{ Item* const itemForSpell = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - if (!itemForSpell || itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT) || itemForSpell->GetTemplate()->InventoryType != INVTYPE_WEAPON) + if (!itemForSpell || itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT) || + itemForSpell->GetTemplate()->InventoryType != INVTYPE_WEAPON) return false; return true; } @@ -50,28 +55,24 @@ bool OffHandWeaponNoImbueTrigger::IsActive() { bool ShockTrigger::IsActive() { return SpellTrigger::IsActive() && !botAI->HasAura("flame shock", GetTarget(), false, true) && - !botAI->HasAura("frost shock", GetTarget(), false, true); + !botAI->HasAura("frost shock", GetTarget(), false, true); } bool TotemTrigger::IsActive() { - return AI_VALUE(uint8, "attacker count") >= attackerCount && !AI_VALUE2(bool, "has totem", name) && !botAI->HasAura(name, bot); + return AI_VALUE(uint8, "attacker count") >= attackerCount && !AI_VALUE2(bool, "has totem", name) && + !botAI->HasAura(name, bot); } bool ManaSpringTotemTrigger::IsActive() { - return AI_VALUE(uint8, "attacker count") >= attackerCount && !AI_VALUE2(bool, "has totem", "mana tide totem") && !AI_VALUE2(bool, "has totem", name); + return AI_VALUE(uint8, "attacker count") >= attackerCount && !AI_VALUE2(bool, "has totem", "mana tide totem") && + !AI_VALUE2(bool, "has totem", name); } -bool WaterWalkingTrigger::IsActive() -{ - return BuffTrigger::IsActive() && AI_VALUE2(bool, "swimming", "self target"); -} +bool WaterWalkingTrigger::IsActive() { return BuffTrigger::IsActive() && AI_VALUE2(bool, "swimming", "self target"); } -bool WaterBreathingTrigger::IsActive() -{ - return BuffTrigger::IsActive() && AI_VALUE2(bool, "swimming", "self target"); -} +bool WaterBreathingTrigger::IsActive() { return BuffTrigger::IsActive() && AI_VALUE2(bool, "swimming", "self target"); } bool WaterWalkingOnPartyTrigger::IsActive() { @@ -85,25 +86,19 @@ bool WaterBreathingOnPartyTrigger::IsActive() bool NoFireTotemTrigger::IsActive() { - return !AI_VALUE2(bool, "has totem", "magma totem") && - !AI_VALUE2(bool, "has totem", "flametongue totem") && - !AI_VALUE2(bool, "has totem", "searing totem") && - !AI_VALUE2(bool, "has totem", "fire elemental totem") && - !AI_VALUE2(bool, "has totem", "frost resistance totem") && - !AI_VALUE2(bool, "has totem", "totem of wrath"); + return !AI_VALUE2(bool, "has totem", "magma totem") && !AI_VALUE2(bool, "has totem", "flametongue totem") && + !AI_VALUE2(bool, "has totem", "searing totem") && !AI_VALUE2(bool, "has totem", "fire elemental totem") && + !AI_VALUE2(bool, "has totem", "frost resistance totem") && !AI_VALUE2(bool, "has totem", "totem of wrath"); } bool NoWaterTotemTrigger::IsActive() { - return !AI_VALUE2(bool, "has totem", "fire resistance totem") && - !AI_VALUE2(bool, "has totem", "mana tide totem") && - !AI_VALUE2(bool, "has totem", "cleansing totem") && - !AI_VALUE2(bool, "has totem", "mana spring totem") && - !AI_VALUE2(bool, "has totem", "healing stream totem"); + return !AI_VALUE2(bool, "has totem", "fire resistance totem") && !AI_VALUE2(bool, "has totem", "mana tide totem") && + !AI_VALUE2(bool, "has totem", "cleansing totem") && !AI_VALUE2(bool, "has totem", "mana spring totem") && + !AI_VALUE2(bool, "has totem", "healing stream totem"); } bool NoAirTotemTrigger::IsActive() { - return !AI_VALUE2(bool, "has totem", "wrath of air totem") && - !AI_VALUE2(bool, "has totem", "windfury totem"); + return !AI_VALUE2(bool, "has totem", "wrath of air totem") && !AI_VALUE2(bool, "has totem", "windfury totem"); } diff --git a/src/strategy/shaman/ShamanTriggers.h b/src/strategy/shaman/ShamanTriggers.h index c4350f79..97e9ec03 100644 --- a/src/strategy/shaman/ShamanTriggers.h +++ b/src/strategy/shaman/ShamanTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SHAMANTRIGGERS_H @@ -26,272 +27,294 @@ class ShamanWeaponTrigger : public BuffTrigger class MainHandWeaponNoImbueTrigger : public BuffTrigger { - public: - MainHandWeaponNoImbueTrigger(PlayerbotAI* ai) : BuffTrigger(ai, "main hand", 1) {} - virtual bool IsActive(); +public: + MainHandWeaponNoImbueTrigger(PlayerbotAI* ai) : BuffTrigger(ai, "main hand", 1) {} + virtual bool IsActive(); }; class OffHandWeaponNoImbueTrigger : public BuffTrigger { - public: - OffHandWeaponNoImbueTrigger(PlayerbotAI* ai) : BuffTrigger(ai, "off hand", 1) {} - virtual bool IsActive(); +public: + OffHandWeaponNoImbueTrigger(PlayerbotAI* ai) : BuffTrigger(ai, "off hand", 1) {} + virtual bool IsActive(); }; class TotemTrigger : public Trigger { - public: - TotemTrigger(PlayerbotAI* botAI, std::string const spell, uint32 attackerCount = 0) : Trigger(botAI, spell), attackerCount(attackerCount) { } +public: + TotemTrigger(PlayerbotAI* botAI, std::string const spell, uint32 attackerCount = 0) + : Trigger(botAI, spell), attackerCount(attackerCount) + { + } - bool IsActive() override; + bool IsActive() override; - protected: - uint32 attackerCount; +protected: + uint32 attackerCount; }; class WindfuryTotemTrigger : public TotemTrigger { - public: - WindfuryTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "windfury totem") { } +public: + WindfuryTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "windfury totem") {} }; class GraceOfAirTotemTrigger : public TotemTrigger { - public: - GraceOfAirTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "grace of air totem") { } +public: + GraceOfAirTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "grace of air totem") {} }; class ManaSpringTotemTrigger : public TotemTrigger { - public: - ManaSpringTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "mana spring totem") { } +public: + ManaSpringTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "mana spring totem") {} - bool IsActive() override; + bool IsActive() override; }; class FlametongueTotemTrigger : public TotemTrigger { - public: - FlametongueTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "flametongue totem") { } +public: + FlametongueTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "flametongue totem") {} }; class StrengthOfEarthTotemTrigger : public TotemTrigger { - public: - StrengthOfEarthTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "strength of earth totem") { } +public: + StrengthOfEarthTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "strength of earth totem") {} }; class FireElementalTotemTrigger : public BoostTrigger { - public: - FireElementalTotemTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "fire elemental totem") { } +public: + FireElementalTotemTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "fire elemental totem") {} }; class MagmaTotemTrigger : public TotemTrigger { - public: - MagmaTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "magma totem", 3) { } +public: + MagmaTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "magma totem", 3) {} }; class SearingTotemTrigger : public TotemTrigger { - public: - SearingTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "searing totem", 1) { } +public: + SearingTotemTrigger(PlayerbotAI* botAI) : TotemTrigger(botAI, "searing totem", 1) {} }; class WindShearInterruptSpellTrigger : public InterruptSpellTrigger { - public: - WindShearInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "wind shear") { } +public: + WindShearInterruptSpellTrigger(PlayerbotAI* botAI) : InterruptSpellTrigger(botAI, "wind shear") {} }; class WaterShieldTrigger : public BuffTrigger { - public: - WaterShieldTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "water shield") { } +public: + WaterShieldTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "water shield") {} }; class LightningShieldTrigger : public BuffTrigger { - public: - LightningShieldTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "lightning shield") { } +public: + LightningShieldTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "lightning shield") {} }; class PurgeTrigger : public TargetAuraDispelTrigger { - public: - PurgeTrigger(PlayerbotAI* botAI) : TargetAuraDispelTrigger(botAI, "purge", DISPEL_MAGIC) { } +public: + PurgeTrigger(PlayerbotAI* botAI) : TargetAuraDispelTrigger(botAI, "purge", DISPEL_MAGIC) {} }; class WaterWalkingTrigger : public BuffTrigger { - public: - WaterWalkingTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "water walking", 7) { } +public: + WaterWalkingTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "water walking", 7) {} - bool IsActive() override; + bool IsActive() override; }; class WaterBreathingTrigger : public BuffTrigger { - public: - WaterBreathingTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "water breathing", 5 * 2000) { } +public: + WaterBreathingTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "water breathing", 5 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class WaterWalkingOnPartyTrigger : public BuffOnPartyTrigger { - public: - WaterWalkingOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "water walking on party", 2 * 2000) { } +public: + WaterWalkingOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "water walking on party", 2 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class WaterBreathingOnPartyTrigger : public BuffOnPartyTrigger { - public: - WaterBreathingOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "water breathing on party", 2 * 2000) { } +public: + WaterBreathingOnPartyTrigger(PlayerbotAI* botAI) : BuffOnPartyTrigger(botAI, "water breathing on party", 2 * 2000) + { + } - bool IsActive() override; + bool IsActive() override; }; class CleanseSpiritPoisonTrigger : public NeedCureTrigger { - public: - CleanseSpiritPoisonTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cleanse spirit", DISPEL_POISON) { } +public: + CleanseSpiritPoisonTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cleanse spirit", DISPEL_POISON) {} }; class PartyMemberCleanseSpiritPoisonTrigger : public PartyMemberNeedCureTrigger { - public: - PartyMemberCleanseSpiritPoisonTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "cleanse spirit", DISPEL_POISON) { } +public: + PartyMemberCleanseSpiritPoisonTrigger(PlayerbotAI* botAI) + : PartyMemberNeedCureTrigger(botAI, "cleanse spirit", DISPEL_POISON) + { + } }; class CleanseSpiritCurseTrigger : public NeedCureTrigger { - public: - CleanseSpiritCurseTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cleanse spirit", DISPEL_CURSE) { } +public: + CleanseSpiritCurseTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cleanse spirit", DISPEL_CURSE) {} }; class PartyMemberCleanseSpiritCurseTrigger : public PartyMemberNeedCureTrigger { - public: - PartyMemberCleanseSpiritCurseTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "cleanse spirit", DISPEL_CURSE) { } +public: + PartyMemberCleanseSpiritCurseTrigger(PlayerbotAI* botAI) + : PartyMemberNeedCureTrigger(botAI, "cleanse spirit", DISPEL_CURSE) + { + } }; class CleanseSpiritDiseaseTrigger : public NeedCureTrigger { - public: - CleanseSpiritDiseaseTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cleanse spirit", DISPEL_DISEASE) { } +public: + CleanseSpiritDiseaseTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cleanse spirit", DISPEL_DISEASE) {} }; class PartyMemberCleanseSpiritDiseaseTrigger : public PartyMemberNeedCureTrigger { - public: - PartyMemberCleanseSpiritDiseaseTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "cleanse spirit", DISPEL_DISEASE) { } +public: + PartyMemberCleanseSpiritDiseaseTrigger(PlayerbotAI* botAI) + : PartyMemberNeedCureTrigger(botAI, "cleanse spirit", DISPEL_DISEASE) + { + } }; class ShockTrigger : public DebuffTrigger { - public: - ShockTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "earth shock", 1, true) { } +public: + ShockTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "earth shock", 1, true) {} - bool IsActive() override; + bool IsActive() override; }; class FrostShockSnareTrigger : public SnareTargetTrigger { - public: - FrostShockSnareTrigger(PlayerbotAI* botAI) : SnareTargetTrigger(botAI, "frost shock") { } +public: + FrostShockSnareTrigger(PlayerbotAI* botAI) : SnareTargetTrigger(botAI, "frost shock") {} }; class HeroismTrigger : public BoostTrigger { - public: - HeroismTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "heroism") { } +public: + HeroismTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "heroism") {} }; class BloodlustTrigger : public BoostTrigger { - public: - BloodlustTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "bloodlust") { } +public: + BloodlustTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "bloodlust") {} }; class ElementalMasteryTrigger : public BoostTrigger { - public: - ElementalMasteryTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "elemental mastery") { } +public: + ElementalMasteryTrigger(PlayerbotAI* botAI) : BoostTrigger(botAI, "elemental mastery") {} }; class MaelstromWeaponTrigger : public HasAuraStackTrigger { - public: - MaelstromWeaponTrigger(PlayerbotAI* botAI) : HasAuraStackTrigger(botAI, "maelstrom weapon", 5) { } +public: + MaelstromWeaponTrigger(PlayerbotAI* botAI) : HasAuraStackTrigger(botAI, "maelstrom weapon", 5) {} }; class WindShearInterruptEnemyHealerSpellTrigger : public InterruptEnemyHealerTrigger { - public: - WindShearInterruptEnemyHealerSpellTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "wind shear") { } +public: + WindShearInterruptEnemyHealerSpellTrigger(PlayerbotAI* botAI) : InterruptEnemyHealerTrigger(botAI, "wind shear") {} }; class CurePoisonTrigger : public NeedCureTrigger { - public: - CurePoisonTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cure poison", DISPEL_POISON) { } +public: + CurePoisonTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cure poison", DISPEL_POISON) {} }; class PartyMemberCurePoisonTrigger : public PartyMemberNeedCureTrigger { - public: - PartyMemberCurePoisonTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "cure poison", DISPEL_POISON) { } +public: + PartyMemberCurePoisonTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "cure poison", DISPEL_POISON) + { + } }; class CureDiseaseTrigger : public NeedCureTrigger { - public: - CureDiseaseTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cure disease", DISPEL_DISEASE) { } +public: + CureDiseaseTrigger(PlayerbotAI* botAI) : NeedCureTrigger(botAI, "cure disease", DISPEL_DISEASE) {} }; class PartyMemberCureDiseaseTrigger : public PartyMemberNeedCureTrigger { - public: - PartyMemberCureDiseaseTrigger(PlayerbotAI* botAI) : PartyMemberNeedCureTrigger(botAI, "cure disease", DISPEL_DISEASE) { } +public: + PartyMemberCureDiseaseTrigger(PlayerbotAI* botAI) + : PartyMemberNeedCureTrigger(botAI, "cure disease", DISPEL_DISEASE) + { + } }; -class NoFireTotemTrigger : public Trigger { - public: - NoFireTotemTrigger(PlayerbotAI* ai) : Trigger(ai, "no fire totem") {} - bool IsActive() override; +class NoFireTotemTrigger : public Trigger +{ +public: + NoFireTotemTrigger(PlayerbotAI* ai) : Trigger(ai, "no fire totem") {} + bool IsActive() override; }; -class NoWaterTotemTrigger : public Trigger { - public: - NoWaterTotemTrigger(PlayerbotAI* ai) : Trigger(ai, "no water totem") {} - bool IsActive() override; +class NoWaterTotemTrigger : public Trigger +{ +public: + NoWaterTotemTrigger(PlayerbotAI* ai) : Trigger(ai, "no water totem") {} + bool IsActive() override; }; class EarthShieldOnMainTankTrigger : public BuffOnMainTankTrigger { - public: - EarthShieldOnMainTankTrigger(PlayerbotAI* botAI) : BuffOnMainTankTrigger(botAI, "earth shield", false) {} +public: + EarthShieldOnMainTankTrigger(PlayerbotAI* botAI) : BuffOnMainTankTrigger(botAI, "earth shield", false) {} }; -class FlameShockTrigger : public DebuffTrigger { - public: - FlameShockTrigger(PlayerbotAI* ai) : DebuffTrigger(ai, "flame shock", 1, true) {} +class FlameShockTrigger : public DebuffTrigger +{ +public: + FlameShockTrigger(PlayerbotAI* ai) : DebuffTrigger(ai, "flame shock", 1, true) {} }; class WrathOfAirTotemTrigger : public TotemTrigger { - public: - WrathOfAirTotemTrigger(PlayerbotAI* ai) : TotemTrigger(ai, "wrath of air totem") {} +public: + WrathOfAirTotemTrigger(PlayerbotAI* ai) : TotemTrigger(ai, "wrath of air totem") {} }; class NoAirTotemTrigger : public TotemTrigger { - public: - NoAirTotemTrigger(PlayerbotAI* ai) : TotemTrigger(ai, "no air totem") {} - bool IsActive() override; +public: + NoAirTotemTrigger(PlayerbotAI* ai) : TotemTrigger(ai, "no air totem") {} + bool IsActive() override; }; #endif diff --git a/src/strategy/shaman/TotemsShamanStrategy.cpp b/src/strategy/shaman/TotemsShamanStrategy.cpp index 4c9a34aa..cfa0c3be 100644 --- a/src/strategy/shaman/TotemsShamanStrategy.cpp +++ b/src/strategy/shaman/TotemsShamanStrategy.cpp @@ -1,40 +1,32 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TotemsShamanStrategy.h" + #include "Playerbots.h" -TotemsShamanStrategy::TotemsShamanStrategy(PlayerbotAI* botAI) : GenericShamanStrategy(botAI) -{ -} +TotemsShamanStrategy::TotemsShamanStrategy(PlayerbotAI* botAI) : GenericShamanStrategy(botAI) {} void TotemsShamanStrategy::InitTriggers(std::vector& triggers) { GenericShamanStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("fire elemental totem", NextAction::array(0, new NextAction("fire elemental totem", 32.0f), nullptr))); - - triggers.push_back(new TriggerNode( - "no air totem", - NextAction::array(0, new NextAction("wrath of air totem", 8.0f), NULL))); + triggers.push_back(new TriggerNode("fire elemental totem", + NextAction::array(0, new NextAction("fire elemental totem", 32.0f), nullptr))); - triggers.push_back(new TriggerNode( - "no water totem", - NextAction::array(0, - new NextAction("mana spring totem", 7.0f), - new NextAction("healing stream totem", 6.0f), - nullptr))); + triggers.push_back( + new TriggerNode("no air totem", NextAction::array(0, new NextAction("wrath of air totem", 8.0f), NULL))); - triggers.push_back(new TriggerNode( - "no fire totem", - NextAction::array(0, - new NextAction("flametongue totem", 7.0f), - new NextAction("searing totem", 6.0f), - nullptr))); + triggers.push_back( + new TriggerNode("no water totem", NextAction::array(0, new NextAction("mana spring totem", 7.0f), + new NextAction("healing stream totem", 6.0f), nullptr))); - triggers.push_back(new TriggerNode( - "strength of earth totem", - NextAction::array(0, new NextAction("strength of earth totem", 6.0f), NULL))); + triggers.push_back( + new TriggerNode("no fire totem", NextAction::array(0, new NextAction("flametongue totem", 7.0f), + new NextAction("searing totem", 6.0f), nullptr))); + triggers.push_back(new TriggerNode("strength of earth totem", + NextAction::array(0, new NextAction("strength of earth totem", 6.0f), NULL))); } diff --git a/src/strategy/shaman/TotemsShamanStrategy.h b/src/strategy/shaman/TotemsShamanStrategy.h index ac500a34..5c19a5ce 100644 --- a/src/strategy/shaman/TotemsShamanStrategy.h +++ b/src/strategy/shaman/TotemsShamanStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TOTEMSSHAMANSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class TotemsShamanStrategy : public GenericShamanStrategy { - public: - TotemsShamanStrategy(PlayerbotAI* botAI); +public: + TotemsShamanStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "totems"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "totems"; } }; #endif diff --git a/src/strategy/triggers/ChatCommandTrigger.cpp b/src/strategy/triggers/ChatCommandTrigger.cpp index 51fd0f7e..6567b7ae 100644 --- a/src/strategy/triggers/ChatCommandTrigger.cpp +++ b/src/strategy/triggers/ChatCommandTrigger.cpp @@ -1,11 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ChatCommandTrigger.h" + #include "Playerbots.h" -ChatCommandTrigger::ChatCommandTrigger(PlayerbotAI* botAI, std::string const command) : Trigger(botAI, command), triggered(false), owner(nullptr) +ChatCommandTrigger::ChatCommandTrigger(PlayerbotAI* botAI, std::string const command) + : Trigger(botAI, command), triggered(false), owner(nullptr) { } @@ -24,7 +27,4 @@ Event ChatCommandTrigger::Check() return Event(getName(), param, owner); } -void ChatCommandTrigger::Reset() -{ - triggered = false; -} +void ChatCommandTrigger::Reset() { triggered = false; } diff --git a/src/strategy/triggers/ChatCommandTrigger.h b/src/strategy/triggers/ChatCommandTrigger.h index afef85fe..599e7dcd 100644 --- a/src/strategy/triggers/ChatCommandTrigger.h +++ b/src/strategy/triggers/ChatCommandTrigger.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHATCOMMANDTRIGGER_H @@ -13,17 +14,17 @@ class PlayerbotAI; class ChatCommandTrigger : public Trigger { - public: - ChatCommandTrigger(PlayerbotAI* botAI, std::string const command); +public: + ChatCommandTrigger(PlayerbotAI* botAI, std::string const command); - void ExternalEvent(std::string const param, Player* owner = nullptr) override; - Event Check() override; - void Reset() override; + void ExternalEvent(std::string const param, Player* owner = nullptr) override; + Event Check() override; + void Reset() override; - private: - std::string param; - bool triggered; - Player* owner; +private: + std::string param; + bool triggered; + Player* owner; }; #endif diff --git a/src/strategy/triggers/ChatTriggerContext.h b/src/strategy/triggers/ChatTriggerContext.h index 598154ef..a63f1a2b 100644 --- a/src/strategy/triggers/ChatTriggerContext.h +++ b/src/strategy/triggers/ChatTriggerContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHATTRIGGERCONTEXT_H @@ -12,214 +13,214 @@ class PlayerbotAI; class ChatTriggerContext : public NamedObjectContext { - public: - ChatTriggerContext() - { - creators["quests"] = &ChatTriggerContext::quests; - creators["stats"] = &ChatTriggerContext::stats; - creators["leave"] = &ChatTriggerContext::leave; - creators["rep"] = &ChatTriggerContext::reputation; - creators["reputation"] = &ChatTriggerContext::reputation; - creators["log"] = &ChatTriggerContext::log; - creators["los"] = &ChatTriggerContext::los; - creators["aura"] = &ChatTriggerContext::aura; - creators["drop"] = &ChatTriggerContext::drop; - creators["share"] = &ChatTriggerContext::share; - creators["q"] = &ChatTriggerContext::q; - creators["ll"] = &ChatTriggerContext::ll; - creators["ss"] = &ChatTriggerContext::ss; - creators["loot all"] = &ChatTriggerContext::loot_all; - creators["add all loot"] = &ChatTriggerContext::loot_all; - creators["release"] = &ChatTriggerContext::release; - creators["teleport"] = &ChatTriggerContext::teleport; - creators["taxi"] = &ChatTriggerContext::taxi; - creators["repair"] = &ChatTriggerContext::repair; - creators["u"] = &ChatTriggerContext::use; - creators["use"] = &ChatTriggerContext::use; - creators["c"] = &ChatTriggerContext::item_count; - creators["items"] = &ChatTriggerContext::item_count; - creators["inventory"] = &ChatTriggerContext::item_count; - creators["inv"] = &ChatTriggerContext::item_count; - creators["e"] = &ChatTriggerContext::equip; - creators["equip"] = &ChatTriggerContext::equip; - creators["ue"] = &ChatTriggerContext::uneqip; - creators["s"] = &ChatTriggerContext::sell; - creators["b"] = &ChatTriggerContext::buy; - creators["r"] = &ChatTriggerContext::reward; - creators["t"] = &ChatTriggerContext::trade; - creators["nt"] = &ChatTriggerContext::nontrade; - creators["talents"] = &ChatTriggerContext::talents; - creators["spells"] = &ChatTriggerContext::spells; - creators["co"] = &ChatTriggerContext::co; - creators["nc"] = &ChatTriggerContext::nc; - creators["de"] = &ChatTriggerContext::dead; - creators["trainer"] = &ChatTriggerContext::trainer; - creators["maintenance"] = &ChatTriggerContext::maintenance; - creators["remove glyph"] = &ChatTriggerContext::remove_glyph; - creators["autogear"] = &ChatTriggerContext::autogear; - creators["equip upgrade"] = &ChatTriggerContext::equip_upgrade; - creators["attack"] = &ChatTriggerContext::attack; - creators["chat"] = &ChatTriggerContext::chat; - creators["accept"] = &ChatTriggerContext::accept; - creators["home"] = &ChatTriggerContext::home; - creators["reset botAI"] = &ChatTriggerContext::reset_ai; - creators["destroy"] = &ChatTriggerContext::destroy; - creators["emote"] = &ChatTriggerContext::emote; - creators["buff"] = &ChatTriggerContext::buff; - creators["help"] = &ChatTriggerContext::help; - creators["gb"] = &ChatTriggerContext::gb; - creators["gbank"] = &ChatTriggerContext::gb; - creators["bank"] = &ChatTriggerContext::bank; - creators["follow"] = &ChatTriggerContext::follow; - creators["stay"] = &ChatTriggerContext::stay; - creators["flee"] = &ChatTriggerContext::flee; - creators["grind"] = &ChatTriggerContext::grind; - creators["tank attack"] = &ChatTriggerContext::tank_attack; - creators["talk"] = &ChatTriggerContext::talk; - creators["cast"] = &ChatTriggerContext::cast; - creators["castnc"] = &ChatTriggerContext::castnc; - creators["invite"] = &ChatTriggerContext::invite; - creators["spell"] = &ChatTriggerContext::spell; - creators["rti"] = &ChatTriggerContext::rti; - creators["revive"] = &ChatTriggerContext::revive; - creators["runaway"] = &ChatTriggerContext::runaway; - creators["warning"] = &ChatTriggerContext::warning; - creators["position"] = &ChatTriggerContext::position; - creators["summon"] = &ChatTriggerContext::summon; - creators["who"] = &ChatTriggerContext::who; - creators["save mana"] = &ChatTriggerContext::save_mana; - creators["max dps"] = &ChatTriggerContext::max_dps; - creators["attackers"] = &ChatTriggerContext::attackers; - creators["target"] = &ChatTriggerContext::target; - creators["formation"] = &ChatTriggerContext::formation; - creators["stance"] = &ChatTriggerContext::stance; - creators["sendmail"] = &ChatTriggerContext::sendmail; - creators["mail"] = &ChatTriggerContext::mail; - creators["outfit"] = &ChatTriggerContext::outfit; - creators["go"] = &ChatTriggerContext::go; - creators["ready"] = &ChatTriggerContext::ready_check; - creators["debug"] = &ChatTriggerContext::debug; - creators["cdebug"] = &ChatTriggerContext::cdebug; - creators["cs"] = &ChatTriggerContext::cs; - creators["wts"] = &ChatTriggerContext::wts; - creators["hire"] = &ChatTriggerContext::hire; - creators["craft"] = &ChatTriggerContext::craft; - creators["flag"] = &ChatTriggerContext::craft; - creators["range"] = &ChatTriggerContext::range; - creators["ra"] = &ChatTriggerContext::ra; - creators["give leader"] = &ChatTriggerContext::give_leader; - creators["cheat"] = &ChatTriggerContext::cheat; - creators["ginvite"] = &ChatTriggerContext::ginvite; - creators["guild promote"] = &ChatTriggerContext::guild_promote; - creators["guild demote"] = &ChatTriggerContext::guild_demote; - creators["guild remove"] = &ChatTriggerContext::guild_remove; - creators["guild leave"] = &ChatTriggerContext::guild_leave; - creators["rtsc"] = &ChatTriggerContext::rtsc; - creators["drink"] = &ChatTriggerContext::drink; - creators["naxx"] = &ChatTriggerContext::naxx; - creators["bwl"] = &ChatTriggerContext::bwl; - creators["dps"] = &ChatTriggerContext::dps; - creators["disperse"] = &ChatTriggerContext::disperse; - } +public: + ChatTriggerContext() + { + creators["quests"] = &ChatTriggerContext::quests; + creators["stats"] = &ChatTriggerContext::stats; + creators["leave"] = &ChatTriggerContext::leave; + creators["rep"] = &ChatTriggerContext::reputation; + creators["reputation"] = &ChatTriggerContext::reputation; + creators["log"] = &ChatTriggerContext::log; + creators["los"] = &ChatTriggerContext::los; + creators["aura"] = &ChatTriggerContext::aura; + creators["drop"] = &ChatTriggerContext::drop; + creators["share"] = &ChatTriggerContext::share; + creators["q"] = &ChatTriggerContext::q; + creators["ll"] = &ChatTriggerContext::ll; + creators["ss"] = &ChatTriggerContext::ss; + creators["loot all"] = &ChatTriggerContext::loot_all; + creators["add all loot"] = &ChatTriggerContext::loot_all; + creators["release"] = &ChatTriggerContext::release; + creators["teleport"] = &ChatTriggerContext::teleport; + creators["taxi"] = &ChatTriggerContext::taxi; + creators["repair"] = &ChatTriggerContext::repair; + creators["u"] = &ChatTriggerContext::use; + creators["use"] = &ChatTriggerContext::use; + creators["c"] = &ChatTriggerContext::item_count; + creators["items"] = &ChatTriggerContext::item_count; + creators["inventory"] = &ChatTriggerContext::item_count; + creators["inv"] = &ChatTriggerContext::item_count; + creators["e"] = &ChatTriggerContext::equip; + creators["equip"] = &ChatTriggerContext::equip; + creators["ue"] = &ChatTriggerContext::uneqip; + creators["s"] = &ChatTriggerContext::sell; + creators["b"] = &ChatTriggerContext::buy; + creators["r"] = &ChatTriggerContext::reward; + creators["t"] = &ChatTriggerContext::trade; + creators["nt"] = &ChatTriggerContext::nontrade; + creators["talents"] = &ChatTriggerContext::talents; + creators["spells"] = &ChatTriggerContext::spells; + creators["co"] = &ChatTriggerContext::co; + creators["nc"] = &ChatTriggerContext::nc; + creators["de"] = &ChatTriggerContext::dead; + creators["trainer"] = &ChatTriggerContext::trainer; + creators["maintenance"] = &ChatTriggerContext::maintenance; + creators["remove glyph"] = &ChatTriggerContext::remove_glyph; + creators["autogear"] = &ChatTriggerContext::autogear; + creators["equip upgrade"] = &ChatTriggerContext::equip_upgrade; + creators["attack"] = &ChatTriggerContext::attack; + creators["chat"] = &ChatTriggerContext::chat; + creators["accept"] = &ChatTriggerContext::accept; + creators["home"] = &ChatTriggerContext::home; + creators["reset botAI"] = &ChatTriggerContext::reset_ai; + creators["destroy"] = &ChatTriggerContext::destroy; + creators["emote"] = &ChatTriggerContext::emote; + creators["buff"] = &ChatTriggerContext::buff; + creators["help"] = &ChatTriggerContext::help; + creators["gb"] = &ChatTriggerContext::gb; + creators["gbank"] = &ChatTriggerContext::gb; + creators["bank"] = &ChatTriggerContext::bank; + creators["follow"] = &ChatTriggerContext::follow; + creators["stay"] = &ChatTriggerContext::stay; + creators["flee"] = &ChatTriggerContext::flee; + creators["grind"] = &ChatTriggerContext::grind; + creators["tank attack"] = &ChatTriggerContext::tank_attack; + creators["talk"] = &ChatTriggerContext::talk; + creators["cast"] = &ChatTriggerContext::cast; + creators["castnc"] = &ChatTriggerContext::castnc; + creators["invite"] = &ChatTriggerContext::invite; + creators["spell"] = &ChatTriggerContext::spell; + creators["rti"] = &ChatTriggerContext::rti; + creators["revive"] = &ChatTriggerContext::revive; + creators["runaway"] = &ChatTriggerContext::runaway; + creators["warning"] = &ChatTriggerContext::warning; + creators["position"] = &ChatTriggerContext::position; + creators["summon"] = &ChatTriggerContext::summon; + creators["who"] = &ChatTriggerContext::who; + creators["save mana"] = &ChatTriggerContext::save_mana; + creators["max dps"] = &ChatTriggerContext::max_dps; + creators["attackers"] = &ChatTriggerContext::attackers; + creators["target"] = &ChatTriggerContext::target; + creators["formation"] = &ChatTriggerContext::formation; + creators["stance"] = &ChatTriggerContext::stance; + creators["sendmail"] = &ChatTriggerContext::sendmail; + creators["mail"] = &ChatTriggerContext::mail; + creators["outfit"] = &ChatTriggerContext::outfit; + creators["go"] = &ChatTriggerContext::go; + creators["ready"] = &ChatTriggerContext::ready_check; + creators["debug"] = &ChatTriggerContext::debug; + creators["cdebug"] = &ChatTriggerContext::cdebug; + creators["cs"] = &ChatTriggerContext::cs; + creators["wts"] = &ChatTriggerContext::wts; + creators["hire"] = &ChatTriggerContext::hire; + creators["craft"] = &ChatTriggerContext::craft; + creators["flag"] = &ChatTriggerContext::craft; + creators["range"] = &ChatTriggerContext::range; + creators["ra"] = &ChatTriggerContext::ra; + creators["give leader"] = &ChatTriggerContext::give_leader; + creators["cheat"] = &ChatTriggerContext::cheat; + creators["ginvite"] = &ChatTriggerContext::ginvite; + creators["guild promote"] = &ChatTriggerContext::guild_promote; + creators["guild demote"] = &ChatTriggerContext::guild_demote; + creators["guild remove"] = &ChatTriggerContext::guild_remove; + creators["guild leave"] = &ChatTriggerContext::guild_leave; + creators["rtsc"] = &ChatTriggerContext::rtsc; + creators["drink"] = &ChatTriggerContext::drink; + creators["naxx"] = &ChatTriggerContext::naxx; + creators["bwl"] = &ChatTriggerContext::bwl; + creators["dps"] = &ChatTriggerContext::dps; + creators["disperse"] = &ChatTriggerContext::disperse; + } - private: - static Trigger* ra(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "ra"); } - static Trigger* range(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "range"); } - static Trigger* flag(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "flag"); } - static Trigger* craft(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "craft"); } - static Trigger* hire(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "hire"); } - static Trigger* wts(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "wts"); } - static Trigger* cs(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "cs"); } - static Trigger* debug(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "debug"); } - static Trigger* cdebug(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "cdebug"); } - static Trigger* go(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "go"); } - static Trigger* outfit(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "outfit"); } - static Trigger* mail(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "mail"); } - static Trigger* sendmail(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "sendmail"); } - static Trigger* formation(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "formation"); } - static Trigger* stance(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "stance"); } - static Trigger* attackers(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "attackers"); } - static Trigger* target(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "target"); } - static Trigger* max_dps(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "max dps"); } - static Trigger* save_mana(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "save mana"); } - static Trigger* who(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "who"); } - static Trigger* summon(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "summon"); } - static Trigger* position(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "position"); } - static Trigger* runaway(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "runaway"); } - static Trigger* warning(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "warning"); } - static Trigger* revive(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "revive"); } - static Trigger* rti(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "rti"); } - static Trigger* invite(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "invite"); } - static Trigger* cast(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "cast"); } - static Trigger* castnc(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "castnc"); } - static Trigger* talk(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "talk"); } - static Trigger* flee(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "flee"); } - static Trigger* grind(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "grind"); } - static Trigger* tank_attack(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "tank attack"); } - static Trigger* stay(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "stay"); } - static Trigger* follow(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "follow"); } - static Trigger* gb(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "gb"); } - static Trigger* bank(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "bank"); } - static Trigger* help(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "help"); } - static Trigger* buff(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "buff"); } - static Trigger* emote(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "emote"); } - static Trigger* destroy(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "destroy"); } - static Trigger* home(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "home"); } - static Trigger* accept(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "accept"); } - static Trigger* chat(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "chat"); } - static Trigger* attack(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "attack"); } - static Trigger* trainer(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "trainer"); } - static Trigger* maintenance(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "maintenance"); } - static Trigger* remove_glyph(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "remove glyph"); } - static Trigger* autogear(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "autogear"); } - static Trigger* equip_upgrade(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "equip upgrade"); } - static Trigger* co(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "co"); } - static Trigger* nc(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "nc"); } - static Trigger* dead(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "de"); } - static Trigger* spells(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "spells"); } - static Trigger* talents(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "talents"); } - static Trigger* equip(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "e"); } - static Trigger* uneqip(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "ue"); } - static Trigger* sell(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "s"); } - static Trigger* buy(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "b"); } - static Trigger* reward(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "r"); } - static Trigger* trade(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "t"); } - static Trigger* nontrade(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "nt"); } - static Trigger* item_count(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "c"); } - static Trigger* use(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "use"); } - static Trigger* repair(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "repair"); } - static Trigger* taxi(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "taxi"); } - static Trigger* teleport(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "teleport"); } - static Trigger* q(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "q"); } - static Trigger* ll(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "ll"); } - static Trigger* ss(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "ss"); } - static Trigger* drop(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "drop"); } - static Trigger* share(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "share"); } - static Trigger* quests(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "quests"); } - static Trigger* stats(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "stats"); } - static Trigger* leave(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "leave"); } - static Trigger* reputation(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "reputation"); } - static Trigger* log(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "log"); } - static Trigger* los(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "los"); } - static Trigger* aura(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "aura"); } - static Trigger* loot_all(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "add all loot"); } - static Trigger* release(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "release"); } - static Trigger* reset_ai(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "reset botAI"); } - static Trigger* spell(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "spell"); } - static Trigger* ready_check(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "ready check"); } - static Trigger* give_leader(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "give leader"); } - static Trigger* cheat(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "cheat"); } - static Trigger* ginvite(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "ginvite"); } - static Trigger* guild_promote(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "guild promote"); } - static Trigger* guild_demote(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "guild demote"); } - static Trigger* guild_remove(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "guild remove"); } - static Trigger* guild_leave(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "guild leave"); } - static Trigger* rtsc(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "rtsc"); } - static Trigger* drink(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "drink"); } - static Trigger* naxx(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "naxx"); } - static Trigger* bwl(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "bwl"); } - static Trigger* dps(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "dps"); } - static Trigger* disperse(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "disperse"); } +private: + static Trigger* ra(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "ra"); } + static Trigger* range(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "range"); } + static Trigger* flag(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "flag"); } + static Trigger* craft(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "craft"); } + static Trigger* hire(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "hire"); } + static Trigger* wts(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "wts"); } + static Trigger* cs(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "cs"); } + static Trigger* debug(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "debug"); } + static Trigger* cdebug(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "cdebug"); } + static Trigger* go(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "go"); } + static Trigger* outfit(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "outfit"); } + static Trigger* mail(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "mail"); } + static Trigger* sendmail(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "sendmail"); } + static Trigger* formation(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "formation"); } + static Trigger* stance(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "stance"); } + static Trigger* attackers(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "attackers"); } + static Trigger* target(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "target"); } + static Trigger* max_dps(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "max dps"); } + static Trigger* save_mana(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "save mana"); } + static Trigger* who(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "who"); } + static Trigger* summon(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "summon"); } + static Trigger* position(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "position"); } + static Trigger* runaway(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "runaway"); } + static Trigger* warning(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "warning"); } + static Trigger* revive(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "revive"); } + static Trigger* rti(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "rti"); } + static Trigger* invite(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "invite"); } + static Trigger* cast(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "cast"); } + static Trigger* castnc(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "castnc"); } + static Trigger* talk(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "talk"); } + static Trigger* flee(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "flee"); } + static Trigger* grind(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "grind"); } + static Trigger* tank_attack(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "tank attack"); } + static Trigger* stay(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "stay"); } + static Trigger* follow(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "follow"); } + static Trigger* gb(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "gb"); } + static Trigger* bank(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "bank"); } + static Trigger* help(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "help"); } + static Trigger* buff(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "buff"); } + static Trigger* emote(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "emote"); } + static Trigger* destroy(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "destroy"); } + static Trigger* home(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "home"); } + static Trigger* accept(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "accept"); } + static Trigger* chat(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "chat"); } + static Trigger* attack(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "attack"); } + static Trigger* trainer(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "trainer"); } + static Trigger* maintenance(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "maintenance"); } + static Trigger* remove_glyph(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "remove glyph"); } + static Trigger* autogear(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "autogear"); } + static Trigger* equip_upgrade(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "equip upgrade"); } + static Trigger* co(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "co"); } + static Trigger* nc(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "nc"); } + static Trigger* dead(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "de"); } + static Trigger* spells(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "spells"); } + static Trigger* talents(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "talents"); } + static Trigger* equip(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "e"); } + static Trigger* uneqip(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "ue"); } + static Trigger* sell(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "s"); } + static Trigger* buy(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "b"); } + static Trigger* reward(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "r"); } + static Trigger* trade(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "t"); } + static Trigger* nontrade(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "nt"); } + static Trigger* item_count(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "c"); } + static Trigger* use(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "use"); } + static Trigger* repair(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "repair"); } + static Trigger* taxi(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "taxi"); } + static Trigger* teleport(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "teleport"); } + static Trigger* q(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "q"); } + static Trigger* ll(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "ll"); } + static Trigger* ss(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "ss"); } + static Trigger* drop(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "drop"); } + static Trigger* share(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "share"); } + static Trigger* quests(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "quests"); } + static Trigger* stats(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "stats"); } + static Trigger* leave(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "leave"); } + static Trigger* reputation(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "reputation"); } + static Trigger* log(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "log"); } + static Trigger* los(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "los"); } + static Trigger* aura(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "aura"); } + static Trigger* loot_all(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "add all loot"); } + static Trigger* release(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "release"); } + static Trigger* reset_ai(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "reset botAI"); } + static Trigger* spell(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "spell"); } + static Trigger* ready_check(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "ready check"); } + static Trigger* give_leader(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "give leader"); } + static Trigger* cheat(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "cheat"); } + static Trigger* ginvite(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "ginvite"); } + static Trigger* guild_promote(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "guild promote"); } + static Trigger* guild_demote(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "guild demote"); } + static Trigger* guild_remove(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "guild remove"); } + static Trigger* guild_leave(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "guild leave"); } + static Trigger* rtsc(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "rtsc"); } + static Trigger* drink(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "drink"); } + static Trigger* naxx(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "naxx"); } + static Trigger* bwl(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "bwl"); } + static Trigger* dps(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "dps"); } + static Trigger* disperse(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "disperse"); } }; #endif diff --git a/src/strategy/triggers/CureTriggers.cpp b/src/strategy/triggers/CureTriggers.cpp index 3eca5699..9c7369d4 100644 --- a/src/strategy/triggers/CureTriggers.cpp +++ b/src/strategy/triggers/CureTriggers.cpp @@ -1,23 +1,22 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CureTriggers.h" + #include "Playerbots.h" #include "WorldBuffAction.h" bool NeedCureTrigger::IsActive() { - Unit* target = GetTarget(); - return target && target->IsInWorld() && botAI->HasAuraToDispel(target, dispelType); + Unit* target = GetTarget(); + return target && target->IsInWorld() && botAI->HasAuraToDispel(target, dispelType); } Value* PartyMemberNeedCureTrigger::GetTargetValue() { - return context->GetValue("party member to dispel", dispelType); + return context->GetValue("party member to dispel", dispelType); } -bool NeedWorldBuffTrigger::IsActive() -{ - return !WorldBuffAction::NeedWorldBuffs(bot).empty(); -} +bool NeedWorldBuffTrigger::IsActive() { return !WorldBuffAction::NeedWorldBuffs(bot).empty(); } diff --git a/src/strategy/triggers/CureTriggers.h b/src/strategy/triggers/CureTriggers.h index 50bedf2f..a18f8a10 100644 --- a/src/strategy/triggers/CureTriggers.h +++ b/src/strategy/triggers/CureTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CURETRIGGERS_H @@ -12,38 +13,47 @@ class Unit; class NeedCureTrigger : public SpellTrigger { - public: - NeedCureTrigger(PlayerbotAI* botAI, std::string const spell, uint32 dispelType) : SpellTrigger(botAI, spell, 1 * 1000), dispelType(dispelType) { } +public: + NeedCureTrigger(PlayerbotAI* botAI, std::string const spell, uint32 dispelType) + : SpellTrigger(botAI, spell, 1 * 1000), dispelType(dispelType) + { + } - std::string const GetTargetName() override { return "self target"; } - bool IsActive() override; + std::string const GetTargetName() override { return "self target"; } + bool IsActive() override; - protected: - uint32 dispelType; +protected: + uint32 dispelType; }; class TargetAuraDispelTrigger : public NeedCureTrigger { - public: - TargetAuraDispelTrigger(PlayerbotAI* botAI, std::string const spell, uint32 dispelType) : NeedCureTrigger(botAI, spell, dispelType) { } +public: + TargetAuraDispelTrigger(PlayerbotAI* botAI, std::string const spell, uint32 dispelType) + : NeedCureTrigger(botAI, spell, dispelType) + { + } - std::string const GetTargetName() override { return "current target"; } + std::string const GetTargetName() override { return "current target"; } }; class PartyMemberNeedCureTrigger : public NeedCureTrigger { - public: - PartyMemberNeedCureTrigger(PlayerbotAI* botAI, std::string const spell, uint32 dispelType) : NeedCureTrigger(botAI, spell, dispelType) { } +public: + PartyMemberNeedCureTrigger(PlayerbotAI* botAI, std::string const spell, uint32 dispelType) + : NeedCureTrigger(botAI, spell, dispelType) + { + } - Value* GetTargetValue() override; + Value* GetTargetValue() override; }; class NeedWorldBuffTrigger : public Trigger { - public: - NeedWorldBuffTrigger(PlayerbotAI* botAI) : Trigger(botAI) { } +public: + NeedWorldBuffTrigger(PlayerbotAI* botAI) : Trigger(botAI) {} - bool IsActive() override; + bool IsActive() override; }; #endif diff --git a/src/strategy/triggers/GenericTriggers.cpp b/src/strategy/triggers/GenericTriggers.cpp index 7d1c7444..49617449 100644 --- a/src/strategy/triggers/GenericTriggers.cpp +++ b/src/strategy/triggers/GenericTriggers.cpp @@ -1,8 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericTriggers.h" + +#include + #include "BattlegroundWS.h" #include "CreatureAI.h" #include "ObjectGuid.h" @@ -10,45 +14,49 @@ #include "SharedDefines.h" #include "TemporarySummon.h" #include "Timer.h" -#include bool LowManaTrigger::IsActive() { - return AI_VALUE2(bool, "has mana", "self target") && AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->lowMana; + return AI_VALUE2(bool, "has mana", "self target") && + AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->lowMana; } bool MediumManaTrigger::IsActive() { - return AI_VALUE2(bool, "has mana", "self target") && AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->mediumMana; + return AI_VALUE2(bool, "has mana", "self target") && + AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->mediumMana; } bool NoPetTrigger::IsActive() { - return (bot->GetMinionGUID().IsEmpty()) && - (!AI_VALUE(Unit*, "pet target")) && - (!bot->GetGuardianPet()) && - (!bot->GetFirstControlled()) && - (!AI_VALUE2(bool, "mounted", "self target")); + return (bot->GetMinionGUID().IsEmpty()) && (!AI_VALUE(Unit*, "pet target")) && (!bot->GetGuardianPet()) && + (!bot->GetFirstControlled()) && (!AI_VALUE2(bool, "mounted", "self target")); } -bool HasPetTrigger::IsActive() { - return (AI_VALUE(Unit*, "pet target")) && !AI_VALUE2(bool, "mounted", "self target");; +bool HasPetTrigger::IsActive() +{ + return (AI_VALUE(Unit*, "pet target")) && !AI_VALUE2(bool, "mounted", "self target"); + ; } -bool PetAttackTrigger::IsActive() +bool PetAttackTrigger::IsActive() { Guardian* pet = bot->GetGuardianPet(); - if (!pet) { + if (!pet) + { return false; } Unit* target = AI_VALUE(Unit*, "current target"); - if (!target) { + if (!target) + { return false; } - if (pet->GetVictim() == target && pet->GetCharmInfo()->IsCommandAttack()) { + if (pet->GetVictim() == target && pet->GetCharmInfo()->IsCommandAttack()) + { return false; } - if (bot->GetMap()->IsDungeon() && bot->GetGroup() && !target->IsInCombat()) { + if (bot->GetMap()->IsDungeon() && bot->GetGroup() && !target->IsInCombat()) + { return false; } return true; @@ -69,35 +77,21 @@ bool EnoughManaTrigger::IsActive() return AI_VALUE2(bool, "has mana", "self target") && AI_VALUE2(uint8, "mana", "self target") > 65; } -bool RageAvailable::IsActive() -{ - return AI_VALUE2(uint8, "rage", "self target") >= amount; -} +bool RageAvailable::IsActive() { return AI_VALUE2(uint8, "rage", "self target") >= amount; } -bool EnergyAvailable::IsActive() -{ - return AI_VALUE2(uint8, "energy", "self target") >= amount; -} +bool EnergyAvailable::IsActive() { return AI_VALUE2(uint8, "energy", "self target") >= amount; } -bool ComboPointsAvailableTrigger::IsActive() -{ - return AI_VALUE2(uint8, "combo", "current target") >= amount; -} +bool ComboPointsAvailableTrigger::IsActive() { return AI_VALUE2(uint8, "combo", "current target") >= amount; } -bool LoseAggroTrigger::IsActive() -{ - return !AI_VALUE2(bool, "has aggro", "current target"); -} +bool LoseAggroTrigger::IsActive() { return !AI_VALUE2(bool, "has aggro", "current target"); } -bool HasAggroTrigger::IsActive() -{ - return AI_VALUE2(bool, "has aggro", "current target"); -} +bool HasAggroTrigger::IsActive() { return AI_VALUE2(bool, "has aggro", "current target"); } bool PanicTrigger::IsActive() { return AI_VALUE2(uint8, "health", "self target") < sPlayerbotAIConfig->criticalHealth && - (!AI_VALUE2(bool, "has mana", "self target") || AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->lowMana); + (!AI_VALUE2(bool, "has mana", "self target") || + AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->lowMana); } bool OutNumberedTrigger::IsActive() @@ -143,27 +137,24 @@ bool OutNumberedTrigger::IsActive() bool BuffTrigger::IsActive() { Unit* target = GetTarget(); - return SpellTrigger::IsActive() && !botAI->HasAura(spell, target, false, checkIsOwner); + return SpellTrigger::IsActive() && !botAI->HasAura(spell, target, false, checkIsOwner); } Value* BuffOnPartyTrigger::GetTargetValue() { - return context->GetValue("party member without aura", spell); + return context->GetValue("party member without aura", spell); } -bool ProtectPartyMemberTrigger::IsActive() -{ - return AI_VALUE(Unit*, "party member to protect"); -} +bool ProtectPartyMemberTrigger::IsActive() { return AI_VALUE(Unit*, "party member to protect"); } Value* DebuffOnAttackerTrigger::GetTargetValue() { - return context->GetValue("attacker without aura", spell); + return context->GetValue("attacker without aura", spell); } Value* DebuffOnMeleeAttackerTrigger::GetTargetValue() { - return context->GetValue("melee attacker without aura", spell); + return context->GetValue("melee attacker without aura", spell); } bool NoAttackersTrigger::IsActive() @@ -171,15 +162,9 @@ bool NoAttackersTrigger::IsActive() return !AI_VALUE(Unit*, "current target") && AI_VALUE(uint8, "my attacker count") > 0; } -bool InvalidTargetTrigger::IsActive() -{ - return AI_VALUE2(bool, "invalid target", "current target"); -} +bool InvalidTargetTrigger::IsActive() { return AI_VALUE2(bool, "invalid target", "current target"); } -bool NoTargetTrigger::IsActive() -{ - return !AI_VALUE(Unit*, "current target"); -} +bool NoTargetTrigger::IsActive() { return !AI_VALUE(Unit*, "current target"); } bool MyAttackerCountTrigger::IsActive() { @@ -189,20 +174,22 @@ bool MyAttackerCountTrigger::IsActive() bool AoeTrigger::IsActive() { Unit* current_target = AI_VALUE(Unit*, "current target"); - if (!current_target) { - return false; - } - GuidVector attackers = context->GetValue("attackers")->Get(); - int attackers_count = 0; + if (!current_target) + { + return false; + } + GuidVector attackers = context->GetValue("attackers")->Get(); + int attackers_count = 0; for (ObjectGuid const guid : attackers) { Unit* unit = botAI->GetUnit(guid); if (!unit || !unit->IsAlive()) continue; - if (unit->GetExactDist2d(current_target) <= range) { - attackers_count++; - } + if (unit->GetExactDist2d(current_target) <= range) + { + attackers_count++; + } } return attackers_count >= amount; } @@ -225,38 +212,34 @@ bool NoDrinkTrigger::IsActive() return AI_VALUE2(std::vector, "inventory items", "conjured water").empty(); } -bool TargetInSightTrigger::IsActive() -{ - return AI_VALUE(Unit*, "grind target"); -} +bool TargetInSightTrigger::IsActive() { return AI_VALUE(Unit*, "grind target"); } bool DebuffTrigger::IsActive() { Unit* target = GetTarget(); - if (!target || !target->IsAlive() || !target->IsInWorld()) { + if (!target || !target->IsAlive() || !target->IsInWorld()) + { return false; } - return BuffTrigger::IsActive() && (target->GetHealth() / AI_VALUE(float, "expected group dps")) >= needLifeTime; + return BuffTrigger::IsActive() && (target->GetHealth() / AI_VALUE(float, "expected group dps")) >= needLifeTime; } bool DebuffOnBossTrigger::IsActive() { - if (!DebuffTrigger::IsActive()) { + if (!DebuffTrigger::IsActive()) + { return false; } - Creature *c = GetTarget()->ToCreature(); + Creature* c = GetTarget()->ToCreature(); return c && ((c->IsDungeonBoss()) || (c->isWorldBoss())); } -bool SpellTrigger::IsActive() -{ - return GetTarget(); -} +bool SpellTrigger::IsActive() { return GetTarget(); } bool SpellCanBeCastTrigger::IsActive() { - Unit* target = GetTarget(); - return target && botAI->CanCastSpell(spell, target); + Unit* target = GetTarget(); + return target && botAI->CanCastSpell(spell, target); } bool SpellNoCooldownTrigger::IsActive() @@ -273,11 +256,12 @@ bool SpellCooldownTrigger::IsActive() uint32 spellId = AI_VALUE2(uint32, "spell id", name); if (!spellId) return false; - + return bot->HasSpellCooldown(spellId); } -RandomTrigger::RandomTrigger(PlayerbotAI* botAI, std::string const name, int32 probability) : Trigger(botAI, name), probability(probability), lastCheck(getMSTime()) +RandomTrigger::RandomTrigger(PlayerbotAI* botAI, std::string const name, int32 probability) + : Trigger(botAI, name), probability(probability), lastCheck(getMSTime()) { } @@ -293,10 +277,7 @@ bool RandomTrigger::IsActive() return (rand() % k) == 0; } -bool AndTrigger::IsActive() -{ - return ls && rs && ls->IsActive() && rs->IsActive(); -} +bool AndTrigger::IsActive() { return ls && rs && ls->IsActive() && rs->IsActive(); } std::string const AndTrigger::getName() { @@ -327,19 +308,13 @@ std::string const TwoTriggers::getName() return name; } -bool BoostTrigger::IsActive() -{ - return BuffTrigger::IsActive() && AI_VALUE(uint8, "balance") <= balance; -} +bool BoostTrigger::IsActive() { return BuffTrigger::IsActive() && AI_VALUE(uint8, "balance") <= balance; } -bool ItemCountTrigger::IsActive() -{ - return AI_VALUE2(uint32, "item count", item) < count; -} +bool ItemCountTrigger::IsActive() { return AI_VALUE2(uint32, "item count", item) < count; } bool InterruptSpellTrigger::IsActive() { - return SpellTrigger::IsActive() && botAI->IsInterruptableSpellCasting(GetTarget(), getName()); + return SpellTrigger::IsActive() && botAI->IsInterruptableSpellCasting(GetTarget(), getName()); } bool DeflectSpellTrigger::IsActive() @@ -385,21 +360,16 @@ bool DeflectSpellTrigger::IsActive() return false; } -bool AttackerCountTrigger::IsActive() -{ - return AI_VALUE(uint8, "attacker count") >= amount; -} +bool AttackerCountTrigger::IsActive() { return AI_VALUE(uint8, "attacker count") >= amount; } -bool HasAuraTrigger::IsActive() -{ - return botAI->HasAura(getName(), GetTarget(), false, false, -1, true); -} +bool HasAuraTrigger::IsActive() { return botAI->HasAura(getName(), GetTarget(), false, false, -1, true); } bool HasAuraStackTrigger::IsActive() { - Aura *aura = botAI->GetAura(getName(), GetTarget(), false, true, stack); - // sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, "HasAuraStackTrigger::IsActive %s %d", getName(), aura ? aura->GetStackAmount() : -1); - return aura; + Aura* aura = botAI->GetAura(getName(), GetTarget(), false, true, stack); + // sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, "HasAuraStackTrigger::IsActive %s %d", getName(), aura ? + // aura->GetStackAmount() : -1); + return aura; } bool TimerTrigger::IsActive() @@ -413,10 +383,7 @@ bool TimerTrigger::IsActive() return false; } -bool HasNoAuraTrigger::IsActive() -{ - return !botAI->HasAura(getName(), GetTarget()); -} +bool HasNoAuraTrigger::IsActive() { return !botAI->HasAura(getName(), GetTarget()); } bool TankAssistTrigger::IsActive() { @@ -446,20 +413,14 @@ bool IsNotBehindTargetTrigger::IsActive() return target && !AI_VALUE2(bool, "behind", "current target"); } -bool IsNotFacingTargetTrigger::IsActive() -{ - return !AI_VALUE2(bool, "facing", "current target"); -} +bool IsNotFacingTargetTrigger::IsActive() { return !AI_VALUE2(bool, "facing", "current target"); } bool HasCcTargetTrigger::IsActive() { return AI_VALUE2(Unit*, "cc target", getName()) && !AI_VALUE2(Unit*, "current cc target", getName()); } -bool NoMovementTrigger::IsActive() -{ - return !AI_VALUE2(bool, "moving", "self target"); -} +bool NoMovementTrigger::IsActive() { return !AI_VALUE2(bool, "moving", "self target"); } bool NoPossibleTargetsTrigger::IsActive() { @@ -467,17 +428,14 @@ bool NoPossibleTargetsTrigger::IsActive() return !targets.size(); } -bool PossibleAddsTrigger::IsActive() -{ - return AI_VALUE(bool, "possible adds") && !AI_VALUE(ObjectGuid, "pull target"); -} +bool PossibleAddsTrigger::IsActive() { return AI_VALUE(bool, "possible adds") && !AI_VALUE(ObjectGuid, "pull target"); } bool NotDpsTargetActiveTrigger::IsActive() { Unit* target = AI_VALUE(Unit*, "current target"); // do not switch if enemy target - if (target && target->IsAlive()) { - + if (target && target->IsAlive()) + { Unit* enemy = AI_VALUE(Unit*, "enemy player target"); if (target == enemy) return false; @@ -500,10 +458,7 @@ bool NotDpsAoeTargetActiveTrigger::IsActive() return dps && target != dps; } -bool IsSwimmingTrigger::IsActive() -{ - return AI_VALUE2(bool, "swimming", "self target"); -} +bool IsSwimmingTrigger::IsActive() { return AI_VALUE2(bool, "swimming", "self target"); } bool HasNearestAddsTrigger::IsActive() { @@ -513,7 +468,7 @@ bool HasNearestAddsTrigger::IsActive() bool HasItemForSpellTrigger::IsActive() { - std::string const spell = getName(); + std::string const spell = getName(); uint32 spellId = AI_VALUE2(uint32, "spell id", spell); return spellId && AI_VALUE2(Item*, "item for spell", spellId); } @@ -530,10 +485,7 @@ Value* InterruptEnemyHealerTrigger::GetTargetValue() return context->GetValue("enemy healer target", spell); } -bool RandomBotUpdateTrigger::IsActive() -{ - return RandomTrigger::IsActive() && AI_VALUE(bool, "random bot update"); -} +bool RandomBotUpdateTrigger::IsActive() { return RandomTrigger::IsActive() && AI_VALUE(bool, "random bot update"); } bool NoNonBotPlayersAroundTrigger::IsActive() { @@ -545,15 +497,9 @@ bool NoNonBotPlayersAroundTrigger::IsActive() */ } -bool NewPlayerNearbyTrigger::IsActive() -{ - return AI_VALUE(ObjectGuid, "new player nearby"); -} +bool NewPlayerNearbyTrigger::IsActive() { return AI_VALUE(ObjectGuid, "new player nearby"); } -bool CollisionTrigger::IsActive() -{ - return AI_VALUE2(bool, "collision", "self target"); -} +bool CollisionTrigger::IsActive() { return AI_VALUE2(bool, "collision", "self target"); } bool GiveItemTrigger::IsActive() { @@ -570,10 +516,7 @@ bool GiveWaterTrigger::IsActive() return AI_VALUE(Unit*, "party member without water") && AI_VALUE2(uint32, "item count", item); } -Value* SnareTargetTrigger::GetTargetValue() -{ - return context->GetValue("snare target", spell); -} +Value* SnareTargetTrigger::GetTargetValue() { return context->GetValue("snare target", spell); } bool StayTimeTrigger::IsActive() { @@ -582,32 +525,17 @@ bool StayTimeTrigger::IsActive() return delay && stayTime && now > stayTime + 2 * delay / 1000; } -bool IsMountedTrigger::IsActive() -{ - return AI_VALUE2(bool, "mounted", "self target"); -} +bool IsMountedTrigger::IsActive() { return AI_VALUE2(bool, "mounted", "self target"); } bool CorpseNearTrigger::IsActive() { return bot->GetCorpse() && bot->GetCorpse()->IsWithinDistInMap(bot, CORPSE_RECLAIM_RADIUS, true); } -bool IsFallingTrigger::IsActive() -{ - return bot->HasUnitMovementFlag(MOVEMENTFLAG_FALLING); -} +bool IsFallingTrigger::IsActive() { return bot->HasUnitMovementFlag(MOVEMENTFLAG_FALLING); } -bool IsFallingFarTrigger::IsActive() -{ - return bot->HasUnitMovementFlag(MOVEMENTFLAG_FALLING_FAR); -} +bool IsFallingFarTrigger::IsActive() { return bot->HasUnitMovementFlag(MOVEMENTFLAG_FALLING_FAR); } -bool HasAreaDebuffTrigger::IsActive() -{ - return AI_VALUE2(bool, "has area debuff", "self target"); -} +bool HasAreaDebuffTrigger::IsActive() { return AI_VALUE2(bool, "has area debuff", "self target"); } -Value* BuffOnMainTankTrigger::GetTargetValue() -{ - return context->GetValue("main tank", spell); -} \ No newline at end of file +Value* BuffOnMainTankTrigger::GetTargetValue() { return context->GetValue("main tank", spell); } \ No newline at end of file diff --git a/src/strategy/triggers/GenericTriggers.h b/src/strategy/triggers/GenericTriggers.h index 4f5cee27..2410f674 100644 --- a/src/strategy/triggers/GenericTriggers.h +++ b/src/strategy/triggers/GenericTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICTRIGGERS_H @@ -7,450 +8,492 @@ #include -#include "RangeTriggers.h" #include "HealthTriggers.h" +#include "RangeTriggers.h" class PlayerbotAI; class Unit; class StatAvailable : public Trigger { - public: - StatAvailable(PlayerbotAI* botAI, int32 amount, std::string const name = "stat available") : Trigger(botAI, name), amount(amount) { } +public: + StatAvailable(PlayerbotAI* botAI, int32 amount, std::string const name = "stat available") + : Trigger(botAI, name), amount(amount) + { + } - protected: - int32 amount; +protected: + int32 amount; }; class HighManaTrigger : public Trigger { - public: - HighManaTrigger(PlayerbotAI* botAI) : Trigger(botAI, "high mana") { } +public: + HighManaTrigger(PlayerbotAI* botAI) : Trigger(botAI, "high mana") {} - bool IsActive() override; + bool IsActive() override; }; class EnoughManaTrigger : public Trigger { - public: - EnoughManaTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enough mana") { } +public: + EnoughManaTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enough mana") {} - bool IsActive() override; + bool IsActive() override; }; class AlmostFullManaTrigger : public Trigger { - public: - AlmostFullManaTrigger(PlayerbotAI* botAI) : Trigger(botAI, "almost full mana") { } +public: + AlmostFullManaTrigger(PlayerbotAI* botAI) : Trigger(botAI, "almost full mana") {} - bool IsActive() override; + bool IsActive() override; }; class RageAvailable : public StatAvailable { - public: - RageAvailable(PlayerbotAI* botAI, int32 amount) : StatAvailable(botAI, amount, "rage available") { } +public: + RageAvailable(PlayerbotAI* botAI, int32 amount) : StatAvailable(botAI, amount, "rage available") {} - bool IsActive() override; + bool IsActive() override; }; class LightRageAvailableTrigger : public RageAvailable { - public: - LightRageAvailableTrigger(PlayerbotAI* botAI) : RageAvailable(botAI, 20) { } +public: + LightRageAvailableTrigger(PlayerbotAI* botAI) : RageAvailable(botAI, 20) {} }; class MediumRageAvailableTrigger : public RageAvailable { - public: - MediumRageAvailableTrigger(PlayerbotAI* botAI) : RageAvailable(botAI, 40) { } +public: + MediumRageAvailableTrigger(PlayerbotAI* botAI) : RageAvailable(botAI, 40) {} }; class HighRageAvailableTrigger : public RageAvailable { - public: - HighRageAvailableTrigger(PlayerbotAI* botAI) : RageAvailable(botAI, 60) { } +public: + HighRageAvailableTrigger(PlayerbotAI* botAI) : RageAvailable(botAI, 60) {} }; class EnergyAvailable : public StatAvailable { - public: - EnergyAvailable(PlayerbotAI* botAI, int32 amount) : StatAvailable(botAI, amount, "energy available") { } +public: + EnergyAvailable(PlayerbotAI* botAI, int32 amount) : StatAvailable(botAI, amount, "energy available") {} - bool IsActive() override; + bool IsActive() override; }; class LightEnergyAvailableTrigger : public EnergyAvailable { - public: - LightEnergyAvailableTrigger(PlayerbotAI* botAI) : EnergyAvailable(botAI, 20) { } +public: + LightEnergyAvailableTrigger(PlayerbotAI* botAI) : EnergyAvailable(botAI, 20) {} }; class MediumEnergyAvailableTrigger : public EnergyAvailable { - public: - MediumEnergyAvailableTrigger(PlayerbotAI* botAI) : EnergyAvailable(botAI, 40) { } +public: + MediumEnergyAvailableTrigger(PlayerbotAI* botAI) : EnergyAvailable(botAI, 40) {} }; class HighEnergyAvailableTrigger : public EnergyAvailable { - public: - HighEnergyAvailableTrigger(PlayerbotAI* botAI) : EnergyAvailable(botAI, 60) { } +public: + HighEnergyAvailableTrigger(PlayerbotAI* botAI) : EnergyAvailable(botAI, 60) {} }; class ComboPointsAvailableTrigger : public StatAvailable { - public: - ComboPointsAvailableTrigger(PlayerbotAI* botAI, int32 amount = 5) : StatAvailable(botAI, amount, "combo points available") { } +public: + ComboPointsAvailableTrigger(PlayerbotAI* botAI, int32 amount = 5) + : StatAvailable(botAI, amount, "combo points available") + { + } - bool IsActive() override; + bool IsActive() override; }; class LoseAggroTrigger : public Trigger { - public: - LoseAggroTrigger(PlayerbotAI* botAI) : Trigger(botAI, "lose aggro") { } +public: + LoseAggroTrigger(PlayerbotAI* botAI) : Trigger(botAI, "lose aggro") {} - bool IsActive() override; + bool IsActive() override; }; class HasAggroTrigger : public Trigger { - public: - HasAggroTrigger(PlayerbotAI* botAI) : Trigger(botAI, "have aggro") { } +public: + HasAggroTrigger(PlayerbotAI* botAI) : Trigger(botAI, "have aggro") {} - bool IsActive() override; + bool IsActive() override; }; class SpellTrigger : public Trigger { - public: - SpellTrigger(PlayerbotAI* botAI, std::string const spell, int32 checkInterval = 1) : Trigger(botAI, spell, checkInterval), spell(spell) { } +public: + SpellTrigger(PlayerbotAI* botAI, std::string const spell, int32 checkInterval = 1) + : Trigger(botAI, spell, checkInterval), spell(spell) + { + } - std::string const GetTargetName() override { return "current target"; } - std::string const getName() override { return spell; } - bool IsActive() override; + std::string const GetTargetName() override { return "current target"; } + std::string const getName() override { return spell; } + bool IsActive() override; - protected: - std::string spell; +protected: + std::string spell; }; class SpellCanBeCastTrigger : public SpellTrigger { - public: - SpellCanBeCastTrigger(PlayerbotAI* botAI, std::string const spell) : SpellTrigger(botAI, spell) { } +public: + SpellCanBeCastTrigger(PlayerbotAI* botAI, std::string const spell) : SpellTrigger(botAI, spell) {} - bool IsActive() override; + bool IsActive() override; }; class SpellNoCooldownTrigger : public SpellTrigger { - public: - SpellNoCooldownTrigger(PlayerbotAI* botAI, std::string const spell) : SpellTrigger(botAI, spell) {} +public: + SpellNoCooldownTrigger(PlayerbotAI* botAI, std::string const spell) : SpellTrigger(botAI, spell) {} - bool IsActive() override; + bool IsActive() override; }; class SpellCooldownTrigger : public SpellTrigger { - public: - SpellCooldownTrigger(PlayerbotAI* botAI, std::string const spell) : SpellTrigger(botAI, spell) { } +public: + SpellCooldownTrigger(PlayerbotAI* botAI, std::string const spell) : SpellTrigger(botAI, spell) {} - std::string const GetTargetName() override { return "self target"; } - bool IsActive() override; + std::string const GetTargetName() override { return "self target"; } + bool IsActive() override; }; // TODO: check other targets class InterruptSpellTrigger : public SpellTrigger { - public: - InterruptSpellTrigger(PlayerbotAI* botAI, std::string const spell) : SpellTrigger(botAI, spell) { } +public: + InterruptSpellTrigger(PlayerbotAI* botAI, std::string const spell) : SpellTrigger(botAI, spell) {} - bool IsActive() override; + bool IsActive() override; }; class DeflectSpellTrigger : public SpellTrigger { - public: - DeflectSpellTrigger(PlayerbotAI* botAI, std::string const spell) : SpellTrigger(botAI, spell) { } +public: + DeflectSpellTrigger(PlayerbotAI* botAI, std::string const spell) : SpellTrigger(botAI, spell) {} - bool IsActive() override; + bool IsActive() override; }; class AttackerCountTrigger : public Trigger { - public: - AttackerCountTrigger(PlayerbotAI* botAI, int32 amount, float distance = sPlayerbotAIConfig->sightDistance) : Trigger(botAI), amount(amount), distance(distance) { } +public: + AttackerCountTrigger(PlayerbotAI* botAI, int32 amount, float distance = sPlayerbotAIConfig->sightDistance) + : Trigger(botAI), amount(amount), distance(distance) + { + } - bool IsActive() override; - std::string const getName() override { return "attacker count"; } + bool IsActive() override; + std::string const getName() override { return "attacker count"; } - protected: - int32 amount; - float distance; +protected: + int32 amount; + float distance; }; class HasAttackersTrigger : public AttackerCountTrigger { - public: - HasAttackersTrigger(PlayerbotAI* botAI) : AttackerCountTrigger(botAI, 1) { } +public: + HasAttackersTrigger(PlayerbotAI* botAI) : AttackerCountTrigger(botAI, 1) {} }; class MyAttackerCountTrigger : public AttackerCountTrigger { - public: - MyAttackerCountTrigger(PlayerbotAI* botAI, int32 amount) : AttackerCountTrigger(botAI, amount) { } +public: + MyAttackerCountTrigger(PlayerbotAI* botAI, int32 amount) : AttackerCountTrigger(botAI, amount) {} - bool IsActive() override; - std::string const getName() override { return "my attacker count"; } + bool IsActive() override; + std::string const getName() override { return "my attacker count"; } }; class MediumThreatTrigger : public MyAttackerCountTrigger { - public: - MediumThreatTrigger(PlayerbotAI* botAI) : MyAttackerCountTrigger(botAI, 2) { } +public: + MediumThreatTrigger(PlayerbotAI* botAI) : MyAttackerCountTrigger(botAI, 2) {} }; class AoeTrigger : public AttackerCountTrigger { - public: - AoeTrigger(PlayerbotAI* botAI, int32 amount = 3, float range = 15.0f) : AttackerCountTrigger(botAI, amount), range(range) { } +public: + AoeTrigger(PlayerbotAI* botAI, int32 amount = 3, float range = 15.0f) + : AttackerCountTrigger(botAI, amount), range(range) + { + } - bool IsActive() override; - std::string const getName() override { return "aoe"; } + bool IsActive() override; + std::string const getName() override { return "aoe"; } - private: - float range; +private: + float range; }; class NoFoodTrigger : public Trigger { - public: - NoFoodTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no food trigger") { } +public: + NoFoodTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no food trigger") {} - bool IsActive() override; + bool IsActive() override; }; class NoDrinkTrigger : public Trigger { - public: - NoDrinkTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no drink trigger") { } +public: + NoDrinkTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no drink trigger") {} - bool IsActive() override; + bool IsActive() override; }; class LightAoeTrigger : public AoeTrigger { - public: - LightAoeTrigger(PlayerbotAI* botAI) : AoeTrigger(botAI, 2, 8.0f) { } +public: + LightAoeTrigger(PlayerbotAI* botAI) : AoeTrigger(botAI, 2, 8.0f) {} }; class MediumAoeTrigger : public AoeTrigger { - public: - MediumAoeTrigger(PlayerbotAI* botAI) : AoeTrigger(botAI, 3, 8.0f) { } +public: + MediumAoeTrigger(PlayerbotAI* botAI) : AoeTrigger(botAI, 3, 8.0f) {} }; class HighAoeTrigger : public AoeTrigger { - public: - HighAoeTrigger(PlayerbotAI* botAI) : AoeTrigger(botAI, 4, 8.0f) { } +public: + HighAoeTrigger(PlayerbotAI* botAI) : AoeTrigger(botAI, 4, 8.0f) {} }; class BuffTrigger : public SpellTrigger { - public: - BuffTrigger(PlayerbotAI* botAI, std::string const spell, int32 checkInterval = 1, bool checkIsOwner = false) : SpellTrigger(botAI, spell, checkInterval) { this->checkIsOwner = checkIsOwner; } +public: + BuffTrigger(PlayerbotAI* botAI, std::string const spell, int32 checkInterval = 1, bool checkIsOwner = false) + : SpellTrigger(botAI, spell, checkInterval) + { + this->checkIsOwner = checkIsOwner; + } - public: - std::string const GetTargetName() override { return "self target"; } - bool IsActive() override; +public: + std::string const GetTargetName() override { return "self target"; } + bool IsActive() override; - protected: - bool checkIsOwner; +protected: + bool checkIsOwner; }; class BuffOnPartyTrigger : public BuffTrigger { - public: - BuffOnPartyTrigger(PlayerbotAI* botAI, std::string const spell, int32 checkInterval = 1) : BuffTrigger(botAI, spell, checkInterval) { } +public: + BuffOnPartyTrigger(PlayerbotAI* botAI, std::string const spell, int32 checkInterval = 1) + : BuffTrigger(botAI, spell, checkInterval) + { + } - Value* GetTargetValue() override; - std::string const getName() override { return spell + " on party"; } + Value* GetTargetValue() override; + std::string const getName() override { return spell + " on party"; } }; class ProtectPartyMemberTrigger : public Trigger { - public: - ProtectPartyMemberTrigger(PlayerbotAI* botAI) : Trigger(botAI, "protect party member") { } +public: + ProtectPartyMemberTrigger(PlayerbotAI* botAI) : Trigger(botAI, "protect party member") {} - std::string const GetTargetName() override { return "party member to protect"; } - bool IsActive() override; + std::string const GetTargetName() override { return "party member to protect"; } + bool IsActive() override; }; class NoAttackersTrigger : public Trigger { - public: - NoAttackersTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no attackers") { } +public: + NoAttackersTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no attackers") {} - bool IsActive() override; + bool IsActive() override; }; class NoTargetTrigger : public Trigger { - public: - NoTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no target") { } +public: + NoTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no target") {} - bool IsActive() override; + bool IsActive() override; }; class InvalidTargetTrigger : public Trigger { - public: - InvalidTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "invalid target") { } +public: + InvalidTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "invalid target") {} - bool IsActive() override; + bool IsActive() override; }; class TargetInSightTrigger : public Trigger { - public: - TargetInSightTrigger(PlayerbotAI* botAI) : Trigger(botAI, "target in sight") { } +public: + TargetInSightTrigger(PlayerbotAI* botAI) : Trigger(botAI, "target in sight") {} - bool IsActive() override; + bool IsActive() override; }; class DebuffTrigger : public BuffTrigger { - public: - DebuffTrigger(PlayerbotAI* botAI, std::string const spell, int32 checkInterval = 1, bool checkIsOwner = false, float needLifeTime = 8.0f) : BuffTrigger(botAI, spell, checkInterval, checkIsOwner), needLifeTime(needLifeTime) { } +public: + DebuffTrigger(PlayerbotAI* botAI, std::string const spell, int32 checkInterval = 1, bool checkIsOwner = false, + float needLifeTime = 8.0f) + : BuffTrigger(botAI, spell, checkInterval, checkIsOwner), needLifeTime(needLifeTime) + { + } - std::string const GetTargetName() override { return "current target"; } - bool IsActive() override; - protected: - float needLifeTime; + std::string const GetTargetName() override { return "current target"; } + bool IsActive() override; + +protected: + float needLifeTime; }; class DebuffOnBossTrigger : public DebuffTrigger { - public: - DebuffOnBossTrigger(PlayerbotAI* botAI, std::string const spell, int32 checkInterval = 1, bool checkIsOwner = false) : DebuffTrigger(botAI, spell, checkInterval, checkIsOwner) {} - bool IsActive() override; +public: + DebuffOnBossTrigger(PlayerbotAI* botAI, std::string const spell, int32 checkInterval = 1, bool checkIsOwner = false) + : DebuffTrigger(botAI, spell, checkInterval, checkIsOwner) + { + } + bool IsActive() override; }; class DebuffOnAttackerTrigger : public DebuffTrigger { - public: - DebuffOnAttackerTrigger(PlayerbotAI* botAI, std::string const spell, bool checkIsOwner = true, float needLifeTime = 8.0f) : DebuffTrigger(botAI, spell, 1, checkIsOwner, needLifeTime) { } +public: + DebuffOnAttackerTrigger(PlayerbotAI* botAI, std::string const spell, bool checkIsOwner = true, + float needLifeTime = 8.0f) + : DebuffTrigger(botAI, spell, 1, checkIsOwner, needLifeTime) + { + } - Value* GetTargetValue() override; - std::string const getName() override { return spell + " on attacker"; } + Value* GetTargetValue() override; + std::string const getName() override { return spell + " on attacker"; } }; class DebuffOnMeleeAttackerTrigger : public DebuffTrigger { - public: - DebuffOnMeleeAttackerTrigger(PlayerbotAI* botAI, std::string const spell, bool checkIsOwner = true, float needLifeTime = 8.0f) : DebuffTrigger(botAI, spell, 1, checkIsOwner, needLifeTime) { } +public: + DebuffOnMeleeAttackerTrigger(PlayerbotAI* botAI, std::string const spell, bool checkIsOwner = true, + float needLifeTime = 8.0f) + : DebuffTrigger(botAI, spell, 1, checkIsOwner, needLifeTime) + { + } - Value* GetTargetValue() override; - std::string const getName() override { return spell + " on attacker"; } + Value* GetTargetValue() override; + std::string const getName() override { return spell + " on attacker"; } }; class BoostTrigger : public BuffTrigger { - public: - BoostTrigger(PlayerbotAI* botAI, std::string const spell, float balance = 50.f) : BuffTrigger(botAI, spell, 1), balance(balance) { } +public: + BoostTrigger(PlayerbotAI* botAI, std::string const spell, float balance = 50.f) + : BuffTrigger(botAI, spell, 1), balance(balance) + { + } - bool IsActive() override; + bool IsActive() override; - protected: - float balance; +protected: + float balance; }; class RandomTrigger : public Trigger { - public: - RandomTrigger(PlayerbotAI* botAI, std::string const name, int32 probability = 7); +public: + RandomTrigger(PlayerbotAI* botAI, std::string const name, int32 probability = 7); - bool IsActive() override; + bool IsActive() override; - protected: - int32 probability; - uint32 lastCheck; +protected: + int32 probability; + uint32 lastCheck; }; class AndTrigger : public Trigger { - public: - AndTrigger(PlayerbotAI* botAI, Trigger* ls, Trigger* rs) : Trigger(botAI), ls(ls), rs(rs) { } - virtual ~AndTrigger() - { - delete ls; - delete rs; - } +public: + AndTrigger(PlayerbotAI* botAI, Trigger* ls, Trigger* rs) : Trigger(botAI), ls(ls), rs(rs) {} + virtual ~AndTrigger() + { + delete ls; + delete rs; + } - bool IsActive() override; - std::string const getName() override; + bool IsActive() override; + std::string const getName() override; - protected: - Trigger* ls; - Trigger* rs; +protected: + Trigger* ls; + Trigger* rs; }; class TwoTriggers : public Trigger { - public: - explicit TwoTriggers(PlayerbotAI* botAI, std::string name1 = "", std::string name2 = "") : Trigger(botAI) - { - this->name1 = std::move(name1); - this->name2 = std::move(name2); - } - bool IsActive() override; - std::string const getName() override; - protected: - std::string name1; - std::string name2; +public: + explicit TwoTriggers(PlayerbotAI* botAI, std::string name1 = "", std::string name2 = "") : Trigger(botAI) + { + this->name1 = std::move(name1); + this->name2 = std::move(name2); + } + bool IsActive() override; + std::string const getName() override; + +protected: + std::string name1; + std::string name2; }; class SnareTargetTrigger : public DebuffTrigger { - public: - SnareTargetTrigger(PlayerbotAI* botAI, std::string const spell) : DebuffTrigger(botAI, spell) { } +public: + SnareTargetTrigger(PlayerbotAI* botAI, std::string const spell) : DebuffTrigger(botAI, spell) {} - Value* GetTargetValue() override; - std::string const getName() override { return spell + " on snare target"; } + Value* GetTargetValue() override; + std::string const getName() override { return spell + " on snare target"; } }; class LowManaTrigger : public Trigger { - public: - LowManaTrigger(PlayerbotAI* botAI) : Trigger(botAI, "low mana") { } +public: + LowManaTrigger(PlayerbotAI* botAI) : Trigger(botAI, "low mana") {} - bool IsActive() override; + bool IsActive() override; }; class MediumManaTrigger : public Trigger { - public: - MediumManaTrigger(PlayerbotAI* botAI) : Trigger(botAI, "medium mana") { } +public: + MediumManaTrigger(PlayerbotAI* botAI) : Trigger(botAI, "medium mana") {} - bool IsActive() override; + bool IsActive() override; }; BEGIN_TRIGGER(PanicTrigger, Trigger) - std::string const getName() override { return "panic"; } +std::string const getName() override { return "panic"; } END_TRIGGER() BEGIN_TRIGGER(OutNumberedTrigger, Trigger) - std::string const getName() override { return "outnumbered"; } +std::string const getName() override { return "outnumbered"; } END_TRIGGER() class NoPetTrigger : public Trigger { - public: - NoPetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no pet", 5 * 1000) { } +public: + NoPetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no pet", 5 * 1000) {} - virtual bool IsActive() override; + virtual bool IsActive() override; }; class HasPetTrigger : public Trigger @@ -471,310 +514,333 @@ public: class ItemCountTrigger : public Trigger { - public: - ItemCountTrigger(PlayerbotAI* botAI, std::string const item, int32 count, int32 interval = 30 * 1000) : Trigger(botAI, item, interval), item(item), count(count) { } +public: + ItemCountTrigger(PlayerbotAI* botAI, std::string const item, int32 count, int32 interval = 30 * 1000) + : Trigger(botAI, item, interval), item(item), count(count) + { + } - bool IsActive() override; - std::string const getName() override { return "item count"; } + bool IsActive() override; + std::string const getName() override { return "item count"; } - protected: - std::string const item; - int32 count; +protected: + std::string const item; + int32 count; }; class AmmoCountTrigger : public ItemCountTrigger { - public: - AmmoCountTrigger(PlayerbotAI* botAI, std::string const item, uint32 count = 1, int32 interval = 30 * 1000) : ItemCountTrigger(botAI, item, count, interval) { } +public: + AmmoCountTrigger(PlayerbotAI* botAI, std::string const item, uint32 count = 1, int32 interval = 30 * 1000) + : ItemCountTrigger(botAI, item, count, interval) + { + } }; class HasAuraTrigger : public Trigger { - public: - HasAuraTrigger(PlayerbotAI* botAI, std::string const spell, int32 checkInterval = 1) : Trigger(botAI, spell, checkInterval) { } +public: + HasAuraTrigger(PlayerbotAI* botAI, std::string const spell, int32 checkInterval = 1) + : Trigger(botAI, spell, checkInterval) + { + } - std::string const GetTargetName() override { return "self target"; } - bool IsActive() override; + std::string const GetTargetName() override { return "self target"; } + bool IsActive() override; }; -class HasAuraStackTrigger : public Trigger { - public: - HasAuraStackTrigger(PlayerbotAI* ai, std::string spell, int stack, int checkInterval = 1) : Trigger(ai, spell, checkInterval), - stack(stack) {} +class HasAuraStackTrigger : public Trigger +{ +public: + HasAuraStackTrigger(PlayerbotAI* ai, std::string spell, int stack, int checkInterval = 1) + : Trigger(ai, spell, checkInterval), stack(stack) + { + } - std::string const GetTargetName() { return "self target"; } - virtual bool IsActive(); - private: - int stack; + std::string const GetTargetName() { return "self target"; } + virtual bool IsActive(); + +private: + int stack; }; class HasNoAuraTrigger : public Trigger { - public: - HasNoAuraTrigger(PlayerbotAI* botAI, std::string const spell) : Trigger(botAI, spell) { } +public: + HasNoAuraTrigger(PlayerbotAI* botAI, std::string const spell) : Trigger(botAI, spell) {} - std::string const GetTargetName() override { return "self target"; } - bool IsActive() override; + std::string const GetTargetName() override { return "self target"; } + bool IsActive() override; }; class TimerTrigger : public Trigger { - public: - TimerTrigger(PlayerbotAI* botAI) : Trigger(botAI, "timer"), lastCheck(0) { } +public: + TimerTrigger(PlayerbotAI* botAI) : Trigger(botAI, "timer"), lastCheck(0) {} - bool IsActive() override; + bool IsActive() override; - private: - time_t lastCheck; +private: + time_t lastCheck; }; class TankAssistTrigger : public NoAttackersTrigger { - public: - TankAssistTrigger(PlayerbotAI* botAI) : NoAttackersTrigger(botAI) { } +public: + TankAssistTrigger(PlayerbotAI* botAI) : NoAttackersTrigger(botAI) {} - bool IsActive() override; + bool IsActive() override; }; class IsBehindTargetTrigger : public Trigger { - public: - IsBehindTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "behind target") { } +public: + IsBehindTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "behind target") {} - bool IsActive() override; + bool IsActive() override; }; class IsNotBehindTargetTrigger : public Trigger { - public: - IsNotBehindTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "is not behind target") { } +public: + IsNotBehindTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "is not behind target") {} - bool IsActive() override; + bool IsActive() override; }; class IsNotFacingTargetTrigger : public Trigger { - public: - IsNotFacingTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "not facing target") { } +public: + IsNotFacingTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "not facing target") {} - bool IsActive() override; + bool IsActive() override; }; class HasCcTargetTrigger : public Trigger { - public: - HasCcTargetTrigger(PlayerbotAI* botAI, std::string const name) : Trigger(botAI, name) { } +public: + HasCcTargetTrigger(PlayerbotAI* botAI, std::string const name) : Trigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class NoMovementTrigger : public Trigger { - public: - NoMovementTrigger(PlayerbotAI* botAI, std::string const name) : Trigger(botAI, name) { } +public: + NoMovementTrigger(PlayerbotAI* botAI, std::string const name) : Trigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class NoPossibleTargetsTrigger : public Trigger { - public: - NoPossibleTargetsTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no possible targets") { } +public: + NoPossibleTargetsTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no possible targets") {} - bool IsActive() override; + bool IsActive() override; }; class NotDpsTargetActiveTrigger : public Trigger { - public: - NotDpsTargetActiveTrigger(PlayerbotAI* botAI) : Trigger(botAI, "not dps target active") { } +public: + NotDpsTargetActiveTrigger(PlayerbotAI* botAI) : Trigger(botAI, "not dps target active") {} - bool IsActive() override; + bool IsActive() override; }; class NotDpsAoeTargetActiveTrigger : public Trigger { - public: - NotDpsAoeTargetActiveTrigger(PlayerbotAI* botAI) : Trigger(botAI, "not dps aoe target active") { } +public: + NotDpsAoeTargetActiveTrigger(PlayerbotAI* botAI) : Trigger(botAI, "not dps aoe target active") {} - bool IsActive() override; + bool IsActive() override; }; class PossibleAddsTrigger : public Trigger { - public: - PossibleAddsTrigger(PlayerbotAI* botAI) : Trigger(botAI, "possible adds") { } +public: + PossibleAddsTrigger(PlayerbotAI* botAI) : Trigger(botAI, "possible adds") {} - bool IsActive() override; + bool IsActive() override; }; class IsSwimmingTrigger : public Trigger { - public: - IsSwimmingTrigger(PlayerbotAI* botAI) : Trigger(botAI, "swimming") { } +public: + IsSwimmingTrigger(PlayerbotAI* botAI) : Trigger(botAI, "swimming") {} - bool IsActive() override; + bool IsActive() override; }; class HasNearestAddsTrigger : public Trigger { - public: - HasNearestAddsTrigger(PlayerbotAI* botAI) : Trigger(botAI, "has nearest adds") { } +public: + HasNearestAddsTrigger(PlayerbotAI* botAI) : Trigger(botAI, "has nearest adds") {} - bool IsActive() override; + bool IsActive() override; }; class HasItemForSpellTrigger : public Trigger { - public: - HasItemForSpellTrigger(PlayerbotAI* botAI, std::string const spell) : Trigger(botAI, spell) { } +public: + HasItemForSpellTrigger(PlayerbotAI* botAI, std::string const spell) : Trigger(botAI, spell) {} - bool IsActive() override; + bool IsActive() override; }; class TargetChangedTrigger : public Trigger { - public: - TargetChangedTrigger(PlayerbotAI* botAI) : Trigger(botAI, "target changed") { } +public: + TargetChangedTrigger(PlayerbotAI* botAI) : Trigger(botAI, "target changed") {} - bool IsActive() override; + bool IsActive() override; }; class InterruptEnemyHealerTrigger : public SpellTrigger { - public: - InterruptEnemyHealerTrigger(PlayerbotAI* botAI, std::string const spell) : SpellTrigger(botAI, spell) { } +public: + InterruptEnemyHealerTrigger(PlayerbotAI* botAI, std::string const spell) : SpellTrigger(botAI, spell) {} - Value* GetTargetValue() override; - std::string const getName() override { return spell + " on enemy healer"; } + Value* GetTargetValue() override; + std::string const getName() override { return spell + " on enemy healer"; } }; class RandomBotUpdateTrigger : public RandomTrigger { - public: - RandomBotUpdateTrigger(PlayerbotAI* botAI) : RandomTrigger(botAI, "random bot update", 30 * 1000) { } +public: + RandomBotUpdateTrigger(PlayerbotAI* botAI) : RandomTrigger(botAI, "random bot update", 30 * 1000) {} - bool IsActive() override; + bool IsActive() override; }; class NoNonBotPlayersAroundTrigger : public Trigger { - public: - NoNonBotPlayersAroundTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no non bot players around", 10 * 1000) { } +public: + NoNonBotPlayersAroundTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no non bot players around", 10 * 1000) {} - bool IsActive() override; + bool IsActive() override; }; class NewPlayerNearbyTrigger : public Trigger { - public: - NewPlayerNearbyTrigger(PlayerbotAI* botAI) : Trigger(botAI, "new player nearby", 10 * 1000) { } +public: + NewPlayerNearbyTrigger(PlayerbotAI* botAI) : Trigger(botAI, "new player nearby", 10 * 1000) {} - bool IsActive() override; + bool IsActive() override; }; class CollisionTrigger : public Trigger { - public: - CollisionTrigger(PlayerbotAI* botAI) : Trigger(botAI, "collision", 5 * 1000) { } +public: + CollisionTrigger(PlayerbotAI* botAI) : Trigger(botAI, "collision", 5 * 1000) {} - bool IsActive() override; + bool IsActive() override; }; class StayTimeTrigger : public Trigger { - public: - StayTimeTrigger(PlayerbotAI* botAI, uint32 delay, std::string const name) : Trigger(botAI, name, 5 * 1000), delay(delay) { } +public: + StayTimeTrigger(PlayerbotAI* botAI, uint32 delay, std::string const name) + : Trigger(botAI, name, 5 * 1000), delay(delay) + { + } - bool IsActive() override; + bool IsActive() override; - private: - uint32 delay; +private: + uint32 delay; }; class SitTrigger : public StayTimeTrigger { - public: - SitTrigger(PlayerbotAI* botAI) : StayTimeTrigger(botAI, sPlayerbotAIConfig->sitDelay, "sit") { } +public: + SitTrigger(PlayerbotAI* botAI) : StayTimeTrigger(botAI, sPlayerbotAIConfig->sitDelay, "sit") {} }; class ReturnTrigger : public StayTimeTrigger { - public: - ReturnTrigger(PlayerbotAI* botAI) : StayTimeTrigger(botAI, sPlayerbotAIConfig->returnDelay, "return") { } +public: + ReturnTrigger(PlayerbotAI* botAI) : StayTimeTrigger(botAI, sPlayerbotAIConfig->returnDelay, "return") {} }; class GiveItemTrigger : public Trigger { - public: - GiveItemTrigger(PlayerbotAI* botAI, std::string const name, std::string const item) : Trigger(botAI, name, 2 * 1000), item(item) { } +public: + GiveItemTrigger(PlayerbotAI* botAI, std::string const name, std::string const item) + : Trigger(botAI, name, 2 * 1000), item(item) + { + } - bool IsActive() override; + bool IsActive() override; - protected: - std::string const item; +protected: + std::string const item; }; class GiveFoodTrigger : public GiveItemTrigger { - public: - GiveFoodTrigger(PlayerbotAI* botAI) : GiveItemTrigger(botAI, "give food", "conjured food") { } +public: + GiveFoodTrigger(PlayerbotAI* botAI) : GiveItemTrigger(botAI, "give food", "conjured food") {} - bool IsActive() override; + bool IsActive() override; }; class GiveWaterTrigger : public GiveItemTrigger { - public: - GiveWaterTrigger(PlayerbotAI* botAI) : GiveItemTrigger(botAI, "give water", "conjured water") { } +public: + GiveWaterTrigger(PlayerbotAI* botAI) : GiveItemTrigger(botAI, "give water", "conjured water") {} - bool IsActive() override; + bool IsActive() override; }; class IsMountedTrigger : public Trigger { - public: - IsMountedTrigger(PlayerbotAI* botAI) : Trigger(botAI, "mounted", 1) { } +public: + IsMountedTrigger(PlayerbotAI* botAI) : Trigger(botAI, "mounted", 1) {} - bool IsActive() override; + bool IsActive() override; }; class CorpseNearTrigger : public Trigger { - public: - CorpseNearTrigger(PlayerbotAI* botAI) : Trigger(botAI, "corpse near", 1 * 1000) { } +public: + CorpseNearTrigger(PlayerbotAI* botAI) : Trigger(botAI, "corpse near", 1 * 1000) {} - bool IsActive() override; + bool IsActive() override; }; class IsFallingTrigger : public Trigger { - public: - IsFallingTrigger(PlayerbotAI* botAI) : Trigger(botAI, "falling", 10 * 1000) { } +public: + IsFallingTrigger(PlayerbotAI* botAI) : Trigger(botAI, "falling", 10 * 1000) {} - bool IsActive() override; + bool IsActive() override; }; class IsFallingFarTrigger : public Trigger { - public: - IsFallingFarTrigger(PlayerbotAI* botAI) : Trigger(botAI, "falling far", 10 * 1000) { } +public: + IsFallingFarTrigger(PlayerbotAI* botAI) : Trigger(botAI, "falling far", 10 * 1000) {} - bool IsActive() override; + bool IsActive() override; }; +class HasAreaDebuffTrigger : public Trigger +{ +public: + HasAreaDebuffTrigger(PlayerbotAI* botAI) : Trigger(botAI, "have area debuff") {} -class HasAreaDebuffTrigger : public Trigger { - public: - HasAreaDebuffTrigger(PlayerbotAI* botAI) : Trigger(botAI, "have area debuff") {} - - bool IsActive() override; + bool IsActive() override; }; class BuffOnMainTankTrigger : public BuffTrigger { public: - BuffOnMainTankTrigger(PlayerbotAI* botAI, std::string spell, bool checkIsOwner = false, int checkInterval = 1) : BuffTrigger(botAI, spell, checkInterval, checkIsOwner) {} + BuffOnMainTankTrigger(PlayerbotAI* botAI, std::string spell, bool checkIsOwner = false, int checkInterval = 1) + : BuffTrigger(botAI, spell, checkInterval, checkIsOwner) + { + } + public: virtual Value* GetTargetValue(); }; diff --git a/src/strategy/triggers/GuildTriggers.cpp b/src/strategy/triggers/GuildTriggers.cpp index 5a39a53a..a31f3a47 100644 --- a/src/strategy/triggers/GuildTriggers.cpp +++ b/src/strategy/triggers/GuildTriggers.cpp @@ -1,14 +1,17 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GuildTriggers.h" + #include "GuildMgr.h" #include "Playerbots.h" bool PetitionTurnInTrigger::IsActive() { - return !bot->GetGuildId() && AI_VALUE2(uint32, "item count", chat->FormatQItem(5863)) && AI_VALUE(uint8, "petition signs") >= sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS); + return !bot->GetGuildId() && AI_VALUE2(uint32, "item count", chat->FormatQItem(5863)) && + AI_VALUE(uint8, "petition signs") >= sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS); } bool BuyTabardTrigger::IsActive() @@ -18,37 +21,37 @@ bool BuyTabardTrigger::IsActive() bool LeaveLargeGuildTrigger::IsActive() { - if (!bot->GetGuildId()) - return false; + if (!bot->GetGuildId()) + return false; - if (botAI->IsRealPlayer()) - return false; + if (botAI->IsRealPlayer()) + return false; - if (botAI->IsAlt()) - return false; + if (botAI->IsAlt()) + return false; if (botAI->IsInRealGuild()) return false; - GuilderType type = botAI->GetGuilderType(); + GuilderType type = botAI->GetGuilderType(); - Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId()); + Guild* guild = sGuildMgr->GetGuildById(bot->GetGuildId()); - Player* leader = ObjectAccessor::FindPlayer(guild->GetLeaderGUID()); + Player* leader = ObjectAccessor::FindPlayer(guild->GetLeaderGUID()); - //Only leave the guild if we know the leader is not a real player. - if (!leader || !GET_PLAYERBOT_AI(leader) || !GET_PLAYERBOT_AI(leader)->IsRealPlayer()) - return false; + // Only leave the guild if we know the leader is not a real player. + if (!leader || !GET_PLAYERBOT_AI(leader) || !GET_PLAYERBOT_AI(leader)->IsRealPlayer()) + return false; PlayerbotAI* leaderBotAI = GET_PLAYERBOT_AI(leader); if (!leaderBotAI || leaderBotAI->IsRealPlayer()) - return false; + return false; - if (type == GuilderType::SOLO && guild->GetLeaderGUID() != bot->GetGUID()) - return true; + if (type == GuilderType::SOLO && guild->GetLeaderGUID() != bot->GetGUID()) + return true; - uint32 members = guild->GetMemberSize(); - uint32 maxMembers = uint8(type); + uint32 members = guild->GetMemberSize(); + uint32 maxMembers = uint8(type); - return members > maxMembers; + return members > maxMembers; } diff --git a/src/strategy/triggers/GuildTriggers.h b/src/strategy/triggers/GuildTriggers.h index 4b8deb43..233a736b 100644 --- a/src/strategy/triggers/GuildTriggers.h +++ b/src/strategy/triggers/GuildTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GUILDTRIGGER_H @@ -11,26 +12,26 @@ class PlayerbotAI; class PetitionTurnInTrigger : public Trigger { - public: - PetitionTurnInTrigger(PlayerbotAI* botAI) : Trigger(botAI) { } +public: + PetitionTurnInTrigger(PlayerbotAI* botAI) : Trigger(botAI) {} - bool IsActive() override; + bool IsActive() override; }; class BuyTabardTrigger : public Trigger { - public: - BuyTabardTrigger(PlayerbotAI* botAI) : Trigger(botAI) { } +public: + BuyTabardTrigger(PlayerbotAI* botAI) : Trigger(botAI) {} - bool IsActive() override; + bool IsActive() override; }; class LeaveLargeGuildTrigger : public Trigger { - public: - LeaveLargeGuildTrigger(PlayerbotAI* botAI) : Trigger(botAI) { } +public: + LeaveLargeGuildTrigger(PlayerbotAI* botAI) : Trigger(botAI) {} - bool IsActive(); + bool IsActive(); }; #endif diff --git a/src/strategy/triggers/HealthTriggers.cpp b/src/strategy/triggers/HealthTriggers.cpp index 026ec30a..d4c971ac 100644 --- a/src/strategy/triggers/HealthTriggers.cpp +++ b/src/strategy/triggers/HealthTriggers.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HealthTriggers.h" + #include "Playerbots.h" bool HealthInRangeTrigger::IsActive() @@ -10,33 +12,19 @@ bool HealthInRangeTrigger::IsActive() return ValueInRangeTrigger::IsActive() && !AI_VALUE2(bool, "dead", GetTargetName()); } -float HealthInRangeTrigger::GetValue() -{ - return AI_VALUE2(uint8, "health", GetTargetName()); -} +float HealthInRangeTrigger::GetValue() { return AI_VALUE2(uint8, "health", GetTargetName()); } -bool PartyMemberDeadTrigger::IsActive() -{ - return GetTarget(); -} +bool PartyMemberDeadTrigger::IsActive() { return GetTarget(); } -bool CombatPartyMemberDeadTrigger::IsActive() -{ - return GetTarget(); -} +bool CombatPartyMemberDeadTrigger::IsActive() { return GetTarget(); } -bool DeadTrigger::IsActive() -{ - return AI_VALUE2(bool, "dead", GetTargetName()); -} +bool DeadTrigger::IsActive() { return AI_VALUE2(bool, "dead", GetTargetName()); } -bool AoeHealTrigger::IsActive() -{ - return AI_VALUE2(uint8, "aoe heal", type) >= count; -} +bool AoeHealTrigger::IsActive() { return AI_VALUE2(uint8, "aoe heal", type) >= count; } bool AoeInGroupTrigger::IsActive() { - Group *group = bot->GetGroup(); - return group && group->GetMembersCount() >= 5 && AI_VALUE2(uint8, "aoe heal", type) >= (group->GetMembersCount() * ratio); + Group* group = bot->GetGroup(); + return group && group->GetMembersCount() >= 5 && + AI_VALUE2(uint8, "aoe heal", type) >= (group->GetMembersCount() * ratio); } \ No newline at end of file diff --git a/src/strategy/triggers/HealthTriggers.h b/src/strategy/triggers/HealthTriggers.h index 3c6549e8..88739fef 100644 --- a/src/strategy/triggers/HealthTriggers.h +++ b/src/strategy/triggers/HealthTriggers.h @@ -1,154 +1,200 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HEALTHTRIGGERS_H #define _PLAYERBOT_HEALTHTRIGGERS_H -#include "Trigger.h" -#include "PlayerbotAIConfig.h" #include +#include "PlayerbotAIConfig.h" +#include "Trigger.h" + class PlayerbotAI; class ValueInRangeTrigger : public Trigger { - public: - ValueInRangeTrigger(PlayerbotAI* botAI, std::string const name, float maxValue, float minValue) : Trigger(botAI, name), maxValue(maxValue), minValue(minValue) { } +public: + ValueInRangeTrigger(PlayerbotAI* botAI, std::string const name, float maxValue, float minValue) + : Trigger(botAI, name), maxValue(maxValue), minValue(minValue) + { + } - virtual float GetValue() = 0; - bool IsActive() override - { - float value = GetValue(); - return value < maxValue && value >= minValue; - } + virtual float GetValue() = 0; + bool IsActive() override + { + float value = GetValue(); + return value < maxValue && value >= minValue; + } - protected: - float maxValue, minValue; +protected: + float maxValue, minValue; }; class HealthInRangeTrigger : public ValueInRangeTrigger { - public: - HealthInRangeTrigger(PlayerbotAI* botAI, std::string const name, float maxValue, float minValue = 0) : ValueInRangeTrigger(botAI, name, maxValue, minValue) { } +public: + HealthInRangeTrigger(PlayerbotAI* botAI, std::string const name, float maxValue, float minValue = 0) + : ValueInRangeTrigger(botAI, name, maxValue, minValue) + { + } - bool IsActive() override; - float GetValue() override; + bool IsActive() override; + float GetValue() override; }; class LowHealthTrigger : public HealthInRangeTrigger { - public: - LowHealthTrigger(PlayerbotAI* botAI, std::string const name = "low health", float value = sPlayerbotAIConfig->lowHealth, float minValue = sPlayerbotAIConfig->criticalHealth) : - HealthInRangeTrigger(botAI, name, value, minValue) { } +public: + LowHealthTrigger(PlayerbotAI* botAI, std::string const name = "low health", + float value = sPlayerbotAIConfig->lowHealth, float minValue = sPlayerbotAIConfig->criticalHealth) + : HealthInRangeTrigger(botAI, name, value, minValue) + { + } - std::string const GetTargetName() override { return "self target"; } + std::string const GetTargetName() override { return "self target"; } }; class CriticalHealthTrigger : public LowHealthTrigger { - public: - CriticalHealthTrigger(PlayerbotAI* botAI) : LowHealthTrigger(botAI, "critical health", sPlayerbotAIConfig->criticalHealth, 0) { } +public: + CriticalHealthTrigger(PlayerbotAI* botAI) + : LowHealthTrigger(botAI, "critical health", sPlayerbotAIConfig->criticalHealth, 0) + { + } }; class MediumHealthTrigger : public LowHealthTrigger { - public: - MediumHealthTrigger(PlayerbotAI* botAI) : LowHealthTrigger(botAI, "medium health", sPlayerbotAIConfig->mediumHealth, sPlayerbotAIConfig->lowHealth) { } +public: + MediumHealthTrigger(PlayerbotAI* botAI) + : LowHealthTrigger(botAI, "medium health", sPlayerbotAIConfig->mediumHealth, sPlayerbotAIConfig->lowHealth) + { + } }; class AlmostFullHealthTrigger : public LowHealthTrigger { - public: - AlmostFullHealthTrigger(PlayerbotAI* botAI) : LowHealthTrigger(botAI, "almost full health", sPlayerbotAIConfig->almostFullHealth, sPlayerbotAIConfig->mediumHealth) { } +public: + AlmostFullHealthTrigger(PlayerbotAI* botAI) + : LowHealthTrigger(botAI, "almost full health", sPlayerbotAIConfig->almostFullHealth, + sPlayerbotAIConfig->mediumHealth) + { + } }; class PartyMemberLowHealthTrigger : public HealthInRangeTrigger { - public: - PartyMemberLowHealthTrigger(PlayerbotAI* botAI, std::string const name = "party member low health", float value = sPlayerbotAIConfig->lowHealth, float minValue = sPlayerbotAIConfig->criticalHealth) : - HealthInRangeTrigger(botAI, name, value, minValue) { } +public: + PartyMemberLowHealthTrigger(PlayerbotAI* botAI, std::string const name = "party member low health", + float value = sPlayerbotAIConfig->lowHealth, + float minValue = sPlayerbotAIConfig->criticalHealth) + : HealthInRangeTrigger(botAI, name, value, minValue) + { + } - std::string const GetTargetName() override { return "party member to heal"; } + std::string const GetTargetName() override { return "party member to heal"; } }; class PartyMemberCriticalHealthTrigger : public PartyMemberLowHealthTrigger { - public: - PartyMemberCriticalHealthTrigger(PlayerbotAI* botAI) : PartyMemberLowHealthTrigger(botAI, "party member critical health", sPlayerbotAIConfig->criticalHealth, 0) { } +public: + PartyMemberCriticalHealthTrigger(PlayerbotAI* botAI) + : PartyMemberLowHealthTrigger(botAI, "party member critical health", sPlayerbotAIConfig->criticalHealth, 0) + { + } }; class PartyMemberMediumHealthTrigger : public PartyMemberLowHealthTrigger { - public: - PartyMemberMediumHealthTrigger(PlayerbotAI* botAI) : PartyMemberLowHealthTrigger(botAI, "party member medium health", sPlayerbotAIConfig->mediumHealth,sPlayerbotAIConfig->lowHealth) { } +public: + PartyMemberMediumHealthTrigger(PlayerbotAI* botAI) + : PartyMemberLowHealthTrigger(botAI, "party member medium health", sPlayerbotAIConfig->mediumHealth, + sPlayerbotAIConfig->lowHealth) + { + } }; class PartyMemberAlmostFullHealthTrigger : public PartyMemberLowHealthTrigger { - public: - PartyMemberAlmostFullHealthTrigger(PlayerbotAI* botAI) : PartyMemberLowHealthTrigger(botAI, "party member almost full health", sPlayerbotAIConfig->almostFullHealth,sPlayerbotAIConfig->mediumHealth) { } +public: + PartyMemberAlmostFullHealthTrigger(PlayerbotAI* botAI) + : PartyMemberLowHealthTrigger(botAI, "party member almost full health", sPlayerbotAIConfig->almostFullHealth, + sPlayerbotAIConfig->mediumHealth) + { + } }; class TargetLowHealthTrigger : public HealthInRangeTrigger { - public: - TargetLowHealthTrigger(PlayerbotAI* botAI, float value, float minValue = 0) : HealthInRangeTrigger(botAI, "target low health", value, minValue) { } +public: + TargetLowHealthTrigger(PlayerbotAI* botAI, float value, float minValue = 0) + : HealthInRangeTrigger(botAI, "target low health", value, minValue) + { + } - std::string const GetTargetName() override { return "current target"; } + std::string const GetTargetName() override { return "current target"; } }; class TargetCriticalHealthTrigger : public TargetLowHealthTrigger { - public: - TargetCriticalHealthTrigger(PlayerbotAI* botAI) : TargetLowHealthTrigger(botAI, 20) { } +public: + TargetCriticalHealthTrigger(PlayerbotAI* botAI) : TargetLowHealthTrigger(botAI, 20) {} }; class PartyMemberDeadTrigger : public Trigger { - public: - PartyMemberDeadTrigger(PlayerbotAI* botAI) : Trigger(botAI, "resurrect", 1 * 1000) { } +public: + PartyMemberDeadTrigger(PlayerbotAI* botAI) : Trigger(botAI, "resurrect", 1 * 1000) {} - std::string const GetTargetName() override { return "party member to resurrect"; } - bool IsActive() override; + std::string const GetTargetName() override { return "party member to resurrect"; } + bool IsActive() override; }; -class CombatPartyMemberDeadTrigger : public Trigger +class CombatPartyMemberDeadTrigger : public Trigger { - public: - CombatPartyMemberDeadTrigger(PlayerbotAI* ai) : Trigger(ai, "combat party member to resurrect", 1) {} - std::string const GetTargetName() override { return "party member to resurrect"; } - bool IsActive() override; +public: + CombatPartyMemberDeadTrigger(PlayerbotAI* ai) : Trigger(ai, "combat party member to resurrect", 1) {} + std::string const GetTargetName() override { return "party member to resurrect"; } + bool IsActive() override; }; class DeadTrigger : public Trigger { - public: - DeadTrigger(PlayerbotAI* botAI) : Trigger(botAI, "dead") { } +public: + DeadTrigger(PlayerbotAI* botAI) : Trigger(botAI, "dead") {} - std::string const GetTargetName() override { return "self target"; } - bool IsActive() override; + std::string const GetTargetName() override { return "self target"; } + bool IsActive() override; }; class AoeHealTrigger : public Trigger { - public: - AoeHealTrigger(PlayerbotAI* botAI, std::string const name, std::string const type, int32 count) : Trigger(botAI, name), count(count), type(type) { } // reorder args - whipowill - bool IsActive() override; +public: + AoeHealTrigger(PlayerbotAI* botAI, std::string const name, std::string const type, int32 count) + : Trigger(botAI, name), count(count), type(type) + { + } // reorder args - whipowill + bool IsActive() override; - protected: - int32 count; - std::string const type; +protected: + int32 count; + std::string const type; }; -class AoeInGroupTrigger : public Trigger { - public: - AoeInGroupTrigger(PlayerbotAI* ai, std::string name, std::string type, float ratio) : - Trigger(ai, name), ratio(ratio), type(type) {} - bool IsActive() override; - protected: - float ratio; - std::string type; - }; +class AoeInGroupTrigger : public Trigger +{ +public: + AoeInGroupTrigger(PlayerbotAI* ai, std::string name, std::string type, float ratio) + : Trigger(ai, name), ratio(ratio), type(type) + { + } + bool IsActive() override; + +protected: + float ratio; + std::string type; +}; #endif diff --git a/src/strategy/triggers/LfgTriggers.cpp b/src/strategy/triggers/LfgTriggers.cpp index cef748a0..aa170e2b 100644 --- a/src/strategy/triggers/LfgTriggers.cpp +++ b/src/strategy/triggers/LfgTriggers.cpp @@ -1,16 +1,16 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LfgTriggers.h" + #include "Playerbots.h" -bool LfgProposalActiveTrigger::IsActive() -{ - return AI_VALUE(uint32, "lfg proposal"); -} +bool LfgProposalActiveTrigger::IsActive() { return AI_VALUE(uint32, "lfg proposal"); } bool UnknownDungeonTrigger::IsActive() { - return botAI->HasActivePlayerMaster() && botAI->GetMaster() && botAI->GetMaster()->IsInWorld() && botAI->GetMaster()->GetMap()->IsDungeon() && bot->GetMapId() == botAI->GetMaster()->GetMapId(); + return botAI->HasActivePlayerMaster() && botAI->GetMaster() && botAI->GetMaster()->IsInWorld() && + botAI->GetMaster()->GetMap()->IsDungeon() && bot->GetMapId() == botAI->GetMaster()->GetMapId(); } diff --git a/src/strategy/triggers/LfgTriggers.h b/src/strategy/triggers/LfgTriggers.h index c1f7d0e4..1c493b18 100644 --- a/src/strategy/triggers/LfgTriggers.h +++ b/src/strategy/triggers/LfgTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LFGTRIGGERS_H @@ -11,18 +12,18 @@ class PlayerbotAI; class LfgProposalActiveTrigger : public Trigger { - public: - LfgProposalActiveTrigger(PlayerbotAI* botAI) : Trigger(botAI, "lfg proposal active", 20 * 2000) { } +public: + LfgProposalActiveTrigger(PlayerbotAI* botAI) : Trigger(botAI, "lfg proposal active", 20 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; class UnknownDungeonTrigger : public Trigger { - public: - UnknownDungeonTrigger(PlayerbotAI* botAI) : Trigger(botAI, "unknown dungeon", 20 * 2000) { } +public: + UnknownDungeonTrigger(PlayerbotAI* botAI) : Trigger(botAI, "unknown dungeon", 20 * 2000) {} - bool IsActive() override; + bool IsActive() override; }; #endif diff --git a/src/strategy/triggers/LootTriggers.cpp b/src/strategy/triggers/LootTriggers.cpp index dcb682d2..3a727668 100644 --- a/src/strategy/triggers/LootTriggers.cpp +++ b/src/strategy/triggers/LootTriggers.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LootTriggers.h" + #include "LootObjectStack.h" #include "Playerbots.h" #include "ServerFacade.h" @@ -10,8 +12,10 @@ bool LootAvailableTrigger::IsActive() { return AI_VALUE(bool, "has available loot") && - (sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "loot target"), INTERACTION_DISTANCE) || AI_VALUE(GuidVector, "all targets").empty()) && - !AI_VALUE2(bool, "combat", "self target") && !AI_VALUE2(bool, "mounted", "self target"); + (sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "loot target"), + INTERACTION_DISTANCE) || + AI_VALUE(GuidVector, "all targets").empty()) && + !AI_VALUE2(bool, "combat", "self target") && !AI_VALUE2(bool, "mounted", "self target"); } bool FarFromCurrentLootTrigger::IsActive() @@ -23,7 +27,4 @@ bool FarFromCurrentLootTrigger::IsActive() return AI_VALUE2(float, "distance", "loot target") > INTERACTION_DISTANCE; } -bool CanLootTrigger::IsActive() -{ - return AI_VALUE(bool, "can loot"); -} +bool CanLootTrigger::IsActive() { return AI_VALUE(bool, "can loot"); } diff --git a/src/strategy/triggers/LootTriggers.h b/src/strategy/triggers/LootTriggers.h index 41267950..f9aedab8 100644 --- a/src/strategy/triggers/LootTriggers.h +++ b/src/strategy/triggers/LootTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LOOTTRIGGERS_H @@ -11,26 +12,26 @@ class PlayerbotAI; class LootAvailableTrigger : public Trigger { - public: - LootAvailableTrigger(PlayerbotAI* botAI) : Trigger(botAI, "loot available") { } +public: + LootAvailableTrigger(PlayerbotAI* botAI) : Trigger(botAI, "loot available") {} - bool IsActive() override; + bool IsActive() override; }; class FarFromCurrentLootTrigger : public Trigger { - public: - FarFromCurrentLootTrigger(PlayerbotAI* botAI) : Trigger(botAI, "far from current loot") { } +public: + FarFromCurrentLootTrigger(PlayerbotAI* botAI) : Trigger(botAI, "far from current loot") {} - bool IsActive() override; + bool IsActive() override; }; class CanLootTrigger : public Trigger { - public: - CanLootTrigger(PlayerbotAI* botAI) : Trigger(botAI, "can loot") { } +public: + CanLootTrigger(PlayerbotAI* botAI) : Trigger(botAI, "can loot") {} - bool IsActive() override; + bool IsActive() override; }; #endif diff --git a/src/strategy/triggers/PvpTriggers.cpp b/src/strategy/triggers/PvpTriggers.cpp index 9597fce8..30d47404 100644 --- a/src/strategy/triggers/PvpTriggers.cpp +++ b/src/strategy/triggers/PvpTriggers.cpp @@ -1,18 +1,17 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PvpTriggers.h" -#include "BattlegroundMgr.h" + #include "BattlegroundEY.h" +#include "BattlegroundMgr.h" #include "BattlegroundWS.h" #include "Playerbots.h" #include "ServerFacade.h" -bool EnemyPlayerNear::IsActive() -{ - return AI_VALUE(Unit*, "enemy player target"); -} +bool EnemyPlayerNear::IsActive() { return AI_VALUE(Unit*, "enemy player target"); } bool PlayerHasNoFlag::IsActive() { @@ -20,11 +19,12 @@ bool PlayerHasNoFlag::IsActive() { if (botAI->GetBot()->GetBattlegroundTypeId() == BattlegroundTypeId::BATTLEGROUND_WS) { - BattlegroundWS *bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); + BattlegroundWS* bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); if (!(bg->GetFlagState(bg->GetOtherTeamId(bot->GetTeamId())) == BG_WS_FLAG_STATE_ON_PLAYER)) return true; - if (bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE) || bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_HORDE)) + if (bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE) || + bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_HORDE)) { return false; } @@ -36,10 +36,7 @@ bool PlayerHasNoFlag::IsActive() return false; } -bool PlayerIsInBattleground::IsActive() -{ - return botAI->GetBot()->InBattleground(); -} +bool PlayerIsInBattleground::IsActive() { return botAI->GetBot()->InBattleground(); } bool BgWaitingTrigger::IsActive() { @@ -84,7 +81,8 @@ bool BgInviteActiveTrigger::IsActive() if (ginfo.IsInvitedToBGInstanceGUID && ginfo.RemoveInviteTime) { LOG_INFO("playerbots", "Bot {} <{}> ({} {}) : Invited to BG but not in BG", - bot->GetGUID().ToString().c_str(), bot->GetName(), bot->GetLevel(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H"); + bot->GetGUID().ToString().c_str(), bot->GetName(), bot->GetLevel(), + bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H"); return true; } } @@ -93,10 +91,7 @@ bool BgInviteActiveTrigger::IsActive() return false; } -bool InsideBGTrigger::IsActive() -{ - return bot->InBattleground() && bot->GetBattleground(); -} +bool InsideBGTrigger::IsActive() { return bot->InBattleground() && bot->GetBattleground(); } bool PlayerIsInBattlegroundWithoutFlag::IsActive() { @@ -104,11 +99,12 @@ bool PlayerIsInBattlegroundWithoutFlag::IsActive() { if (botAI->GetBot()->GetBattlegroundTypeId() == BattlegroundTypeId::BATTLEGROUND_WS) { - BattlegroundWS *bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); + BattlegroundWS* bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); if (!(bg->GetFlagState(bg->GetOtherTeamId(bot->GetTeamId())) == BG_WS_FLAG_STATE_ON_PLAYER)) return true; - if (bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE) || bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE)) + if (bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE) || + bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE)) { return false; } @@ -126,8 +122,9 @@ bool PlayerHasFlag::IsActive() { if (bot->GetBattlegroundTypeId() == BATTLEGROUND_WS) { - BattlegroundWS *bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); - if (bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE) || bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_HORDE)) + BattlegroundWS* bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); + if (bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE) || + bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_HORDE)) { return true; } @@ -135,7 +132,7 @@ bool PlayerHasFlag::IsActive() if (bot->GetBattlegroundTypeId() == BATTLEGROUND_EY) { - BattlegroundEY* bg = (BattlegroundEY*) botAI->GetBot()->GetBattleground(); + BattlegroundEY* bg = (BattlegroundEY*)botAI->GetBot()->GetBattleground(); return bot->GetGUID() == bg->GetFlagPickerGUID(); } @@ -151,9 +148,10 @@ bool TeamHasFlag::IsActive() { if (botAI->GetBot()->GetBattlegroundTypeId() == BattlegroundTypeId::BATTLEGROUND_WS) { - BattlegroundWS *bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); + BattlegroundWS* bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); - if (bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE) || bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_HORDE)) + if (bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_ALLIANCE) || + bot->GetGUID() == bg->GetFlagPickerGUID(TEAM_HORDE)) { return false; } @@ -174,7 +172,7 @@ bool EnemyTeamHasFlag::IsActive() { if (botAI->GetBot()->GetBattlegroundTypeId() == BattlegroundTypeId::BATTLEGROUND_WS) { - BattlegroundWS *bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); + BattlegroundWS* bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); if (bot->GetTeamId() == TEAM_HORDE) { @@ -229,8 +227,4 @@ bool VehicleNearTrigger::IsActive() return npcs.size(); } -bool InVehicleTrigger::IsActive() -{ - return botAI->IsInVehicle(); -} - +bool InVehicleTrigger::IsActive() { return botAI->IsInVehicle(); } diff --git a/src/strategy/triggers/PvpTriggers.h b/src/strategy/triggers/PvpTriggers.h index 11eeedd3..7633c654 100644 --- a/src/strategy/triggers/PvpTriggers.h +++ b/src/strategy/triggers/PvpTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PVPTRIGGERS_H @@ -11,129 +12,129 @@ class PlayerbotAI; class EnemyPlayerNear : public Trigger { - public: - EnemyPlayerNear(PlayerbotAI* botAI) : Trigger(botAI, "enemy player near", 3) { } +public: + EnemyPlayerNear(PlayerbotAI* botAI) : Trigger(botAI, "enemy player near", 3) {} - bool IsActive() override; + bool IsActive() override; }; class PlayerHasNoFlag : public Trigger { - public: - PlayerHasNoFlag(PlayerbotAI* botAI) : Trigger(botAI, "player has no flag") { } +public: + PlayerHasNoFlag(PlayerbotAI* botAI) : Trigger(botAI, "player has no flag") {} - bool IsActive() override; + bool IsActive() override; }; class PlayerHasFlag : public Trigger { - public: - PlayerHasFlag(PlayerbotAI* botAI) : Trigger(botAI, "player has flag") { } +public: + PlayerHasFlag(PlayerbotAI* botAI) : Trigger(botAI, "player has flag") {} - bool IsActive() override; + bool IsActive() override; }; class EnemyFlagCarrierNear : public Trigger { - public: - EnemyFlagCarrierNear(PlayerbotAI* botAI) : Trigger(botAI, "enemy flagcarrier near") { } +public: + EnemyFlagCarrierNear(PlayerbotAI* botAI) : Trigger(botAI, "enemy flagcarrier near") {} - bool IsActive() override; + bool IsActive() override; }; class TeamFlagCarrierNear : public Trigger { - public: - TeamFlagCarrierNear(PlayerbotAI* botAI) : Trigger(botAI, "team flagcarrier near") { } +public: + TeamFlagCarrierNear(PlayerbotAI* botAI) : Trigger(botAI, "team flagcarrier near") {} - bool IsActive() override; + bool IsActive() override; }; class TeamHasFlag : public Trigger { - public: - TeamHasFlag(PlayerbotAI* botAI) : Trigger(botAI, "team has flag") { } +public: + TeamHasFlag(PlayerbotAI* botAI) : Trigger(botAI, "team has flag") {} - bool IsActive() override; + bool IsActive() override; }; class EnemyTeamHasFlag : public Trigger { - public: - EnemyTeamHasFlag(PlayerbotAI* botAI) : Trigger(botAI, "enemy team has flag") { } +public: + EnemyTeamHasFlag(PlayerbotAI* botAI) : Trigger(botAI, "enemy team has flag") {} - bool IsActive() override; + bool IsActive() override; }; class PlayerIsInBattleground : public Trigger { - public: - PlayerIsInBattleground(PlayerbotAI* botAI) : Trigger(botAI, "in Battleground") { } +public: + PlayerIsInBattleground(PlayerbotAI* botAI) : Trigger(botAI, "in Battleground") {} - bool IsActive() override; + bool IsActive() override; }; class BgWaitingTrigger : public Trigger { - public: - BgWaitingTrigger(PlayerbotAI* botAI) : Trigger(botAI, "bg waiting", 30) { } +public: + BgWaitingTrigger(PlayerbotAI* botAI) : Trigger(botAI, "bg waiting", 30) {} - bool IsActive() override; + bool IsActive() override; }; class BgActiveTrigger : public Trigger { - public: - BgActiveTrigger(PlayerbotAI* botAI) : Trigger(botAI, "bg active", 1) { } +public: + BgActiveTrigger(PlayerbotAI* botAI) : Trigger(botAI, "bg active", 1) {} - bool IsActive() override; + bool IsActive() override; }; class BgInviteActiveTrigger : public Trigger { - public: - BgInviteActiveTrigger(PlayerbotAI* botAI) : Trigger(botAI, "bg invite active", 10) { } +public: + BgInviteActiveTrigger(PlayerbotAI* botAI) : Trigger(botAI, "bg invite active", 10) {} - bool IsActive() override; + bool IsActive() override; }; class InsideBGTrigger : public Trigger { - public: - InsideBGTrigger(PlayerbotAI* botAI) : Trigger(botAI, "inside bg", 1) { } +public: + InsideBGTrigger(PlayerbotAI* botAI) : Trigger(botAI, "inside bg", 1) {} - bool IsActive() override; + bool IsActive() override; }; class PlayerIsInBattlegroundWithoutFlag : public Trigger { - public: - PlayerIsInBattlegroundWithoutFlag(PlayerbotAI* botAI) : Trigger(botAI, "in Battleground without flag") { } +public: + PlayerIsInBattlegroundWithoutFlag(PlayerbotAI* botAI) : Trigger(botAI, "in Battleground without flag") {} - bool IsActive() override; + bool IsActive() override; }; class PlayerWantsInBattlegroundTrigger : public Trigger { - public: - PlayerWantsInBattlegroundTrigger(PlayerbotAI* botAI) : Trigger(botAI, "wants in bg") { } +public: + PlayerWantsInBattlegroundTrigger(PlayerbotAI* botAI) : Trigger(botAI, "wants in bg") {} - bool IsActive() override; + bool IsActive() override; }; class VehicleNearTrigger : public Trigger { - public: - VehicleNearTrigger(PlayerbotAI* botAI) : Trigger(botAI, "vehicle near", 10) { } +public: + VehicleNearTrigger(PlayerbotAI* botAI) : Trigger(botAI, "vehicle near", 10) {} - bool IsActive() override; + bool IsActive() override; }; class InVehicleTrigger : public Trigger { - public: - InVehicleTrigger(PlayerbotAI* botAI) : Trigger(botAI, "in vehicle") { } +public: + InVehicleTrigger(PlayerbotAI* botAI) : Trigger(botAI, "in vehicle") {} - bool IsActive() override; + bool IsActive() override; }; #endif diff --git a/src/strategy/triggers/RangeTriggers.cpp b/src/strategy/triggers/RangeTriggers.cpp index 6431e779..5d64283d 100644 --- a/src/strategy/triggers/RangeTriggers.cpp +++ b/src/strategy/triggers/RangeTriggers.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RangeTriggers.h" + #include "MoveSplineInit.h" #include "PlayerbotAIConfig.h" #include "Playerbots.h" @@ -16,46 +18,50 @@ static float GetSpeedInMotion(Unit* target) bool EnemyTooCloseForSpellTrigger::IsActive() { Unit* target = AI_VALUE(Unit*, "current target"); - return target && (target->GetVictim() != bot || target->isFrozen() || !target->CanFreeMove()) && - target->GetObjectSize() <= 10.0f && - target->IsWithinCombatRange(bot, MIN_MELEE_REACH); -// Unit* target = AI_VALUE(Unit*, "current target"); -// if (!target) { -// return false; -// } + return target && (target->GetVictim() != bot || target->isFrozen() || !target->CanFreeMove()) && + target->GetObjectSize() <= 10.0f && target->IsWithinCombatRange(bot, MIN_MELEE_REACH); + // Unit* target = AI_VALUE(Unit*, "current target"); + // if (!target) { + // return false; + // } -// if (target->GetTarget() == bot->GetGUID() && !bot->GetGroup() && !target->HasUnitState(UNIT_STATE_ROOT) && GetSpeedInMotion(target) > GetSpeedInMotion(bot) * 0.65f) -// return false; + // if (target->GetTarget() == bot->GetGUID() && !bot->GetGroup() && !target->HasUnitState(UNIT_STATE_ROOT) && + // GetSpeedInMotion(target) > GetSpeedInMotion(bot) * 0.65f) + // return false; -// bool isBoss = false; -// bool isRaid = false; -// float combatReach = bot->GetCombatReach() + target->GetCombatReach(); -// float targetDistance = sServerFacade->GetDistance2d(bot, target) + combatReach; -// if (target->GetTypeId() == TYPEID_UNIT) -// { -// Creature* creature = botAI->GetCreature(target->GetGUID()); -// if (creature) -// { -// isBoss = creature->isWorldBoss(); -// } -// } + // bool isBoss = false; + // bool isRaid = false; + // float combatReach = bot->GetCombatReach() + target->GetCombatReach(); + // float targetDistance = sServerFacade->GetDistance2d(bot, target) + combatReach; + // if (target->GetTypeId() == TYPEID_UNIT) + // { + // Creature* creature = botAI->GetCreature(target->GetGUID()); + // if (creature) + // { + // isBoss = creature->isWorldBoss(); + // } + // } -// if (bot->GetMap() && bot->GetMap()->IsRaid()) -// isRaid = true; + // if (bot->GetMap() && bot->GetMap()->IsRaid()) + // isRaid = true; -// // if (isBoss || isRaid) -// // return sServerFacade->IsDistanceLessThan(targetDistance, (sPlayerbotAIConfig->tooCloseDistance + combatReach) / 2); + // // if (isBoss || isRaid) + // // return sServerFacade->IsDistanceLessThan(targetDistance, (sPlayerbotAIConfig->tooCloseDistance + + // combatReach) / 2); -// return sServerFacade->IsDistanceLessOrEqualThan(targetDistance, (sPlayerbotAIConfig->tooCloseDistance + combatReach / 2)); + // return sServerFacade->IsDistanceLessOrEqualThan(targetDistance, (sPlayerbotAIConfig->tooCloseDistance + + // combatReach / 2)); } bool EnemyTooCloseForAutoShotTrigger::IsActive() { Unit* target = AI_VALUE(Unit*, "current target"); - - return target && (target->GetVictim() != bot || target->isFrozen() || !target->CanFreeMove()) && bot->IsWithinMeleeRange(target); - // if (target->GetTarget() == bot->GetGUID() && !bot->GetGroup() && !target->HasUnitState(UNIT_STATE_ROOT) && GetSpeedInMotion(target) > GetSpeedInMotion(bot) * 0.65f) + return target && (target->GetVictim() != bot || target->isFrozen() || !target->CanFreeMove()) && + bot->IsWithinMeleeRange(target); + + // if (target->GetTarget() == bot->GetGUID() && !bot->GetGroup() && !target->HasUnitState(UNIT_STATE_ROOT) && + // GetSpeedInMotion(target) > GetSpeedInMotion(bot) * 0.65f) // return false; // bool isBoss = false; @@ -82,35 +88,38 @@ bool EnemyTooCloseForShootTrigger::IsActive() Unit* target = AI_VALUE(Unit*, "current target"); // target->IsWithinCombatRange() - return target && (target->GetVictim() != bot || target->isFrozen() || !target->CanFreeMove()) && target->IsWithinCombatRange(bot, MIN_MELEE_REACH); + return target && (target->GetVictim() != bot || target->isFrozen() || !target->CanFreeMove()) && + target->IsWithinCombatRange(bot, MIN_MELEE_REACH); -// Unit* target = AI_VALUE(Unit*, "current target"); -// if (!target) -// return false; + // Unit* target = AI_VALUE(Unit*, "current target"); + // if (!target) + // return false; -// if (target->GetTarget() == bot->GetGUID() && !bot->GetGroup() && !target->HasUnitState(UNIT_STATE_ROOT) && GetSpeedInMotion(target) > GetSpeedInMotion(bot) * 0.65f) -// return false; + // if (target->GetTarget() == bot->GetGUID() && !bot->GetGroup() && !target->HasUnitState(UNIT_STATE_ROOT) && + // GetSpeedInMotion(target) > GetSpeedInMotion(bot) * 0.65f) + // return false; -// bool isBoss = false; -// bool isRaid = false; -// float combatReach = bot->GetCombatReach() + target->GetCombatReach(); -// float targetDistance = sServerFacade->GetDistance2d(bot, target) + combatReach; -// if (target->GetTypeId() == TYPEID_UNIT) -// { -// Creature* creature = botAI->GetCreature(target->GetGUID()); -// if (creature) -// { -// isBoss = creature->isWorldBoss(); -// } -// } + // bool isBoss = false; + // bool isRaid = false; + // float combatReach = bot->GetCombatReach() + target->GetCombatReach(); + // float targetDistance = sServerFacade->GetDistance2d(bot, target) + combatReach; + // if (target->GetTypeId() == TYPEID_UNIT) + // { + // Creature* creature = botAI->GetCreature(target->GetGUID()); + // if (creature) + // { + // isBoss = creature->isWorldBoss(); + // } + // } -// if (bot->GetMap() && bot->GetMap()->IsRaid()) -// isRaid = true; + // if (bot->GetMap() && bot->GetMap()->IsRaid()) + // isRaid = true; -// // if (isBoss || isRaid) -// // return sServerFacade->IsDistanceLessThan(targetDistance, botAI->GetRange("shoot") + combatReach); + // // if (isBoss || isRaid) + // // return sServerFacade->IsDistanceLessThan(targetDistance, botAI->GetRange("shoot") + combatReach); -// return sServerFacade->IsDistanceLessOrEqualThan(targetDistance, (botAI->GetRange("shoot") + combatReach / 2)); + // return sServerFacade->IsDistanceLessOrEqualThan(targetDistance, (botAI->GetRange("shoot") + combatReach / + // 2)); } bool EnemyTooCloseForMeleeTrigger::IsActive() @@ -125,7 +134,8 @@ bool EnemyTooCloseForMeleeTrigger::IsActive() bool EnemyIsCloseTrigger::IsActive() { Unit* target = AI_VALUE(Unit*, "current target"); - return target && sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "current target"), sPlayerbotAIConfig->tooCloseDistance); + return target && sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "current target"), + sPlayerbotAIConfig->tooCloseDistance); } bool EnemyWithinMeleeTrigger::IsActive() @@ -139,10 +149,14 @@ bool OutOfRangeTrigger::IsActive() Unit* target = AI_VALUE(Unit*, GetTargetName()); // increase contact distance to prevent calculation error float dis = distance + CONTACT_DISTANCE; - return target && !bot->IsWithinCombatRange(target, dis); // sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", GetTargetName()), distance); + return target && + !bot->IsWithinCombatRange( + target, + dis); // sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", GetTargetName()), distance); } -EnemyOutOfSpellRangeTrigger::EnemyOutOfSpellRangeTrigger(PlayerbotAI* botAI) : OutOfRangeTrigger(botAI, "enemy out of spell range", botAI->GetRange("spell")) +EnemyOutOfSpellRangeTrigger::EnemyOutOfSpellRangeTrigger(PlayerbotAI* botAI) + : OutOfRangeTrigger(botAI, "enemy out of spell range", botAI->GetRange("spell")) { } @@ -153,7 +167,8 @@ EnemyOutOfSpellRangeTrigger::EnemyOutOfSpellRangeTrigger(PlayerbotAI* botAI) : O // return false; // float combatReach = bot->GetCombatReach() + target->GetCombatReach(); -// return target && (sServerFacade->GetDistance2d(bot, target) > (distance + combatReach + sPlayerbotAIConfig->contactDistance) || !bot->IsWithinLOSInMap(target)); +// return target && (sServerFacade->GetDistance2d(bot, target) > (distance + combatReach + +// sPlayerbotAIConfig->contactDistance) || !bot->IsWithinLOSInMap(target)); // } // bool EnemyOutOfMeleeTrigger::IsActive() @@ -163,7 +178,8 @@ EnemyOutOfSpellRangeTrigger::EnemyOutOfSpellRangeTrigger(PlayerbotAI* botAI) : O // return false; // float targetDistance = sServerFacade->GetDistance2d(bot, target); -// return target && (targetDistance > std::max(5.0f, bot->GetCombatReach() + target->GetCombatReach()) || (!bot->IsWithinLOSInMap(target) && targetDistance > 5.0f)); +// return target && (targetDistance > std::max(5.0f, bot->GetCombatReach() + target->GetCombatReach()) || +// (!bot->IsWithinLOSInMap(target) && targetDistance > 5.0f)); // } bool PartyMemberToHealOutOfSpellRangeTrigger::IsActive() @@ -173,11 +189,12 @@ bool PartyMemberToHealOutOfSpellRangeTrigger::IsActive() return false; float combatReach = bot->GetCombatReach() + target->GetCombatReach(); - return target && (sServerFacade->GetDistance2d(bot, target) > (distance + sPlayerbotAIConfig->contactDistance) || !bot->IsWithinLOSInMap(target)); + return target && (sServerFacade->GetDistance2d(bot, target) > (distance + sPlayerbotAIConfig->contactDistance) || + !bot->IsWithinLOSInMap(target)); } -PartyMemberToHealOutOfSpellRangeTrigger::PartyMemberToHealOutOfSpellRangeTrigger(PlayerbotAI* botAI) : - OutOfRangeTrigger(botAI, "party member to heal out of spell range", botAI->GetRange("heal") + 1.0f) +PartyMemberToHealOutOfSpellRangeTrigger::PartyMemberToHealOutOfSpellRangeTrigger(PlayerbotAI* botAI) + : OutOfRangeTrigger(botAI, "party member to heal out of spell range", botAI->GetRange("heal") + 1.0f) { } diff --git a/src/strategy/triggers/RangeTriggers.h b/src/strategy/triggers/RangeTriggers.h index 470b5a8f..b975aca3 100644 --- a/src/strategy/triggers/RangeTriggers.h +++ b/src/strategy/triggers/RangeTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RANGETRIGGERS_H @@ -12,103 +13,112 @@ class PlayerbotAI; class EnemyTooCloseForSpellTrigger : public Trigger { - public: - EnemyTooCloseForSpellTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enemy too close for spell") { } +public: + EnemyTooCloseForSpellTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enemy too close for spell") {} - bool IsActive() override; + bool IsActive() override; }; class EnemyTooCloseForShootTrigger : public Trigger { - public: - EnemyTooCloseForShootTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enemy too close for shoot") { } +public: + EnemyTooCloseForShootTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enemy too close for shoot") {} - bool IsActive() override; + bool IsActive() override; }; class EnemyTooCloseForAutoShotTrigger : public Trigger { - public: - EnemyTooCloseForAutoShotTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enemy too close for auto shot") { } +public: + EnemyTooCloseForAutoShotTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enemy too close for auto shot") {} - bool IsActive() override; + bool IsActive() override; }; class EnemyTooCloseForMeleeTrigger : public Trigger { - public: - EnemyTooCloseForMeleeTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enemy too close for melee", 5) { } +public: + EnemyTooCloseForMeleeTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enemy too close for melee", 5) {} - bool IsActive() override; + bool IsActive() override; }; class EnemyIsCloseTrigger : public Trigger { - public: - EnemyIsCloseTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enemy is close") { } +public: + EnemyIsCloseTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enemy is close") {} - bool IsActive() override; + bool IsActive() override; }; class EnemyWithinMeleeTrigger : public Trigger { - public: - EnemyWithinMeleeTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enemy within melee") { } +public: + EnemyWithinMeleeTrigger(PlayerbotAI* botAI) : Trigger(botAI, "enemy within melee") {} - bool IsActive() override; + bool IsActive() override; }; class OutOfRangeTrigger : public Trigger { - public: - OutOfRangeTrigger(PlayerbotAI* botAI, std::string const name, float distance) : Trigger(botAI, name), distance(distance) { } +public: + OutOfRangeTrigger(PlayerbotAI* botAI, std::string const name, float distance) + : Trigger(botAI, name), distance(distance) + { + } - bool IsActive() override; - std::string const GetTargetName() override { return "current target"; } + bool IsActive() override; + std::string const GetTargetName() override { return "current target"; } - protected: - float distance; +protected: + float distance; }; class EnemyOutOfMeleeTrigger : public OutOfRangeTrigger { - public: - EnemyOutOfMeleeTrigger(PlayerbotAI* botAI) : OutOfRangeTrigger(botAI, "enemy out of melee range", sPlayerbotAIConfig->meleeDistance) { } +public: + EnemyOutOfMeleeTrigger(PlayerbotAI* botAI) + : OutOfRangeTrigger(botAI, "enemy out of melee range", sPlayerbotAIConfig->meleeDistance) + { + } - // bool IsActive() override; + // bool IsActive() override; }; class EnemyOutOfSpellRangeTrigger : public OutOfRangeTrigger { - public: - EnemyOutOfSpellRangeTrigger(PlayerbotAI* botAI); +public: + EnemyOutOfSpellRangeTrigger(PlayerbotAI* botAI); }; class PartyMemberToHealOutOfSpellRangeTrigger : public OutOfRangeTrigger { - public: - PartyMemberToHealOutOfSpellRangeTrigger(PlayerbotAI* botAI); +public: + PartyMemberToHealOutOfSpellRangeTrigger(PlayerbotAI* botAI); - bool IsActive() override; - std::string const GetTargetName() override { return "party member to heal"; } + bool IsActive() override; + std::string const GetTargetName() override { return "party member to heal"; } }; class FarFromMasterTrigger : public Trigger { - public: - FarFromMasterTrigger(PlayerbotAI* botAI, std::string const name = "far from master", float distance = 12.0f, int32 checkInterval = 50) : - Trigger(botAI, name, checkInterval), distance(distance) { } +public: + FarFromMasterTrigger(PlayerbotAI* botAI, std::string const name = "far from master", float distance = 12.0f, + int32 checkInterval = 50) + : Trigger(botAI, name, checkInterval), distance(distance) + { + } - bool IsActive() override; + bool IsActive() override; - private: - float distance; +private: + float distance; }; class OutOfReactRangeTrigger : public FarFromMasterTrigger { - public: - OutOfReactRangeTrigger(PlayerbotAI* botAI) : FarFromMasterTrigger(botAI, "out of react range", 50.0f, 5) { } +public: + OutOfReactRangeTrigger(PlayerbotAI* botAI) : FarFromMasterTrigger(botAI, "out of react range", 50.0f, 5) {} }; #endif diff --git a/src/strategy/triggers/RpgTriggers.cpp b/src/strategy/triggers/RpgTriggers.cpp index b500ad89..199cc7b3 100644 --- a/src/strategy/triggers/RpgTriggers.cpp +++ b/src/strategy/triggers/RpgTriggers.cpp @@ -1,23 +1,19 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RpgTriggers.h" + #include "BudgetValues.h" #include "GuildCreateActions.h" #include "Playerbots.h" #include "ServerFacade.h" #include "SocialMgr.h" -bool NoRpgTargetTrigger::IsActive() -{ - return !AI_VALUE(GuidPosition, "rpg target"); -} +bool NoRpgTargetTrigger::IsActive() { return !AI_VALUE(GuidPosition, "rpg target"); } -bool HasRpgTargetTrigger::IsActive() -{ - return !NoRpgTargetTrigger::IsActive(); -} +bool HasRpgTargetTrigger::IsActive() { return !NoRpgTargetTrigger::IsActive(); } bool FarFromRpgTargetTrigger::IsActive() { @@ -29,19 +25,14 @@ bool NearRpgTargetTrigger::IsActive() return !NoRpgTargetTrigger::IsActive() && !FarFromRpgTargetTrigger::IsActive(); } -GuidPosition RpgTrigger::getGuidP() -{ - return AI_VALUE(GuidPosition, "rpg target"); -} +GuidPosition RpgTrigger::getGuidP() { return AI_VALUE(GuidPosition, "rpg target"); } -bool RpgTrigger::IsActive() -{ - return true; -} +bool RpgTrigger::IsActive() { return true; } Event RpgTrigger::Check() { - if (!NoRpgTargetTrigger::IsActive() && (AI_VALUE(std::string, "next rpg action") == "choose rpg target") || !FarFromRpgTargetTrigger::IsActive()) + if (!NoRpgTargetTrigger::IsActive() && (AI_VALUE(std::string, "next rpg action") == "choose rpg target") || + !FarFromRpgTargetTrigger::IsActive()) return Trigger::Check(); return Event(); @@ -54,7 +45,8 @@ bool RpgTaxiTrigger::IsActive() if (!guidP.HasNpcFlag(UNIT_NPC_FLAG_FLIGHTMASTER)) return false; - uint32 node = sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId()); + uint32 node = + sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId()); if (!node) return false; @@ -75,7 +67,8 @@ bool RpgDiscoverTrigger::IsActive() if (bot->isTaxiCheater()) return false; - uint32 node = sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId()); + uint32 node = + sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId()); if (bot->m_taxi.IsTaximaskNodeKnown(node)) return false; @@ -127,7 +120,7 @@ bool RpgBuyTrigger::IsActive() if (AI_VALUE(uint8, "durability") > 50) return false; - if (!AI_VALUE(bool, "can sell")) //Need better condition. + if (!AI_VALUE(bool, "can sell")) // Need better condition. return false; return true; @@ -197,7 +190,7 @@ bool RpgTrainTrigger::IsTrainerOf(CreatureTemplate const* cInfo, Player* pPlayer } break; default: - return false; // checked and error output at creature_template loading + return false; // checked and error output at creature_template loading } return true; @@ -292,7 +285,7 @@ bool RpgHomeBindTrigger::IsActive() bool RpgQueueBGTrigger::IsActive() { // skip bots not in continents - if (!WorldPosition(bot).isOverworld()) // bg, raid, dungeon + if (!WorldPosition(bot).isOverworld()) // bg, raid, dungeon return false; GuidPosition guidP(getGuidP()); @@ -390,7 +383,7 @@ bool RpgTradeUsefulTrigger::IsActive() if (!player) return false; - //More code/botAI-value here to see if bot is friendly enough. + // More code/botAI-value here to see if bot is friendly enough. bool isFriend = false; if (player->GetGuildId() != bot->GetGuildId()) isFriend = true; @@ -439,7 +432,6 @@ bool RpgDuelTrigger::IsActive() if (AI_VALUE2(uint8, "health", "self target") < 90) return false; - GuidPosition guidP(getGuidP()); if (!guidP.IsPlayer()) diff --git a/src/strategy/triggers/RpgTriggers.h b/src/strategy/triggers/RpgTriggers.h index 5c027b38..59c7092c 100644 --- a/src/strategy/triggers/RpgTriggers.h +++ b/src/strategy/triggers/RpgTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RPGTRIGGERS_H @@ -15,184 +16,199 @@ struct CreatureTemplate; class NoRpgTargetTrigger : public Trigger { - public: - NoRpgTargetTrigger(PlayerbotAI* botAI, std::string const name = "no rpg target", int checkInterval = 1) : Trigger(botAI, name, checkInterval) { } +public: + NoRpgTargetTrigger(PlayerbotAI* botAI, std::string const name = "no rpg target", int checkInterval = 1) + : Trigger(botAI, name, checkInterval) + { + } - bool IsActive() override; + bool IsActive() override; }; class HasRpgTargetTrigger : public NoRpgTargetTrigger { - public: - HasRpgTargetTrigger(PlayerbotAI* botAI, std::string const name = "has rpg target", int checkInterval = 1) : NoRpgTargetTrigger(botAI, name, checkInterval) { } +public: + HasRpgTargetTrigger(PlayerbotAI* botAI, std::string const name = "has rpg target", int checkInterval = 1) + : NoRpgTargetTrigger(botAI, name, checkInterval) + { + } - bool IsActive() override; + bool IsActive() override; }; class FarFromRpgTargetTrigger : public NoRpgTargetTrigger { - public: - FarFromRpgTargetTrigger(PlayerbotAI* botAI, std::string const name = "far from rpg target", int checkInterval = 1) : NoRpgTargetTrigger(botAI, name, checkInterval) { } +public: + FarFromRpgTargetTrigger(PlayerbotAI* botAI, std::string const name = "far from rpg target", int checkInterval = 1) + : NoRpgTargetTrigger(botAI, name, checkInterval) + { + } - bool IsActive() override; + bool IsActive() override; }; class NearRpgTargetTrigger : public FarFromRpgTargetTrigger { - public: - NearRpgTargetTrigger(PlayerbotAI* botAI, std::string const name = "near rpg target", int checkInterval = 1) : FarFromRpgTargetTrigger(botAI, name, checkInterval) { } +public: + NearRpgTargetTrigger(PlayerbotAI* botAI, std::string const name = "near rpg target", int checkInterval = 1) + : FarFromRpgTargetTrigger(botAI, name, checkInterval) + { + } - bool IsActive() override; + bool IsActive() override; }; -//Sub actions: +// Sub actions: class RpgTrigger : public FarFromRpgTargetTrigger { - public: - RpgTrigger(PlayerbotAI* botAI, std::string const name = "sub rpg", int checkInterval = 2) : FarFromRpgTargetTrigger(botAI, name, checkInterval) { } +public: + RpgTrigger(PlayerbotAI* botAI, std::string const name = "sub rpg", int checkInterval = 2) + : FarFromRpgTargetTrigger(botAI, name, checkInterval) + { + } - GuidPosition getGuidP(); + GuidPosition getGuidP(); - bool IsActive() override; - Event Check() override; + bool IsActive() override; + Event Check() override; }; class RpgTaxiTrigger : public RpgTrigger { - public: - RpgTaxiTrigger(PlayerbotAI* botAI, std::string const name = "rpg taxi") : RpgTrigger(botAI, name) { } +public: + RpgTaxiTrigger(PlayerbotAI* botAI, std::string const name = "rpg taxi") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgDiscoverTrigger : public RpgTrigger { - public: - RpgDiscoverTrigger(PlayerbotAI* botAI, std::string const name = "rpg discover") : RpgTrigger(botAI, name) { } +public: + RpgDiscoverTrigger(PlayerbotAI* botAI, std::string const name = "rpg discover") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgStartQuestTrigger : public RpgTrigger { - public: - RpgStartQuestTrigger(PlayerbotAI* botAI, std::string const name = "rpg start quest") : RpgTrigger(botAI, name) { } +public: + RpgStartQuestTrigger(PlayerbotAI* botAI, std::string const name = "rpg start quest") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgEndQuestTrigger : public RpgTrigger { - public: - RpgEndQuestTrigger(PlayerbotAI* botAI, std::string const name = "rpg end quest") : RpgTrigger(botAI, name) { } +public: + RpgEndQuestTrigger(PlayerbotAI* botAI, std::string const name = "rpg end quest") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgBuyTrigger : public RpgTrigger { - public: - RpgBuyTrigger(PlayerbotAI* botAI, std::string const name = "rpg buy") : RpgTrigger(botAI, name) { } +public: + RpgBuyTrigger(PlayerbotAI* botAI, std::string const name = "rpg buy") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgSellTrigger : public RpgTrigger { - public: - RpgSellTrigger(PlayerbotAI* botAI, std::string const name = "rpg sell") : RpgTrigger(botAI, name) { } +public: + RpgSellTrigger(PlayerbotAI* botAI, std::string const name = "rpg sell") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgRepairTrigger : public RpgTrigger { - public: - RpgRepairTrigger(PlayerbotAI* botAI, std::string const name = "rpg repair") : RpgTrigger(botAI, name) { } +public: + RpgRepairTrigger(PlayerbotAI* botAI, std::string const name = "rpg repair") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgTrainTrigger : public RpgTrigger { - public: - RpgTrainTrigger(PlayerbotAI* botAI, std::string const name = "rpg train") : RpgTrigger(botAI, name) { } +public: + RpgTrainTrigger(PlayerbotAI* botAI, std::string const name = "rpg train") : RpgTrigger(botAI, name) {} - static bool IsTrainerOf(CreatureTemplate const* cInfo, Player* pPlayer); + static bool IsTrainerOf(CreatureTemplate const* cInfo, Player* pPlayer); - bool IsActive() override; + bool IsActive() override; }; class RpgHealTrigger : public RpgTrigger { - public: - RpgHealTrigger(PlayerbotAI* botAI, std::string const name = "rpg heal") : RpgTrigger(botAI, name) { } +public: + RpgHealTrigger(PlayerbotAI* botAI, std::string const name = "rpg heal") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgHomeBindTrigger : public RpgTrigger { - public: - RpgHomeBindTrigger(PlayerbotAI* botAI, std::string const name = "rpg home bind") : RpgTrigger(botAI, name) { } +public: + RpgHomeBindTrigger(PlayerbotAI* botAI, std::string const name = "rpg home bind") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgQueueBGTrigger : public RpgTrigger { - public: - RpgQueueBGTrigger(PlayerbotAI* botAI, std::string const name = "rpg queue bg") : RpgTrigger(botAI, name) { } +public: + RpgQueueBGTrigger(PlayerbotAI* botAI, std::string const name = "rpg queue bg") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgBuyPetitionTrigger : public RpgTrigger { - public: - RpgBuyPetitionTrigger(PlayerbotAI* botAI, std::string const name = "rpg buy petition") : RpgTrigger(botAI, name) { } +public: + RpgBuyPetitionTrigger(PlayerbotAI* botAI, std::string const name = "rpg buy petition") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgUseTrigger : public RpgTrigger { - public: - RpgUseTrigger(PlayerbotAI* botAI, std::string const name = "rpg use") : RpgTrigger(botAI, name) { } +public: + RpgUseTrigger(PlayerbotAI* botAI, std::string const name = "rpg use") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgSpellTrigger : public RpgTrigger { - public: - RpgSpellTrigger(PlayerbotAI* botAI, std::string const name = "rpg spell") : RpgTrigger(botAI, name) { } +public: + RpgSpellTrigger(PlayerbotAI* botAI, std::string const name = "rpg spell") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgCraftTrigger : public RpgTrigger { - public: - RpgCraftTrigger(PlayerbotAI* botAI, std::string const name = "rpg craft") : RpgTrigger(botAI, name) { } +public: + RpgCraftTrigger(PlayerbotAI* botAI, std::string const name = "rpg craft") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgTradeUsefulTrigger : public RpgTrigger { - public: - RpgTradeUsefulTrigger(PlayerbotAI* botAI, std::string const name = "rpg trade useful") : RpgTrigger(botAI, name) { } +public: + RpgTradeUsefulTrigger(PlayerbotAI* botAI, std::string const name = "rpg trade useful") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; class RpgDuelTrigger : public RpgTrigger { - public: - RpgDuelTrigger(PlayerbotAI* botAI, std::string const name = "rpg duel") : RpgTrigger(botAI, name) { } +public: + RpgDuelTrigger(PlayerbotAI* botAI, std::string const name = "rpg duel") : RpgTrigger(botAI, name) {} - bool IsActive() override; + bool IsActive() override; }; #endif diff --git a/src/strategy/triggers/RtiTriggers.cpp b/src/strategy/triggers/RtiTriggers.cpp index 10d7a80d..8ccd8b54 100644 --- a/src/strategy/triggers/RtiTriggers.cpp +++ b/src/strategy/triggers/RtiTriggers.cpp @@ -1,11 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RtiTriggers.h" + #include "Playerbots.h" -bool NoRtiTrigger::IsActive() -{ - return !AI_VALUE(Unit*, "rti target"); -} +bool NoRtiTrigger::IsActive() { return !AI_VALUE(Unit*, "rti target"); } diff --git a/src/strategy/triggers/RtiTriggers.h b/src/strategy/triggers/RtiTriggers.h index 5072f1ce..2780af79 100644 --- a/src/strategy/triggers/RtiTriggers.h +++ b/src/strategy/triggers/RtiTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RTITRIGGERS_H @@ -11,10 +12,10 @@ class PlayerbotAI; class NoRtiTrigger : public Trigger { - public: - NoRtiTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no rti target") { } +public: + NoRtiTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no rti target") {} - bool IsActive() override; + bool IsActive() override; }; #endif diff --git a/src/strategy/triggers/StuckTriggers.cpp b/src/strategy/triggers/StuckTriggers.cpp index c288ad86..5cd56c38 100644 --- a/src/strategy/triggers/StuckTriggers.cpp +++ b/src/strategy/triggers/StuckTriggers.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "StuckTriggers.h" + #include "CellImpl.h" #include "PathGenerator.h" #include "Playerbots.h" @@ -17,12 +19,14 @@ bool MoveStuckTrigger::IsActive() WorldPosition botPos(bot); - LogCalculatedValue* posVal = dynamic_cast*>(context->GetUntypedValue("current position")); + LogCalculatedValue* posVal = + dynamic_cast*>(context->GetUntypedValue("current position")); if (posVal->LastChangeDelay() > 5 * MINUTE) { // LOG_INFO("playerbots", "Bot {} {}:{} <{}> was in the same position for {} seconds", - // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), posVal->LastChangeDelay()); + // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + // bot->GetName(), posVal->LastChangeDelay()); return true; } @@ -45,7 +49,8 @@ bool MoveStuckTrigger::IsActive() if (longLog) { // LOG_INFO("playerbots", "Bot {} {}:{} <{}> was in the same position for 10mins", - // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), posVal->LastChangeDelay()); + // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + // bot->GetName(), posVal->LastChangeDelay()); } return longLog; @@ -68,7 +73,8 @@ bool MoveLongStuckTrigger::IsActive() if (grid.x_coord < 0 || grid.x_coord >= MAX_NUMBER_OF_GRIDS) { // LOG_INFO("playerbots", "Bot {} {}:{} <{}> was in grid {},{} on map {}", - // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), grid.x_coord, grid.y_coord, botPos.getMapId()); + // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + // bot->GetName(), grid.x_coord, grid.y_coord, botPos.getMapId()); return true; } @@ -76,30 +82,36 @@ bool MoveLongStuckTrigger::IsActive() if (grid.y_coord < 0 || grid.y_coord >= MAX_NUMBER_OF_GRIDS) { // LOG_INFO("playerbots", "Bot {} {}:{} <{}> was in grid {},{} on map {}", - // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), grid.x_coord, grid.y_coord, botPos.getMapId()); + // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + // bot->GetName(), grid.x_coord, grid.y_coord, botPos.getMapId()); return true; } - if (cell.GridX() > 0 && cell.GridY() > 0 && !MMAP::MMapFactory::createOrGetMMapMgr()->loadMap(botPos.getMapId(), cell.GridX(), cell.GridY())) + if (cell.GridX() > 0 && cell.GridY() > 0 && + !MMAP::MMapFactory::createOrGetMMapMgr()->loadMap(botPos.getMapId(), cell.GridX(), cell.GridY())) { // LOG_INFO("playerbots", "Bot {} {}:{} <{}> was in unloaded grid {},{} on map {}", - // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), grid.x_coord, grid.y_coord, botPos.getMapId()); + // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + // bot->GetName(), grid.x_coord, grid.y_coord, botPos.getMapId()); return true; } - LogCalculatedValue* posVal = dynamic_cast*>(context->GetUntypedValue("current position")); + LogCalculatedValue* posVal = + dynamic_cast*>(context->GetUntypedValue("current position")); if (posVal->LastChangeDelay() > 10 * MINUTE) { // LOG_INFO("playerbots", "Bot {} {}:{} <{}> was in the same position for {} seconds", - // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), posVal->LastChangeDelay()); + // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + // bot->GetName(), posVal->LastChangeDelay()); return true; } - MemoryCalculatedValue* expVal = dynamic_cast*>(context->GetUntypedValue("experience")); + MemoryCalculatedValue* expVal = + dynamic_cast*>(context->GetUntypedValue("experience")); if (expVal->LastChangeDelay() < 15 * MINUTE) return false; @@ -122,7 +134,8 @@ bool MoveLongStuckTrigger::IsActive() if (longLog) { // LOG_INFO("playerbots", "Bot {} {}:{} <{}> was in the same position for 15mins", - // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), posVal->LastChangeDelay()); + // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + // bot->GetName(), posVal->LastChangeDelay()); } return longLog; @@ -141,12 +154,14 @@ bool CombatStuckTrigger::IsActive() WorldPosition botPos(bot); - MemoryCalculatedValue* combatVal = dynamic_cast*>(context->GetUntypedValue("combat::self target")); + MemoryCalculatedValue* combatVal = + dynamic_cast*>(context->GetUntypedValue("combat::self target")); if (combatVal->LastChangeDelay() > 5 * MINUTE) { // LOG_INFO("playerbots", "Bot {} {}:{} <{}> was in combat for {} seconds", - // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), posVal->LastChangeDelay()); + // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + // bot->GetName(), posVal->LastChangeDelay()); return true; } @@ -167,12 +182,14 @@ bool CombatLongStuckTrigger::IsActive() WorldPosition botPos(bot); - MemoryCalculatedValue* combatVal = dynamic_cast*>(context->GetUntypedValue("combat::self target")); + MemoryCalculatedValue* combatVal = + dynamic_cast*>(context->GetUntypedValue("combat::self target")); if (combatVal->LastChangeDelay() > 15 * MINUTE) { // LOG_INFO("playerbots", "Bot {} {}:{} <{}> was in combat for {} seconds", - // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName(), posVal->LastChangeDelay()); + // bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), + // bot->GetName(), posVal->LastChangeDelay()); return true; } diff --git a/src/strategy/triggers/StuckTriggers.h b/src/strategy/triggers/StuckTriggers.h index 4246946c..62434a34 100644 --- a/src/strategy/triggers/StuckTriggers.h +++ b/src/strategy/triggers/StuckTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_STUCKTRIGGERS_H @@ -9,34 +10,34 @@ class MoveStuckTrigger : public Trigger { - public: - MoveStuckTrigger(PlayerbotAI* botAI) : Trigger(botAI, "move stuck", 5) { } +public: + MoveStuckTrigger(PlayerbotAI* botAI) : Trigger(botAI, "move stuck", 5) {} - bool IsActive() override; + bool IsActive() override; }; class MoveLongStuckTrigger : public Trigger { - public: - MoveLongStuckTrigger(PlayerbotAI* botAI) : Trigger(botAI, "move long stuck", 5) { } +public: + MoveLongStuckTrigger(PlayerbotAI* botAI) : Trigger(botAI, "move long stuck", 5) {} - bool IsActive() override; + bool IsActive() override; }; class CombatStuckTrigger : public Trigger { - public: - CombatStuckTrigger(PlayerbotAI* botAI) : Trigger(botAI, "combat stuck", 5) { } +public: + CombatStuckTrigger(PlayerbotAI* botAI) : Trigger(botAI, "combat stuck", 5) {} - bool IsActive() override; + bool IsActive() override; }; class CombatLongStuckTrigger : public Trigger { - public: - CombatLongStuckTrigger(PlayerbotAI* botAI) : Trigger(botAI, "combat long stuck", 5) { } +public: + CombatLongStuckTrigger(PlayerbotAI* botAI) : Trigger(botAI, "combat long stuck", 5) {} - bool IsActive() override; + bool IsActive() override; }; #endif diff --git a/src/strategy/triggers/TravelTriggers.cpp b/src/strategy/triggers/TravelTriggers.cpp index eda6b9bf..0aaa77a2 100644 --- a/src/strategy/triggers/TravelTriggers.cpp +++ b/src/strategy/triggers/TravelTriggers.cpp @@ -1,25 +1,21 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TravelTriggers.h" + #include "Playerbots.h" #include "ServerFacade.h" -bool NoTravelTargetTrigger::IsActive() -{ - return !context->GetValue("travel target")->Get()->isActive(); -} +bool NoTravelTargetTrigger::IsActive() { return !context->GetValue("travel target")->Get()->isActive(); } bool FarFromTravelTargetTrigger::IsActive() { return context->GetValue("travel target")->Get()->isTraveling(); } -bool NearDarkPortalTrigger::IsActive() -{ - return bot->GetAreaId() == 72; -} +bool NearDarkPortalTrigger::IsActive() { return bot->GetAreaId() == 72; } bool AtDarkPortalAzerothTrigger::IsActive() { diff --git a/src/strategy/triggers/TravelTriggers.h b/src/strategy/triggers/TravelTriggers.h index d467a239..b1874be9 100644 --- a/src/strategy/triggers/TravelTriggers.h +++ b/src/strategy/triggers/TravelTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TRAVELTRIGGERS_H @@ -11,42 +12,42 @@ class PlayerbotAI; class NoTravelTargetTrigger : public Trigger { - public: - NoTravelTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no travel target") { } +public: + NoTravelTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "no travel target") {} - bool IsActive() override; + bool IsActive() override; }; class FarFromTravelTargetTrigger : public Trigger { - public: - FarFromTravelTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "far from travel target") { } +public: + FarFromTravelTargetTrigger(PlayerbotAI* botAI) : Trigger(botAI, "far from travel target") {} - bool IsActive() override; + bool IsActive() override; }; class NearDarkPortalTrigger : public Trigger { - public: - NearDarkPortalTrigger(PlayerbotAI* botAI) : Trigger(botAI, "near dark portal", 10) { } +public: + NearDarkPortalTrigger(PlayerbotAI* botAI) : Trigger(botAI, "near dark portal", 10) {} - virtual bool IsActive(); + virtual bool IsActive(); }; class AtDarkPortalAzerothTrigger : public Trigger { - public: - AtDarkPortalAzerothTrigger(PlayerbotAI* botAI) : Trigger(botAI, "at dark portal azeroth", 10) { } +public: + AtDarkPortalAzerothTrigger(PlayerbotAI* botAI) : Trigger(botAI, "at dark portal azeroth", 10) {} - bool IsActive() override; + bool IsActive() override; }; class AtDarkPortalOutlandTrigger : public Trigger { - public: - AtDarkPortalOutlandTrigger(PlayerbotAI* botAI) : Trigger(botAI, "at dark portal outland", 10) { } +public: + AtDarkPortalOutlandTrigger(PlayerbotAI* botAI) : Trigger(botAI, "at dark portal outland", 10) {} - bool IsActive() override; + bool IsActive() override; }; #endif diff --git a/src/strategy/triggers/TriggerContext.h b/src/strategy/triggers/TriggerContext.h index df04b983..e0b7ce99 100644 --- a/src/strategy/triggers/TriggerContext.h +++ b/src/strategy/triggers/TriggerContext.h @@ -1,354 +1,384 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TRIGGERCONTEXT_H #define _PLAYERBOT_TRIGGERCONTEXT_H -#include "GenericTriggers.h" #include "CureTriggers.h" +#include "GenericTriggers.h" #include "GuildTriggers.h" -#include "LootTriggers.h" #include "LfgTriggers.h" +#include "LootTriggers.h" +#include "NamedObjectContext.h" #include "PvpTriggers.h" +#include "RaidNaxxTriggers.h" #include "RpgTriggers.h" #include "RtiTriggers.h" #include "StuckTriggers.h" #include "TravelTriggers.h" -#include "NamedObjectContext.h" -#include "RaidNaxxTriggers.h" class PlayerbotAI; class TriggerContext : public NamedObjectContext { - public: - TriggerContext() - { - creators["return"] = &TriggerContext::_return; - creators["sit"] = &TriggerContext::sit; - creators["collision"] = &TriggerContext::collision; +public: + TriggerContext() + { + creators["return"] = &TriggerContext::_return; + creators["sit"] = &TriggerContext::sit; + creators["collision"] = &TriggerContext::collision; - creators["timer"] = &TriggerContext::Timer; - creators["random"] = &TriggerContext::Random; - creators["seldom"] = &TriggerContext::seldom; - creators["often"] = &TriggerContext::often; + creators["timer"] = &TriggerContext::Timer; + creators["random"] = &TriggerContext::Random; + creators["seldom"] = &TriggerContext::seldom; + creators["often"] = &TriggerContext::often; - creators["target critical health"] = &TriggerContext::TargetCriticalHealth; + creators["target critical health"] = &TriggerContext::TargetCriticalHealth; - creators["critical health"] = &TriggerContext::CriticalHealth; - creators["low health"] = &TriggerContext::LowHealth; - creators["medium health"] = &TriggerContext::MediumHealth; - creators["almost full health"] = &TriggerContext::AlmostFullHealth; + creators["critical health"] = &TriggerContext::CriticalHealth; + creators["low health"] = &TriggerContext::LowHealth; + creators["medium health"] = &TriggerContext::MediumHealth; + creators["almost full health"] = &TriggerContext::AlmostFullHealth; - creators["low mana"] = &TriggerContext::LowMana; - creators["medium mana"] = &TriggerContext::MediumMana; - creators["high mana"] = &TriggerContext::HighMana; - creators["almost full mana"] = &TriggerContext::AlmostFullMana; - creators["enough mana"] = &TriggerContext::EnoughMana; + creators["low mana"] = &TriggerContext::LowMana; + creators["medium mana"] = &TriggerContext::MediumMana; + creators["high mana"] = &TriggerContext::HighMana; + creators["almost full mana"] = &TriggerContext::AlmostFullMana; + creators["enough mana"] = &TriggerContext::EnoughMana; - creators["party member critical health"] = &TriggerContext::PartyMemberCriticalHealth; - creators["party member low health"] = &TriggerContext::PartyMemberLowHealth; - creators["party member medium health"] = &TriggerContext::PartyMemberMediumHealth; - creators["party member almost full health"] = &TriggerContext::PartyMemberAlmostFullHealth; + creators["party member critical health"] = &TriggerContext::PartyMemberCriticalHealth; + creators["party member low health"] = &TriggerContext::PartyMemberLowHealth; + creators["party member medium health"] = &TriggerContext::PartyMemberMediumHealth; + creators["party member almost full health"] = &TriggerContext::PartyMemberAlmostFullHealth; - creators["protect party member"] = &TriggerContext::protect_party_member; + creators["protect party member"] = &TriggerContext::protect_party_member; - creators["light rage available"] = &TriggerContext::LightRageAvailable; - creators["medium rage available"] = &TriggerContext::MediumRageAvailable; - creators["high rage available"] = &TriggerContext::HighRageAvailable; + creators["light rage available"] = &TriggerContext::LightRageAvailable; + creators["medium rage available"] = &TriggerContext::MediumRageAvailable; + creators["high rage available"] = &TriggerContext::HighRageAvailable; - creators["light energy available"] = &TriggerContext::LightEnergyAvailable; - creators["medium energy available"] = &TriggerContext::MediumEnergyAvailable; - creators["high energy available"] = &TriggerContext::HighEnergyAvailable; + creators["light energy available"] = &TriggerContext::LightEnergyAvailable; + creators["medium energy available"] = &TriggerContext::MediumEnergyAvailable; + creators["high energy available"] = &TriggerContext::HighEnergyAvailable; - creators["loot available"] = &TriggerContext::LootAvailable; - creators["no attackers"] = &TriggerContext::NoAttackers; - creators["no target"] = &TriggerContext::NoTarget; - creators["target in sight"] = &TriggerContext::TargetInSight; - creators["not dps target active"] = &TriggerContext::not_dps_target_active; - creators["not dps aoe target active"] = &TriggerContext::not_dps_aoe_target_active; - creators["has nearest adds"] = &TriggerContext::has_nearest_adds; - creators["enemy player near"] = &TriggerContext::enemy_player_near; + creators["loot available"] = &TriggerContext::LootAvailable; + creators["no attackers"] = &TriggerContext::NoAttackers; + creators["no target"] = &TriggerContext::NoTarget; + creators["target in sight"] = &TriggerContext::TargetInSight; + creators["not dps target active"] = &TriggerContext::not_dps_target_active; + creators["not dps aoe target active"] = &TriggerContext::not_dps_aoe_target_active; + creators["has nearest adds"] = &TriggerContext::has_nearest_adds; + creators["enemy player near"] = &TriggerContext::enemy_player_near; - creators["tank assist"] = &TriggerContext::TankAssist; - creators["lose aggro"] = &TriggerContext::LoseAggro; - creators["has aggro"] = &TriggerContext::HasAggro; + creators["tank assist"] = &TriggerContext::TankAssist; + creators["lose aggro"] = &TriggerContext::LoseAggro; + creators["has aggro"] = &TriggerContext::HasAggro; - creators["light aoe"] = &TriggerContext::LightAoe; - creators["medium aoe"] = &TriggerContext::MediumAoe; - creators["high aoe"] = &TriggerContext::HighAoe; + creators["light aoe"] = &TriggerContext::LightAoe; + creators["medium aoe"] = &TriggerContext::MediumAoe; + creators["high aoe"] = &TriggerContext::HighAoe; - creators["has area debuff"] = &TriggerContext::HasAreaDebuff; + creators["has area debuff"] = &TriggerContext::HasAreaDebuff; - creators["enemy out of melee"] = &TriggerContext::EnemyOutOfMelee; - creators["enemy out of spell"] = &TriggerContext::EnemyOutOfSpell; - creators["enemy too close for spell"] = &TriggerContext::enemy_too_close_for_spell; - creators["enemy too close for shoot"] = &TriggerContext::enemy_too_close_for_shoot; - creators["enemy too close for auto shot"] = &TriggerContext::enemy_too_close_for_auto_shot; - creators["enemy too close for melee"] = &TriggerContext::enemy_too_close_for_melee; - creators["enemy is close"] = &TriggerContext::enemy_is_close; - creators["enemy within melee"] = &TriggerContext::enemy_within_melee; - creators["party member to heal out of spell range"] = &TriggerContext::party_member_to_heal_out_of_spell_range; + creators["enemy out of melee"] = &TriggerContext::EnemyOutOfMelee; + creators["enemy out of spell"] = &TriggerContext::EnemyOutOfSpell; + creators["enemy too close for spell"] = &TriggerContext::enemy_too_close_for_spell; + creators["enemy too close for shoot"] = &TriggerContext::enemy_too_close_for_shoot; + creators["enemy too close for auto shot"] = &TriggerContext::enemy_too_close_for_auto_shot; + creators["enemy too close for melee"] = &TriggerContext::enemy_too_close_for_melee; + creators["enemy is close"] = &TriggerContext::enemy_is_close; + creators["enemy within melee"] = &TriggerContext::enemy_within_melee; + creators["party member to heal out of spell range"] = &TriggerContext::party_member_to_heal_out_of_spell_range; - creators["combo points available"] = &TriggerContext::ComboPointsAvailable; - creators["combo points 3 available"] = &TriggerContext::ComboPoints3Available; + creators["combo points available"] = &TriggerContext::ComboPointsAvailable; + creators["combo points 3 available"] = &TriggerContext::ComboPoints3Available; - creators["medium threat"] = &TriggerContext::MediumThreat; + creators["medium threat"] = &TriggerContext::MediumThreat; - creators["dead"] = &TriggerContext::Dead; - creators["corpse near"] = &TriggerContext::corpse_near; - creators["party member dead"] = &TriggerContext::PartyMemberDead; - creators["combat party member dead"] = &TriggerContext::CombatPartyMemberDead; - creators["no pet"] = &TriggerContext::no_pet; - creators["has pet"] = &TriggerContext::has_pet; - creators["pet attack"] = &TriggerContext::pet_attack; - - creators["has attackers"] = &TriggerContext::has_attackers; - creators["no possible targets"] = &TriggerContext::no_possible_targets; - creators["possible adds"] = &TriggerContext::possible_adds; + creators["dead"] = &TriggerContext::Dead; + creators["corpse near"] = &TriggerContext::corpse_near; + creators["party member dead"] = &TriggerContext::PartyMemberDead; + creators["combat party member dead"] = &TriggerContext::CombatPartyMemberDead; + creators["no pet"] = &TriggerContext::no_pet; + creators["has pet"] = &TriggerContext::has_pet; + creators["pet attack"] = &TriggerContext::pet_attack; - creators["no drink"] = &TriggerContext::no_drink; - creators["no food"] = &TriggerContext::no_food; + creators["has attackers"] = &TriggerContext::has_attackers; + creators["no possible targets"] = &TriggerContext::no_possible_targets; + creators["possible adds"] = &TriggerContext::possible_adds; - creators["panic"] = &TriggerContext::panic; - creators["outnumbered"] = &TriggerContext::outnumbered; - creators["behind target"] = &TriggerContext::behind_target; - creators["not behind target"] = &TriggerContext::not_behind_target; - creators["not facing target"] = &TriggerContext::not_facing_target; - creators["far from master"] = &TriggerContext::far_from_master; - creators["far from loot target"] = &TriggerContext::far_from_loot_target; - creators["can loot"] = &TriggerContext::can_loot; - creators["swimming"] = &TriggerContext::swimming; - creators["target changed"] = &TriggerContext::target_changed; + creators["no drink"] = &TriggerContext::no_drink; + creators["no food"] = &TriggerContext::no_food; - creators["critical aoe heal"] = &TriggerContext::critical_aoe_heal; - creators["low aoe heal"] = &TriggerContext::low_aoe_heal; - creators["medium aoe heal"] = &TriggerContext::medium_aoe_heal; - creators["almost full aoe heal"] = &TriggerContext::almost_full_aoe_heal; + creators["panic"] = &TriggerContext::panic; + creators["outnumbered"] = &TriggerContext::outnumbered; + creators["behind target"] = &TriggerContext::behind_target; + creators["not behind target"] = &TriggerContext::not_behind_target; + creators["not facing target"] = &TriggerContext::not_facing_target; + creators["far from master"] = &TriggerContext::far_from_master; + creators["far from loot target"] = &TriggerContext::far_from_loot_target; + creators["can loot"] = &TriggerContext::can_loot; + creators["swimming"] = &TriggerContext::swimming; + creators["target changed"] = &TriggerContext::target_changed; - creators["group heal occasion"] = &TriggerContext::group_heal_occasion; - creators["medium group heal occasion"] = &TriggerContext::medium_group_heal_occasion; - creators["invalid target"] = &TriggerContext::invalid_target; - creators["lfg proposal active"] = &TriggerContext::lfg_proposal_active; + creators["critical aoe heal"] = &TriggerContext::critical_aoe_heal; + creators["low aoe heal"] = &TriggerContext::low_aoe_heal; + creators["medium aoe heal"] = &TriggerContext::medium_aoe_heal; + creators["almost full aoe heal"] = &TriggerContext::almost_full_aoe_heal; - creators["unknown dungeon"] = &TriggerContext::unknown_dungeon; + creators["group heal occasion"] = &TriggerContext::group_heal_occasion; + creators["medium group heal occasion"] = &TriggerContext::medium_group_heal_occasion; + creators["invalid target"] = &TriggerContext::invalid_target; + creators["lfg proposal active"] = &TriggerContext::lfg_proposal_active; - creators["random bot update"] = &TriggerContext::random_bot_update_trigger; - creators["no non bot players around"] = &TriggerContext::no_non_bot_players_around; - creators["new player nearby"] = &TriggerContext::new_player_nearby; - creators["no rpg target"] = &TriggerContext::no_rpg_target; - creators["has rpg target"] = &TriggerContext::has_rpg_target; - creators["far from rpg target"] = &TriggerContext::far_from_rpg_target; - creators["near rpg target"] = &TriggerContext::near_rpg_target; - creators["no travel target"] = &TriggerContext::no_travel_target; - creators["far from travel target"] = &TriggerContext::far_from_travel_target; - creators["no rti target"] = &TriggerContext::no_rti; + creators["unknown dungeon"] = &TriggerContext::unknown_dungeon; - creators["give food"] = &TriggerContext::give_food; - creators["give water"] = &TriggerContext::give_water; + creators["random bot update"] = &TriggerContext::random_bot_update_trigger; + creators["no non bot players around"] = &TriggerContext::no_non_bot_players_around; + creators["new player nearby"] = &TriggerContext::new_player_nearby; + creators["no rpg target"] = &TriggerContext::no_rpg_target; + creators["has rpg target"] = &TriggerContext::has_rpg_target; + creators["far from rpg target"] = &TriggerContext::far_from_rpg_target; + creators["near rpg target"] = &TriggerContext::near_rpg_target; + creators["no travel target"] = &TriggerContext::no_travel_target; + creators["far from travel target"] = &TriggerContext::far_from_travel_target; + creators["no rti target"] = &TriggerContext::no_rti; - creators["bg waiting"] = &TriggerContext::bg_waiting; - creators["bg active"] = &TriggerContext::bg_active; - creators["bg invite active"] = &TriggerContext::bg_invite_active; - creators["inside bg"] = &TriggerContext::inside_bg; - creators["player has no flag"] = &TriggerContext::player_has_no_flag; - creators["player has flag"] = &TriggerContext::player_has_flag; - creators["team has flag"] = &TriggerContext::team_has_flag; - creators["enemy team has flag"] = &TriggerContext::enemy_team_has_flag; - creators["enemy flagcarrier near"] = &TriggerContext::enemy_flagcarrier_near; - creators["in Battleground"] = &TriggerContext::player_is_in_BATTLEGROUND; - creators["in Battleground without flag"] = &TriggerContext::player_is_in_BATTLEGROUND_no_flag; - creators["wants in bg"] = &TriggerContext::player_wants_in_bg; + creators["give food"] = &TriggerContext::give_food; + creators["give water"] = &TriggerContext::give_water; - creators["mounted"] = &TriggerContext::mounted; + creators["bg waiting"] = &TriggerContext::bg_waiting; + creators["bg active"] = &TriggerContext::bg_active; + creators["bg invite active"] = &TriggerContext::bg_invite_active; + creators["inside bg"] = &TriggerContext::inside_bg; + creators["player has no flag"] = &TriggerContext::player_has_no_flag; + creators["player has flag"] = &TriggerContext::player_has_flag; + creators["team has flag"] = &TriggerContext::team_has_flag; + creators["enemy team has flag"] = &TriggerContext::enemy_team_has_flag; + creators["enemy flagcarrier near"] = &TriggerContext::enemy_flagcarrier_near; + creators["in Battleground"] = &TriggerContext::player_is_in_BATTLEGROUND; + creators["in Battleground without flag"] = &TriggerContext::player_is_in_BATTLEGROUND_no_flag; + creators["wants in bg"] = &TriggerContext::player_wants_in_bg; - // move to/enter dark portal if near - creators["near dark portal"] = &TriggerContext::near_dark_portal; - creators["at dark portal azeroth"] = &TriggerContext::at_dark_portal_azeroth; - creators["at dark portal outland"] = &TriggerContext::at_dark_portal_outland; + creators["mounted"] = &TriggerContext::mounted; - creators["vehicle near"] = &TriggerContext::vehicle_near; - creators["in vehicle"] = &TriggerContext::in_vehicle; + // move to/enter dark portal if near + creators["near dark portal"] = &TriggerContext::near_dark_portal; + creators["at dark portal azeroth"] = &TriggerContext::at_dark_portal_azeroth; + creators["at dark portal outland"] = &TriggerContext::at_dark_portal_outland; - creators["need world buff"] = &TriggerContext::need_world_buff; - creators["falling"] = &TriggerContext::falling; - creators["falling far"] = &TriggerContext::falling_far; - creators["move stuck"] = &TriggerContext::move_stuck; - creators["move long stuck"] = &TriggerContext::move_long_stuck; - creators["combat stuck"] = &TriggerContext::combat_stuck; - creators["combat long stuck"] = &TriggerContext::combat_long_stuck; + creators["vehicle near"] = &TriggerContext::vehicle_near; + creators["in vehicle"] = &TriggerContext::in_vehicle; - creators["petition signed"] = &TriggerContext::petition_signed; - creators["buy tabard"] = &TriggerContext::buy_tabard; - creators["leave large guild"] = &TriggerContext::leave_large_guild; + creators["need world buff"] = &TriggerContext::need_world_buff; + creators["falling"] = &TriggerContext::falling; + creators["falling far"] = &TriggerContext::falling_far; + creators["move stuck"] = &TriggerContext::move_stuck; + creators["move long stuck"] = &TriggerContext::move_long_stuck; + creators["combat stuck"] = &TriggerContext::combat_stuck; + creators["combat long stuck"] = &TriggerContext::combat_long_stuck; - creators["rpg"] = &TriggerContext::rpg; - creators["rpg taxi"] = &TriggerContext::rpg_taxi; - creators["rpg discover"] = &TriggerContext::rpg_discover; - creators["rpg start quest"] = &TriggerContext::rpg_start_quest; - creators["rpg end quest"] = &TriggerContext::rpg_end_quest; - creators["rpg buy"] = &TriggerContext::rpg_buy; - creators["rpg sell"] = &TriggerContext::rpg_sell; - creators["rpg repair"] = &TriggerContext::rpg_repair; - creators["rpg train"] = &TriggerContext::rpg_train; - creators["rpg heal"] = &TriggerContext::rpg_heal; - creators["rpg home bind"] = &TriggerContext::rpg_home_bind; - creators["rpg queue bg"] = &TriggerContext::rpg_queue_bg; - creators["rpg buy petition"] = &TriggerContext::rpg_buy_petition; - creators["rpg use"] = &TriggerContext::rpg_use; - creators["rpg spell"] = &TriggerContext::rpg_spell; - creators["rpg craft"] = &TriggerContext::rpg_craft; - creators["rpg trade useful"] = &TriggerContext::rpg_trade_useful; - creators["rpg duel"] = &TriggerContext::rpg_duel; - } + creators["petition signed"] = &TriggerContext::petition_signed; + creators["buy tabard"] = &TriggerContext::buy_tabard; + creators["leave large guild"] = &TriggerContext::leave_large_guild; - private: - static Trigger* give_food(PlayerbotAI* botAI) { return new GiveFoodTrigger(botAI); } - static Trigger* give_water(PlayerbotAI* botAI) { return new GiveWaterTrigger(botAI); } - static Trigger* no_rti(PlayerbotAI* botAI) { return new NoRtiTrigger(botAI); } - static Trigger* _return(PlayerbotAI* botAI) { return new ReturnTrigger(botAI); } - static Trigger* sit(PlayerbotAI* botAI) { return new SitTrigger(botAI); } - static Trigger* far_from_rpg_target(PlayerbotAI* botAI) { return new FarFromRpgTargetTrigger(botAI); } - static Trigger* near_rpg_target(PlayerbotAI* botAI) { return new NearRpgTargetTrigger(botAI); } - static Trigger* far_from_travel_target(PlayerbotAI* botAI) { return new FarFromTravelTargetTrigger(botAI); } - static Trigger* no_travel_target(PlayerbotAI* botAI) { return new NoTravelTargetTrigger(botAI); } - static Trigger* no_rpg_target(PlayerbotAI* botAI) { return new NoRpgTargetTrigger(botAI); } - static Trigger* has_rpg_target(PlayerbotAI* botAI) { return new HasRpgTargetTrigger(botAI); } - static Trigger* collision(PlayerbotAI* botAI) { return new CollisionTrigger(botAI); } - static Trigger* lfg_proposal_active(PlayerbotAI* botAI) { return new LfgProposalActiveTrigger(botAI); } - static Trigger* unknown_dungeon(PlayerbotAI* botAI) { return new UnknownDungeonTrigger(botAI); } - static Trigger* invalid_target(PlayerbotAI* botAI) { return new InvalidTargetTrigger(botAI); } - static Trigger* critical_aoe_heal(PlayerbotAI* botAI) { return new AoeHealTrigger(botAI, "critical aoe heal", "critical", 2); } - static Trigger* low_aoe_heal(PlayerbotAI* botAI) { return new AoeHealTrigger(botAI, "low aoe heal", "low", 2); } - static Trigger* medium_aoe_heal(PlayerbotAI* botAI) { return new AoeHealTrigger(botAI, "medium aoe heal", "medium", 2); } - static Trigger* almost_full_aoe_heal(PlayerbotAI* botAI) { return new AoeHealTrigger(botAI, "almost full aoe heal", "almost full", 2); } - static Trigger* group_heal_occasion(PlayerbotAI* ai) { return new AoeInGroupTrigger(ai, "group heal occasion", "almost full", 0.6); } - static Trigger* medium_group_heal_occasion(PlayerbotAI* ai) { return new AoeInGroupTrigger(ai, "group heal occasion", "medium", 0.4); } - static Trigger* target_changed(PlayerbotAI* botAI) { return new TargetChangedTrigger(botAI); } - static Trigger* swimming(PlayerbotAI* botAI) { return new IsSwimmingTrigger(botAI); } - static Trigger* no_possible_targets(PlayerbotAI* botAI) { return new NoPossibleTargetsTrigger(botAI); } - static Trigger* possible_adds(PlayerbotAI* botAI) { return new PossibleAddsTrigger(botAI); } - static Trigger* can_loot(PlayerbotAI* botAI) { return new CanLootTrigger(botAI); } - static Trigger* far_from_loot_target(PlayerbotAI* botAI) { return new FarFromCurrentLootTrigger(botAI); } - static Trigger* far_from_master(PlayerbotAI* botAI) { return new FarFromMasterTrigger(botAI); } - static Trigger* behind_target(PlayerbotAI* botAI) { return new IsBehindTargetTrigger(botAI); } - static Trigger* not_behind_target(PlayerbotAI* botAI) { return new IsNotBehindTargetTrigger(botAI); } - static Trigger* not_facing_target(PlayerbotAI* botAI) { return new IsNotFacingTargetTrigger(botAI); } - static Trigger* panic(PlayerbotAI* botAI) { return new PanicTrigger(botAI); } - static Trigger* outnumbered(PlayerbotAI* botAI) { return new OutNumberedTrigger(botAI); } - static Trigger* no_drink(PlayerbotAI* botAI) { return new NoDrinkTrigger(botAI); } - static Trigger* no_food(PlayerbotAI* botAI) { return new NoFoodTrigger(botAI); } - static Trigger* LightAoe(PlayerbotAI* botAI) { return new LightAoeTrigger(botAI); } - static Trigger* MediumAoe(PlayerbotAI* botAI) { return new MediumAoeTrigger(botAI); } - static Trigger* HighAoe(PlayerbotAI* botAI) { return new HighAoeTrigger(botAI); } - static Trigger* HasAreaDebuff(PlayerbotAI* botAI) { return new HasAreaDebuffTrigger(botAI); } - static Trigger* LoseAggro(PlayerbotAI* botAI) { return new LoseAggroTrigger(botAI); } - static Trigger* HasAggro(PlayerbotAI* botAI) { return new HasAggroTrigger(botAI); } - static Trigger* LowHealth(PlayerbotAI* botAI) { return new LowHealthTrigger(botAI); } - static Trigger* MediumHealth(PlayerbotAI* botAI) { return new MediumHealthTrigger(botAI); } - static Trigger* AlmostFullHealth(PlayerbotAI* botAI) { return new AlmostFullHealthTrigger(botAI); } - static Trigger* CriticalHealth(PlayerbotAI* botAI) { return new CriticalHealthTrigger(botAI); } - static Trigger* TargetCriticalHealth(PlayerbotAI* botAI) { return new TargetCriticalHealthTrigger(botAI); } - static Trigger* LowMana(PlayerbotAI* botAI) { return new LowManaTrigger(botAI); } - static Trigger* MediumMana(PlayerbotAI* botAI) { return new MediumManaTrigger(botAI); } - static Trigger* HighMana(PlayerbotAI* botAI) { return new HighManaTrigger(botAI); } - static Trigger* AlmostFullMana(PlayerbotAI* botAI) { return new AlmostFullManaTrigger(botAI); } - static Trigger* EnoughMana(PlayerbotAI* botAI) { return new EnoughManaTrigger(botAI); } - static Trigger* LightRageAvailable(PlayerbotAI* botAI) { return new LightRageAvailableTrigger(botAI); } - static Trigger* MediumRageAvailable(PlayerbotAI* botAI) { return new MediumRageAvailableTrigger(botAI); } - static Trigger* HighRageAvailable(PlayerbotAI* botAI) { return new HighRageAvailableTrigger(botAI); } - static Trigger* LightEnergyAvailable(PlayerbotAI* botAI) { return new LightEnergyAvailableTrigger(botAI); } - static Trigger* MediumEnergyAvailable(PlayerbotAI* botAI) { return new MediumEnergyAvailableTrigger(botAI); } - static Trigger* HighEnergyAvailable(PlayerbotAI* botAI) { return new HighEnergyAvailableTrigger(botAI); } - static Trigger* LootAvailable(PlayerbotAI* botAI) { return new LootAvailableTrigger(botAI); } - static Trigger* NoAttackers(PlayerbotAI* botAI) { return new NoAttackersTrigger(botAI); } - static Trigger* TankAssist(PlayerbotAI* botAI) { return new TankAssistTrigger(botAI); } - static Trigger* Timer(PlayerbotAI* botAI) { return new TimerTrigger(botAI); } - static Trigger* NoTarget(PlayerbotAI* botAI) { return new NoTargetTrigger(botAI); } - static Trigger* TargetInSight(PlayerbotAI* botAI) { return new TargetInSightTrigger(botAI); } - static Trigger* not_dps_target_active(PlayerbotAI* botAI) { return new NotDpsTargetActiveTrigger(botAI); } - static Trigger* not_dps_aoe_target_active(PlayerbotAI* botAI) { return new NotDpsAoeTargetActiveTrigger(botAI); } - static Trigger* has_nearest_adds(PlayerbotAI* botAI) { return new HasNearestAddsTrigger(botAI); } - static Trigger* enemy_player_near(PlayerbotAI* botAI) { return new EnemyPlayerNear(botAI); } - static Trigger* Random(PlayerbotAI* botAI) { return new RandomTrigger(botAI, "random", 20); } - static Trigger* seldom(PlayerbotAI* botAI) { return new RandomTrigger(botAI, "seldom", 300); } - static Trigger* often(PlayerbotAI* botAI) { return new RandomTrigger(botAI, "often", 5); } - static Trigger* EnemyOutOfMelee(PlayerbotAI* botAI) { return new EnemyOutOfMeleeTrigger(botAI); } - static Trigger* EnemyOutOfSpell(PlayerbotAI* botAI) { return new EnemyOutOfSpellRangeTrigger(botAI); } - static Trigger* enemy_too_close_for_spell(PlayerbotAI* botAI) { return new EnemyTooCloseForSpellTrigger(botAI); } - static Trigger* enemy_too_close_for_auto_shot(PlayerbotAI* botAI) { return new EnemyTooCloseForAutoShotTrigger(botAI); } - static Trigger* enemy_too_close_for_shoot(PlayerbotAI* botAI) { return new EnemyTooCloseForShootTrigger(botAI); } - static Trigger* enemy_too_close_for_melee(PlayerbotAI* botAI) { return new EnemyTooCloseForMeleeTrigger(botAI); } - static Trigger* enemy_is_close(PlayerbotAI* botAI) { return new EnemyIsCloseTrigger(botAI); } - static Trigger* enemy_within_melee(PlayerbotAI* botAI) { return new EnemyWithinMeleeTrigger(botAI); } - static Trigger* party_member_to_heal_out_of_spell_range(PlayerbotAI* botAI) { return new PartyMemberToHealOutOfSpellRangeTrigger(botAI); } - static Trigger* ComboPointsAvailable(PlayerbotAI* botAI) { return new ComboPointsAvailableTrigger(botAI); } - static Trigger* ComboPoints3Available(PlayerbotAI* botAI) { return new ComboPointsAvailableTrigger(botAI, 3); } - static Trigger* MediumThreat(PlayerbotAI* botAI) { return new MediumThreatTrigger(botAI); } - static Trigger* Dead(PlayerbotAI* botAI) { return new DeadTrigger(botAI); } - static Trigger* corpse_near(PlayerbotAI* botAI) { return new CorpseNearTrigger(botAI); } - static Trigger* PartyMemberDead(PlayerbotAI* botAI) { return new PartyMemberDeadTrigger(botAI); } - static Trigger* CombatPartyMemberDead(PlayerbotAI* botAI) { return new CombatPartyMemberDeadTrigger(botAI); } - static Trigger* PartyMemberLowHealth(PlayerbotAI* botAI) { return new PartyMemberLowHealthTrigger(botAI); } - static Trigger* PartyMemberMediumHealth(PlayerbotAI* botAI) { return new PartyMemberMediumHealthTrigger(botAI); } - static Trigger* PartyMemberAlmostFullHealth(PlayerbotAI* botAI) { return new PartyMemberAlmostFullHealthTrigger(botAI); } - static Trigger* PartyMemberCriticalHealth(PlayerbotAI* botAI) { return new PartyMemberCriticalHealthTrigger(botAI); } - static Trigger* protect_party_member(PlayerbotAI* botAI) { return new ProtectPartyMemberTrigger(botAI); } - static Trigger* no_pet(PlayerbotAI* botAI) { return new NoPetTrigger(botAI); } - static Trigger* has_pet(PlayerbotAI* botAI) { return new HasPetTrigger(botAI); } - static Trigger* pet_attack(PlayerbotAI* botAI) { return new PetAttackTrigger(botAI); } - static Trigger* has_attackers(PlayerbotAI* botAI) { return new HasAttackersTrigger(botAI); } - static Trigger* random_bot_update_trigger(PlayerbotAI* botAI) { return new RandomBotUpdateTrigger(botAI); } - static Trigger* no_non_bot_players_around(PlayerbotAI* botAI) { return new NoNonBotPlayersAroundTrigger(botAI); } - static Trigger* new_player_nearby(PlayerbotAI* botAI) { return new NewPlayerNearbyTrigger(botAI); } - static Trigger* bg_waiting(PlayerbotAI* botAI) { return new BgWaitingTrigger(botAI); } - static Trigger* bg_active(PlayerbotAI* botAI) { return new BgActiveTrigger(botAI); } - static Trigger* bg_invite_active(PlayerbotAI* botAI) { return new BgInviteActiveTrigger(botAI); } - static Trigger* inside_bg(PlayerbotAI* botAI) { return new InsideBGTrigger(botAI); } - static Trigger* player_has_no_flag(PlayerbotAI* botAI) { return new PlayerHasNoFlag(botAI); } - static Trigger* player_has_flag(PlayerbotAI* botAI) { return new PlayerHasFlag(botAI); } - static Trigger* team_has_flag(PlayerbotAI* botAI) { return new TeamHasFlag(botAI); } - static Trigger* enemy_team_has_flag(PlayerbotAI* botAI) { return new EnemyTeamHasFlag(botAI); } - static Trigger* enemy_flagcarrier_near(PlayerbotAI* botAI) { return new EnemyFlagCarrierNear(botAI); } - static Trigger* player_is_in_BATTLEGROUND(PlayerbotAI* botAI) { return new PlayerIsInBattleground(botAI); } - static Trigger* player_is_in_BATTLEGROUND_no_flag(PlayerbotAI* botAI) { return new PlayerIsInBattlegroundWithoutFlag(botAI); } - static Trigger* mounted(PlayerbotAI* botAI) { return new IsMountedTrigger(botAI); } - static Trigger* at_dark_portal_outland(PlayerbotAI* botAI) { return new AtDarkPortalOutlandTrigger(botAI); } - static Trigger* at_dark_portal_azeroth(PlayerbotAI* botAI) { return new AtDarkPortalAzerothTrigger(botAI); } - static Trigger* in_vehicle(PlayerbotAI* botAI) { return new InVehicleTrigger(botAI); } - static Trigger* vehicle_near(PlayerbotAI* botAI) { return new VehicleNearTrigger(botAI); } - static Trigger* near_dark_portal(PlayerbotAI* botAI) { return new NearDarkPortalTrigger(botAI); } - static Trigger* need_world_buff(PlayerbotAI* botAI) { return new NeedWorldBuffTrigger(botAI); } - static Trigger* falling(PlayerbotAI* botAI) { return new IsFallingTrigger(botAI); } - static Trigger* falling_far(PlayerbotAI* botAI) { return new IsFallingFarTrigger(botAI); } - static Trigger* move_stuck(PlayerbotAI* botAI) { return new MoveStuckTrigger(botAI); } - static Trigger* move_long_stuck(PlayerbotAI* botAI) { return new MoveLongStuckTrigger(botAI); } - static Trigger* combat_stuck(PlayerbotAI* botAI) { return new CombatStuckTrigger(botAI); } - static Trigger* combat_long_stuck(PlayerbotAI* botAI) { return new CombatLongStuckTrigger(botAI); } - static Trigger* player_wants_in_bg(PlayerbotAI* botAI) { return new PlayerWantsInBattlegroundTrigger(botAI); } - static Trigger* petition_signed(PlayerbotAI* botAI) { return new PetitionTurnInTrigger(botAI); } - static Trigger* buy_tabard(PlayerbotAI* botAI) { return new BuyTabardTrigger(botAI); } - static Trigger* leave_large_guild(PlayerbotAI* botAI) { return new LeaveLargeGuildTrigger(botAI); } - static Trigger* rpg(PlayerbotAI* botAI) { return new RpgTrigger(botAI); } - static Trigger* rpg_taxi(PlayerbotAI* botAI) { return new RpgTaxiTrigger(botAI); } - static Trigger* rpg_discover(PlayerbotAI* botAI) { return new RpgDiscoverTrigger(botAI); } - static Trigger* rpg_start_quest(PlayerbotAI* botAI) { return new RpgStartQuestTrigger(botAI); } - static Trigger* rpg_end_quest(PlayerbotAI* botAI) { return new RpgEndQuestTrigger(botAI); } - static Trigger* rpg_buy(PlayerbotAI* botAI) { return new RpgBuyTrigger(botAI); } - static Trigger* rpg_sell(PlayerbotAI* botAI) { return new RpgSellTrigger(botAI); } - static Trigger* rpg_repair(PlayerbotAI* botAI) { return new RpgRepairTrigger(botAI); } - static Trigger* rpg_train(PlayerbotAI* botAI) { return new RpgTrainTrigger(botAI); } - static Trigger* rpg_heal(PlayerbotAI* botAI) { return new RpgHealTrigger(botAI); } - static Trigger* rpg_home_bind(PlayerbotAI* botAI) { return new RpgHomeBindTrigger(botAI); } - static Trigger* rpg_queue_bg(PlayerbotAI* botAI) { return new RpgQueueBGTrigger(botAI); } - static Trigger* rpg_buy_petition(PlayerbotAI* botAI) { return new RpgBuyPetitionTrigger(botAI); } - static Trigger* rpg_use(PlayerbotAI* botAI) { return new RpgUseTrigger(botAI); } - static Trigger* rpg_spell(PlayerbotAI* botAI) { return new RpgUseTrigger(botAI); } - static Trigger* rpg_craft(PlayerbotAI* botAI) { return new RpgCraftTrigger(botAI); } - static Trigger* rpg_trade_useful(PlayerbotAI* botAI) { return new RpgTradeUsefulTrigger(botAI); } - static Trigger* rpg_duel(PlayerbotAI* botAI) { return new RpgDuelTrigger(botAI); } + creators["rpg"] = &TriggerContext::rpg; + creators["rpg taxi"] = &TriggerContext::rpg_taxi; + creators["rpg discover"] = &TriggerContext::rpg_discover; + creators["rpg start quest"] = &TriggerContext::rpg_start_quest; + creators["rpg end quest"] = &TriggerContext::rpg_end_quest; + creators["rpg buy"] = &TriggerContext::rpg_buy; + creators["rpg sell"] = &TriggerContext::rpg_sell; + creators["rpg repair"] = &TriggerContext::rpg_repair; + creators["rpg train"] = &TriggerContext::rpg_train; + creators["rpg heal"] = &TriggerContext::rpg_heal; + creators["rpg home bind"] = &TriggerContext::rpg_home_bind; + creators["rpg queue bg"] = &TriggerContext::rpg_queue_bg; + creators["rpg buy petition"] = &TriggerContext::rpg_buy_petition; + creators["rpg use"] = &TriggerContext::rpg_use; + creators["rpg spell"] = &TriggerContext::rpg_spell; + creators["rpg craft"] = &TriggerContext::rpg_craft; + creators["rpg trade useful"] = &TriggerContext::rpg_trade_useful; + creators["rpg duel"] = &TriggerContext::rpg_duel; + } + +private: + static Trigger* give_food(PlayerbotAI* botAI) { return new GiveFoodTrigger(botAI); } + static Trigger* give_water(PlayerbotAI* botAI) { return new GiveWaterTrigger(botAI); } + static Trigger* no_rti(PlayerbotAI* botAI) { return new NoRtiTrigger(botAI); } + static Trigger* _return(PlayerbotAI* botAI) { return new ReturnTrigger(botAI); } + static Trigger* sit(PlayerbotAI* botAI) { return new SitTrigger(botAI); } + static Trigger* far_from_rpg_target(PlayerbotAI* botAI) { return new FarFromRpgTargetTrigger(botAI); } + static Trigger* near_rpg_target(PlayerbotAI* botAI) { return new NearRpgTargetTrigger(botAI); } + static Trigger* far_from_travel_target(PlayerbotAI* botAI) { return new FarFromTravelTargetTrigger(botAI); } + static Trigger* no_travel_target(PlayerbotAI* botAI) { return new NoTravelTargetTrigger(botAI); } + static Trigger* no_rpg_target(PlayerbotAI* botAI) { return new NoRpgTargetTrigger(botAI); } + static Trigger* has_rpg_target(PlayerbotAI* botAI) { return new HasRpgTargetTrigger(botAI); } + static Trigger* collision(PlayerbotAI* botAI) { return new CollisionTrigger(botAI); } + static Trigger* lfg_proposal_active(PlayerbotAI* botAI) { return new LfgProposalActiveTrigger(botAI); } + static Trigger* unknown_dungeon(PlayerbotAI* botAI) { return new UnknownDungeonTrigger(botAI); } + static Trigger* invalid_target(PlayerbotAI* botAI) { return new InvalidTargetTrigger(botAI); } + static Trigger* critical_aoe_heal(PlayerbotAI* botAI) + { + return new AoeHealTrigger(botAI, "critical aoe heal", "critical", 2); + } + static Trigger* low_aoe_heal(PlayerbotAI* botAI) { return new AoeHealTrigger(botAI, "low aoe heal", "low", 2); } + static Trigger* medium_aoe_heal(PlayerbotAI* botAI) + { + return new AoeHealTrigger(botAI, "medium aoe heal", "medium", 2); + } + static Trigger* almost_full_aoe_heal(PlayerbotAI* botAI) + { + return new AoeHealTrigger(botAI, "almost full aoe heal", "almost full", 2); + } + static Trigger* group_heal_occasion(PlayerbotAI* ai) + { + return new AoeInGroupTrigger(ai, "group heal occasion", "almost full", 0.6); + } + static Trigger* medium_group_heal_occasion(PlayerbotAI* ai) + { + return new AoeInGroupTrigger(ai, "group heal occasion", "medium", 0.4); + } + static Trigger* target_changed(PlayerbotAI* botAI) { return new TargetChangedTrigger(botAI); } + static Trigger* swimming(PlayerbotAI* botAI) { return new IsSwimmingTrigger(botAI); } + static Trigger* no_possible_targets(PlayerbotAI* botAI) { return new NoPossibleTargetsTrigger(botAI); } + static Trigger* possible_adds(PlayerbotAI* botAI) { return new PossibleAddsTrigger(botAI); } + static Trigger* can_loot(PlayerbotAI* botAI) { return new CanLootTrigger(botAI); } + static Trigger* far_from_loot_target(PlayerbotAI* botAI) { return new FarFromCurrentLootTrigger(botAI); } + static Trigger* far_from_master(PlayerbotAI* botAI) { return new FarFromMasterTrigger(botAI); } + static Trigger* behind_target(PlayerbotAI* botAI) { return new IsBehindTargetTrigger(botAI); } + static Trigger* not_behind_target(PlayerbotAI* botAI) { return new IsNotBehindTargetTrigger(botAI); } + static Trigger* not_facing_target(PlayerbotAI* botAI) { return new IsNotFacingTargetTrigger(botAI); } + static Trigger* panic(PlayerbotAI* botAI) { return new PanicTrigger(botAI); } + static Trigger* outnumbered(PlayerbotAI* botAI) { return new OutNumberedTrigger(botAI); } + static Trigger* no_drink(PlayerbotAI* botAI) { return new NoDrinkTrigger(botAI); } + static Trigger* no_food(PlayerbotAI* botAI) { return new NoFoodTrigger(botAI); } + static Trigger* LightAoe(PlayerbotAI* botAI) { return new LightAoeTrigger(botAI); } + static Trigger* MediumAoe(PlayerbotAI* botAI) { return new MediumAoeTrigger(botAI); } + static Trigger* HighAoe(PlayerbotAI* botAI) { return new HighAoeTrigger(botAI); } + static Trigger* HasAreaDebuff(PlayerbotAI* botAI) { return new HasAreaDebuffTrigger(botAI); } + static Trigger* LoseAggro(PlayerbotAI* botAI) { return new LoseAggroTrigger(botAI); } + static Trigger* HasAggro(PlayerbotAI* botAI) { return new HasAggroTrigger(botAI); } + static Trigger* LowHealth(PlayerbotAI* botAI) { return new LowHealthTrigger(botAI); } + static Trigger* MediumHealth(PlayerbotAI* botAI) { return new MediumHealthTrigger(botAI); } + static Trigger* AlmostFullHealth(PlayerbotAI* botAI) { return new AlmostFullHealthTrigger(botAI); } + static Trigger* CriticalHealth(PlayerbotAI* botAI) { return new CriticalHealthTrigger(botAI); } + static Trigger* TargetCriticalHealth(PlayerbotAI* botAI) { return new TargetCriticalHealthTrigger(botAI); } + static Trigger* LowMana(PlayerbotAI* botAI) { return new LowManaTrigger(botAI); } + static Trigger* MediumMana(PlayerbotAI* botAI) { return new MediumManaTrigger(botAI); } + static Trigger* HighMana(PlayerbotAI* botAI) { return new HighManaTrigger(botAI); } + static Trigger* AlmostFullMana(PlayerbotAI* botAI) { return new AlmostFullManaTrigger(botAI); } + static Trigger* EnoughMana(PlayerbotAI* botAI) { return new EnoughManaTrigger(botAI); } + static Trigger* LightRageAvailable(PlayerbotAI* botAI) { return new LightRageAvailableTrigger(botAI); } + static Trigger* MediumRageAvailable(PlayerbotAI* botAI) { return new MediumRageAvailableTrigger(botAI); } + static Trigger* HighRageAvailable(PlayerbotAI* botAI) { return new HighRageAvailableTrigger(botAI); } + static Trigger* LightEnergyAvailable(PlayerbotAI* botAI) { return new LightEnergyAvailableTrigger(botAI); } + static Trigger* MediumEnergyAvailable(PlayerbotAI* botAI) { return new MediumEnergyAvailableTrigger(botAI); } + static Trigger* HighEnergyAvailable(PlayerbotAI* botAI) { return new HighEnergyAvailableTrigger(botAI); } + static Trigger* LootAvailable(PlayerbotAI* botAI) { return new LootAvailableTrigger(botAI); } + static Trigger* NoAttackers(PlayerbotAI* botAI) { return new NoAttackersTrigger(botAI); } + static Trigger* TankAssist(PlayerbotAI* botAI) { return new TankAssistTrigger(botAI); } + static Trigger* Timer(PlayerbotAI* botAI) { return new TimerTrigger(botAI); } + static Trigger* NoTarget(PlayerbotAI* botAI) { return new NoTargetTrigger(botAI); } + static Trigger* TargetInSight(PlayerbotAI* botAI) { return new TargetInSightTrigger(botAI); } + static Trigger* not_dps_target_active(PlayerbotAI* botAI) { return new NotDpsTargetActiveTrigger(botAI); } + static Trigger* not_dps_aoe_target_active(PlayerbotAI* botAI) { return new NotDpsAoeTargetActiveTrigger(botAI); } + static Trigger* has_nearest_adds(PlayerbotAI* botAI) { return new HasNearestAddsTrigger(botAI); } + static Trigger* enemy_player_near(PlayerbotAI* botAI) { return new EnemyPlayerNear(botAI); } + static Trigger* Random(PlayerbotAI* botAI) { return new RandomTrigger(botAI, "random", 20); } + static Trigger* seldom(PlayerbotAI* botAI) { return new RandomTrigger(botAI, "seldom", 300); } + static Trigger* often(PlayerbotAI* botAI) { return new RandomTrigger(botAI, "often", 5); } + static Trigger* EnemyOutOfMelee(PlayerbotAI* botAI) { return new EnemyOutOfMeleeTrigger(botAI); } + static Trigger* EnemyOutOfSpell(PlayerbotAI* botAI) { return new EnemyOutOfSpellRangeTrigger(botAI); } + static Trigger* enemy_too_close_for_spell(PlayerbotAI* botAI) { return new EnemyTooCloseForSpellTrigger(botAI); } + static Trigger* enemy_too_close_for_auto_shot(PlayerbotAI* botAI) + { + return new EnemyTooCloseForAutoShotTrigger(botAI); + } + static Trigger* enemy_too_close_for_shoot(PlayerbotAI* botAI) { return new EnemyTooCloseForShootTrigger(botAI); } + static Trigger* enemy_too_close_for_melee(PlayerbotAI* botAI) { return new EnemyTooCloseForMeleeTrigger(botAI); } + static Trigger* enemy_is_close(PlayerbotAI* botAI) { return new EnemyIsCloseTrigger(botAI); } + static Trigger* enemy_within_melee(PlayerbotAI* botAI) { return new EnemyWithinMeleeTrigger(botAI); } + static Trigger* party_member_to_heal_out_of_spell_range(PlayerbotAI* botAI) + { + return new PartyMemberToHealOutOfSpellRangeTrigger(botAI); + } + static Trigger* ComboPointsAvailable(PlayerbotAI* botAI) { return new ComboPointsAvailableTrigger(botAI); } + static Trigger* ComboPoints3Available(PlayerbotAI* botAI) { return new ComboPointsAvailableTrigger(botAI, 3); } + static Trigger* MediumThreat(PlayerbotAI* botAI) { return new MediumThreatTrigger(botAI); } + static Trigger* Dead(PlayerbotAI* botAI) { return new DeadTrigger(botAI); } + static Trigger* corpse_near(PlayerbotAI* botAI) { return new CorpseNearTrigger(botAI); } + static Trigger* PartyMemberDead(PlayerbotAI* botAI) { return new PartyMemberDeadTrigger(botAI); } + static Trigger* CombatPartyMemberDead(PlayerbotAI* botAI) { return new CombatPartyMemberDeadTrigger(botAI); } + static Trigger* PartyMemberLowHealth(PlayerbotAI* botAI) { return new PartyMemberLowHealthTrigger(botAI); } + static Trigger* PartyMemberMediumHealth(PlayerbotAI* botAI) { return new PartyMemberMediumHealthTrigger(botAI); } + static Trigger* PartyMemberAlmostFullHealth(PlayerbotAI* botAI) + { + return new PartyMemberAlmostFullHealthTrigger(botAI); + } + static Trigger* PartyMemberCriticalHealth(PlayerbotAI* botAI) + { + return new PartyMemberCriticalHealthTrigger(botAI); + } + static Trigger* protect_party_member(PlayerbotAI* botAI) { return new ProtectPartyMemberTrigger(botAI); } + static Trigger* no_pet(PlayerbotAI* botAI) { return new NoPetTrigger(botAI); } + static Trigger* has_pet(PlayerbotAI* botAI) { return new HasPetTrigger(botAI); } + static Trigger* pet_attack(PlayerbotAI* botAI) { return new PetAttackTrigger(botAI); } + static Trigger* has_attackers(PlayerbotAI* botAI) { return new HasAttackersTrigger(botAI); } + static Trigger* random_bot_update_trigger(PlayerbotAI* botAI) { return new RandomBotUpdateTrigger(botAI); } + static Trigger* no_non_bot_players_around(PlayerbotAI* botAI) { return new NoNonBotPlayersAroundTrigger(botAI); } + static Trigger* new_player_nearby(PlayerbotAI* botAI) { return new NewPlayerNearbyTrigger(botAI); } + static Trigger* bg_waiting(PlayerbotAI* botAI) { return new BgWaitingTrigger(botAI); } + static Trigger* bg_active(PlayerbotAI* botAI) { return new BgActiveTrigger(botAI); } + static Trigger* bg_invite_active(PlayerbotAI* botAI) { return new BgInviteActiveTrigger(botAI); } + static Trigger* inside_bg(PlayerbotAI* botAI) { return new InsideBGTrigger(botAI); } + static Trigger* player_has_no_flag(PlayerbotAI* botAI) { return new PlayerHasNoFlag(botAI); } + static Trigger* player_has_flag(PlayerbotAI* botAI) { return new PlayerHasFlag(botAI); } + static Trigger* team_has_flag(PlayerbotAI* botAI) { return new TeamHasFlag(botAI); } + static Trigger* enemy_team_has_flag(PlayerbotAI* botAI) { return new EnemyTeamHasFlag(botAI); } + static Trigger* enemy_flagcarrier_near(PlayerbotAI* botAI) { return new EnemyFlagCarrierNear(botAI); } + static Trigger* player_is_in_BATTLEGROUND(PlayerbotAI* botAI) { return new PlayerIsInBattleground(botAI); } + static Trigger* player_is_in_BATTLEGROUND_no_flag(PlayerbotAI* botAI) + { + return new PlayerIsInBattlegroundWithoutFlag(botAI); + } + static Trigger* mounted(PlayerbotAI* botAI) { return new IsMountedTrigger(botAI); } + static Trigger* at_dark_portal_outland(PlayerbotAI* botAI) { return new AtDarkPortalOutlandTrigger(botAI); } + static Trigger* at_dark_portal_azeroth(PlayerbotAI* botAI) { return new AtDarkPortalAzerothTrigger(botAI); } + static Trigger* in_vehicle(PlayerbotAI* botAI) { return new InVehicleTrigger(botAI); } + static Trigger* vehicle_near(PlayerbotAI* botAI) { return new VehicleNearTrigger(botAI); } + static Trigger* near_dark_portal(PlayerbotAI* botAI) { return new NearDarkPortalTrigger(botAI); } + static Trigger* need_world_buff(PlayerbotAI* botAI) { return new NeedWorldBuffTrigger(botAI); } + static Trigger* falling(PlayerbotAI* botAI) { return new IsFallingTrigger(botAI); } + static Trigger* falling_far(PlayerbotAI* botAI) { return new IsFallingFarTrigger(botAI); } + static Trigger* move_stuck(PlayerbotAI* botAI) { return new MoveStuckTrigger(botAI); } + static Trigger* move_long_stuck(PlayerbotAI* botAI) { return new MoveLongStuckTrigger(botAI); } + static Trigger* combat_stuck(PlayerbotAI* botAI) { return new CombatStuckTrigger(botAI); } + static Trigger* combat_long_stuck(PlayerbotAI* botAI) { return new CombatLongStuckTrigger(botAI); } + static Trigger* player_wants_in_bg(PlayerbotAI* botAI) { return new PlayerWantsInBattlegroundTrigger(botAI); } + static Trigger* petition_signed(PlayerbotAI* botAI) { return new PetitionTurnInTrigger(botAI); } + static Trigger* buy_tabard(PlayerbotAI* botAI) { return new BuyTabardTrigger(botAI); } + static Trigger* leave_large_guild(PlayerbotAI* botAI) { return new LeaveLargeGuildTrigger(botAI); } + static Trigger* rpg(PlayerbotAI* botAI) { return new RpgTrigger(botAI); } + static Trigger* rpg_taxi(PlayerbotAI* botAI) { return new RpgTaxiTrigger(botAI); } + static Trigger* rpg_discover(PlayerbotAI* botAI) { return new RpgDiscoverTrigger(botAI); } + static Trigger* rpg_start_quest(PlayerbotAI* botAI) { return new RpgStartQuestTrigger(botAI); } + static Trigger* rpg_end_quest(PlayerbotAI* botAI) { return new RpgEndQuestTrigger(botAI); } + static Trigger* rpg_buy(PlayerbotAI* botAI) { return new RpgBuyTrigger(botAI); } + static Trigger* rpg_sell(PlayerbotAI* botAI) { return new RpgSellTrigger(botAI); } + static Trigger* rpg_repair(PlayerbotAI* botAI) { return new RpgRepairTrigger(botAI); } + static Trigger* rpg_train(PlayerbotAI* botAI) { return new RpgTrainTrigger(botAI); } + static Trigger* rpg_heal(PlayerbotAI* botAI) { return new RpgHealTrigger(botAI); } + static Trigger* rpg_home_bind(PlayerbotAI* botAI) { return new RpgHomeBindTrigger(botAI); } + static Trigger* rpg_queue_bg(PlayerbotAI* botAI) { return new RpgQueueBGTrigger(botAI); } + static Trigger* rpg_buy_petition(PlayerbotAI* botAI) { return new RpgBuyPetitionTrigger(botAI); } + static Trigger* rpg_use(PlayerbotAI* botAI) { return new RpgUseTrigger(botAI); } + static Trigger* rpg_spell(PlayerbotAI* botAI) { return new RpgUseTrigger(botAI); } + static Trigger* rpg_craft(PlayerbotAI* botAI) { return new RpgCraftTrigger(botAI); } + static Trigger* rpg_trade_useful(PlayerbotAI* botAI) { return new RpgTradeUsefulTrigger(botAI); } + static Trigger* rpg_duel(PlayerbotAI* botAI) { return new RpgDuelTrigger(botAI); } }; #endif - diff --git a/src/strategy/triggers/WithinAreaTrigger.cpp b/src/strategy/triggers/WithinAreaTrigger.cpp index f7128c39..6d9cb3fc 100644 --- a/src/strategy/triggers/WithinAreaTrigger.cpp +++ b/src/strategy/triggers/WithinAreaTrigger.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "WithinAreaTrigger.h" + #include "LastMovementValue.h" #include "Playerbots.h" @@ -19,10 +21,12 @@ bool WithinAreaTrigger::IsActive() if (!sObjectMgr->GetAreaTriggerTeleport(movement.lastAreaTrigger)) return false; - return IsPointInAreaTriggerZone(at, bot->GetMapId(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), 0.5f); + return IsPointInAreaTriggerZone(at, bot->GetMapId(), bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(), + 0.5f); } -bool WithinAreaTrigger::IsPointInAreaTriggerZone(AreaTrigger const* atEntry, uint32 mapid, float x, float y, float z, float delta) +bool WithinAreaTrigger::IsPointInAreaTriggerZone(AreaTrigger const* atEntry, uint32 mapid, float x, float y, float z, + float delta) { if (mapid != atEntry->map) return false; @@ -30,7 +34,8 @@ bool WithinAreaTrigger::IsPointInAreaTriggerZone(AreaTrigger const* atEntry, uin if (atEntry->radius > 0) { // if we have radius check it - float dist2 = (x - atEntry->x) * (x - atEntry->x) + (y - atEntry->y) * (y - atEntry->y) + (z - atEntry->z) * (z - atEntry->z); + float dist2 = (x - atEntry->x) * (x - atEntry->x) + (y - atEntry->y) * (y - atEntry->y) + + (z - atEntry->z) * (z - atEntry->z); if (dist2 > (atEntry->radius + delta) * (atEntry->radius + delta)) return false; } @@ -56,7 +61,8 @@ bool WithinAreaTrigger::IsPointInAreaTriggerZone(AreaTrigger const* atEntry, uin float dz = z - atEntry->z; float dx = rotPlayerX - atEntry->x; float dy = rotPlayerY - atEntry->y; - if ((fabs(dx) > atEntry->x / 2 + delta) || (fabs(dy) > atEntry->y / 2 + delta) || (fabs(dz) > atEntry->z / 2 + delta)) + if ((fabs(dx) > atEntry->x / 2 + delta) || (fabs(dy) > atEntry->y / 2 + delta) || + (fabs(dz) > atEntry->z / 2 + delta)) { return false; } diff --git a/src/strategy/triggers/WithinAreaTrigger.h b/src/strategy/triggers/WithinAreaTrigger.h index 5d815e67..f4d041e9 100644 --- a/src/strategy/triggers/WithinAreaTrigger.h +++ b/src/strategy/triggers/WithinAreaTrigger.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WITHINAREATRIGGER_H @@ -13,13 +14,13 @@ struct AreaTrigger; class WithinAreaTrigger : public Trigger { - public: - WithinAreaTrigger(PlayerbotAI* botAI) : Trigger(botAI, "within area trigger") { } +public: + WithinAreaTrigger(PlayerbotAI* botAI) : Trigger(botAI, "within area trigger") {} - bool IsActive() override; + bool IsActive() override; - private: - bool IsPointInAreaTriggerZone(AreaTrigger const* atEntry, uint32 mapid, float x, float y, float z, float delta); +private: + bool IsPointInAreaTriggerZone(AreaTrigger const* atEntry, uint32 mapid, float x, float y, float z, float delta); }; #endif diff --git a/src/strategy/triggers/WorldPacketTrigger.cpp b/src/strategy/triggers/WorldPacketTrigger.cpp index 83ba8329..638081a2 100644 --- a/src/strategy/triggers/WorldPacketTrigger.cpp +++ b/src/strategy/triggers/WorldPacketTrigger.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "WorldPacketTrigger.h" + #include "Playerbots.h" void WorldPacketTrigger::ExternalEvent(WorldPacket& revData, Player* eventOwner) @@ -20,7 +22,4 @@ Event WorldPacketTrigger::Check() return Event(getName(), packet, owner); } -void WorldPacketTrigger::Reset() -{ - triggered = false; -} +void WorldPacketTrigger::Reset() { triggered = false; } diff --git a/src/strategy/triggers/WorldPacketTrigger.h b/src/strategy/triggers/WorldPacketTrigger.h index 8515349a..7012f5dc 100644 --- a/src/strategy/triggers/WorldPacketTrigger.h +++ b/src/strategy/triggers/WorldPacketTrigger.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WORLDPACKETTRIGGER_H @@ -14,17 +15,17 @@ class WorldPacket; class WorldPacketTrigger : public Trigger { - public: - WorldPacketTrigger(PlayerbotAI* botAI, std::string const command) : Trigger(botAI, command), triggered(false) { } +public: + WorldPacketTrigger(PlayerbotAI* botAI, std::string const command) : Trigger(botAI, command), triggered(false) {} - void ExternalEvent(WorldPacket& packet, Player* owner = nullptr) override; - Event Check() override; - void Reset() override; + void ExternalEvent(WorldPacket& packet, Player* owner = nullptr) override; + Event Check() override; + void Reset() override; - private: - WorldPacket packet; - bool triggered; - Player* owner; +private: + WorldPacket packet; + bool triggered; + Player* owner; }; #endif diff --git a/src/strategy/triggers/WorldPacketTriggerContext.h b/src/strategy/triggers/WorldPacketTriggerContext.h index 8f08eeda..51caae86 100644 --- a/src/strategy/triggers/WorldPacketTriggerContext.h +++ b/src/strategy/triggers/WorldPacketTriggerContext.h @@ -1,122 +1,144 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WORLDPACKETTRIGGERCONTEXT_H #define _PLAYERBOT_WORLDPACKETTRIGGERCONTEXT_H -#include "WorldPacketTrigger.h" -#include "WithinAreaTrigger.h" #include "NamedObjectContext.h" +#include "WithinAreaTrigger.h" +#include "WorldPacketTrigger.h" class WorldPacketTriggerContext : public NamedObjectContext { - public: - WorldPacketTriggerContext() - { - creators["gossip hello"] = &WorldPacketTriggerContext::gossip_hello; - creators["group invite"] = &WorldPacketTriggerContext::group_invite; - creators["group set leader"] = &WorldPacketTriggerContext::group_set_leader; - creators["not enough money"] = &WorldPacketTriggerContext::no_money; - creators["not enough reputation"] = &WorldPacketTriggerContext::no_reputation; - creators["cannot equip"] = &WorldPacketTriggerContext::cannot_equip; - creators["use game object"] = &WorldPacketTriggerContext::use_game_object; - creators["complete quest"] = &WorldPacketTriggerContext::complete_quest; - creators["accept quest"] = &WorldPacketTriggerContext::accept_quest; - creators["quest share"] = &WorldPacketTriggerContext::quest_share; - creators["loot roll"] = &WorldPacketTriggerContext::loot_roll; - creators["resurrect request"] = &WorldPacketTriggerContext::resurrect_request; - creators["area trigger"] = &WorldPacketTriggerContext::area_trigger; - creators["within area trigger"] = &WorldPacketTriggerContext::within_area_trigger; - creators["check mount state"] = &WorldPacketTriggerContext::check_mount_state; - creators["activate taxi"] = &WorldPacketTriggerContext::taxi; - creators["trade status"] = &WorldPacketTriggerContext::trade_status; - creators["loot response"] = &WorldPacketTriggerContext::loot_response; - creators["out of react range"] = &WorldPacketTriggerContext::out_of_react_range; - creators["quest objective completed"] = &WorldPacketTriggerContext::quest_objective_completed; - creators["item push result"] = &WorldPacketTriggerContext::item_push_result; - creators["party command"] = &WorldPacketTriggerContext::party_command; - creators["taxi done"] = &WorldPacketTriggerContext::taxi_done; - creators["cast failed"] = &WorldPacketTriggerContext::cast_failed; - creators["duel requested"] = &WorldPacketTriggerContext::duel_requested; - creators["ready check"] = &WorldPacketTriggerContext::ready_check; - creators["ready check finished"] = &WorldPacketTriggerContext::ready_check_finished; - creators["uninvite"] = &WorldPacketTriggerContext::uninvite; - creators["uninvite guid"] = &WorldPacketTriggerContext::uninvite_guid; - creators["lfg join"] = &WorldPacketTriggerContext::lfg_update; - creators["lfg proposal"] = &WorldPacketTriggerContext::lfg_proposal; - creators["lfg role check"] = &WorldPacketTriggerContext::lfg_role_check; - creators["lfg leave"] = &WorldPacketTriggerContext::lfg_leave; - creators["guild invite"] = &WorldPacketTriggerContext::guild_invite; - creators["petition offer"] = &WorldPacketTriggerContext::petition_offer; - creators["lfg teleport"] = &WorldPacketTriggerContext::lfg_teleport; - creators["inventory change failure"] = &WorldPacketTriggerContext::inventory_change_failure; - creators["bg status"] = &WorldPacketTriggerContext::bg_status; - creators["levelup"] = &WorldPacketTriggerContext::levelup; - creators["xpgain"] = &WorldPacketTriggerContext::xpgain; - creators["see spell"] = &WorldPacketTriggerContext::seespell; - creators["release spirit"] = &WorldPacketTriggerContext::release_spirit; - creators["revive from corpse"] = &WorldPacketTriggerContext::revive_from_corpse; - creators["receive emote"] = &WorldPacketTriggerContext::receive_emote; - creators["receive text emote"] = &WorldPacketTriggerContext::receive_text_emote; - creators["arena team invite"] = &WorldPacketTriggerContext::arena_team_invite; - creators["quest confirm accept"] = &WorldPacketTriggerContext::quest_confirm_accept; - creators["group destroyed"] = &WorldPacketTriggerContext::group_destroyed; - creators["group list"] = &WorldPacketTriggerContext::group_list; - creators["questgiver quest details"] = &WorldPacketTriggerContext::questgiver_quest_details; - } +public: + WorldPacketTriggerContext() + { + creators["gossip hello"] = &WorldPacketTriggerContext::gossip_hello; + creators["group invite"] = &WorldPacketTriggerContext::group_invite; + creators["group set leader"] = &WorldPacketTriggerContext::group_set_leader; + creators["not enough money"] = &WorldPacketTriggerContext::no_money; + creators["not enough reputation"] = &WorldPacketTriggerContext::no_reputation; + creators["cannot equip"] = &WorldPacketTriggerContext::cannot_equip; + creators["use game object"] = &WorldPacketTriggerContext::use_game_object; + creators["complete quest"] = &WorldPacketTriggerContext::complete_quest; + creators["accept quest"] = &WorldPacketTriggerContext::accept_quest; + creators["quest share"] = &WorldPacketTriggerContext::quest_share; + creators["loot roll"] = &WorldPacketTriggerContext::loot_roll; + creators["resurrect request"] = &WorldPacketTriggerContext::resurrect_request; + creators["area trigger"] = &WorldPacketTriggerContext::area_trigger; + creators["within area trigger"] = &WorldPacketTriggerContext::within_area_trigger; + creators["check mount state"] = &WorldPacketTriggerContext::check_mount_state; + creators["activate taxi"] = &WorldPacketTriggerContext::taxi; + creators["trade status"] = &WorldPacketTriggerContext::trade_status; + creators["loot response"] = &WorldPacketTriggerContext::loot_response; + creators["out of react range"] = &WorldPacketTriggerContext::out_of_react_range; + creators["quest objective completed"] = &WorldPacketTriggerContext::quest_objective_completed; + creators["item push result"] = &WorldPacketTriggerContext::item_push_result; + creators["party command"] = &WorldPacketTriggerContext::party_command; + creators["taxi done"] = &WorldPacketTriggerContext::taxi_done; + creators["cast failed"] = &WorldPacketTriggerContext::cast_failed; + creators["duel requested"] = &WorldPacketTriggerContext::duel_requested; + creators["ready check"] = &WorldPacketTriggerContext::ready_check; + creators["ready check finished"] = &WorldPacketTriggerContext::ready_check_finished; + creators["uninvite"] = &WorldPacketTriggerContext::uninvite; + creators["uninvite guid"] = &WorldPacketTriggerContext::uninvite_guid; + creators["lfg join"] = &WorldPacketTriggerContext::lfg_update; + creators["lfg proposal"] = &WorldPacketTriggerContext::lfg_proposal; + creators["lfg role check"] = &WorldPacketTriggerContext::lfg_role_check; + creators["lfg leave"] = &WorldPacketTriggerContext::lfg_leave; + creators["guild invite"] = &WorldPacketTriggerContext::guild_invite; + creators["petition offer"] = &WorldPacketTriggerContext::petition_offer; + creators["lfg teleport"] = &WorldPacketTriggerContext::lfg_teleport; + creators["inventory change failure"] = &WorldPacketTriggerContext::inventory_change_failure; + creators["bg status"] = &WorldPacketTriggerContext::bg_status; + creators["levelup"] = &WorldPacketTriggerContext::levelup; + creators["xpgain"] = &WorldPacketTriggerContext::xpgain; + creators["see spell"] = &WorldPacketTriggerContext::seespell; + creators["release spirit"] = &WorldPacketTriggerContext::release_spirit; + creators["revive from corpse"] = &WorldPacketTriggerContext::revive_from_corpse; + creators["receive emote"] = &WorldPacketTriggerContext::receive_emote; + creators["receive text emote"] = &WorldPacketTriggerContext::receive_text_emote; + creators["arena team invite"] = &WorldPacketTriggerContext::arena_team_invite; + creators["quest confirm accept"] = &WorldPacketTriggerContext::quest_confirm_accept; + creators["group destroyed"] = &WorldPacketTriggerContext::group_destroyed; + creators["group list"] = &WorldPacketTriggerContext::group_list; + creators["questgiver quest details"] = &WorldPacketTriggerContext::questgiver_quest_details; + } - private: - static Trigger* inventory_change_failure(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "inventory change failure"); } - static Trigger* guild_invite(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "guild invite"); } - static Trigger* lfg_teleport(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "lfg teleport"); } - static Trigger* lfg_leave(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "lfg leave"); } - static Trigger* lfg_proposal(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "lfg proposal"); } - static Trigger* lfg_role_check(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "lfg role check"); } - static Trigger* lfg_update(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "lfg join"); } - static Trigger* uninvite(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "uninvite"); } - static Trigger* uninvite_guid(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "uninvite guid"); } - static Trigger* ready_check_finished(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "ready check finished"); } - static Trigger* ready_check(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "ready check"); } - static Trigger* duel_requested(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "duel requested"); } - static Trigger* cast_failed(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "cast failed"); } - static Trigger* taxi_done(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "taxi done"); } - static Trigger* party_command(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "party command"); } - static Trigger* item_push_result(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "item push result"); } - static Trigger* quest_objective_completed(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "quest objective completed"); } - static Trigger* out_of_react_range(PlayerbotAI* botAI) { return new OutOfReactRangeTrigger(botAI); } - static Trigger* loot_response(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "loot response"); } - static Trigger* trade_status(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "trade status"); } - static Trigger* cannot_equip(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "cannot equip"); } - static Trigger* check_mount_state(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "check mount state"); } - static Trigger* area_trigger(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "area trigger"); } - static Trigger* within_area_trigger(PlayerbotAI* botAI) { return new WithinAreaTrigger(botAI); } - static Trigger* resurrect_request(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "resurrect request"); } - static Trigger* gossip_hello(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "gossip hello"); } - static Trigger* group_invite(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "group invite"); } - static Trigger* group_set_leader(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "group set leader"); } - static Trigger* no_money(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "not enough money"); } - static Trigger* no_reputation(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "not enough reputation"); } - static Trigger* use_game_object(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "use game object"); } - static Trigger* complete_quest(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "complete quest"); } - static Trigger* accept_quest(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "accept quest"); } - static Trigger* quest_share(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "quest share"); } - static Trigger* loot_roll(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "loot roll"); } - static Trigger* taxi(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "activate taxi"); } - static Trigger* bg_status(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "bg status"); } - static Trigger* levelup(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "levelup"); } - static Trigger* xpgain(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "xpgain"); } - static Trigger* petition_offer(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "petition offer"); } - static Trigger* seespell(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "see spell"); } - static Trigger* release_spirit(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "release spirit"); } - static Trigger* revive_from_corpse(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "revive from corpse"); } - static Trigger* receive_emote(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "receive emote"); } - static Trigger* receive_text_emote(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "receive text emote"); } - static Trigger* arena_team_invite(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "arena team invite"); } - static Trigger* quest_confirm_accept(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "quest confirm accept"); } - static Trigger* group_destroyed(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "group destroyed"); } - static Trigger* group_list(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "group list"); } - static Trigger* questgiver_quest_details(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "questgiver quest details"); } +private: + static Trigger* inventory_change_failure(PlayerbotAI* botAI) + { + return new WorldPacketTrigger(botAI, "inventory change failure"); + } + static Trigger* guild_invite(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "guild invite"); } + static Trigger* lfg_teleport(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "lfg teleport"); } + static Trigger* lfg_leave(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "lfg leave"); } + static Trigger* lfg_proposal(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "lfg proposal"); } + static Trigger* lfg_role_check(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "lfg role check"); } + static Trigger* lfg_update(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "lfg join"); } + static Trigger* uninvite(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "uninvite"); } + static Trigger* uninvite_guid(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "uninvite guid"); } + static Trigger* ready_check_finished(PlayerbotAI* botAI) + { + return new WorldPacketTrigger(botAI, "ready check finished"); + } + static Trigger* ready_check(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "ready check"); } + static Trigger* duel_requested(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "duel requested"); } + static Trigger* cast_failed(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "cast failed"); } + static Trigger* taxi_done(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "taxi done"); } + static Trigger* party_command(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "party command"); } + static Trigger* item_push_result(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "item push result"); } + static Trigger* quest_objective_completed(PlayerbotAI* botAI) + { + return new WorldPacketTrigger(botAI, "quest objective completed"); + } + static Trigger* out_of_react_range(PlayerbotAI* botAI) { return new OutOfReactRangeTrigger(botAI); } + static Trigger* loot_response(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "loot response"); } + static Trigger* trade_status(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "trade status"); } + static Trigger* cannot_equip(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "cannot equip"); } + static Trigger* check_mount_state(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "check mount state"); } + static Trigger* area_trigger(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "area trigger"); } + static Trigger* within_area_trigger(PlayerbotAI* botAI) { return new WithinAreaTrigger(botAI); } + static Trigger* resurrect_request(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "resurrect request"); } + static Trigger* gossip_hello(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "gossip hello"); } + static Trigger* group_invite(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "group invite"); } + static Trigger* group_set_leader(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "group set leader"); } + static Trigger* no_money(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "not enough money"); } + static Trigger* no_reputation(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "not enough reputation"); } + static Trigger* use_game_object(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "use game object"); } + static Trigger* complete_quest(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "complete quest"); } + static Trigger* accept_quest(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "accept quest"); } + static Trigger* quest_share(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "quest share"); } + static Trigger* loot_roll(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "loot roll"); } + static Trigger* taxi(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "activate taxi"); } + static Trigger* bg_status(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "bg status"); } + static Trigger* levelup(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "levelup"); } + static Trigger* xpgain(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "xpgain"); } + static Trigger* petition_offer(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "petition offer"); } + static Trigger* seespell(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "see spell"); } + static Trigger* release_spirit(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "release spirit"); } + static Trigger* revive_from_corpse(PlayerbotAI* botAI) + { + return new WorldPacketTrigger(botAI, "revive from corpse"); + } + static Trigger* receive_emote(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "receive emote"); } + static Trigger* receive_text_emote(PlayerbotAI* botAI) + { + return new WorldPacketTrigger(botAI, "receive text emote"); + } + static Trigger* arena_team_invite(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "arena team invite"); } + static Trigger* quest_confirm_accept(PlayerbotAI* botAI) + { + return new WorldPacketTrigger(botAI, "quest confirm accept"); + } + static Trigger* group_destroyed(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "group destroyed"); } + static Trigger* group_list(PlayerbotAI* botAI) { return new WorldPacketTrigger(botAI, "group list"); } + static Trigger* questgiver_quest_details(PlayerbotAI* botAI) + { + return new WorldPacketTrigger(botAI, "questgiver quest details"); + } }; #endif diff --git a/src/strategy/values/ActiveSpellValue.cpp b/src/strategy/values/ActiveSpellValue.cpp index 62b7f185..9acc9cb6 100644 --- a/src/strategy/values/ActiveSpellValue.cpp +++ b/src/strategy/values/ActiveSpellValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ActiveSpellValue.h" + #include "Playerbots.h" uint32 ActiveSpellValue::Calculate() @@ -21,4 +23,3 @@ uint32 ActiveSpellValue::Calculate() return 0; } - diff --git a/src/strategy/values/ActiveSpellValue.h b/src/strategy/values/ActiveSpellValue.h index 1fd497a5..14605442 100644 --- a/src/strategy/values/ActiveSpellValue.h +++ b/src/strategy/values/ActiveSpellValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ACTIVESPELLVALUE_H @@ -11,10 +12,12 @@ class PlayerbotAI; class ActiveSpellValue : public CalculatedValue { - public: - ActiveSpellValue(PlayerbotAI* botAI, std::string const name = "active spell") : CalculatedValue(botAI, name) { } +public: + ActiveSpellValue(PlayerbotAI* botAI, std::string const name = "active spell") : CalculatedValue(botAI, name) + { + } - uint32 Calculate() override; + uint32 Calculate() override; }; #endif diff --git a/src/strategy/values/AlwaysLootListValue.cpp b/src/strategy/values/AlwaysLootListValue.cpp index 220aa4af..ebdc22f8 100644 --- a/src/strategy/values/AlwaysLootListValue.cpp +++ b/src/strategy/values/AlwaysLootListValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AlwaysLootListValue.h" + #include "Playerbots.h" std::string const AlwaysLootListValue::Save() diff --git a/src/strategy/values/AlwaysLootListValue.h b/src/strategy/values/AlwaysLootListValue.h index b4b2d39d..6fcdd99f 100644 --- a/src/strategy/values/AlwaysLootListValue.h +++ b/src/strategy/values/AlwaysLootListValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ALWAYSLOOTLISTVALUE_H @@ -11,14 +12,17 @@ class PlayerbotAI; class AlwaysLootListValue : public ManualSetValue&> { - public: - AlwaysLootListValue(PlayerbotAI* botAI, std::string const name = "always loot list") : ManualSetValue&>(botAI, list, name) { } +public: + AlwaysLootListValue(PlayerbotAI* botAI, std::string const name = "always loot list") + : ManualSetValue&>(botAI, list, name) + { + } - std::string const Save() override; - bool Load(std::string const value) override; + std::string const Save() override; + bool Load(std::string const value) override; - private: - std::set list; +private: + std::set list; }; #endif diff --git a/src/strategy/values/AoeHealValues.cpp b/src/strategy/values/AoeHealValues.cpp index 20a388a1..76e72584 100644 --- a/src/strategy/values/AoeHealValues.cpp +++ b/src/strategy/values/AoeHealValues.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AoeHealValues.h" + #include "PlayerbotAIConfig.h" #include "Playerbots.h" @@ -10,34 +12,33 @@ uint8 AoeHealValue::Calculate() { Group* group = bot->GetGroup(); if (!group) - return 0; + return 0; float range = 0; if (qualifier == "low") - range = sPlayerbotAIConfig->lowHealth; + range = sPlayerbotAIConfig->lowHealth; else if (qualifier == "medium") - range = sPlayerbotAIConfig->mediumHealth; + range = sPlayerbotAIConfig->mediumHealth; else if (qualifier == "critical") - range = sPlayerbotAIConfig->criticalHealth; - else if (qualifier == "almost full") - range = sPlayerbotAIConfig->almostFullHealth; + range = sPlayerbotAIConfig->criticalHealth; + else if (qualifier == "almost full") + range = sPlayerbotAIConfig->almostFullHealth; uint8 count = 0; - Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); - for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) - { - Player* player = ObjectAccessor::FindPlayer(itr->guid); - if (!player || !player->IsAlive()) - continue; - - if (player->GetDistance(bot) >= sPlayerbotAIConfig->sightDistance) - continue; - - float percent = (static_cast (player->GetHealth()) / player->GetMaxHealth()) * 100; - if (percent <= range) + Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); + for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) + { + Player* player = ObjectAccessor::FindPlayer(itr->guid); + if (!player || !player->IsAlive()) + continue; + + if (player->GetDistance(bot) >= sPlayerbotAIConfig->sightDistance) + continue; + + float percent = (static_cast(player->GetHealth()) / player->GetMaxHealth()) * 100; + if (percent <= range) ++count; - } + } - return count; + return count; } - diff --git a/src/strategy/values/AoeHealValues.h b/src/strategy/values/AoeHealValues.h index 9efd63af..3315b7c1 100644 --- a/src/strategy/values/AoeHealValues.h +++ b/src/strategy/values/AoeHealValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_AOEHEALVALUES_H @@ -12,10 +13,10 @@ class PlayerbotAI; class AoeHealValue : public Uint8CalculatedValue, public Qualified { - public: - AoeHealValue(PlayerbotAI* botAI, std::string const name = "aoe heal") : Uint8CalculatedValue(botAI, name) { } +public: + AoeHealValue(PlayerbotAI* botAI, std::string const name = "aoe heal") : Uint8CalculatedValue(botAI, name) {} - uint8 Calculate() override; + uint8 Calculate() override; }; #endif diff --git a/src/strategy/values/AoeValues.cpp b/src/strategy/values/AoeValues.cpp index e3f44bb2..069acc73 100644 --- a/src/strategy/values/AoeValues.cpp +++ b/src/strategy/values/AoeValues.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AoeValues.h" + #include "Playerbots.h" #include "ServerFacade.h" #include "SpellAuraEffects.h" @@ -77,15 +79,13 @@ WorldLocation AoePositionValue::Calculate() float x = (x1 + x2) / 2; float y = (y1 + y2) / 2; - float z = bot->GetPositionZ() + CONTACT_DISTANCE;; + float z = bot->GetPositionZ() + CONTACT_DISTANCE; + ; bot->UpdateAllowedPositionZ(x, y, z); return WorldLocation(bot->GetMapId(), x, y, z, 0); } -uint8 AoeCountValue::Calculate() -{ - return FindMaxDensity(bot).size(); -} +uint8 AoeCountValue::Calculate() { return FindMaxDensity(bot).size(); } bool HasAreaDebuffValue::Calculate() { @@ -104,7 +104,7 @@ bool HasAreaDebuffValue::Calculate() continue; uint32 trigger_spell_id = proto->Effects[aurEff->GetEffIndex()].TriggerSpell; - if (trigger_spell_id == 29767) //Overload + if (trigger_spell_id == 29767) // Overload { return true; } @@ -122,25 +122,32 @@ Aura* AreaDebuffValue::Calculate() { // Unit::AuraApplicationMap& map = bot->GetAppliedAuras(); Unit::AuraEffectList const& aurasPeriodicDamage = bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE); - Unit::AuraEffectList const& aurasPeriodicDamagePercent = bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE_PERCENT); - Unit::AuraEffectList const& aurasPeriodicTriggerSpell = bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL); - Unit::AuraEffectList const& aurasPeriodicTriggerWithValueSpell = bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE); + Unit::AuraEffectList const& aurasPeriodicDamagePercent = + bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE_PERCENT); + Unit::AuraEffectList const& aurasPeriodicTriggerSpell = + bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL); + Unit::AuraEffectList const& aurasPeriodicTriggerWithValueSpell = + bot->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE); Unit::AuraEffectList const& aurasDummy = bot->GetAuraEffectsByType(SPELL_AURA_DUMMY); - for (const Unit::AuraEffectList& list : {aurasPeriodicDamage, aurasPeriodicDamagePercent, aurasPeriodicTriggerSpell, aurasPeriodicTriggerWithValueSpell, aurasDummy}) { + for (const Unit::AuraEffectList& list : {aurasPeriodicDamage, aurasPeriodicDamagePercent, aurasPeriodicTriggerSpell, + aurasPeriodicTriggerWithValueSpell, aurasDummy}) + { for (auto i = list.begin(); i != list.end(); ++i) { AuraEffect* aurEff = *i; - Aura *aura = aurEff->GetBase(); + Aura* aura = aurEff->GetBase(); AuraObjectType type = aura->GetType(); bool isPositive = aura->GetSpellInfo()->IsPositive(); - if (type == DYNOBJ_AURA_TYPE && !isPositive) { + if (type == DYNOBJ_AURA_TYPE && !isPositive) + { DynamicObject* dynOwner = aura->GetDynobjOwner(); - if (!dynOwner) { + if (!dynOwner) + { continue; } return aura; } } } - return nullptr; + return nullptr; } \ No newline at end of file diff --git a/src/strategy/values/AoeValues.h b/src/strategy/values/AoeValues.h index 0eb22bb5..12b1ec6c 100644 --- a/src/strategy/values/AoeValues.h +++ b/src/strategy/values/AoeValues.h @@ -1,54 +1,54 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_AOEVALUES_H #define _PLAYERBOT_AOEVALUES_H +#include "AiObjectContext.h" #include "GameObject.h" #include "Object.h" #include "Value.h" -#include "AiObjectContext.h" class PlayerbotAI; class AoePositionValue : public CalculatedValue { - public: - AoePositionValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "aoe position") { } +public: + AoePositionValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "aoe position") {} - WorldLocation Calculate() override; + WorldLocation Calculate() override; }; class AoeCountValue : public CalculatedValue { - public: - AoeCountValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "aoe count") { } +public: + AoeCountValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "aoe count") {} - uint8 Calculate() override; + uint8 Calculate() override; }; class HasAreaDebuffValue : public BoolCalculatedValue, public Qualified { - public: - HasAreaDebuffValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI) {} +public: + HasAreaDebuffValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI) {} - Unit* GetTarget() - { - AiObjectContext* ctx = AiObject::context; + Unit* GetTarget() + { + AiObjectContext* ctx = AiObject::context; - return ctx->GetValue(qualifier)->Get(); - } - virtual bool Calculate(); + return ctx->GetValue(qualifier)->Get(); + } + virtual bool Calculate(); }; class AreaDebuffValue : public CalculatedValue { - public: - AreaDebuffValue(PlayerbotAI* botAI) : - CalculatedValue(botAI, "area debuff", 1) { } +public: + AreaDebuffValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "area debuff", 1) {} - Aura* Calculate() override; + Aura* Calculate() override; }; #endif diff --git a/src/strategy/values/Arrow.cpp b/src/strategy/values/Arrow.cpp index 3c3daf28..adcfcde4 100644 --- a/src/strategy/values/Arrow.cpp +++ b/src/strategy/values/Arrow.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "Arrow.h" + #include "Map.h" #include "Playerbots.h" @@ -20,7 +22,8 @@ WorldLocation ArrowFormation::GetLocationInternal() float offset = 0.f; Player* master = botAI->GetMaster(); - if (!master) { + if (!master) + { return Formation::NullLocation; } float orientation = master->GetOrientation(); @@ -44,7 +47,7 @@ WorldLocation ArrowFormation::GetLocationInternal() float x = master->GetPositionX() - masterUnit->GetX() + botUnit->GetX(); float y = master->GetPositionY() - masterUnit->GetY() + botUnit->GetY(); float z = master->GetPositionZ(); - + float ground = master->GetMapHeight(x, y, z + 30.0f); if (ground <= INVALID_HEIGHT) return Formation::NullLocation; @@ -125,7 +128,7 @@ void FormationSlot::PlaceUnits(UnitPlacer* placer) } } -UnitPosition MultiLineUnitPlacer::Place(FormationUnit *unit, uint32 index, uint32 count) +UnitPosition MultiLineUnitPlacer::Place(FormationUnit* unit, uint32 index, uint32 count) { SingleLineUnitPlacer placer(orientation); if (count <= 6) @@ -139,7 +142,7 @@ UnitPosition MultiLineUnitPlacer::Place(FormationUnit *unit, uint32 index, uint3 return placer.Place(unit, indexInLine, lineSize); } -UnitPosition SingleLineUnitPlacer::Place(FormationUnit *unit, uint32 index, uint32 count) +UnitPosition SingleLineUnitPlacer::Place(FormationUnit* unit, uint32 index, uint32 count) { float angle = orientation - M_PI / 2.0f; float x = cos(angle) * sPlayerbotAIConfig->followDistance * ((float)index - (float)count / 2); diff --git a/src/strategy/values/Arrow.h b/src/strategy/values/Arrow.h index 5c6154a1..cd090802 100644 --- a/src/strategy/values/Arrow.h +++ b/src/strategy/values/Arrow.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ARROW_H @@ -13,107 +14,114 @@ class PlayerbotAI; class UnitPosition { - public: - UnitPosition(float x, float y) : x(x), y(y) { } - UnitPosition(UnitPosition const& other) - { - x = other.x; - y = other.y; - } +public: + UnitPosition(float x, float y) : x(x), y(y) {} + UnitPosition(UnitPosition const& other) + { + x = other.x; + y = other.y; + } - float x, y; + float x, y; }; class FormationUnit { - public: - FormationUnit(uint32 groupIndex, bool master) : groupIndex(groupIndex), master(master), position(0, 0) { } - FormationUnit(FormationUnit const& other) : position(other.position.x, other.position.y) - { - groupIndex = other.groupIndex; - master = other.master; - } +public: + FormationUnit(uint32 groupIndex, bool master) : groupIndex(groupIndex), master(master), position(0, 0) {} + FormationUnit(FormationUnit const& other) : position(other.position.x, other.position.y) + { + groupIndex = other.groupIndex; + master = other.master; + } - uint32 GetGroupIdex() { return groupIndex; } - void SetLocation(UnitPosition pos) { position = pos; } - void SetLocation(float x, float y) { position.x = x; position.y = y; } - float GetX() { return position.x; } - float GetY() { return position.y; } + uint32 GetGroupIdex() { return groupIndex; } + void SetLocation(UnitPosition pos) { position = pos; } + void SetLocation(float x, float y) + { + position.x = x; + position.y = y; + } + float GetX() { return position.x; } + float GetY() { return position.y; } - private: - uint32 groupIndex; - bool master; - UnitPosition position; +private: + uint32 groupIndex; + bool master; + UnitPosition position; }; class UnitPlacer { - public: - UnitPlacer() { } +public: + UnitPlacer() {} - virtual UnitPosition Place(FormationUnit* unit, uint32 index, uint32 count) = 0; + virtual UnitPosition Place(FormationUnit* unit, uint32 index, uint32 count) = 0; }; class FormationSlot { - public: - FormationSlot() { } - virtual ~FormationSlot(); +public: + FormationSlot() {} + virtual ~FormationSlot(); - void AddLast(FormationUnit* unit) { units.push_back(unit); } - void InsertAtCenter(FormationUnit* unit) { units.insert(units.begin() + (units.size() + 1) / 2, unit); } - void PlaceUnits(UnitPlacer* placer); - void Move(float dx, float dy); - uint32 Size() const { return units.size(); } + void AddLast(FormationUnit* unit) { units.push_back(unit); } + void InsertAtCenter(FormationUnit* unit) { units.insert(units.begin() + (units.size() + 1) / 2, unit); } + void PlaceUnits(UnitPlacer* placer); + void Move(float dx, float dy); + uint32 Size() const { return units.size(); } - private: - WorldLocation center; - std::vector units; +private: + WorldLocation center; + std::vector units; }; class MultiLineUnitPlacer : public UnitPlacer { - public: - MultiLineUnitPlacer(float orientation) : UnitPlacer(), orientation(orientation) { } +public: + MultiLineUnitPlacer(float orientation) : UnitPlacer(), orientation(orientation) {} - UnitPosition Place(FormationUnit* unit, uint32 index, uint32 count) override; + UnitPosition Place(FormationUnit* unit, uint32 index, uint32 count) override; - private: - float orientation; +private: + float orientation; }; class SingleLineUnitPlacer { - public: - SingleLineUnitPlacer(float orientation) : orientation(orientation) { } +public: + SingleLineUnitPlacer(float orientation) : orientation(orientation) {} - virtual UnitPosition Place(FormationUnit* unit, uint32 index, uint32 count); + virtual UnitPosition Place(FormationUnit* unit, uint32 index, uint32 count); - private: - float orientation; +private: + float orientation; }; class ArrowFormation : public MoveAheadFormation { - public: - ArrowFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "arrow"), built(false), masterUnit(nullptr), botUnit(nullptr) { } +public: + ArrowFormation(PlayerbotAI* botAI) + : MoveAheadFormation(botAI, "arrow"), built(false), masterUnit(nullptr), botUnit(nullptr) + { + } - WorldLocation GetLocationInternal() override; + WorldLocation GetLocationInternal() override; - private: - void Build(); - void FillSlotsExceptMaster(); - void AddMasterToSlot(); - FormationSlot* FindSlot(Player* member); +private: + void Build(); + void FillSlotsExceptMaster(); + void AddMasterToSlot(); + FormationSlot* FindSlot(Player* member); - private: - FormationSlot tanks; - FormationSlot melee; - FormationSlot ranged; - FormationSlot healers; - FormationUnit* masterUnit; - FormationUnit* botUnit; - bool built; +private: + FormationSlot tanks; + FormationSlot melee; + FormationSlot ranged; + FormationSlot healers; + FormationUnit* masterUnit; + FormationUnit* botUnit; + bool built; }; #endif diff --git a/src/strategy/values/AttackerCountValues.cpp b/src/strategy/values/AttackerCountValues.cpp index 7cac0cf0..9cc82a37 100644 --- a/src/strategy/values/AttackerCountValues.cpp +++ b/src/strategy/values/AttackerCountValues.cpp @@ -1,28 +1,31 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AttackerCountValues.h" + #include "Playerbots.h" #include "SharedDefines.h" -uint8 MyAttackerCountValue::Calculate() -{ - return bot->getAttackers().size(); -} +uint8 MyAttackerCountValue::Calculate() { return bot->getAttackers().size(); } bool HasAggroValue::Calculate() { Unit* target = GetTarget(); - if (!target) { + if (!target) + { return true; } Unit* victim = target->GetVictim(); - if (!victim) { + if (!victim) + { return true; } bool isMT = botAI->IsMainTank(bot); - if (victim && (victim->GetGUID() == bot->GetGUID() || (!isMT && victim->ToPlayer() && botAI->IsTank(victim->ToPlayer())))) { + if (victim && + (victim->GetGUID() == bot->GetGUID() || (!isMT && victim->ToPlayer() && botAI->IsTank(victim->ToPlayer())))) + { return true; } return false; @@ -33,7 +36,7 @@ uint8 AttackerCountValue::Calculate() uint32 count = 0; float range = sPlayerbotAIConfig->sightDistance; - GuidVector attackers = context->GetValue("attackers")->Get(); + GuidVector attackers = context->GetValue("attackers")->Get(); for (ObjectGuid const guid : attackers) { Unit* unit = botAI->GetUnit(guid); @@ -50,15 +53,14 @@ uint8 AttackerCountValue::Calculate() uint8 BalancePercentValue::Calculate() { - float playerLevel = 0, - attackerLevel = 0; + float playerLevel = 0, attackerLevel = 0; if (Group* group = bot->GetGroup()) { Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) { - Player *player = ObjectAccessor::FindPlayer(itr->guid); + Player* player = ObjectAccessor::FindPlayer(itr->guid); if (!player || !player->IsAlive()) continue; diff --git a/src/strategy/values/AttackerCountValues.h b/src/strategy/values/AttackerCountValues.h index 0c62d97c..2ee6290c 100644 --- a/src/strategy/values/AttackerCountValues.h +++ b/src/strategy/values/AttackerCountValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ATTACKERCOUNTVALUES_H @@ -13,38 +14,47 @@ class Unit; class AttackerCountValue : public Uint8CalculatedValue, public Qualified { - public: - AttackerCountValue(PlayerbotAI* botAI, std::string const name = "attackers count") : Uint8CalculatedValue(botAI, name) { } +public: + AttackerCountValue(PlayerbotAI* botAI, std::string const name = "attackers count") + : Uint8CalculatedValue(botAI, name) + { + } - Unit* GetTarget(); - uint8 Calculate() override; + Unit* GetTarget(); + uint8 Calculate() override; }; class MyAttackerCountValue : public Uint8CalculatedValue, public Qualified { - public: - MyAttackerCountValue(PlayerbotAI* botAI, std::string const name = "my attackers count") : Uint8CalculatedValue(botAI, name) { } +public: + MyAttackerCountValue(PlayerbotAI* botAI, std::string const name = "my attackers count") + : Uint8CalculatedValue(botAI, name) + { + } - Unit* GetTarget(); - uint8 Calculate() override; + Unit* GetTarget(); + uint8 Calculate() override; }; class HasAggroValue : public BoolCalculatedValue, public Qualified { - public: - HasAggroValue(PlayerbotAI* botAI, std::string const name = "has aggro") : BoolCalculatedValue(botAI, name) { } +public: + HasAggroValue(PlayerbotAI* botAI, std::string const name = "has aggro") : BoolCalculatedValue(botAI, name) {} - Unit* GetTarget(); - bool Calculate() override; + Unit* GetTarget(); + bool Calculate() override; }; class BalancePercentValue : public Uint8CalculatedValue, public Qualified { - public: - BalancePercentValue(PlayerbotAI* botAI, std::string const name = "balance percentage") : Uint8CalculatedValue(botAI, name) { } +public: + BalancePercentValue(PlayerbotAI* botAI, std::string const name = "balance percentage") + : Uint8CalculatedValue(botAI, name) + { + } - Unit* GetTarget(); - uint8 Calculate() override; + Unit* GetTarget(); + uint8 Calculate() override; }; #endif diff --git a/src/strategy/values/AttackerWithoutAuraTargetValue.cpp b/src/strategy/values/AttackerWithoutAuraTargetValue.cpp index 93664712..a9fcd5c4 100644 --- a/src/strategy/values/AttackerWithoutAuraTargetValue.cpp +++ b/src/strategy/values/AttackerWithoutAuraTargetValue.cpp @@ -1,13 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AttackerWithoutAuraTargetValue.h" + #include "Playerbots.h" Unit* AttackerWithoutAuraTargetValue::Calculate() { - GuidVector attackers = botAI->GetAiObjectContext()->GetValue("attackers")->Get(); + GuidVector attackers = botAI->GetAiObjectContext()->GetValue("attackers")->Get(); // Unit* target = botAI->GetAiObjectContext()->GetValue("current target")->Get(); uint32 max_health = 0; Unit* result = nullptr; @@ -20,11 +22,13 @@ Unit* AttackerWithoutAuraTargetValue::Calculate() if (bot->GetDistance(unit) > botAI->GetRange(range)) continue; - if (unit->GetHealth() < max_health) { + if (unit->GetHealth() < max_health) + { continue; } - - if (!botAI->HasAura(qualifier, unit, false, true)) { + + if (!botAI->HasAura(qualifier, unit, false, true)) + { max_health = unit->GetHealth(); result = unit; } diff --git a/src/strategy/values/AttackerWithoutAuraTargetValue.h b/src/strategy/values/AttackerWithoutAuraTargetValue.h index 66e3b891..73867f9d 100644 --- a/src/strategy/values/AttackerWithoutAuraTargetValue.h +++ b/src/strategy/values/AttackerWithoutAuraTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ATTACKERWITHOUTAURATARGETVALUE_H @@ -13,18 +14,21 @@ class Unit; class AttackerWithoutAuraTargetValue : public UnitCalculatedValue, public Qualified { - public: - AttackerWithoutAuraTargetValue(PlayerbotAI* botAI, std::string range = "spell") : UnitCalculatedValue(botAI, "attacker without aura"), range(range) { } +public: + AttackerWithoutAuraTargetValue(PlayerbotAI* botAI, std::string range = "spell") + : UnitCalculatedValue(botAI, "attacker without aura"), range(range) + { + } - protected: - Unit* Calculate() override; - std::string range; +protected: + Unit* Calculate() override; + std::string range; }; class MeleeAttackerWithoutAuraTargetValue : public AttackerWithoutAuraTargetValue { - public: - MeleeAttackerWithoutAuraTargetValue(PlayerbotAI* botAI) : AttackerWithoutAuraTargetValue(botAI, "melee") {} +public: + MeleeAttackerWithoutAuraTargetValue(PlayerbotAI* botAI) : AttackerWithoutAuraTargetValue(botAI, "melee") {} }; #endif diff --git a/src/strategy/values/AttackersValue.cpp b/src/strategy/values/AttackersValue.cpp index 1df21258..b7d5c91f 100644 --- a/src/strategy/values/AttackersValue.cpp +++ b/src/strategy/values/AttackersValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AttackersValue.h" + #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" @@ -23,27 +25,30 @@ GuidVector AttackersValue::Calculate() if (Group* group = bot->GetGroup()) AddAttackersOf(group, targets); - RemoveNonThreating(targets); // prioritized target GuidVector prioritizedTargets = AI_VALUE(GuidVector, "prioritized targets"); - for (ObjectGuid target : prioritizedTargets) { + for (ObjectGuid target : prioritizedTargets) + { Unit* unit = botAI->GetUnit(target); - if (unit && IsValidTarget(unit, bot)) { + if (unit && IsValidTarget(unit, bot)) + { targets.insert(unit); } } - if (Group* group = bot->GetGroup()) { + if (Group* group = bot->GetGroup()) + { ObjectGuid skullGuid = group->GetTargetIcon(7); Unit* skullTarget = botAI->GetUnit(skullGuid); - if (skullTarget && IsValidTarget(skullTarget, bot)) { + if (skullTarget && IsValidTarget(skullTarget, bot)) + { targets.insert(skullTarget); } } - for (Unit* unit : targets) - result.push_back(unit->GetGUID()); + for (Unit* unit : targets) + result.push_back(unit->GetGUID()); if (bot->duel && bot->duel->Opponent) result.push_back(bot->duel->Opponent->GetGUID()); @@ -55,7 +60,8 @@ GuidVector AttackersValue::Calculate() for (ObjectGuid const guid : possibleTargets) { Unit* unit = botAI->GetUnit(guid); - if (unit && unit->IsPlayer() && IsValidTarget(unit, bot)) { + if (unit && unit->IsPlayer() && IsValidTarget(unit, bot)) + { result.push_back(unit->GetGUID()); } } @@ -69,8 +75,9 @@ void AttackersValue::AddAttackersOf(Group* group, std::unordered_set& tar Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) { - Player *member = ObjectAccessor::FindPlayer(itr->guid); - if (!member || !member->IsAlive() || member == bot || member->GetMapId() != bot->GetMapId() || sServerFacade->GetDistance2d(bot, member) > sPlayerbotAIConfig->sightDistance) + Player* member = ObjectAccessor::FindPlayer(itr->guid); + if (!member || !member->IsAlive() || member == bot || member->GetMapId() != bot->GetMapId() || + sServerFacade->GetDistance2d(bot, member) > sPlayerbotAIConfig->sightDistance) continue; AddAttackersOf(member, targets); @@ -79,14 +86,11 @@ void AttackersValue::AddAttackersOf(Group* group, std::unordered_set& tar struct AddGuardiansHelper { - explicit AddGuardiansHelper(std::vector &units) : units(units) { } + explicit AddGuardiansHelper(std::vector& units) : units(units) {} - void operator()(Unit* target) const - { - units.push_back(target); - } + void operator()(Unit* target) const { units.push_back(target); } - std::vector &units; + std::vector& units; }; void AttackersValue::AddAttackersOf(Player* player, std::unordered_set& targets) @@ -94,18 +98,20 @@ void AttackersValue::AddAttackersOf(Player* player, std::unordered_set& t if (!player || !player->IsInWorld() || player->IsBeingTeleported()) return; - HostileRefMgr& refManager = player->getHostileRefMgr(); - HostileReference *ref = refManager.getFirst(); + HostileRefMgr& refManager = player->getHostileRefMgr(); + HostileReference* ref = refManager.getFirst(); if (!ref) return; - while( ref ) + while (ref) { - ThreatMgr *threatMgr = ref->GetSource(); - Unit *attacker = threatMgr->GetOwner(); - Unit *victim = attacker->GetVictim(); + ThreatMgr* threatMgr = ref->GetSource(); + Unit* attacker = threatMgr->GetOwner(); + Unit* victim = attacker->GetVictim(); - if (player->IsValidAttackTarget(attacker) && player->GetDistance2d(attacker) < sPlayerbotAIConfig->sightDistance) { + if (player->IsValidAttackTarget(attacker) && + player->GetDistance2d(attacker) < sPlayerbotAIConfig->sightDistance) + { targets.insert(attacker); } ref = ref->next(); @@ -114,12 +120,12 @@ void AttackersValue::AddAttackersOf(Player* player, std::unordered_set& t void AttackersValue::RemoveNonThreating(std::unordered_set& targets) { - for(std::unordered_set::iterator tIter = targets.begin(); tIter != targets.end();) + for (std::unordered_set::iterator tIter = targets.begin(); tIter != targets.end();) { Unit* unit = *tIter; - if(bot->GetMapId() != unit->GetMapId() || !hasRealThreat(unit) || !IsValidTarget(unit, bot)) + if (bot->GetMapId() != unit->GetMapId() || !hasRealThreat(unit) || !IsValidTarget(unit, bot)) { - std::unordered_set::iterator tIter2 = tIter; + std::unordered_set::iterator tIter2 = tIter; ++tIter; targets.erase(tIter2); } @@ -128,18 +134,14 @@ void AttackersValue::RemoveNonThreating(std::unordered_set& targets) } } -bool AttackersValue::hasRealThreat(Unit *attacker) +bool AttackersValue::hasRealThreat(Unit* attacker) { - return attacker && - attacker->IsInWorld() && - attacker->IsAlive() && - !attacker->IsPolymorphed() && - // !attacker->isInRoots() && - !attacker->IsFriendlyTo(bot); - (attacker->GetThreatMgr().getCurrentVictim() || dynamic_cast(attacker)); + return attacker && attacker->IsInWorld() && attacker->IsAlive() && !attacker->IsPolymorphed() && + // !attacker->isInRoots() && + !attacker->IsFriendlyTo(bot); + (attacker->GetThreatMgr().getCurrentVictim() || dynamic_cast(attacker)); } - bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range) { Creature* c = attacker->ToCreature(); @@ -148,7 +150,7 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range) rti = bot->GetGroup()->GetTargetIcon(7) == attacker->GetGUID(); PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - + bool leaderHasThreat = false; if (attacker && bot->GetGroup() && botAI->GetMaster()) leaderHasThreat = attacker->GetThreatMgr().GetThreat(botAI->GetMaster()); @@ -163,40 +165,48 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range) // bool inCannon = botAI->IsInVehicle(false, true); // bool enemy = botAI->GetAiObjectContext()->GetValue("enemy player target")->Get(); - - return attacker && attacker->IsVisible() && - attacker->IsInWorld() && - attacker->GetMapId() == bot->GetMapId() && - !attacker->isDead() && - !attacker->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NON_ATTACKABLE_2) && - // (inCannon || !attacker->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) && attacker->CanSeeOrDetect(bot) && - // !(attacker->HasUnitState(UNIT_STATE_STUNNED) && botAI->HasAura("shackle undead", attacker)) && !((attacker->IsPolymorphed() || botAI->HasAura("sap", attacker) || /*attacker->IsCharmed() ||*/ attacker->isFeared()) && !rti) && - /*!sServerFacade->IsInRoots(attacker) &&*/ - !attacker->IsFriendlyTo(bot) && - !attacker->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION) && - // !(attacker->GetGUID().IsPet() && enemy) && - !(attacker->GetCreatureType() == CREATURE_TYPE_CRITTER && !attacker->IsInCombat()) && - !attacker->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC) && - !attacker->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE) && - bot->CanSeeOrDetect(attacker) && - !(sPlayerbotAIConfig->IsPvpProhibited(attacker->GetZoneId(), attacker->GetAreaId()) && (attacker->GetGUID().IsPlayer() || attacker->GetGUID().IsPet())) && - !(attacker->IsPlayer() && !attacker->IsPvP() && !attacker->IsFFAPvP() && (!bot->duel || bot->duel->Opponent != attacker)) && - (!c || (!c->IsInEvadeMode() && ((!isMemberBotGroup && botAI->HasStrategy("attack tagged", BOT_STATE_NON_COMBAT)) || - leaderHasThreat || (!c->hasLootRecipient() && (!c->GetVictim() || (c->GetVictim() && ((!c->GetVictim()->IsPlayer() || bot->IsInSameGroupWith(c->GetVictim()->ToPlayer())) || - (botAI->GetMaster() && c->GetVictim() == botAI->GetMaster()))))) || c->isTappedBy(bot)))); + + return attacker && attacker->IsVisible() && attacker->IsInWorld() && attacker->GetMapId() == bot->GetMapId() && + !attacker->isDead() && + !attacker->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NON_ATTACKABLE_2) && + // (inCannon || !attacker->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) && + // attacker->CanSeeOrDetect(bot) && + // !(attacker->HasUnitState(UNIT_STATE_STUNNED) && botAI->HasAura("shackle undead", attacker)) && + // !((attacker->IsPolymorphed() || botAI->HasAura("sap", attacker) || /*attacker->IsCharmed() ||*/ + // attacker->isFeared()) && !rti) && + /*!sServerFacade->IsInRoots(attacker) &&*/ + !attacker->IsFriendlyTo(bot) && !attacker->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION) && + // !(attacker->GetGUID().IsPet() && enemy) && + !(attacker->GetCreatureType() == CREATURE_TYPE_CRITTER && !attacker->IsInCombat()) && + !attacker->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC) && !attacker->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE) && + bot->CanSeeOrDetect(attacker) && + !(sPlayerbotAIConfig->IsPvpProhibited(attacker->GetZoneId(), attacker->GetAreaId()) && + (attacker->GetGUID().IsPlayer() || attacker->GetGUID().IsPet())) && + !(attacker->IsPlayer() && !attacker->IsPvP() && !attacker->IsFFAPvP() && + (!bot->duel || bot->duel->Opponent != attacker)) && + (!c || + (!c->IsInEvadeMode() && + ((!isMemberBotGroup && botAI->HasStrategy("attack tagged", BOT_STATE_NON_COMBAT)) || leaderHasThreat || + (!c->hasLootRecipient() && + (!c->GetVictim() || + (c->GetVictim() && + ((!c->GetVictim()->IsPlayer() || bot->IsInSameGroupWith(c->GetVictim()->ToPlayer())) || + (botAI->GetMaster() && c->GetVictim() == botAI->GetMaster()))))) || + c->isTappedBy(bot)))); } -bool AttackersValue::IsValidTarget(Unit *attacker, Player *bot) +bool AttackersValue::IsValidTarget(Unit* attacker, Player* bot) { return IsPossibleTarget(attacker, bot) && bot->IsWithinLOSInMap(attacker); - // (attacker->GetThreatMgr().getCurrentVictim() || attacker->GetGuidValue(UNIT_FIELD_TARGET) || - // attacker->GetGUID().IsPlayer() || attacker->GetGUID() == GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue("pull target")->Get()); + // (attacker->GetThreatMgr().getCurrentVictim() || attacker->GetGuidValue(UNIT_FIELD_TARGET) || + // attacker->GetGUID().IsPlayer() || attacker->GetGUID() == + // GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue("pull target")->Get()); } bool PossibleAddsValue::Calculate() { - GuidVector possible = botAI->GetAiObjectContext()->GetValue("possible targets no los")->Get(); - GuidVector attackers = botAI->GetAiObjectContext()->GetValue("attackers")->Get(); + GuidVector possible = botAI->GetAiObjectContext()->GetValue("possible targets no los")->Get(); + GuidVector attackers = botAI->GetAiObjectContext()->GetValue("attackers")->Get(); for (ObjectGuid const guid : possible) { diff --git a/src/strategy/values/AttackersValue.h b/src/strategy/values/AttackersValue.h index 3a4ae20a..d2f69c27 100644 --- a/src/strategy/values/AttackersValue.h +++ b/src/strategy/values/AttackersValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ATTACKERSVALUE_H @@ -15,32 +16,37 @@ class Unit; class AttackersValue : public ObjectGuidListCalculatedValue { - public: - AttackersValue(PlayerbotAI* botAI) : ObjectGuidListCalculatedValue(botAI, "attackers", 1 * 1000) { } +public: + AttackersValue(PlayerbotAI* botAI) : ObjectGuidListCalculatedValue(botAI, "attackers", 1 * 1000) {} - GuidVector Calculate(); - static bool IsPossibleTarget(Unit* attacker, Player* bot, float range = sPlayerbotAIConfig->sightDistance); - static bool IsValidTarget(Unit* attacker, Player* bot); + GuidVector Calculate(); + static bool IsPossibleTarget(Unit* attacker, Player* bot, float range = sPlayerbotAIConfig->sightDistance); + static bool IsValidTarget(Unit* attacker, Player* bot); - private: - void AddAttackersOf(Group* group, std::unordered_set& targets); - void AddAttackersOf(Player* player, std::unordered_set& targets); - void RemoveNonThreating(std::unordered_set& targets); - bool hasRealThreat(Unit* attacker); +private: + void AddAttackersOf(Group* group, std::unordered_set& targets); + void AddAttackersOf(Player* player, std::unordered_set& targets); + void RemoveNonThreating(std::unordered_set& targets); + bool hasRealThreat(Unit* attacker); }; class PossibleAddsValue : public BoolCalculatedValue { - public: - PossibleAddsValue(PlayerbotAI* botAI, std::string const name = "possible adds") : BoolCalculatedValue(botAI, name) { } +public: + PossibleAddsValue(PlayerbotAI* botAI, std::string const name = "possible adds") : BoolCalculatedValue(botAI, name) + { + } - bool Calculate() override; + bool Calculate() override; }; class PrioritizedTargetsValue : public ManualSetValue -{ - public: - PrioritizedTargetsValue(PlayerbotAI* botAI, std::string const name = "prioritized targets"): ManualSetValue(botAI, GuidVector(), name) {} +{ +public: + PrioritizedTargetsValue(PlayerbotAI* botAI, std::string const name = "prioritized targets") + : ManualSetValue(botAI, GuidVector(), name) + { + } }; #endif diff --git a/src/strategy/values/AvailableLootValue.cpp b/src/strategy/values/AvailableLootValue.cpp index 3bc556c2..2adb410f 100644 --- a/src/strategy/values/AvailableLootValue.cpp +++ b/src/strategy/values/AvailableLootValue.cpp @@ -1,23 +1,24 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "AvailableLootValue.h" + #include "LootObjectStack.h" #include "Playerbots.h" #include "ServerFacade.h" -AvailableLootValue::AvailableLootValue(PlayerbotAI* botAI, std::string const name) : ManualSetValue(botAI, nullptr, name) +AvailableLootValue::AvailableLootValue(PlayerbotAI* botAI, std::string const name) + : ManualSetValue(botAI, nullptr, name) { value = new LootObjectStack(botAI->GetBot()); } -AvailableLootValue::~AvailableLootValue() -{ - delete value; -} +AvailableLootValue::~AvailableLootValue() { delete value; } -LootTargetValue::LootTargetValue(PlayerbotAI* botAI, std::string const name) : ManualSetValue(botAI, LootObject(), name) +LootTargetValue::LootTargetValue(PlayerbotAI* botAI, std::string const name) + : ManualSetValue(botAI, LootObject(), name) { } @@ -25,5 +26,5 @@ bool CanLootValue::Calculate() { LootObject loot = AI_VALUE(LootObject, "loot target"); return !loot.IsEmpty() && loot.GetWorldObject(bot) && loot.IsLootPossible(bot) && - sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "loot target"), INTERACTION_DISTANCE); + sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "loot target"), INTERACTION_DISTANCE); } diff --git a/src/strategy/values/AvailableLootValue.h b/src/strategy/values/AvailableLootValue.h index 9cbb8def..1ecea8fe 100644 --- a/src/strategy/values/AvailableLootValue.h +++ b/src/strategy/values/AvailableLootValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_AVAILABLELOOTVALUE_H @@ -12,23 +13,23 @@ class PlayerbotAI; class AvailableLootValue : public ManualSetValue { - public: - AvailableLootValue(PlayerbotAI* botAI, std::string const name = "available loot"); - virtual ~AvailableLootValue(); +public: + AvailableLootValue(PlayerbotAI* botAI, std::string const name = "available loot"); + virtual ~AvailableLootValue(); }; class LootTargetValue : public ManualSetValue { - public: - LootTargetValue(PlayerbotAI* botAI, std::string const name = "loot target"); +public: + LootTargetValue(PlayerbotAI* botAI, std::string const name = "loot target"); }; class CanLootValue : public BoolCalculatedValue { - public: - CanLootValue(PlayerbotAI* botAI, std::string const name = "can loot") : BoolCalculatedValue(botAI, name) { } +public: + CanLootValue(PlayerbotAI* botAI, std::string const name = "can loot") : BoolCalculatedValue(botAI, name) {} - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/BudgetValues.cpp b/src/strategy/values/BudgetValues.cpp index e086d598..e6ee8c80 100644 --- a/src/strategy/values/BudgetValues.cpp +++ b/src/strategy/values/BudgetValues.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "BudgetValues.h" + #include "Playerbots.h" uint32 MaxGearRepairCostValue::Calculate() @@ -22,7 +24,7 @@ uint32 MaxGearRepairCostValue::Calculate() uint32 curDurability = item->GetUInt32Value(ITEM_FIELD_DURABILITY); - if (i >= EQUIPMENT_SLOT_END && curDurability >= maxDurability) //Only count items equiped or already damanged. + if (i >= EQUIPMENT_SLOT_END && curDurability >= maxDurability) // Only count items equiped or already damanged. continue; ItemTemplate const* ditemProto = item->GetTemplate(); @@ -36,11 +38,11 @@ uint32 MaxGearRepairCostValue::Calculate() if (!dQualitymodEntry) continue; - uint32 dmultiplier = dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class, ditemProto->SubClass)]; + uint32 dmultiplier = + dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class, ditemProto->SubClass)]; uint32 costs = uint32(maxDurability * dmultiplier * double(dQualitymodEntry->quality_mod)); - TotalCost += costs; } @@ -80,7 +82,8 @@ uint32 RepairCostValue::Calculate() if (!dQualitymodEntry) continue; - uint32 dmultiplier = dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class, ditemProto->SubClass)]; + uint32 dmultiplier = + dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class, ditemProto->SubClass)]; uint32 costs = uint32(LostDurability * dmultiplier * double(dQualitymodEntry->quality_mod)); TotalCost += costs; @@ -109,7 +112,8 @@ uint32 TrainCostValue::Calculate() if (!trainer_spells) continue; - for (TrainerSpellMap::const_iterator iter = trainer_spells->spellList.begin(); iter != trainer_spells->spellList.end(); ++iter) + for (TrainerSpellMap::const_iterator iter = trainer_spells->spellList.begin(); + iter != trainer_spells->spellList.end(); ++iter) { TrainerSpell const* tSpell = &iter->second; if (!tSpell) @@ -136,14 +140,14 @@ uint32 TrainCostValue::Calculate() uint32 MoneyNeededForValue::Calculate() { - NeedMoneyFor needMoneyFor = NeedMoneyFor(stoi(getQualifier())); + NeedMoneyFor needMoneyFor = NeedMoneyFor(stoi(getQualifier())); - PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - AiObjectContext* context = botAI->GetAiObjectContext(); + PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); + AiObjectContext* context = botAI->GetAiObjectContext(); - uint32 moneyWanted = 0; + uint32 moneyWanted = 0; - uint32 level = bot->GetLevel(); + uint32 level = bot->GetLevel(); switch (needMoneyFor) { @@ -154,37 +158,49 @@ uint32 MoneyNeededForValue::Calculate() moneyWanted = AI_VALUE(uint32, "max repair cost"); break; case NeedMoneyFor::ammo: - moneyWanted = (bot->getClass() == CLASS_HUNTER) ? (level * level * level) / 10 : 0; //Or level^3 (1s @ lvl10, 30s @ lvl30, 2g @ lvl60, 5g @ lvl80): Todo replace (should be best ammo buyable x 8 stacks cost) + moneyWanted = (bot->getClass() == CLASS_HUNTER) + ? (level * level * level) / 10 + : 0; // Or level^3 (1s @ lvl10, 30s @ lvl30, 2g @ lvl60, 5g @ lvl80): Todo replace + // (should be best ammo buyable x 8 stacks cost) break; case NeedMoneyFor::spells: moneyWanted = AI_VALUE(uint32, "train cost"); break; case NeedMoneyFor::travel: - moneyWanted = bot->isTaxiCheater() ? 0 : 1500; //15s for traveling half a continent. Todo: Add better calculation (Should be ???) + moneyWanted = + bot->isTaxiCheater() + ? 0 + : 1500; // 15s for traveling half a continent. Todo: Add better calculation (Should be ???) break; case NeedMoneyFor::gear: - moneyWanted = level * level * level; //Or level^3 (10s @ lvl10, 3g @ lvl30, 20g @ lvl60, 50g @ lvl80): Todo replace (Should be ~total cost of all >green gear equiped) + moneyWanted = level * level * level; // Or level^3 (10s @ lvl10, 3g @ lvl30, 20g @ lvl60, 50g @ lvl80): + // Todo replace (Should be ~total cost of all >green gear equiped) break; case NeedMoneyFor::consumables: - moneyWanted = (level * level * level) / 10; //Or level^3 (1s @ lvl10, 30s @ lvl30, 2g @ lvl60, 5g @ lvl80): Todo replace (Should be best food/drink x 2 stacks cost) + moneyWanted = + (level * level * level) / 10; // Or level^3 (1s @ lvl10, 30s @ lvl30, 2g @ lvl60, 5g @ lvl80): Todo + // replace (Should be best food/drink x 2 stacks cost) break; case NeedMoneyFor::guild: if (botAI->HasStrategy("guild", BOT_STATE_NON_COMBAT)) { if (bot->GetGuildId()) - moneyWanted = AI_VALUE2(uint32, "item count", chat->FormatQItem(5976)) ? 0 : 10000; //1g (tabard) + moneyWanted = AI_VALUE2(uint32, "item count", chat->FormatQItem(5976)) ? 0 : 10000; // 1g (tabard) else - moneyWanted = AI_VALUE2(uint32, "item count", chat->FormatQItem(5863)) ? 0 : 10000; //10s (guild charter) + moneyWanted = + AI_VALUE2(uint32, "item count", chat->FormatQItem(5863)) ? 0 : 10000; // 10s (guild charter) } break; case NeedMoneyFor::tradeskill: - moneyWanted = (level * level * level); //Or level^3 (10s @ lvl10, 3g @ lvl30, 20g @ lvl60, 50g @ lvl80): Todo replace (Should be buyable reagents that combined allow crafting of usefull items) + moneyWanted = (level * level * + level); // Or level^3 (10s @ lvl10, 3g @ lvl30, 20g @ lvl60, 50g @ lvl80): Todo replace + // (Should be buyable reagents that combined allow crafting of usefull items) break; default: break; } - return moneyWanted; + return moneyWanted; }; uint32 TotalMoneyNeededForValue::Calculate() @@ -217,7 +233,8 @@ uint32 FreeMoneyForValue::Calculate() if (botAI->HasActivePlayerMaster()) return money; - uint32 savedMoney = AI_VALUE2(uint32, "total money needed for", getQualifier()) - AI_VALUE2(uint32, "money needed for", getQualifier()); + uint32 savedMoney = AI_VALUE2(uint32, "total money needed for", getQualifier()) - + AI_VALUE2(uint32, "money needed for", getQualifier()); if (savedMoney > money) return 0; @@ -225,7 +242,4 @@ uint32 FreeMoneyForValue::Calculate() return money - savedMoney; }; -bool ShouldGetMoneyValue::Calculate() -{ - return !AI_VALUE2(uint32, "free money for", (uint32) NeedMoneyFor::anything); -}; +bool ShouldGetMoneyValue::Calculate() { return !AI_VALUE2(uint32, "free money for", (uint32)NeedMoneyFor::anything); }; diff --git a/src/strategy/values/BudgetValues.h b/src/strategy/values/BudgetValues.h index 47585dd7..b1516953 100644 --- a/src/strategy/values/BudgetValues.h +++ b/src/strategy/values/BudgetValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_BUDGETVALUES_H @@ -12,75 +13,76 @@ class PlayerbotAI; enum class NeedMoneyFor : uint32 { - none = 0, - repair = 1, - ammo = 2, - spells = 3, - travel = 4, + none = 0, + repair = 1, + ammo = 2, + spells = 3, + travel = 4, consumables = 5, - gear = 6, - guild = 7, - tradeskill = 8, - anything = 9 + gear = 6, + guild = 7, + tradeskill = 8, + anything = 9 }; class MaxGearRepairCostValue : public Uint32CalculatedValue { - public: - MaxGearRepairCostValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI,"max repair cost", 60) { } +public: + MaxGearRepairCostValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "max repair cost", 60) {} - uint32 Calculate() override; + uint32 Calculate() override; }; class RepairCostValue : public Uint32CalculatedValue { - public: - RepairCostValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "repair cost", 60) { } +public: + RepairCostValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "repair cost", 60) {} - uint32 Calculate() override; + uint32 Calculate() override; }; class TrainCostValue : public Uint32CalculatedValue { - public: - TrainCostValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "train cost", 60) { } +public: + TrainCostValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "train cost", 60) {} - uint32 Calculate() override; + uint32 Calculate() override; }; class MoneyNeededForValue : public Uint32CalculatedValue, public Qualified { - public: - MoneyNeededForValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "money needed for",60) { } +public: + MoneyNeededForValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "money needed for", 60) {} - uint32 Calculate() override; + uint32 Calculate() override; }; class TotalMoneyNeededForValue : public Uint32CalculatedValue, public Qualified { - public: - TotalMoneyNeededForValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "total money needed for", 60) { } +public: + TotalMoneyNeededForValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "total money needed for", 60) {} - uint32 Calculate() override; + uint32 Calculate() override; - private: - std::vector saveMoneyFor = { NeedMoneyFor::guild,NeedMoneyFor::repair,NeedMoneyFor::ammo, NeedMoneyFor::spells, NeedMoneyFor::travel }; +private: + std::vector saveMoneyFor = {NeedMoneyFor::guild, NeedMoneyFor::repair, NeedMoneyFor::ammo, + NeedMoneyFor::spells, NeedMoneyFor::travel}; }; class FreeMoneyForValue : public Uint32CalculatedValue, public Qualified { - public: - FreeMoneyForValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "free money for") { } +public: + FreeMoneyForValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "free money for") {} - uint32 Calculate() override; + uint32 Calculate() override; }; class ShouldGetMoneyValue : public BoolCalculatedValue { - public: - ShouldGetMoneyValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should get money",2) { } +public: + ShouldGetMoneyValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should get money", 2) {} - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/CcTargetValue.cpp b/src/strategy/values/CcTargetValue.cpp index dd7a0e1c..5b91c239 100644 --- a/src/strategy/values/CcTargetValue.cpp +++ b/src/strategy/values/CcTargetValue.cpp @@ -1,83 +1,90 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CcTargetValue.h" + #include "Action.h" #include "Playerbots.h" #include "ServerFacade.h" class FindTargetForCcStrategy : public FindTargetStrategy { - public: - FindTargetForCcStrategy(PlayerbotAI* botAI, std::string const spell) : FindTargetStrategy(botAI), spell(spell), maxDistance(0.f) { } +public: + FindTargetForCcStrategy(PlayerbotAI* botAI, std::string const spell) + : FindTargetStrategy(botAI), spell(spell), maxDistance(0.f) + { + } - public: - void CheckAttacker(Unit* creature, ThreatMgr* threatMgr) override +public: + void CheckAttacker(Unit* creature, ThreatMgr* threatMgr) override + { + Player* bot = botAI->GetBot(); + if (!botAI->CanCastSpell(spell, creature)) + return; + + if (*botAI->GetAiObjectContext()->GetValue("rti cc target") == creature) { - Player* bot = botAI->GetBot(); - if (!botAI->CanCastSpell(spell, creature)) - return; - - if (*botAI->GetAiObjectContext()->GetValue("rti cc target") == creature) - { - result = creature; - return; - } - - if (*botAI->GetAiObjectContext()->GetValue("current target") == creature) - return; - - uint8 health = static_cast(creature->GetHealthPct()); - if (health < sPlayerbotAIConfig->mediumHealth) - return; - - float minDistance = botAI->GetRange("spell"); - Group* group = bot->GetGroup(); - if (!group) - return; - - if (*botAI->GetAiObjectContext()->GetValue("aoe count") > 2) - { - WorldLocation aoe = *botAI->GetAiObjectContext()->GetValue("aoe position"); - if (sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(creature, aoe.GetPositionX(), aoe.GetPositionY()), sPlayerbotAIConfig->aoeRadius)) - return; - } - - uint32 tankCount = 0; - uint32 dpsCount = 0; - GetPlayerCount(creature, &tankCount, &dpsCount); - if (!tankCount || !dpsCount) - { - result = creature; - return; - } - - Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); - for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) - { - Player *member = ObjectAccessor::FindPlayer(itr->guid); - if (!member || !member->IsAlive() || member == bot) - continue; - - if (!botAI->IsTank(member)) - continue; - - float distance = sServerFacade->GetDistance2d(member, creature); - if (distance < minDistance) - minDistance = distance; - } - - if (!result || minDistance > maxDistance) - { - result = creature; - maxDistance = minDistance; - } + result = creature; + return; } - private: - std::string const spell; - float maxDistance; + if (*botAI->GetAiObjectContext()->GetValue("current target") == creature) + return; + + uint8 health = static_cast(creature->GetHealthPct()); + if (health < sPlayerbotAIConfig->mediumHealth) + return; + + float minDistance = botAI->GetRange("spell"); + Group* group = bot->GetGroup(); + if (!group) + return; + + if (*botAI->GetAiObjectContext()->GetValue("aoe count") > 2) + { + WorldLocation aoe = *botAI->GetAiObjectContext()->GetValue("aoe position"); + if (sServerFacade->IsDistanceLessOrEqualThan( + sServerFacade->GetDistance2d(creature, aoe.GetPositionX(), aoe.GetPositionY()), + sPlayerbotAIConfig->aoeRadius)) + return; + } + + uint32 tankCount = 0; + uint32 dpsCount = 0; + GetPlayerCount(creature, &tankCount, &dpsCount); + if (!tankCount || !dpsCount) + { + result = creature; + return; + } + + Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); + for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) + { + Player* member = ObjectAccessor::FindPlayer(itr->guid); + if (!member || !member->IsAlive() || member == bot) + continue; + + if (!botAI->IsTank(member)) + continue; + + float distance = sServerFacade->GetDistance2d(member, creature); + if (distance < minDistance) + minDistance = distance; + } + + if (!result || minDistance > maxDistance) + { + result = creature; + maxDistance = minDistance; + } + } + +private: + std::string const spell; + float maxDistance; }; Unit* CcTargetValue::Calculate() diff --git a/src/strategy/values/CcTargetValue.h b/src/strategy/values/CcTargetValue.h index e42992d0..b77b5a0a 100644 --- a/src/strategy/values/CcTargetValue.h +++ b/src/strategy/values/CcTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CCTARGETVALUE_H @@ -13,10 +14,10 @@ class Unit; class CcTargetValue : public TargetValue, public Qualified { - public: - CcTargetValue(PlayerbotAI* botAI, std::string const name = "cc target") : TargetValue(botAI, name) { } +public: + CcTargetValue(PlayerbotAI* botAI, std::string const name = "cc target") : TargetValue(botAI, name) {} - Unit* Calculate() override; + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/ChatValue.h b/src/strategy/values/ChatValue.h index 7c867361..6859374e 100644 --- a/src/strategy/values/ChatValue.h +++ b/src/strategy/values/ChatValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CHATVALUE_H @@ -13,8 +14,11 @@ enum ChatMsg : uint32; class ChatValue : public ManualSetValue { - public: - ChatValue(PlayerbotAI* botAI, std::string const name = "chat") : ManualSetValue(botAI, CHAT_MSG_WHISPER, name) { } +public: + ChatValue(PlayerbotAI* botAI, std::string const name = "chat") + : ManualSetValue(botAI, CHAT_MSG_WHISPER, name) + { + } }; #endif diff --git a/src/strategy/values/CollisionValue.cpp b/src/strategy/values/CollisionValue.cpp index 3592e540..119bfc94 100644 --- a/src/strategy/values/CollisionValue.cpp +++ b/src/strategy/values/CollisionValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CollisionValue.h" + #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" diff --git a/src/strategy/values/CollisionValue.h b/src/strategy/values/CollisionValue.h index 25bff729..84d32261 100644 --- a/src/strategy/values/CollisionValue.h +++ b/src/strategy/values/CollisionValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_COLLISIONVALUE_H @@ -12,10 +13,13 @@ class PlayerbotAI; class CollisionValue : public BoolCalculatedValue, public Qualified { - public: - CollisionValue(PlayerbotAI* botAI, std::string const name = "collision") : BoolCalculatedValue(botAI, name), Qualified() { } +public: + CollisionValue(PlayerbotAI* botAI, std::string const name = "collision") + : BoolCalculatedValue(botAI, name), Qualified() + { + } - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/CraftValue.h b/src/strategy/values/CraftValue.h index eb51b1d9..fea09a21 100644 --- a/src/strategy/values/CraftValue.h +++ b/src/strategy/values/CraftValue.h @@ -1,71 +1,72 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CRAFTVALUE_H #define _PLAYERBOT_CRAFTVALUE_H -#include "Value.h" - #include +#include "Value.h" + class PlayerbotAI; class CraftData { - public: - CraftData() : itemId(0) { } - CraftData(CraftData const& other) : itemId(other.itemId) +public: + CraftData() : itemId(0) {} + CraftData(CraftData const& other) : itemId(other.itemId) + { + required.insert(other.required.begin(), other.required.end()); + obtained.insert(other.obtained.begin(), other.obtained.end()); + } + + uint32 itemId; + std::map required, obtained; + + bool IsEmpty() { return itemId == 0; } + void Reset() { itemId = 0; } + bool IsRequired(uint32 item) { return required.find(item) != required.end(); } + bool IsFulfilled() + { + for (std::map::iterator i = required.begin(); i != required.end(); ++i) { - required.insert(other.required.begin(), other.required.end()); - obtained.insert(other.obtained.begin(), other.obtained.end()); + uint32 item = i->first; + if (obtained[item] < i->second) + return false; } - uint32 itemId; - std::map required, obtained; - - bool IsEmpty() { return itemId == 0; } - void Reset() { itemId = 0; } - bool IsRequired(uint32 item) { return required.find(item) != required.end(); } - bool IsFulfilled() + return true; + } + void AddObtained(uint32 itemId, uint32 count) + { + if (IsRequired(itemId)) { - for (std::map::iterator i = required.begin(); i != required.end(); ++i) - { - uint32 item = i->first; - if (obtained[item] < i->second) - return false; - } - - return true; + obtained[itemId] += count; } - void AddObtained(uint32 itemId, uint32 count) + } + + void Crafted(uint32 count) + { + for (std::map::iterator i = required.begin(); i != required.end(); ++i) { - if (IsRequired(itemId)) + uint32 item = i->first; + if (obtained[item] >= required[item] * count) { - obtained[itemId] += count; - } - } - - void Crafted(uint32 count) - { - for (std::map::iterator i = required.begin(); i != required.end(); ++i) - { - uint32 item = i->first; - if (obtained[item] >= required[item] * count) - { - obtained[item] -= required[item] * count; - } + obtained[item] -= required[item] * count; } } + } }; class CraftValue : public ManualSetValue { - public: - CraftValue(PlayerbotAI* botAI, std::string const name = "craft") : ManualSetValue(botAI, data, name) { } +public: + CraftValue(PlayerbotAI* botAI, std::string const name = "craft") : ManualSetValue(botAI, data, name) {} - private: - CraftData data; +private: + CraftData data; }; #endif diff --git a/src/strategy/values/CurrentCcTargetValue.cpp b/src/strategy/values/CurrentCcTargetValue.cpp index 459845d9..2b107207 100644 --- a/src/strategy/values/CurrentCcTargetValue.cpp +++ b/src/strategy/values/CurrentCcTargetValue.cpp @@ -1,23 +1,27 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CurrentCcTargetValue.h" + #include "Playerbots.h" class FindCurrentCcTargetStrategy : public FindTargetStrategy { - public: - FindCurrentCcTargetStrategy(PlayerbotAI* botAI, std::string const spell) : FindTargetStrategy(botAI), spell(spell) { } +public: + FindCurrentCcTargetStrategy(PlayerbotAI* botAI, std::string const spell) : FindTargetStrategy(botAI), spell(spell) + { + } - void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override - { - if (botAI->HasAura(spell, attacker)) - result = attacker; - } + void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + { + if (botAI->HasAura(spell, attacker)) + result = attacker; + } - private: - std::string const spell; +private: + std::string const spell; }; Unit* CurrentCcTargetValue::Calculate() diff --git a/src/strategy/values/CurrentCcTargetValue.h b/src/strategy/values/CurrentCcTargetValue.h index 21271b22..35e8c808 100644 --- a/src/strategy/values/CurrentCcTargetValue.h +++ b/src/strategy/values/CurrentCcTargetValue.h @@ -1,22 +1,23 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CURRENTCCTARGETVALUE_H #define _PLAYERBOT_CURRENTCCTARGETVALUE_H -#include "TargetValue.h" #include "NamedObjectContext.h" +#include "TargetValue.h" class PlayerbotAI; class Unit; class CurrentCcTargetValue : public TargetValue, public Qualified { - public: - CurrentCcTargetValue(PlayerbotAI* botAI, std::string const name = "current cc target") : TargetValue(botAI, name) { } +public: + CurrentCcTargetValue(PlayerbotAI* botAI, std::string const name = "current cc target") : TargetValue(botAI, name) {} - Unit* Calculate() override; + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/CurrentTargetValue.cpp b/src/strategy/values/CurrentTargetValue.cpp index 66e33a2b..8a25de9c 100644 --- a/src/strategy/values/CurrentTargetValue.cpp +++ b/src/strategy/values/CurrentTargetValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "CurrentTargetValue.h" + #include "Playerbots.h" Unit* CurrentTargetValue::Get() @@ -17,7 +19,4 @@ Unit* CurrentTargetValue::Get() return unit; } -void CurrentTargetValue::Set(Unit* target) -{ - selection = target ? target->GetGUID() : ObjectGuid::Empty; -} +void CurrentTargetValue::Set(Unit* target) { selection = target ? target->GetGUID() : ObjectGuid::Empty; } diff --git a/src/strategy/values/CurrentTargetValue.h b/src/strategy/values/CurrentTargetValue.h index 538bd321..f7f79dfa 100644 --- a/src/strategy/values/CurrentTargetValue.h +++ b/src/strategy/values/CurrentTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_CURRENTTARGETVALUE_H @@ -12,14 +13,17 @@ class Unit; class CurrentTargetValue : public UnitManualSetValue { - public: - CurrentTargetValue(PlayerbotAI* botAI, std::string const name = "current target") : UnitManualSetValue(botAI, nullptr, name) { } +public: + CurrentTargetValue(PlayerbotAI* botAI, std::string const name = "current target") + : UnitManualSetValue(botAI, nullptr, name) + { + } - Unit* Get() override; - void Set(Unit* unit) override; + Unit* Get() override; + void Set(Unit* unit) override; - private: - ObjectGuid selection; +private: + ObjectGuid selection; }; #endif diff --git a/src/strategy/values/DistanceValue.cpp b/src/strategy/values/DistanceValue.cpp index 00850ed6..25cefe0a 100644 --- a/src/strategy/values/DistanceValue.cpp +++ b/src/strategy/values/DistanceValue.cpp @@ -1,14 +1,16 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DistanceValue.h" + #include "Formations.h" -#include "PositionValue.h" -#include "Stances.h" #include "LootObjectStack.h" #include "Playerbots.h" +#include "PositionValue.h" #include "ServerFacade.h" +#include "Stances.h" float DistanceValue::Calculate() { diff --git a/src/strategy/values/DistanceValue.h b/src/strategy/values/DistanceValue.h index 8c8dcf2f..c8281739 100644 --- a/src/strategy/values/DistanceValue.h +++ b/src/strategy/values/DistanceValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DISTANCEVALUE_H @@ -12,18 +13,20 @@ class PlayerbotAI; class DistanceValue : public FloatCalculatedValue, public Qualified { - public: - DistanceValue(PlayerbotAI* botAI, std::string const name = "distance") : FloatCalculatedValue(botAI, name) { } +public: + DistanceValue(PlayerbotAI* botAI, std::string const name = "distance") : FloatCalculatedValue(botAI, name) {} - float Calculate() override; + float Calculate() override; }; class InsideTargetValue : public BoolCalculatedValue, public Qualified { - public: - InsideTargetValue(PlayerbotAI* botAI, std::string const name = "inside target") : BoolCalculatedValue(botAI, name) { } +public: + InsideTargetValue(PlayerbotAI* botAI, std::string const name = "inside target") : BoolCalculatedValue(botAI, name) + { + } - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/DpsTargetValue.cpp b/src/strategy/values/DpsTargetValue.cpp index 6e6415d6..e2e12cb3 100644 --- a/src/strategy/values/DpsTargetValue.cpp +++ b/src/strategy/values/DpsTargetValue.cpp @@ -1,240 +1,287 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DpsTargetValue.h" + #include "PlayerbotAIConfig.h" #include "Playerbots.h" class FindMaxThreatGapTargetStrategy : public FindTargetStrategy { - public: - FindMaxThreatGapTargetStrategy(PlayerbotAI* botAI) : FindTargetStrategy(botAI), minThreat(0) { } +public: + FindMaxThreatGapTargetStrategy(PlayerbotAI* botAI) : FindTargetStrategy(botAI), minThreat(0) {} - void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + { + if (!attacker->IsAlive()) { - if (!attacker->IsAlive()) { - return; - } - if (foundHighPriority) { - return; - } - if (IsHighPriority(attacker)) { - result = attacker; - foundHighPriority = true; - return; - } - Unit* victim = attacker->GetVictim(); - if (!result || CalcThreatGap(attacker, threatMgr) > CalcThreatGap(result, &result->GetThreatMgr())) - result = attacker; + return; } - float CalcThreatGap(Unit* attacker, ThreatMgr* threatMgr) { - Unit* victim = attacker->GetVictim(); - return threatMgr->GetThreat(victim) - threatMgr->GetThreat(attacker); + if (foundHighPriority) + { + return; } + if (IsHighPriority(attacker)) + { + result = attacker; + foundHighPriority = true; + return; + } + Unit* victim = attacker->GetVictim(); + if (!result || CalcThreatGap(attacker, threatMgr) > CalcThreatGap(result, &result->GetThreatMgr())) + result = attacker; + } + float CalcThreatGap(Unit* attacker, ThreatMgr* threatMgr) + { + Unit* victim = attacker->GetVictim(); + return threatMgr->GetThreat(victim) - threatMgr->GetThreat(attacker); + } - protected: - float minThreat; +protected: + float minThreat; }; // caster class CasterFindTargetSmartStrategy : public FindTargetStrategy { - public: - CasterFindTargetSmartStrategy(PlayerbotAI* botAI, float dps) : FindTargetStrategy(botAI), dps_(dps), targetExpectedLifeTime(1000000) { } +public: + CasterFindTargetSmartStrategy(PlayerbotAI* botAI, float dps) + : FindTargetStrategy(botAI), dps_(dps), targetExpectedLifeTime(1000000) + { + } - void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + { + if (Group* group = botAI->GetBot()->GetGroup()) { - if (Group* group = botAI->GetBot()->GetGroup()) - { - ObjectGuid guid = group->GetTargetIcon(4); - if (guid && attacker->GetGUID() == guid) - return; - } - if (!attacker->IsAlive()) { + ObjectGuid guid = group->GetTargetIcon(4); + if (guid && attacker->GetGUID() == guid) return; - } - if (foundHighPriority) { - return; - } - if (IsHighPriority(attacker)) { - result = attacker; - foundHighPriority = true; - return; - } - float expectedLifeTime = attacker->GetHealth() / dps_; - // Unit* victim = attacker->GetVictim(); - if (!result || IsBetter(attacker, result)) { - targetExpectedLifeTime = expectedLifeTime; - result = attacker; - } } - bool IsBetter(Unit* new_unit, Unit* old_unit) { - float new_time = new_unit->GetHealth() / dps_; - float old_time = old_unit->GetHealth() / dps_; - // [5-20] > (5-0] > (20-inf) - if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit)) { - return true; - } - int32_t level = GetIntervalLevel(new_unit); - if (level % 10 == 2 || level % 10 == 1) { - return new_time < old_time; - } - // dont switch targets when all of them with low health - Unit* currentTarget = botAI->GetAiObjectContext()->GetValue("current target")->Get(); - if (currentTarget == new_unit) { - return true; - } - if (currentTarget == old_unit) { - return false; - } - return new_time > old_time; + if (!attacker->IsAlive()) + { + return; } - int32_t GetIntervalLevel(Unit* unit) { - float time = unit->GetHealth() / dps_; - float dis = unit->GetDistance(botAI->GetBot()); - float attackRange = botAI->IsRanged(botAI->GetBot()) ? sPlayerbotAIConfig->spellDistance : sPlayerbotAIConfig->meleeDistance; - attackRange += 5.0f; - int level = dis < attackRange ? 10 : 0; - if (time >= 3 && time <= 20) { - return level + 2; - } - if (time > 20) { - return level + 1; - } - return level; + if (foundHighPriority) + { + return; } + if (IsHighPriority(attacker)) + { + result = attacker; + foundHighPriority = true; + return; + } + float expectedLifeTime = attacker->GetHealth() / dps_; + // Unit* victim = attacker->GetVictim(); + if (!result || IsBetter(attacker, result)) + { + targetExpectedLifeTime = expectedLifeTime; + result = attacker; + } + } + bool IsBetter(Unit* new_unit, Unit* old_unit) + { + float new_time = new_unit->GetHealth() / dps_; + float old_time = old_unit->GetHealth() / dps_; + // [5-20] > (5-0] > (20-inf) + if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit)) + { + return true; + } + int32_t level = GetIntervalLevel(new_unit); + if (level % 10 == 2 || level % 10 == 1) + { + return new_time < old_time; + } + // dont switch targets when all of them with low health + Unit* currentTarget = botAI->GetAiObjectContext()->GetValue("current target")->Get(); + if (currentTarget == new_unit) + { + return true; + } + if (currentTarget == old_unit) + { + return false; + } + return new_time > old_time; + } + int32_t GetIntervalLevel(Unit* unit) + { + float time = unit->GetHealth() / dps_; + float dis = unit->GetDistance(botAI->GetBot()); + float attackRange = + botAI->IsRanged(botAI->GetBot()) ? sPlayerbotAIConfig->spellDistance : sPlayerbotAIConfig->meleeDistance; + attackRange += 5.0f; + int level = dis < attackRange ? 10 : 0; + if (time >= 3 && time <= 20) + { + return level + 2; + } + if (time > 20) + { + return level + 1; + } + return level; + } - protected: - float dps_; - float targetExpectedLifeTime; +protected: + float dps_; + float targetExpectedLifeTime; }; // non caster class NonCasterFindTargetSmartStrategy : public FindTargetStrategy { - public: - NonCasterFindTargetSmartStrategy(PlayerbotAI* botAI, float dps) : FindTargetStrategy(botAI), dps_(dps), targetExpectedLifeTime(1000000) { } +public: + NonCasterFindTargetSmartStrategy(PlayerbotAI* botAI, float dps) + : FindTargetStrategy(botAI), dps_(dps), targetExpectedLifeTime(1000000) + { + } - void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + { + if (Group* group = botAI->GetBot()->GetGroup()) { - if (Group* group = botAI->GetBot()->GetGroup()) - { - ObjectGuid guid = group->GetTargetIcon(4); - if (guid && attacker->GetGUID() == guid) - return; - } - if (!attacker->IsAlive()) { + ObjectGuid guid = group->GetTargetIcon(4); + if (guid && attacker->GetGUID() == guid) return; - } - if (foundHighPriority) { - return; - } - if (IsHighPriority(attacker)) { - result = attacker; - foundHighPriority = true; - return; - } - float expectedLifeTime = attacker->GetHealth() / dps_; - // Unit* victim = attacker->GetVictim(); - if (!result || IsBetter(attacker, result)) { - targetExpectedLifeTime = expectedLifeTime; - result = attacker; - } } - bool IsBetter(Unit* new_unit, Unit* old_unit) { - float new_time = new_unit->GetHealth() / dps_; - float old_time = old_unit->GetHealth() / dps_; - // [5-20] > (5-0] > (20-inf) - if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit)) { - return true; - } - // attack enemy in range and with lowest health - int level = GetIntervalLevel(new_unit); - if (level == 10) { - return new_time < old_time; - } - // all targets are far away, choose the closest one - return botAI->GetBot()->GetDistance(new_unit) < botAI->GetBot()->GetDistance(old_unit); + if (!attacker->IsAlive()) + { + return; } - int32_t GetIntervalLevel(Unit* unit) { - float time = unit->GetHealth() / dps_; - float dis = unit->GetDistance(botAI->GetBot()); - float attackRange = botAI->IsRanged(botAI->GetBot()) ? sPlayerbotAIConfig->spellDistance : sPlayerbotAIConfig->meleeDistance; - attackRange += 5.0f; - int level = dis < attackRange ? 10 : 0; - return level; + if (foundHighPriority) + { + return; } + if (IsHighPriority(attacker)) + { + result = attacker; + foundHighPriority = true; + return; + } + float expectedLifeTime = attacker->GetHealth() / dps_; + // Unit* victim = attacker->GetVictim(); + if (!result || IsBetter(attacker, result)) + { + targetExpectedLifeTime = expectedLifeTime; + result = attacker; + } + } + bool IsBetter(Unit* new_unit, Unit* old_unit) + { + float new_time = new_unit->GetHealth() / dps_; + float old_time = old_unit->GetHealth() / dps_; + // [5-20] > (5-0] > (20-inf) + if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit)) + { + return true; + } + // attack enemy in range and with lowest health + int level = GetIntervalLevel(new_unit); + if (level == 10) + { + return new_time < old_time; + } + // all targets are far away, choose the closest one + return botAI->GetBot()->GetDistance(new_unit) < botAI->GetBot()->GetDistance(old_unit); + } + int32_t GetIntervalLevel(Unit* unit) + { + float time = unit->GetHealth() / dps_; + float dis = unit->GetDistance(botAI->GetBot()); + float attackRange = + botAI->IsRanged(botAI->GetBot()) ? sPlayerbotAIConfig->spellDistance : sPlayerbotAIConfig->meleeDistance; + attackRange += 5.0f; + int level = dis < attackRange ? 10 : 0; + return level; + } - protected: - float dps_; - float targetExpectedLifeTime; +protected: + float dps_; + float targetExpectedLifeTime; }; // combo class ComboFindTargetSmartStrategy : public FindTargetStrategy { - public: - ComboFindTargetSmartStrategy(PlayerbotAI* botAI, float dps) : FindTargetStrategy(botAI), dps_(dps), targetExpectedLifeTime(1000000) { } +public: + ComboFindTargetSmartStrategy(PlayerbotAI* botAI, float dps) + : FindTargetStrategy(botAI), dps_(dps), targetExpectedLifeTime(1000000) + { + } - void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + { + if (Group* group = botAI->GetBot()->GetGroup()) { - if (Group* group = botAI->GetBot()->GetGroup()) - { - ObjectGuid guid = group->GetTargetIcon(4); - if (guid && attacker->GetGUID() == guid) - return; - } - if (!attacker->IsAlive()) { + ObjectGuid guid = group->GetTargetIcon(4); + if (guid && attacker->GetGUID() == guid) return; - } - if (foundHighPriority) { - return; - } - if (IsHighPriority(attacker)) { - result = attacker; - foundHighPriority = true; - return; - } - float expectedLifeTime = attacker->GetHealth() / dps_; - // Unit* victim = attacker->GetVictim(); - if (!result || IsBetter(attacker, result)) { - targetExpectedLifeTime = expectedLifeTime; - result = attacker; - } } - bool IsBetter(Unit* new_unit, Unit* old_unit) { - float new_time = new_unit->GetHealth() / dps_; - float old_time = old_unit->GetHealth() / dps_; - // [5-20] > (5-0] > (20-inf) - if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit)) { + if (!attacker->IsAlive()) + { + return; + } + if (foundHighPriority) + { + return; + } + if (IsHighPriority(attacker)) + { + result = attacker; + foundHighPriority = true; + return; + } + float expectedLifeTime = attacker->GetHealth() / dps_; + // Unit* victim = attacker->GetVictim(); + if (!result || IsBetter(attacker, result)) + { + targetExpectedLifeTime = expectedLifeTime; + result = attacker; + } + } + bool IsBetter(Unit* new_unit, Unit* old_unit) + { + float new_time = new_unit->GetHealth() / dps_; + float old_time = old_unit->GetHealth() / dps_; + // [5-20] > (5-0] > (20-inf) + if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit)) + { + return true; + } + // attack enemy in range and with lowest health + int level = GetIntervalLevel(new_unit); + Player* bot = botAI->GetBot(); + if (level == 10) + { + Unit* combo_unit = bot->GetComboTarget(); + if (new_unit == combo_unit) + { return true; } - // attack enemy in range and with lowest health - int level = GetIntervalLevel(new_unit); - Player* bot = botAI->GetBot(); - if (level == 10) { - Unit* combo_unit = bot->GetComboTarget(); - if (new_unit == combo_unit) { - return true; - } - return new_time < old_time; - } - // all targets are far away, choose the closest one - return bot->GetDistance(new_unit) < bot->GetDistance(old_unit); - } - int32_t GetIntervalLevel(Unit* unit) { - float time = unit->GetHealth() / dps_; - float dis = unit->GetDistance(botAI->GetBot()); - float attackRange = botAI->IsRanged(botAI->GetBot()) ? sPlayerbotAIConfig->spellDistance : sPlayerbotAIConfig->meleeDistance; - attackRange += 5.0f; - int level = dis < attackRange ? 10 : 0; - return level; + return new_time < old_time; } + // all targets are far away, choose the closest one + return bot->GetDistance(new_unit) < bot->GetDistance(old_unit); + } + int32_t GetIntervalLevel(Unit* unit) + { + float time = unit->GetHealth() / dps_; + float dis = unit->GetDistance(botAI->GetBot()); + float attackRange = + botAI->IsRanged(botAI->GetBot()) ? sPlayerbotAIConfig->spellDistance : sPlayerbotAIConfig->meleeDistance; + attackRange += 5.0f; + int level = dis < attackRange ? 10 : 0; + return level; + } - protected: - float dps_; - float targetExpectedLifeTime; +protected: + float dps_; + float targetExpectedLifeTime; }; Unit* DpsTargetValue::Calculate() @@ -245,10 +292,13 @@ Unit* DpsTargetValue::Calculate() // FindLeastHpTargetStrategy strategy(botAI); float dps = AI_VALUE(float, "expected group dps"); - if (botAI->IsCaster(bot)) { + if (botAI->IsCaster(bot)) + { CasterFindTargetSmartStrategy strategy(botAI, dps); return TargetValue::FindTarget(&strategy); - } else if (botAI->IsCombo(bot)) { + } + else if (botAI->IsCombo(bot)) + { ComboFindTargetSmartStrategy strategy(botAI, dps); return TargetValue::FindTarget(&strategy); } @@ -258,24 +308,24 @@ Unit* DpsTargetValue::Calculate() class FindMaxHpTargetStrategy : public FindTargetStrategy { - public: - FindMaxHpTargetStrategy(PlayerbotAI* botAI) : FindTargetStrategy(botAI), maxHealth(0) { } +public: + FindMaxHpTargetStrategy(PlayerbotAI* botAI) : FindTargetStrategy(botAI), maxHealth(0) {} - void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + { + if (Group* group = botAI->GetBot()->GetGroup()) { - if (Group* group = botAI->GetBot()->GetGroup()) - { - ObjectGuid guid = group->GetTargetIcon(4); - if (guid && attacker->GetGUID() == guid) - return; - } - - if (!result || result->GetHealth() < attacker->GetHealth()) - result = attacker; + ObjectGuid guid = group->GetTargetIcon(4); + if (guid && attacker->GetGUID() == guid) + return; } - protected: - float maxHealth; + if (!result || result->GetHealth() < attacker->GetHealth()) + result = attacker; + } + +protected: + float maxHealth; }; Unit* DpsAoeTargetValue::Calculate() diff --git a/src/strategy/values/DpsTargetValue.h b/src/strategy/values/DpsTargetValue.h index dda25edf..bf5ad3b5 100644 --- a/src/strategy/values/DpsTargetValue.h +++ b/src/strategy/values/DpsTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DPSTARGETVALUE_H @@ -11,18 +12,24 @@ class PlayerbotAI; class DpsTargetValue : public RtiTargetValue { - public: - DpsTargetValue(PlayerbotAI* botAI, std::string const type = "rti", std::string const name = "dps target") : RtiTargetValue(botAI, type, name) { } +public: + DpsTargetValue(PlayerbotAI* botAI, std::string const type = "rti", std::string const name = "dps target") + : RtiTargetValue(botAI, type, name) + { + } - Unit* Calculate() override; + Unit* Calculate() override; }; class DpsAoeTargetValue : public RtiTargetValue { - public: - DpsAoeTargetValue(PlayerbotAI* botAI, std::string const type = "rti", std::string const name = "dps aoe target") : RtiTargetValue(botAI, type, name) { } +public: + DpsAoeTargetValue(PlayerbotAI* botAI, std::string const type = "rti", std::string const name = "dps aoe target") + : RtiTargetValue(botAI, type, name) + { + } - Unit* Calculate() override; + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/DuelTargetValue.cpp b/src/strategy/values/DuelTargetValue.cpp index c03a0e35..cd2cf24f 100644 --- a/src/strategy/values/DuelTargetValue.cpp +++ b/src/strategy/values/DuelTargetValue.cpp @@ -1,11 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DuelTargetValue.h" + #include "Playerbots.h" -Unit* DuelTargetValue::Calculate() -{ - return bot->duel ? bot->duel->Opponent : nullptr; -} +Unit* DuelTargetValue::Calculate() { return bot->duel ? bot->duel->Opponent : nullptr; } diff --git a/src/strategy/values/DuelTargetValue.h b/src/strategy/values/DuelTargetValue.h index 60cc8a57..0ba67af8 100644 --- a/src/strategy/values/DuelTargetValue.h +++ b/src/strategy/values/DuelTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DUELTARGETVALUE_H @@ -12,10 +13,10 @@ class Unit; class DuelTargetValue : public TargetValue { - public: - DuelTargetValue(PlayerbotAI* botAI, std::string const name = "duel target") : TargetValue(botAI, name) { } +public: + DuelTargetValue(PlayerbotAI* botAI, std::string const name = "duel target") : TargetValue(botAI, name) {} - Unit* Calculate() override; + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/EnemyHealerTargetValue.cpp b/src/strategy/values/EnemyHealerTargetValue.cpp index bee1e80c..ebc761c0 100644 --- a/src/strategy/values/EnemyHealerTargetValue.cpp +++ b/src/strategy/values/EnemyHealerTargetValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "EnemyHealerTargetValue.h" + #include "Playerbots.h" #include "ServerFacade.h" diff --git a/src/strategy/values/EnemyHealerTargetValue.h b/src/strategy/values/EnemyHealerTargetValue.h index 093a1824..ad0599ba 100644 --- a/src/strategy/values/EnemyHealerTargetValue.h +++ b/src/strategy/values/EnemyHealerTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ENEMYHEALERTARGETVALUE_H @@ -13,11 +14,11 @@ class Unit; class EnemyHealerTargetValue : public UnitCalculatedValue, public Qualified { - public: - EnemyHealerTargetValue(PlayerbotAI* botAI) : UnitCalculatedValue(botAI, "enemy healer target") { } +public: + EnemyHealerTargetValue(PlayerbotAI* botAI) : UnitCalculatedValue(botAI, "enemy healer target") {} - protected: - Unit* Calculate() override; +protected: + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/EnemyPlayerValue.cpp b/src/strategy/values/EnemyPlayerValue.cpp index 4b412ce8..ba346a47 100644 --- a/src/strategy/values/EnemyPlayerValue.cpp +++ b/src/strategy/values/EnemyPlayerValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "EnemyPlayerValue.h" + #include "Playerbots.h" #include "ServerFacade.h" @@ -10,9 +12,12 @@ bool NearestEnemyPlayersValue::AcceptUnit(Unit* unit) { bool inCannon = botAI->IsInVehicle(false, true); Player* enemy = dynamic_cast(unit); - if (enemy && botAI->IsOpposing(enemy) && enemy->IsPvP() && !sPlayerbotAIConfig->IsPvpProhibited(enemy->GetZoneId(), enemy->GetAreaId()) && - !enemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NON_ATTACKABLE_2) && ((inCannon || !enemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))) && - /*!enemy->HasStealthAura() && !enemy->HasInvisibilityAura()*/ enemy->CanSeeOrDetect(bot) && !(enemy->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))) + if (enemy && botAI->IsOpposing(enemy) && enemy->IsPvP() && + !sPlayerbotAIConfig->IsPvpProhibited(enemy->GetZoneId(), enemy->GetAreaId()) && + !enemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NON_ATTACKABLE_2) && + ((inCannon || !enemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))) && + /*!enemy->HasStealthAura() && !enemy->HasInvisibilityAura()*/ enemy->CanSeeOrDetect(bot) && + !(enemy->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))) return true; return false; @@ -31,7 +36,8 @@ Unit* EnemyPlayerValue::Calculate() ThreatMgr* threatMgr = pReference->GetSource(); if (Unit* pTarget = threatMgr->GetOwner()) { - if (pTarget != pVictim && pTarget->IsPlayer() && pTarget->CanSeeOrDetect(bot) && bot->IsWithinDist(pTarget, VISIBILITY_DISTANCE_NORMAL)) + if (pTarget != pVictim && pTarget->IsPlayer() && pTarget->CanSeeOrDetect(bot) && + bot->IsWithinDist(pTarget, VISIBILITY_DISTANCE_NORMAL)) { if (bot->GetTeamId() == TEAM_HORDE) { @@ -53,10 +59,9 @@ Unit* EnemyPlayerValue::Calculate() if (!targets.empty()) { - std::sort(targets.begin(), targets.end(), [&](Unit const* pUnit1, Unit const* pUnit2) - { - return bot->GetDistance(pUnit1) < bot->GetDistance(pUnit2); - }); + std::sort(targets.begin(), targets.end(), + [&](Unit const* pUnit1, Unit const* pUnit2) + { return bot->GetDistance(pUnit1) < bot->GetDistance(pUnit2); }); return *targets.begin(); } @@ -94,7 +99,8 @@ Unit* EnemyPlayerValue::Calculate() if (!bot->IsWithinDist(pTarget, aggroDistance)) continue; - if (bot->IsWithinLOSInMap(pTarget) && (inCannon || (fabs(bot->GetPositionZ() - pTarget->GetPositionZ()) < 30.0f))) + if (bot->IsWithinLOSInMap(pTarget) && + (inCannon || (fabs(bot->GetPositionZ() - pTarget->GetPositionZ()) < 30.0f))) return pTarget; } @@ -113,8 +119,8 @@ Unit* EnemyPlayerValue::Calculate() continue; if (Unit* pAttacker = pMember->getAttackerForHelper()) - if (pAttacker->IsPlayer() && bot->IsWithinDist(pAttacker, maxAggroDistance * 2.0f) && bot->IsWithinLOSInMap(pAttacker) && pAttacker != pVictim - && pAttacker->CanSeeOrDetect(bot)) + if (pAttacker->IsPlayer() && bot->IsWithinDist(pAttacker, maxAggroDistance * 2.0f) && + bot->IsWithinLOSInMap(pAttacker) && pAttacker != pVictim && pAttacker->CanSeeOrDetect(bot)) return pAttacker; } } diff --git a/src/strategy/values/EnemyPlayerValue.h b/src/strategy/values/EnemyPlayerValue.h index d3be32f0..90957e3d 100644 --- a/src/strategy/values/EnemyPlayerValue.h +++ b/src/strategy/values/EnemyPlayerValue.h @@ -1,36 +1,42 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ENEMYPLAYERVALUE_H #define _PLAYERBOT_ENEMYPLAYERVALUE_H #include "PlayerbotAIConfig.h" -#include "TargetValue.h" #include "PossibleTargetsValue.h" +#include "TargetValue.h" class PlayerbotAI; class Unit; class NearestEnemyPlayersValue : public PossibleTargetsValue { - public: - NearestEnemyPlayersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->grindDistance) : - PossibleTargetsValue(botAI, "nearest enemy players", range) { } +public: + NearestEnemyPlayersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->grindDistance) + : PossibleTargetsValue(botAI, "nearest enemy players", range) + { + } - public: - bool AcceptUnit(Unit* unit) override; +public: + bool AcceptUnit(Unit* unit) override; }; class EnemyPlayerValue : public UnitCalculatedValue { - public: - EnemyPlayerValue(PlayerbotAI* botAI, std::string const name = "enemy player") : UnitCalculatedValue(botAI, name, 1 * 1000) { } +public: + EnemyPlayerValue(PlayerbotAI* botAI, std::string const name = "enemy player") + : UnitCalculatedValue(botAI, name, 1 * 1000) + { + } - Unit* Calculate() override; + Unit* Calculate() override; - private: - float GetMaxAttackDistance(); +private: + float GetMaxAttackDistance(); }; #endif diff --git a/src/strategy/values/ExpectedLifetimeValue.cpp b/src/strategy/values/ExpectedLifetimeValue.cpp index 5d291f73..a8a554b6 100644 --- a/src/strategy/values/ExpectedLifetimeValue.cpp +++ b/src/strategy/values/ExpectedLifetimeValue.cpp @@ -1,4 +1,5 @@ #include "ExpectedLifetimeValue.h" + #include "AiFactory.h" #include "PlayerbotAI.h" #include "Playerbots.h" @@ -7,7 +8,8 @@ float ExpectedLifetimeValue::Calculate() { Unit* target = AI_VALUE(Unit*, qualifier); - if (!target || !target->IsAlive()) { + if (!target || !target->IsAlive()) + { return 0.0f; } float dps = AI_VALUE(float, "expected group dps"); @@ -20,9 +22,12 @@ float ExpectedGroupDpsValue::Calculate() { float dps_num; Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { dps_num = 0.7; - } else { + } + else + { dps_num = group->GetMembersCount() * 0.7; } uint32 mixedGearScore = PlayerbotAI::GetMixedGearScore(bot, true, false, 12); @@ -31,40 +36,64 @@ float ExpectedGroupDpsValue::Calculate() float basic_dps; int32 basic_gs; int32 level = bot->GetLevel(); - - if (level <= 15) { + + if (level <= 15) + { basic_dps = 5 + level * 1; - } else if (level <= 25) { + } + else if (level <= 25) + { basic_dps = 20 + (level - 15) * 2; - } else if (level <= 40) { + } + else if (level <= 40) + { basic_dps = 40 + (level - 30) * 4; - } else if (level <= 55) { + } + else if (level <= 55) + { basic_dps = 100 + (level - 45) * 20; - } else if (level <= 60) { + } + else if (level <= 60) + { basic_dps = 300 + (level - 55) * 50; - } else if (level <= 70) { + } + else if (level <= 70) + { basic_dps = 450 + (level - 60) * 40; - } else { + } + else + { basic_dps = 750 + (level - 70) * 175; } - if (level <= 8) { + if (level <= 8) + { basic_gs = (level + 5) * 2; - } else if (level <= 15) { + } + else if (level <= 15) + { basic_gs = (level + 5) * 3; - } else if (level <= 60) { + } + else if (level <= 60) + { basic_gs = (level + 5) * 4; - } else if (level <= 70) { + } + else if (level <= 70) + { basic_gs = (85 + (level - 60) * 3) * 4; - } else { + } + else + { basic_gs = (155 + (level - 70) * 4) * 4; } float gap = mixedGearScore - basic_gs; float gs_modifier = (float)mixedGearScore / basic_gs - 1; gs_modifier = gs_modifier * 3 + 1; - if (gs_modifier < 0.75) gs_modifier = 0.75; - if (gs_modifier > 4) gs_modifier = 4; + if (gs_modifier < 0.75) + gs_modifier = 0.75; + if (gs_modifier > 4) + gs_modifier = 4; return dps_num * basic_dps * gs_modifier; } \ No newline at end of file diff --git a/src/strategy/values/ExpectedLifetimeValue.h b/src/strategy/values/ExpectedLifetimeValue.h index 8b5e994d..2afcece8 100644 --- a/src/strategy/values/ExpectedLifetimeValue.h +++ b/src/strategy/values/ExpectedLifetimeValue.h @@ -1,13 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_EXPECTEDLIFETIMEVALUE_H #define _PLAYERBOT_EXPECTEDLIFETIMEVALUE_H #include "NamedObjectContext.h" -#include "TargetValue.h" #include "PossibleTargetsValue.h" +#include "TargetValue.h" #include "Value.h" class PlayerbotAI; @@ -16,22 +17,20 @@ class Unit; // [target health] / [expected group single target dps] = [expected lifetime] class ExpectedLifetimeValue : public FloatCalculatedValue, public Qualified { - public: - ExpectedLifetimeValue(PlayerbotAI* botAI) : - FloatCalculatedValue(botAI, "expected lifetime") { } +public: + ExpectedLifetimeValue(PlayerbotAI* botAI) : FloatCalculatedValue(botAI, "expected lifetime") {} - public: - float Calculate() override; +public: + float Calculate() override; }; class ExpectedGroupDpsValue : public FloatCalculatedValue { - public: - ExpectedGroupDpsValue(PlayerbotAI* botAI) : - FloatCalculatedValue(botAI, "expected group dps", 20 * 1000) { } +public: + ExpectedGroupDpsValue(PlayerbotAI* botAI) : FloatCalculatedValue(botAI, "expected group dps", 20 * 1000) {} - public: - float Calculate() override; +public: + float Calculate() override; }; #endif diff --git a/src/strategy/values/Formations.cpp b/src/strategy/values/Formations.cpp index eee6dcf7..7036609f 100644 --- a/src/strategy/values/Formations.cpp +++ b/src/strategy/values/Formations.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "Formations.h" + #include "Arrow.h" #include "Event.h" #include "Playerbots.h" @@ -10,15 +12,13 @@ WorldLocation Formation::NullLocation = WorldLocation(); -bool IsSameLocation(WorldLocation const &a, WorldLocation const &b) +bool IsSameLocation(WorldLocation const& a, WorldLocation const& b) { - return a.GetPositionX() == b.GetPositionX() && a.GetPositionY() == b.GetPositionY() && a.GetPositionZ() == b.GetPositionZ() && a.GetMapId() == b.GetMapId(); + return a.GetPositionX() == b.GetPositionX() && a.GetPositionY() == b.GetPositionY() && + a.GetPositionZ() == b.GetPositionZ() && a.GetMapId() == b.GetMapId(); } -bool Formation::IsNullLocation(WorldLocation const& loc) -{ - return IsSameLocation(loc, Formation::NullLocation); -} +bool Formation::IsNullLocation(WorldLocation const& loc) { return IsSameLocation(loc, Formation::NullLocation); } WorldLocation MoveAheadFormation::GetLocation() { @@ -51,315 +51,317 @@ WorldLocation MoveAheadFormation::GetLocation() // if (ground <= INVALID_HEIGHT) // return Formation::NullLocation; - //z += CONTACT_DISTANCE; - //bot->UpdateAllowedPositionZ(x, y, z); + // z += CONTACT_DISTANCE; + // bot->UpdateAllowedPositionZ(x, y, z); return WorldLocation(master->GetMapId(), x, y, z); } class MeleeFormation : public FollowFormation { - public: - MeleeFormation(PlayerbotAI* botAI) : FollowFormation(botAI, "melee") { } +public: + MeleeFormation(PlayerbotAI* botAI) : FollowFormation(botAI, "melee") {} - std::string const GetTargetName() override { return "master target"; } + std::string const GetTargetName() override { return "master target"; } }; class QueueFormation : public FollowFormation { - public: - QueueFormation(PlayerbotAI* botAI) : FollowFormation(botAI, "queue") { } +public: + QueueFormation(PlayerbotAI* botAI) : FollowFormation(botAI, "queue") {} - std::string const GetTargetName() override { return "line target"; } + std::string const GetTargetName() override { return "line target"; } }; class NearFormation : public MoveAheadFormation { - public: - NearFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "near") { } +public: + NearFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "near") {} - WorldLocation GetLocationInternal() override - { - Player* master = GetMaster(); - if (!master) - return WorldLocation(); + WorldLocation GetLocationInternal() override + { + Player* master = GetMaster(); + if (!master) + return WorldLocation(); - float range = sPlayerbotAIConfig->followDistance; - float angle = GetFollowAngle(); - float x = master->GetPositionX() + cos(angle) * range; - float y = master->GetPositionY() + sin(angle) * range; - float z = master->GetPositionZ(); - - float ground = master->GetMapHeight(x, y, z + 30.0f); - if (ground <= INVALID_HEIGHT) - return Formation::NullLocation; + float range = sPlayerbotAIConfig->followDistance; + float angle = GetFollowAngle(); + float x = master->GetPositionX() + cos(angle) * range; + float y = master->GetPositionY() + sin(angle) * range; + float z = master->GetPositionZ(); - //z += CONTACT_DISTANCE; - //bot->UpdateAllowedPositionZ(x, y, z); - return WorldLocation(master->GetMapId(), x, y, z); - } + float ground = master->GetMapHeight(x, y, z + 30.0f); + if (ground <= INVALID_HEIGHT) + return Formation::NullLocation; - float GetMaxDistance() override { return sPlayerbotAIConfig->followDistance; } + // z += CONTACT_DISTANCE; + // bot->UpdateAllowedPositionZ(x, y, z); + return WorldLocation(master->GetMapId(), x, y, z); + } + + float GetMaxDistance() override { return sPlayerbotAIConfig->followDistance; } }; class ChaosFormation : public MoveAheadFormation { - public: - ChaosFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "chaos"), lastChangeTime(0) { } +public: + ChaosFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "chaos"), lastChangeTime(0) {} - WorldLocation GetLocationInternal() override + WorldLocation GetLocationInternal() override + { + Player* master = botAI->GetGroupMaster(); + if (!master) + return WorldLocation(); + + float range = sPlayerbotAIConfig->followDistance; + float angle = GetFollowAngle(); + + time_t now = time(nullptr); + if (!lastChangeTime || now - lastChangeTime >= 3) { - Player* master = botAI->GetGroupMaster(); - if (!master) - return WorldLocation(); - - float range = sPlayerbotAIConfig->followDistance; - float angle = GetFollowAngle(); - - time_t now = time(nullptr); - if (!lastChangeTime || now - lastChangeTime >= 3) - { - lastChangeTime = now; - dx = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance; - dy = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance; - dr = sqrt(dx*dx + dy*dy); - } - - float x = master->GetPositionX() + cos(angle) * range + dx; - float y = master->GetPositionY() + sin(angle) * range + dy; - float z = master->GetPositionZ(); - float ground = master->GetMapHeight(x, y, z + 30.0f); - if (ground <= INVALID_HEIGHT) - return Formation::NullLocation; - - z += CONTACT_DISTANCE; - bot->UpdateAllowedPositionZ(x, y, z); - return WorldLocation(master->GetMapId(), x, y, z); + lastChangeTime = now; + dx = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance; + dy = (urand(0, 10) / 10.0 - 0.5) * sPlayerbotAIConfig->tooCloseDistance; + dr = sqrt(dx * dx + dy * dy); } - float GetMaxDistance() override { return sPlayerbotAIConfig->followDistance + dr; } + float x = master->GetPositionX() + cos(angle) * range + dx; + float y = master->GetPositionY() + sin(angle) * range + dy; + float z = master->GetPositionZ(); + float ground = master->GetMapHeight(x, y, z + 30.0f); + if (ground <= INVALID_HEIGHT) + return Formation::NullLocation; - private: - time_t lastChangeTime; - float dx = 0.f; - float dy = 0.f; - float dr = 0.f; + z += CONTACT_DISTANCE; + bot->UpdateAllowedPositionZ(x, y, z); + return WorldLocation(master->GetMapId(), x, y, z); + } + + float GetMaxDistance() override { return sPlayerbotAIConfig->followDistance + dr; } + +private: + time_t lastChangeTime; + float dx = 0.f; + float dy = 0.f; + float dr = 0.f; }; class CircleFormation : public MoveFormation { - public: - CircleFormation(PlayerbotAI* botAI) : MoveFormation(botAI, "circle") { } +public: + CircleFormation(PlayerbotAI* botAI) : MoveFormation(botAI, "circle") {} - WorldLocation GetLocation() override + WorldLocation GetLocation() override + { + float range = 2.0f; + + Unit* target = AI_VALUE(Unit*, "current target"); + Player* master = botAI->GetGroupMaster(); + if (!target && target != bot) + target = master; + + if (!target) + return Formation::NullLocation; + + switch (bot->getClass()) { - float range = 2.0f; - - Unit* target = AI_VALUE(Unit*, "current target"); - Player* master = botAI->GetGroupMaster(); - if (!target && target != bot) - target = master; - - if (!target) - return Formation::NullLocation; - - switch (bot->getClass()) - { - case CLASS_HUNTER: - case CLASS_MAGE: - case CLASS_PRIEST: - case CLASS_WARLOCK: + case CLASS_HUNTER: + case CLASS_MAGE: + case CLASS_PRIEST: + case CLASS_WARLOCK: + range = botAI->GetRange("flee"); + break; + case CLASS_DRUID: + if (!botAI->IsTank(bot)) range = botAI->GetRange("flee"); - break; - case CLASS_DRUID: - if (!botAI->IsTank(bot)) - range = botAI->GetRange("flee"); - break; - case CLASS_SHAMAN: - if (botAI->IsHeal(bot)) - range = botAI->GetRange("flee"); - break; - } - - float angle = GetFollowAngle(); - float x = target->GetPositionX() + cos(angle) * range; - float y = target->GetPositionY() + sin(angle) * range; - float z = target->GetPositionZ(); - float ground = target->GetMapHeight(x, y, z + 30.0f); - if (ground <= INVALID_HEIGHT) - return Formation::NullLocation; - - z += CONTACT_DISTANCE; - bot->UpdateAllowedPositionZ(x, y, z); - - return WorldLocation(bot->GetMapId(), x, y, z); + break; + case CLASS_SHAMAN: + if (botAI->IsHeal(bot)) + range = botAI->GetRange("flee"); + break; } + + float angle = GetFollowAngle(); + float x = target->GetPositionX() + cos(angle) * range; + float y = target->GetPositionY() + sin(angle) * range; + float z = target->GetPositionZ(); + float ground = target->GetMapHeight(x, y, z + 30.0f); + if (ground <= INVALID_HEIGHT) + return Formation::NullLocation; + + z += CONTACT_DISTANCE; + bot->UpdateAllowedPositionZ(x, y, z); + + return WorldLocation(bot->GetMapId(), x, y, z); + } }; class LineFormation : public MoveAheadFormation { - public: - LineFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "line") { } +public: + LineFormation(PlayerbotAI* botAI) : MoveAheadFormation(botAI, "line") {} - WorldLocation GetLocationInternal() override + WorldLocation GetLocationInternal() override + { + Group* group = bot->GetGroup(); + if (!group) + return Formation::NullLocation; + + float range = 2.0f; + + Player* master = botAI->GetGroupMaster(); + if (!master) + return Formation::NullLocation; + + float x = master->GetPositionX(); + float y = master->GetPositionY(); + float z = master->GetPositionZ(); + float orientation = master->GetOrientation(); + + std::vector players; + GroupReference* gref = group->GetFirstMember(); + while (gref) { - Group* group = bot->GetGroup(); - if (!group) - return Formation::NullLocation; + Player* member = gref->GetSource(); + if (member != master) + players.push_back(member); - float range = 2.0f; - - Player* master = botAI->GetGroupMaster(); - if (!master) - return Formation::NullLocation; - - float x = master->GetPositionX(); - float y = master->GetPositionY(); - float z = master->GetPositionZ(); - float orientation = master->GetOrientation(); - - std::vector players; - GroupReference* gref = group->GetFirstMember(); - while (gref) - { - Player* member = gref->GetSource(); - if (member != master) - players.push_back(member); - - gref = gref->next(); - } - - players.insert(players.begin() + group->GetMembersCount() / 2, master); - - return MoveLine(players, 0.0f, x, y, z, orientation, range); + gref = gref->next(); } + + players.insert(players.begin() + group->GetMembersCount() / 2, master); + + return MoveLine(players, 0.0f, x, y, z, orientation, range); + } }; class ShieldFormation : public MoveFormation { - public: - ShieldFormation(PlayerbotAI* botAI) : MoveFormation(botAI, "shield") { } - - WorldLocation GetLocation() override - { - Group* group = bot->GetGroup(); - if (!group) - return Formation::NullLocation; - - float range = sPlayerbotAIConfig->followDistance; - - Player* master = GetMaster(); - if (!master) - return Formation::NullLocation; - - float x = master->GetPositionX(); - float y = master->GetPositionY(); - float z = master->GetPositionZ(); - float orientation = master->GetOrientation(); - - std::vector tanks; - std::vector dps; - GroupReference* gref = group->GetFirstMember(); - while (gref) - { - Player* member = gref->GetSource(); - if (member != master) - { - if (botAI->IsTank(member)) - tanks.push_back(member); - else - dps.push_back(member); - } - - gref = gref->next(); - } - - if (botAI->IsTank(master)) - tanks.insert(tanks.begin() + (tanks.size() + 1) / 2, master); - else - dps.insert(dps.begin() + (dps.size() + 1) / 2, master); - - if (botAI->IsTank(bot) && botAI->IsTank(master)) - { - return MoveLine(tanks, 0.0f, x, y, z, orientation, range); - } - - if (!botAI->IsTank(bot) && !botAI->IsTank(master)) - { - return MoveLine(dps, 0.0f, x, y, z, orientation, range); - } - - if (botAI->IsTank(bot) && !botAI->IsTank(master)) - { - float diff = tanks.size() % 2 == 0 ? -sPlayerbotAIConfig->tooCloseDistance / 2.0f : 0.0f; - return MoveLine(tanks, diff, x + cos(orientation) * range, y + sin(orientation) * range, z, orientation, range); - } - - if (!botAI->IsTank(bot) && botAI->IsTank(master)) - { - float diff = dps.size() % 2 == 0 ? -sPlayerbotAIConfig->tooCloseDistance / 2.0f : 0.0f; - return MoveLine(dps, diff, x - cos(orientation) * range, y - sin(orientation) * range, z, orientation, range); - } +public: + ShieldFormation(PlayerbotAI* botAI) : MoveFormation(botAI, "shield") {} + WorldLocation GetLocation() override + { + Group* group = bot->GetGroup(); + if (!group) return Formation::NullLocation; + + float range = sPlayerbotAIConfig->followDistance; + + Player* master = GetMaster(); + if (!master) + return Formation::NullLocation; + + float x = master->GetPositionX(); + float y = master->GetPositionY(); + float z = master->GetPositionZ(); + float orientation = master->GetOrientation(); + + std::vector tanks; + std::vector dps; + GroupReference* gref = group->GetFirstMember(); + while (gref) + { + Player* member = gref->GetSource(); + if (member != master) + { + if (botAI->IsTank(member)) + tanks.push_back(member); + else + dps.push_back(member); + } + + gref = gref->next(); } + + if (botAI->IsTank(master)) + tanks.insert(tanks.begin() + (tanks.size() + 1) / 2, master); + else + dps.insert(dps.begin() + (dps.size() + 1) / 2, master); + + if (botAI->IsTank(bot) && botAI->IsTank(master)) + { + return MoveLine(tanks, 0.0f, x, y, z, orientation, range); + } + + if (!botAI->IsTank(bot) && !botAI->IsTank(master)) + { + return MoveLine(dps, 0.0f, x, y, z, orientation, range); + } + + if (botAI->IsTank(bot) && !botAI->IsTank(master)) + { + float diff = tanks.size() % 2 == 0 ? -sPlayerbotAIConfig->tooCloseDistance / 2.0f : 0.0f; + return MoveLine(tanks, diff, x + cos(orientation) * range, y + sin(orientation) * range, z, orientation, + range); + } + + if (!botAI->IsTank(bot) && botAI->IsTank(master)) + { + float diff = dps.size() % 2 == 0 ? -sPlayerbotAIConfig->tooCloseDistance / 2.0f : 0.0f; + return MoveLine(dps, diff, x - cos(orientation) * range, y - sin(orientation) * range, z, orientation, + range); + } + + return Formation::NullLocation; + } }; class FarFormation : public FollowFormation { - public: - FarFormation(PlayerbotAI* botAI) : FollowFormation(botAI, "far") { } +public: + FarFormation(PlayerbotAI* botAI) : FollowFormation(botAI, "far") {} - WorldLocation GetLocation() override + WorldLocation GetLocation() override + { + float range = sPlayerbotAIConfig->farDistance; + float followRange = sPlayerbotAIConfig->followDistance; + + Player* master = GetMaster(); + if (!master) + return Formation::NullLocation; + + if (sServerFacade->GetDistance2d(bot, master) <= range) + return Formation::NullLocation; + + float angle = master->GetAngle(bot); + float followAngle = GetFollowAngle(); + + float x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange; + float y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange; + float z = master->GetPositionZ(); + + float ground = master->GetMapHeight(x, y, z + 30.0f); + if (ground <= INVALID_HEIGHT) { - float range = sPlayerbotAIConfig->farDistance; - float followRange = sPlayerbotAIConfig->followDistance; - - Player* master = GetMaster(); - if (!master) - return Formation::NullLocation; - - if (sServerFacade->GetDistance2d(bot, master) <= range) - return Formation::NullLocation; - - float angle = master->GetAngle(bot); - float followAngle = GetFollowAngle(); - - float x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange; - float y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange; - float z = master->GetPositionZ(); - - float ground = master->GetMapHeight(x, y, z + 30.0f); - if (ground <= INVALID_HEIGHT) + float minDist = 0, minX = 0, minY = 0; + for (float angle = 0.0f; angle <= 2 * M_PI; angle += M_PI / 16.0f) { - float minDist = 0, minX = 0, minY = 0; - for (float angle = 0.0f; angle <= 2 * M_PI; angle += M_PI / 16.0f) + x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange; + y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange; + float dist = sServerFacade->GetDistance2d(bot, x, y); + float ground = master->GetMapHeight(x, y, z + 30.0f); + if (ground > INVALID_HEIGHT && (!minDist || minDist > dist)) { - x = master->GetPositionX() + cos(angle) * range + cos(followAngle) * followRange; - y = master->GetPositionY() + sin(angle) * range + sin(followAngle) * followRange; - float dist = sServerFacade->GetDistance2d(bot, x, y); - float ground = master->GetMapHeight(x, y, z + 30.0f); - if (ground > INVALID_HEIGHT && (!minDist || minDist > dist)) - { - minDist = dist; - minX = x; - minY = y; - } + minDist = dist; + minX = x; + minY = y; } - - if (minDist) - { - z += CONTACT_DISTANCE; - bot->UpdateAllowedPositionZ(minX, minY, z); - return WorldLocation(bot->GetMapId(), minX, minY, z); - } - - return Formation::NullLocation; } - z += CONTACT_DISTANCE; - bot->UpdateAllowedPositionZ(x, y, z); - return WorldLocation(bot->GetMapId(), x, y, z); + if (minDist) + { + z += CONTACT_DISTANCE; + bot->UpdateAllowedPositionZ(minX, minY, z); + return WorldLocation(bot->GetMapId(), minX, minY, z); + } + + return Formation::NullLocation; } + + z += CONTACT_DISTANCE; + bot->UpdateAllowedPositionZ(x, y, z); + return WorldLocation(bot->GetMapId(), x, y, z); + } }; float Formation::GetFollowAngle() @@ -376,7 +378,8 @@ float Formation::GetFollowAngle() masterBotMgr = GET_PLAYERBOT_MGR(master); if (!group && master && !GET_PLAYERBOT_AI(master) && masterBotMgr) { - for (PlayerBotMap::const_iterator i = masterBotMgr->GetPlayerBotsBegin(); i != masterBotMgr->GetPlayerBotsEnd(); ++i) + for (PlayerBotMap::const_iterator i = masterBotMgr->GetPlayerBotsBegin(); i != masterBotMgr->GetPlayerBotsEnd(); + ++i) { if (i->second == bot) index = total; @@ -441,7 +444,8 @@ float Formation::GetFollowAngle() return start + (0.125f + 1.75f * index / total + (total == 2 ? 0.125f : 0.0f)) * M_PI; } -FormationValue::FormationValue(PlayerbotAI* botAI) : ManualSetValue(botAI, new NearFormation(botAI), "formation") +FormationValue::FormationValue(PlayerbotAI* botAI) + : ManualSetValue(botAI, new NearFormation(botAI), "formation") { } @@ -454,10 +458,7 @@ FormationValue::~FormationValue() } } -std::string const FormationValue::Save() -{ - return value ? value->getName() : "?"; -} +std::string const FormationValue::Save() { return value ? value->getName() : "?"; } bool FormationValue::Load(std::string const formation) { @@ -557,7 +558,8 @@ bool SetFormationAction::Execute(Event event) std::ostringstream str; str << "Invalid formation: |cffff0000" << formation; botAI->TellMaster(str); - botAI->TellMaster("Please set to any of:|cffffffff near (default), queue, chaos, circle, line, shield, arrow, melee, far"); + botAI->TellMaster( + "Please set to any of:|cffffffff near (default), queue, chaos, circle, line, shield, arrow, melee, far"); return false; } @@ -567,7 +569,8 @@ bool SetFormationAction::Execute(Event event) return true; } -WorldLocation MoveFormation::MoveLine(std::vector line, float diff, float cx, float cy, float cz, float orientation, float range) +WorldLocation MoveFormation::MoveLine(std::vector line, float diff, float cx, float cy, float cz, + float orientation, float range) { if (line.size() < 5) { @@ -588,7 +591,7 @@ WorldLocation MoveFormation::MoveLine(std::vector line, float diff, flo line.pop_back(); } - WorldLocation loc = MoveSingleLine(singleLine, diff, x, y,cz, orientation, range); + WorldLocation loc = MoveSingleLine(singleLine, diff, x, y, cz, orientation, range); if (!Formation::IsNullLocation(loc)) return loc; } @@ -596,7 +599,8 @@ WorldLocation MoveFormation::MoveLine(std::vector line, float diff, flo return Formation::NullLocation; } -WorldLocation MoveFormation::MoveSingleLine(std::vector line, float diff, float cx, float cy, float cz, float orientation, float range) +WorldLocation MoveFormation::MoveSingleLine(std::vector line, float diff, float cx, float cy, float cz, + float orientation, float range) { float count = line.size(); float angle = orientation - M_PI / 2.0f; diff --git a/src/strategy/values/Formations.h b/src/strategy/values/Formations.h index 0f2aba56..beff6210 100644 --- a/src/strategy/values/Formations.h +++ b/src/strategy/values/Formations.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_FORMATIONS_H @@ -15,60 +16,62 @@ class PlayerbotAI; class Formation : public AiNamedObject { - public: - Formation(PlayerbotAI* botAI, std::string const name) : AiNamedObject(botAI, name) { } - virtual ~Formation() = default; - virtual std::string const GetTargetName() { return ""; } - virtual WorldLocation GetLocation() { return NullLocation; } - virtual float GetMaxDistance() { return sPlayerbotAIConfig->followDistance; } - static WorldLocation NullLocation; - static bool IsNullLocation(WorldLocation const& loc); +public: + Formation(PlayerbotAI* botAI, std::string const name) : AiNamedObject(botAI, name) {} + virtual ~Formation() = default; + virtual std::string const GetTargetName() { return ""; } + virtual WorldLocation GetLocation() { return NullLocation; } + virtual float GetMaxDistance() { return sPlayerbotAIConfig->followDistance; } + static WorldLocation NullLocation; + static bool IsNullLocation(WorldLocation const& loc); - protected: - float GetFollowAngle(); +protected: + float GetFollowAngle(); }; class FollowFormation : public Formation { - public: - FollowFormation(PlayerbotAI* botAI, std::string const name) : Formation(botAI, name) { } +public: + FollowFormation(PlayerbotAI* botAI, std::string const name) : Formation(botAI, name) {} }; class MoveFormation : public Formation { - public: - MoveFormation(PlayerbotAI* botAI, std::string const name) : Formation(botAI, name) { } +public: + MoveFormation(PlayerbotAI* botAI, std::string const name) : Formation(botAI, name) {} - protected: - WorldLocation MoveLine(std::vector line, float diff, float cx, float cy, float cz, float orientation, float range); - WorldLocation MoveSingleLine(std::vector line, float diff, float cx, float cy, float cz, float orientation, float range); +protected: + WorldLocation MoveLine(std::vector line, float diff, float cx, float cy, float cz, float orientation, + float range); + WorldLocation MoveSingleLine(std::vector line, float diff, float cx, float cy, float cz, float orientation, + float range); }; class MoveAheadFormation : public MoveFormation { - public: - MoveAheadFormation(PlayerbotAI* botAI, std::string const name) : MoveFormation(botAI, name) { } +public: + MoveAheadFormation(PlayerbotAI* botAI, std::string const name) : MoveFormation(botAI, name) {} - WorldLocation GetLocation() override; - virtual WorldLocation GetLocationInternal() { return NullLocation; } + WorldLocation GetLocation() override; + virtual WorldLocation GetLocationInternal() { return NullLocation; } }; class FormationValue : public ManualSetValue { - public: - FormationValue(PlayerbotAI* botAI); - ~FormationValue(); +public: + FormationValue(PlayerbotAI* botAI); + ~FormationValue(); - std::string const Save() override; - bool Load(std::string const value) override; + std::string const Save() override; + bool Load(std::string const value) override; }; class SetFormationAction : public Action { - public: - SetFormationAction(PlayerbotAI* botAI) : Action(botAI, "set formation") { } +public: + SetFormationAction(PlayerbotAI* botAI) : Action(botAI, "set formation") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/values/GrindTargetValue.cpp b/src/strategy/values/GrindTargetValue.cpp index 0be03904..14942a85 100644 --- a/src/strategy/values/GrindTargetValue.cpp +++ b/src/strategy/values/GrindTargetValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GrindTargetValue.h" + #include "Playerbots.h" #include "ReputationMgr.h" #include "SharedDefines.h" @@ -52,61 +54,66 @@ Unit* GrindTargetValue::FindTargetForGrinding(uint32 assistCount) for (ObjectGuid const guid : targets) { Unit* unit = botAI->GetUnit(guid); - + if (!unit) continue; - - auto &rep = bot->ToPlayer()->GetReputationMgr(); - if (unit->ToCreature() && !unit->ToCreature()->GetCreatureTemplate()->lootid && bot->GetReactionTo(unit) >= REP_NEUTRAL) { + + auto& rep = bot->ToPlayer()->GetReputationMgr(); + if (unit->ToCreature() && !unit->ToCreature()->GetCreatureTemplate()->lootid && + bot->GetReactionTo(unit) >= REP_NEUTRAL) + { continue; } - if (!bot->IsHostileTo(unit) && unit->GetNpcFlags() != UNIT_NPC_FLAG_NONE) { + if (!bot->IsHostileTo(unit) && unit->GetNpcFlags() != UNIT_NPC_FLAG_NONE) + { continue; } - - if (!bot->isHonorOrXPTarget(unit)) { + + if (!bot->isHonorOrXPTarget(unit)) + { continue; } - + if (abs(bot->GetPositionZ() - unit->GetPositionZ()) > INTERACTION_DISTANCE) continue; if (!bot->InBattleground() && GetTargetingPlayerCount(unit) > assistCount) continue; - //if (!bot->InBattleground() && master && master->GetDistance(unit) >= sPlayerbotAIConfig->grindDistance && !sRandomPlayerbotMgr->IsRandomBot(bot)) - //continue; + // if (!bot->InBattleground() && master && master->GetDistance(unit) >= sPlayerbotAIConfig->grindDistance && + // !sRandomPlayerbotMgr->IsRandomBot(bot)) continue; - if (!bot->InBattleground() && (int)unit->GetLevel() - (int)bot->GetLevel() > 4 && !unit->GetGUID().IsPlayer()) - continue; + if (!bot->InBattleground() && (int)unit->GetLevel() - (int)bot->GetLevel() > 4 && !unit->GetGUID().IsPlayer()) + continue; // if (needForQuestMap.find(unit->GetEntry()) == needForQuestMap.end()) // needForQuestMap[unit->GetEntry()] = needForQuest(unit); // if (!needForQuestMap[unit->GetEntry()]) // if ((urand(0, 100) < 75 || (context->GetValue("travel target")->Get()->isWorking() && - // context->GetValue("travel target")->Get()->getDestination()->getName() != "GrindTravelDestination"))) - // continue; + // context->GetValue("travel target")->Get()->getDestination()->getName() != + // "GrindTravelDestination"))) continue; - //if (bot->InBattleground() && bot->GetDistance(unit) > 40.0f) - //continue; + // if (bot->InBattleground() && bot->GetDistance(unit) > 40.0f) + // continue; - if (Creature* creature = unit->ToCreature()) + if (Creature* creature = unit->ToCreature()) if (CreatureTemplate const* CreatureTemplate = creature->GetCreatureTemplate()) - if (CreatureTemplate->rank > CREATURE_ELITE_NORMAL && !AI_VALUE(bool, "can fight elite")) - continue; - - if (!bot->IsWithinLOSInMap(unit)) { + if (CreatureTemplate->rank > CREATURE_ELITE_NORMAL && !AI_VALUE(bool, "can fight elite")) + continue; + + if (!bot->IsWithinLOSInMap(unit)) + { continue; } - + if (group) { Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) { - Player *member = ObjectAccessor::FindPlayer(itr->guid); + Player* member = ObjectAccessor::FindPlayer(itr->guid); if (!member || !member->IsAlive()) continue; @@ -121,7 +128,8 @@ Unit* GrindTargetValue::FindTargetForGrinding(uint32 assistCount) else { float newdistance = bot->GetDistance(unit); - if (!result || (newdistance < distance && urand(0, abs(distance - newdistance)) > sPlayerbotAIConfig->sightDistance * 0.1)) + if (!result || (newdistance < distance && + urand(0, abs(distance - newdistance)) > sPlayerbotAIConfig->sightDistance * 0.1)) { distance = newdistance; result = unit; @@ -160,7 +168,7 @@ bool GrindTargetValue::needForQuest(Unit* target) { QuestStatusData* questStatus = sTravelMgr->getQuestStatus(bot, questId); - if (questTemplate->GetQuestLevel() > bot->GetLevel()+5) + if (questTemplate->GetQuestLevel() > bot->GetLevel() + 5) continue; for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) @@ -218,7 +226,7 @@ uint32 GrindTargetValue::GetTargetingPlayerCount(Unit* unit) Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) { - Player *member = ObjectAccessor::FindPlayer(itr->guid); + Player* member = ObjectAccessor::FindPlayer(itr->guid); if (!member || !member->IsAlive() || member == bot) continue; diff --git a/src/strategy/values/GrindTargetValue.h b/src/strategy/values/GrindTargetValue.h index cb0ced24..bf26763f 100644 --- a/src/strategy/values/GrindTargetValue.h +++ b/src/strategy/values/GrindTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GRINDTARGETVALUE_H @@ -12,15 +13,15 @@ class Unit; class GrindTargetValue : public TargetValue { - public: - GrindTargetValue(PlayerbotAI* botAI, std::string const name = "grind target") : TargetValue(botAI, name) { } +public: + GrindTargetValue(PlayerbotAI* botAI, std::string const name = "grind target") : TargetValue(botAI, name) {} - Unit* Calculate() override; + Unit* Calculate() override; - private: - uint32 GetTargetingPlayerCount(Unit* unit); - Unit* FindTargetForGrinding(uint32 assistCount); - bool needForQuest(Unit* target); +private: + uint32 GetTargetingPlayerCount(Unit* unit); + Unit* FindTargetForGrinding(uint32 assistCount); + bool needForQuest(Unit* target); }; #endif diff --git a/src/strategy/values/GroupValues.cpp b/src/strategy/values/GroupValues.cpp index 422f4f86..397bf86b 100644 --- a/src/strategy/values/GroupValues.cpp +++ b/src/strategy/values/GroupValues.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GroupValues.h" + #include "Playerbots.h" #include "ServerFacade.h" @@ -24,7 +26,6 @@ GuidVector GroupMembersValue::Calculate() return members; } - bool IsFollowingPartyValue::Calculate() { if (botAI->GetGroupMaster() == bot) @@ -55,7 +56,7 @@ bool BoolANDValue::Calculate() for (auto value : values) { - if(!AI_VALUE(bool, value)) + if (!AI_VALUE(bool, value)) return false; } @@ -101,7 +102,7 @@ bool GroupBoolANDValue::Calculate() if (!GET_PLAYERBOT_AI(player)) continue; - if (!PAI_VALUE2(bool,"and", getQualifier())) + if (!PAI_VALUE2(bool, "and", getQualifier())) return false; } @@ -141,7 +142,7 @@ bool GroupReadyValue::Calculate() if (!member) continue; - if (inDungeon) //In dungeons all following members need to be alive before continueing. + if (inDungeon) // In dungeons all following members need to be alive before continueing. { PlayerbotAI* memberAi = GET_PLAYERBOT_AI(member); @@ -151,8 +152,10 @@ bool GroupReadyValue::Calculate() return false; } - //We only wait for members that are in range otherwise we might be waiting for bots stuck in dead loops forever. - if (botAI->GetGroupMaster() && sServerFacade->GetDistance2d(member, botAI->GetGroupMaster()) > sPlayerbotAIConfig->sightDistance) + // We only wait for members that are in range otherwise we might be waiting for bots stuck in dead loops + // forever. + if (botAI->GetGroupMaster() && + sServerFacade->GetDistance2d(member, botAI->GetGroupMaster()) > sPlayerbotAIConfig->sightDistance) continue; if (member->GetHealthPct() < sPlayerbotAIConfig->almostFullHealth) @@ -161,7 +164,7 @@ bool GroupReadyValue::Calculate() if (!member->GetPower(POWER_MANA)) continue; - float mana = (static_cast (member->GetPower(POWER_MANA)) / member->GetMaxPower(POWER_MANA)) * 100; + float mana = (static_cast(member->GetPower(POWER_MANA)) / member->GetMaxPower(POWER_MANA)) * 100; if (mana < sPlayerbotAIConfig->mediumMana) return false; diff --git a/src/strategy/values/GroupValues.h b/src/strategy/values/GroupValues.h index 49ab3fb5..b59a1d51 100644 --- a/src/strategy/values/GroupValues.h +++ b/src/strategy/values/GroupValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "NamedObjectContext.h" @@ -9,64 +10,64 @@ class PlayerbotAI; class GroupMembersValue : public ObjectGuidListCalculatedValue { - public: - GroupMembersValue(PlayerbotAI* botAI) : ObjectGuidListCalculatedValue(botAI, "group members", 2 * 1000) { } +public: + GroupMembersValue(PlayerbotAI* botAI) : ObjectGuidListCalculatedValue(botAI, "group members", 2 * 1000) {} - GuidVector Calculate() override; + GuidVector Calculate() override; }; class IsFollowingPartyValue : public BoolCalculatedValue { - public: - IsFollowingPartyValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "following party") { } +public: + IsFollowingPartyValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "following party") {} - bool Calculate() override; + bool Calculate() override; }; class IsNearLeaderValue : public BoolCalculatedValue { - public: - IsNearLeaderValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "near leader") { } +public: + IsNearLeaderValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "near leader") {} - bool Calculate() override; + bool Calculate() override; }; class BoolANDValue : public BoolCalculatedValue, public Qualified { - public: - BoolANDValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "bool and") { } +public: + BoolANDValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "bool and") {} - bool Calculate() override; + bool Calculate() override; }; class GroupBoolCountValue : public Uint32CalculatedValue, public Qualified { - public: - GroupBoolCountValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "group count") { } +public: + GroupBoolCountValue(PlayerbotAI* botAI) : Uint32CalculatedValue(botAI, "group count") {} - uint32 Calculate() override; + uint32 Calculate() override; }; class GroupBoolANDValue : public BoolCalculatedValue, public Qualified { - public: - GroupBoolANDValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "group bool and") { } +public: + GroupBoolANDValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "group bool and") {} - bool Calculate() override; + bool Calculate() override; }; class GroupBoolORValue : public BoolCalculatedValue, public Qualified { - public: - GroupBoolORValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "group bool or") { } +public: + GroupBoolORValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "group bool or") {} - bool Calculate() override; + bool Calculate() override; }; class GroupReadyValue : public BoolCalculatedValue, public Qualified { - public: - GroupReadyValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "group ready", 2 * 2000) { } +public: + GroupReadyValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "group ready", 2 * 2000) {} - bool Calculate()override; + bool Calculate() override; }; diff --git a/src/strategy/values/GuildValues.cpp b/src/strategy/values/GuildValues.cpp index e533c7d3..3be92adc 100644 --- a/src/strategy/values/GuildValues.cpp +++ b/src/strategy/values/GuildValues.cpp @@ -1,19 +1,22 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GuildValues.h" + #include "Playerbots.h" uint8 PetitionSignsValue::Calculate() { if (bot->GetGuildId()) - return 0; + return 0; std::vector petitions = AI_VALUE2(std::vector, "inventory items", chat->FormatQItem(5863)); if (petitions.empty()) return 0; - QueryResult result = CharacterDatabase.Query("SELECT playerguid FROM petition_sign WHERE petitionguid = {}", petitions.front()->GetGUID().GetCounter()); + QueryResult result = CharacterDatabase.Query("SELECT playerguid FROM petition_sign WHERE petitionguid = {}", + petitions.front()->GetGUID().GetCounter()); return result ? (uint8)result->GetRowCount() : 0; } diff --git a/src/strategy/values/GuildValues.h b/src/strategy/values/GuildValues.h index 6f859657..aa07def1 100644 --- a/src/strategy/values/GuildValues.h +++ b/src/strategy/values/GuildValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GUILDVALUES_H @@ -11,10 +12,10 @@ class PlayerbotAI; class PetitionSignsValue : public SingleCalculatedValue { - public: - PetitionSignsValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "petition signs") { } +public: + PetitionSignsValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "petition signs") {} - uint8 Calculate(); + uint8 Calculate(); }; #endif diff --git a/src/strategy/values/HasAvailableLootValue.cpp b/src/strategy/values/HasAvailableLootValue.cpp index c5babd9c..091bf62d 100644 --- a/src/strategy/values/HasAvailableLootValue.cpp +++ b/src/strategy/values/HasAvailableLootValue.cpp @@ -1,12 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HasAvailableLootValue.h" + #include "LootObjectStack.h" #include "Playerbots.h" bool HasAvailableLootValue::Calculate() { - return !AI_VALUE(bool, "can loot") && AI_VALUE(LootObjectStack*, "available loot")->CanLoot(sPlayerbotAIConfig->lootDistance); + return !AI_VALUE(bool, "can loot") && + AI_VALUE(LootObjectStack*, "available loot")->CanLoot(sPlayerbotAIConfig->lootDistance); } diff --git a/src/strategy/values/HasAvailableLootValue.h b/src/strategy/values/HasAvailableLootValue.h index c61bc8fa..dafd8e5c 100644 --- a/src/strategy/values/HasAvailableLootValue.h +++ b/src/strategy/values/HasAvailableLootValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HASAVAILABLELOOTVALUE_H @@ -11,10 +12,10 @@ class PlayerbotAI; class HasAvailableLootValue : public BoolCalculatedValue { - public: - HasAvailableLootValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI) { } +public: + HasAvailableLootValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI) {} - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/HasTotemValue.cpp b/src/strategy/values/HasTotemValue.cpp index 7a5446b0..052369eb 100644 --- a/src/strategy/values/HasTotemValue.cpp +++ b/src/strategy/values/HasTotemValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "HasTotemValue.h" + #include "Playerbots.h" char* strstri(char const* str1, char const* str2); diff --git a/src/strategy/values/HasTotemValue.h b/src/strategy/values/HasTotemValue.h index 445e8bbe..84d49bca 100644 --- a/src/strategy/values/HasTotemValue.h +++ b/src/strategy/values/HasTotemValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_HASTOTEMVALUE_H @@ -12,10 +13,10 @@ class PlayerbotAI; class HasTotemValue : public BoolCalculatedValue, public Qualified { - public: - HasTotemValue(PlayerbotAI* botAI, std::string const name = "has totem") : BoolCalculatedValue(botAI, name) { } +public: + HasTotemValue(PlayerbotAI* botAI, std::string const name = "has totem") : BoolCalculatedValue(botAI, name) {} - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/InvalidTargetValue.cpp b/src/strategy/values/InvalidTargetValue.cpp index c940424a..63bf10c3 100644 --- a/src/strategy/values/InvalidTargetValue.cpp +++ b/src/strategy/values/InvalidTargetValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "InvalidTargetValue.h" + #include "AttackersValue.h" #include "Playerbots.h" #include "Unit.h" @@ -16,17 +18,10 @@ bool InvalidTargetValue::Calculate() if (target && qualifier == "current target") { - return target->GetMapId() != bot->GetMapId() || - target->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE) || - target->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE) || - target->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE_2) || - !target->IsVisible() || - !target->IsAlive() || - target->IsPolymorphed() || - target->IsCharmed() || - target->isFeared() || - target->HasUnitState(UNIT_STATE_ISOLATED) || - target->IsFriendlyTo(bot) || + return target->GetMapId() != bot->GetMapId() || target->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE) || + target->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE) || target->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE_2) || + !target->IsVisible() || !target->IsAlive() || target->IsPolymorphed() || target->IsCharmed() || + target->isFeared() || target->HasUnitState(UNIT_STATE_ISOLATED) || target->IsFriendlyTo(bot) || !AttackersValue::IsValidTarget(target, bot); } diff --git a/src/strategy/values/InvalidTargetValue.h b/src/strategy/values/InvalidTargetValue.h index 5651198b..0d7c563a 100644 --- a/src/strategy/values/InvalidTargetValue.h +++ b/src/strategy/values/InvalidTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_INVALIDTARGETVALUE_H @@ -12,10 +13,12 @@ class PlayerbotAI; class InvalidTargetValue : public BoolCalculatedValue, public Qualified { - public: - InvalidTargetValue(PlayerbotAI* botAI, std::string const name = "invalid target") : BoolCalculatedValue(botAI, name) { } +public: + InvalidTargetValue(PlayerbotAI* botAI, std::string const name = "invalid target") : BoolCalculatedValue(botAI, name) + { + } - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/IsBehindValue.cpp b/src/strategy/values/IsBehindValue.cpp index 488ad293..c803f681 100644 --- a/src/strategy/values/IsBehindValue.cpp +++ b/src/strategy/values/IsBehindValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "IsBehindValue.h" + #include "Playerbots.h" bool IsBehindValue::Calculate() @@ -11,7 +13,6 @@ bool IsBehindValue::Calculate() if (!target) return false; - float targetOrientation = target->GetOrientation(); float orientation = bot->GetOrientation(); float distance = bot->GetDistance(target); diff --git a/src/strategy/values/IsBehindValue.h b/src/strategy/values/IsBehindValue.h index 17b64baf..3f121f19 100644 --- a/src/strategy/values/IsBehindValue.h +++ b/src/strategy/values/IsBehindValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ISBEHINDVALUE_H @@ -12,10 +13,10 @@ class PlayerbotAI; class IsBehindValue : public BoolCalculatedValue, public Qualified { - public: - IsBehindValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI) { } +public: + IsBehindValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI) {} - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/IsFacingValue.cpp b/src/strategy/values/IsFacingValue.cpp index 8aa32c9b..9ac841d6 100644 --- a/src/strategy/values/IsFacingValue.cpp +++ b/src/strategy/values/IsFacingValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "IsFacingValue.h" + #include "Playerbots.h" bool IsFacingValue::Calculate() diff --git a/src/strategy/values/IsFacingValue.h b/src/strategy/values/IsFacingValue.h index e09654b1..95e46065 100644 --- a/src/strategy/values/IsFacingValue.h +++ b/src/strategy/values/IsFacingValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ISFACINGVALUE_H @@ -12,10 +13,10 @@ class PlayerbotAI; class IsFacingValue : public BoolCalculatedValue, public Qualified { - public: - IsFacingValue(PlayerbotAI* botAI, std::string const name = "is facing") : BoolCalculatedValue(botAI, name) { } +public: + IsFacingValue(PlayerbotAI* botAI, std::string const name = "is facing") : BoolCalculatedValue(botAI, name) {} - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/IsMovingValue.cpp b/src/strategy/values/IsMovingValue.cpp index 47f297a3..a61c329c 100644 --- a/src/strategy/values/IsMovingValue.cpp +++ b/src/strategy/values/IsMovingValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "IsMovingValue.h" + #include "Playerbots.h" bool IsMovingValue::Calculate() diff --git a/src/strategy/values/IsMovingValue.h b/src/strategy/values/IsMovingValue.h index e5476a8b..c9a31189 100644 --- a/src/strategy/values/IsMovingValue.h +++ b/src/strategy/values/IsMovingValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ISMOVINGVALUE_H @@ -12,18 +13,18 @@ class PlayerbotAI; class IsMovingValue : public BoolCalculatedValue, public Qualified { - public: - IsMovingValue(PlayerbotAI* botAI, std::string const name = "is moving") : BoolCalculatedValue(botAI, name) { } +public: + IsMovingValue(PlayerbotAI* botAI, std::string const name = "is moving") : BoolCalculatedValue(botAI, name) {} - bool Calculate() override; + bool Calculate() override; }; class IsSwimmingValue : public BoolCalculatedValue, public Qualified { - public: - IsSwimmingValue(PlayerbotAI* botAI, std::string const name = "is swimming") : BoolCalculatedValue(botAI, name) { } +public: + IsSwimmingValue(PlayerbotAI* botAI, std::string const name = "is swimming") : BoolCalculatedValue(botAI, name) {} - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/ItemCountValue.cpp b/src/strategy/values/ItemCountValue.cpp index 91f97cca..d17d9e7c 100644 --- a/src/strategy/values/ItemCountValue.cpp +++ b/src/strategy/values/ItemCountValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ItemCountValue.h" + #include "Playerbots.h" std::vector InventoryItemValueBase::Find(std::string const qualifier) @@ -30,7 +32,4 @@ uint32 ItemCountValue::Calculate() return count; } -std::vector InventoryItemValue::Calculate() -{ - return Find(qualifier); -} +std::vector InventoryItemValue::Calculate() { return Find(qualifier); } diff --git a/src/strategy/values/ItemCountValue.h b/src/strategy/values/ItemCountValue.h index cb280be9..de04ec43 100644 --- a/src/strategy/values/ItemCountValue.h +++ b/src/strategy/values/ItemCountValue.h @@ -1,41 +1,47 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ITEMCOUNTVALUE_H #define _PLAYERBOT_ITEMCOUNTVALUE_H +#include "InventoryAction.h" #include "Item.h" #include "NamedObjectContext.h" -#include "InventoryAction.h" class PlayerbotAI; class InventoryItemValueBase : public InventoryAction { - public: - InventoryItemValueBase(PlayerbotAI* botAI) : InventoryAction(botAI, "empty") { } +public: + InventoryItemValueBase(PlayerbotAI* botAI) : InventoryAction(botAI, "empty") {} - bool Execute(Event event) override { return false; } + bool Execute(Event event) override { return false; } - protected: - std::vector Find(std::string const qualifier); +protected: + std::vector Find(std::string const qualifier); }; class ItemCountValue : public Uint32CalculatedValue, public Qualified, InventoryItemValueBase { - public: - ItemCountValue(PlayerbotAI* botAI, std::string const name = "inventory items") : Uint32CalculatedValue(botAI, name), InventoryItemValueBase(botAI) { } +public: + ItemCountValue(PlayerbotAI* botAI, std::string const name = "inventory items") + : Uint32CalculatedValue(botAI, name), InventoryItemValueBase(botAI) + { + } - uint32 Calculate() override; + uint32 Calculate() override; }; class InventoryItemValue : public CalculatedValue>, public Qualified, InventoryItemValueBase { - public: - InventoryItemValue(PlayerbotAI* botAI) : CalculatedValue>(botAI), InventoryItemValueBase(botAI) { } +public: + InventoryItemValue(PlayerbotAI* botAI) : CalculatedValue>(botAI), InventoryItemValueBase(botAI) + { + } - std::vector Calculate() override; + std::vector Calculate() override; }; #endif diff --git a/src/strategy/values/ItemForSpellValue.cpp b/src/strategy/values/ItemForSpellValue.cpp index 58c4fae1..95751b4a 100644 --- a/src/strategy/values/ItemForSpellValue.cpp +++ b/src/strategy/values/ItemForSpellValue.cpp @@ -1,14 +1,18 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ItemForSpellValue.h" + #include "Playerbots.h" #ifndef WIN32 inline int strcmpi(char const* s1, char const* s2) { - for (; *s1 && *s2 && (toupper(*s1) == toupper(*s2)); ++s1, ++s2) {} + for (; *s1 && *s2 && (toupper(*s1) == toupper(*s2)); ++s1, ++s2) + { + } return *s1 - *s2; } #endif @@ -19,7 +23,7 @@ Item* ItemForSpellValue::Calculate() if (!spellid) return nullptr; - SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spellid); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); if (!spellInfo) return nullptr; @@ -45,7 +49,9 @@ Item* ItemForSpellValue::Calculate() } // Workaround as some spells have no item mask (e.g. shaman weapon enhancements) - if (!strcmpi(spellInfo->SpellName[0], "rockbiter weapon") || !strcmpi(spellInfo->SpellName[0], "flametongue weapon") || !strcmpi(spellInfo->SpellName[0], "earthliving weapon") || + if (!strcmpi(spellInfo->SpellName[0], "rockbiter weapon") || + !strcmpi(spellInfo->SpellName[0], "flametongue weapon") || + !strcmpi(spellInfo->SpellName[0], "earthliving weapon") || !strcmpi(spellInfo->SpellName[0], "frostbrand weapon") || !strcmpi(spellInfo->SpellName[0], "windfury weapon")) { itemForSpell = GetItemFitsToSpellRequirements(EQUIPMENT_SLOT_MAINHAND, spellInfo); @@ -65,7 +71,7 @@ Item* ItemForSpellValue::Calculate() if (!strcmpi(spellInfo->SpellName[0], "disenchant")) return nullptr; - for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; slot++ ) + for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; slot++) { itemForSpell = GetItemFitsToSpellRequirements(slot, spellInfo); if (itemForSpell) @@ -75,9 +81,9 @@ Item* ItemForSpellValue::Calculate() return nullptr; } -Item* ItemForSpellValue::GetItemFitsToSpellRequirements(uint8 slot, SpellInfo const *spellInfo) +Item* ItemForSpellValue::GetItemFitsToSpellRequirements(uint8 slot, SpellInfo const* spellInfo) { - Item* const itemForSpell = bot->GetItemByPos( INVENTORY_SLOT_BAG_0, slot ); + Item* const itemForSpell = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot); if (!itemForSpell || itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) return nullptr; diff --git a/src/strategy/values/ItemForSpellValue.h b/src/strategy/values/ItemForSpellValue.h index 525a9109..a2a2a2bd 100644 --- a/src/strategy/values/ItemForSpellValue.h +++ b/src/strategy/values/ItemForSpellValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ITEMFORSPELLVALUE_H @@ -14,13 +15,16 @@ class SpellInfo; class ItemForSpellValue : public CalculatedValue, public Qualified { - public: - ItemForSpellValue(PlayerbotAI* botAI, std::string const name = "item for spell") : CalculatedValue(botAI, name, 1) { } +public: + ItemForSpellValue(PlayerbotAI* botAI, std::string const name = "item for spell") + : CalculatedValue(botAI, name, 1) + { + } - Item* Calculate() override; + Item* Calculate() override; - private: - Item* GetItemFitsToSpellRequirements(uint8 slot, SpellInfo const *spellInfo); +private: + Item* GetItemFitsToSpellRequirements(uint8 slot, SpellInfo const* spellInfo); }; #endif diff --git a/src/strategy/values/ItemUsageValue.cpp b/src/strategy/values/ItemUsageValue.cpp index ac7d2cc5..f42aca0c 100644 --- a/src/strategy/values/ItemUsageValue.cpp +++ b/src/strategy/values/ItemUsageValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ItemUsageValue.h" + #include "AiFactory.h" #include "ChatHelper.h" #include "GuildTaskMgr.h" @@ -37,7 +39,8 @@ ItemUsage ItemUsageValue::Calculate() { bool lowBagSpace = AI_VALUE(uint8, "bag space") > 50; - if (proto->Class == ITEM_CLASS_TRADE_GOODS || proto->Class == ITEM_CLASS_MISC || proto->Class == ITEM_CLASS_REAGENT) + if (proto->Class == ITEM_CLASS_TRADE_GOODS || proto->Class == ITEM_CLASS_MISC || + proto->Class == ITEM_CLASS_REAGENT) needItem = IsItemNeededForUsefullSpell(proto, lowBagSpace); else if (proto->Class == ITEM_CLASS_RECIPE) { @@ -52,9 +55,9 @@ ItemUsage ItemUsageValue::Calculate() { float stacks = CurrentStacks(proto); if (stacks < 1) - return ITEM_USAGE_SKILL; //Buy more. + return ITEM_USAGE_SKILL; // Buy more. if (stacks < 2) - return ITEM_USAGE_KEEP; //Keep current amount. + return ITEM_USAGE_KEEP; // Keep current amount. } } @@ -73,13 +76,13 @@ ItemUsage ItemUsageValue::Calculate() stacks += CurrentStacks(proto); if (stacks < 2) - return ITEM_USAGE_USE; // Buy some to get to 2 stacks - else if (stacks < 3) // Keep the item if less than 3 stacks + return ITEM_USAGE_USE; // Buy some to get to 2 stacks + else if (stacks < 3) // Keep the item if less than 3 stacks return ITEM_USAGE_KEEP; } } } - + if (bot->GetGuildId() && sGuildTaskMgr->IsGuildTaskItem(itemId, bot->GetGuildId())) return ITEM_USAGE_GUILD_TASK; @@ -87,12 +90,14 @@ ItemUsage ItemUsageValue::Calculate() if (equip != ITEM_USAGE_NONE) return equip; - if ((proto->Class == ITEM_CLASS_ARMOR || proto->Class == ITEM_CLASS_WEAPON) && proto->Bonding != BIND_WHEN_PICKED_UP && - botAI->HasSkill(SKILL_ENCHANTING) && proto->Quality >= ITEM_QUALITY_UNCOMMON) + if ((proto->Class == ITEM_CLASS_ARMOR || proto->Class == ITEM_CLASS_WEAPON) && + proto->Bonding != BIND_WHEN_PICKED_UP && botAI->HasSkill(SKILL_ENCHANTING) && + proto->Quality >= ITEM_QUALITY_UNCOMMON) return ITEM_USAGE_DISENCHANT; - //While sync is on, do not loot quest items that are also Useful for master. Master - if (!botAI->GetMaster() || !sPlayerbotAIConfig->syncQuestWithPlayer || !IsItemUsefulForQuest(botAI->GetMaster(), proto)) + // While sync is on, do not loot quest items that are also Useful for master. Master + if (!botAI->GetMaster() || !sPlayerbotAIConfig->syncQuestWithPlayer || + !IsItemUsefulForQuest(botAI->GetMaster(), proto)) if (IsItemUsefulForQuest(bot, proto)) return ITEM_USAGE_QUEST; @@ -118,20 +123,20 @@ ItemUsage ItemUsageValue::Calculate() float ammo = BetterStacks(proto, "ammo"); float needAmmo = (bot->getClass() == CLASS_HUNTER) ? 8 : 2; - if (ammo < needAmmo) //We already have enough of the current ammo. + if (ammo < needAmmo) // We already have enough of the current ammo. { ammo += CurrentStacks(proto); - if (ammo < needAmmo) //Buy ammo to get to the proper supply + if (ammo < needAmmo) // Buy ammo to get to the proper supply return ITEM_USAGE_AMMO; else if (ammo < needAmmo + 1) - return ITEM_USAGE_KEEP; // Keep the ammo until we have too much. + return ITEM_USAGE_KEEP; // Keep the ammo until we have too much. } } } } - //Need to add something like free bagspace or item value. + // Need to add something like free bagspace or item value. if (proto->SellPrice > 0) { if (proto->Quality > ITEM_QUALITY_NORMAL) @@ -164,7 +169,7 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto) pItem->RemoveFromUpdateQueueOf(bot); delete pItem; - if (result != EQUIP_ERR_OK ) + if (result != EQUIP_ERR_OK) return ITEM_USAGE_NONE; if (itemProto->Class == ITEM_CLASS_QUIVER) @@ -174,7 +179,8 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto) if (itemProto->Class == ITEM_CLASS_CONTAINER) { if (itemProto->SubClass != ITEM_SUBCLASS_CONTAINER) - return ITEM_USAGE_NONE; //Todo add logic for non-bag containers. We want to look at professions/class and only replace if non-bag is larger than bag. + return ITEM_USAGE_NONE; // Todo add logic for non-bag containers. We want to look at professions/class and + // only replace if non-bag is larger than bag. if (GetSmallestBagSize() >= itemProto->ContainerSlots) return ITEM_USAGE_NONE; @@ -190,16 +196,19 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto) if (itemProto->Class == ITEM_CLASS_WEAPON && !sRandomItemMgr->CanEquipWeapon(bot->getClass(), itemProto)) shouldEquip = false; - if (itemProto->Class == ITEM_CLASS_ARMOR && !sRandomItemMgr->CanEquipArmor(bot->getClass(), bot->GetLevel(), itemProto)) + if (itemProto->Class == ITEM_CLASS_ARMOR && + !sRandomItemMgr->CanEquipArmor(bot->getClass(), bot->GetLevel(), itemProto)) shouldEquip = false; Item* oldItem = bot->GetItemByPos(dest); - //No item equiped - if (!oldItem) { + // No item equiped + if (!oldItem) + { if (shouldEquip) return ITEM_USAGE_EQUIP; - else { + else + { return ITEM_USAGE_BAD_EQUIP; } } @@ -216,10 +225,14 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto) } // Bigger quiver - if (itemProto->Class == ITEM_CLASS_QUIVER) { - if (!oldItem || oldItemProto->ContainerSlots < itemProto->ContainerSlots) { + if (itemProto->Class == ITEM_CLASS_QUIVER) + { + if (!oldItem || oldItemProto->ContainerSlots < itemProto->ContainerSlots) + { return ITEM_USAGE_EQUIP; - } else { + } + else + { return ITEM_USAGE_NONE; } } @@ -228,41 +241,45 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto) if (oldItemProto->Class == ITEM_CLASS_WEAPON && !sRandomItemMgr->CanEquipWeapon(bot->getClass(), oldItemProto)) existingShouldEquip = false; - if (oldItemProto->Class == ITEM_CLASS_ARMOR && !sRandomItemMgr->CanEquipArmor(bot->getClass(), bot->GetLevel(), oldItemProto)) + if (oldItemProto->Class == ITEM_CLASS_ARMOR && + !sRandomItemMgr->CanEquipArmor(bot->getClass(), bot->GetLevel(), oldItemProto)) existingShouldEquip = false; // uint32 oldItemPower = sRandomItemMgr->GetLiveStatWeight(bot, oldItemProto->ItemId); // uint32 newItemPower = sRandomItemMgr->GetLiveStatWeight(bot, itemProto->ItemId); - //Compare items based on item level, quality or itemId. + // Compare items based on item level, quality or itemId. bool isBetter = false; if (itemScore > oldScore) isBetter = true; // else if (newItemPower == oldScore && itemProto->Quality > oldItemProto->Quality) // isBetter = true; - // else if (newItemPower == oldScore && itemProto->Quality == oldItemProto->Quality && itemProto->ItemId > oldItemProto->ItemId) + // else if (newItemPower == oldScore && itemProto->Quality == oldItemProto->Quality && itemProto->ItemId > + // oldItemProto->ItemId) // isBetter = true; Item* item = CurrentItem(itemProto); - bool itemIsBroken = item && item->GetUInt32Value(ITEM_FIELD_DURABILITY) == 0 && item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0; - bool oldItemIsBroken = oldItem->GetUInt32Value(ITEM_FIELD_DURABILITY) == 0 && oldItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0; + bool itemIsBroken = + item && item->GetUInt32Value(ITEM_FIELD_DURABILITY) == 0 && item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0; + bool oldItemIsBroken = + oldItem->GetUInt32Value(ITEM_FIELD_DURABILITY) == 0 && oldItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0; if (itemProto->ItemId != oldItemProto->ItemId && (shouldEquip || !existingShouldEquip) && isBetter) { switch (itemProto->Class) { case ITEM_CLASS_ARMOR: - if (oldItemProto->SubClass <= itemProto->SubClass) - { - if (itemIsBroken && !oldItemIsBroken) - return ITEM_USAGE_BROKEN_EQUIP; - else if (shouldEquip) - return ITEM_USAGE_REPLACE; - else - return ITEM_USAGE_BAD_EQUIP; + if (oldItemProto->SubClass <= itemProto->SubClass) + { + if (itemIsBroken && !oldItemIsBroken) + return ITEM_USAGE_BROKEN_EQUIP; + else if (shouldEquip) + return ITEM_USAGE_REPLACE; + else + return ITEM_USAGE_BAD_EQUIP; - break; - } + break; + } default: { if (itemIsBroken && !oldItemIsBroken) @@ -282,7 +299,7 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto) return ITEM_USAGE_NONE; } -//Return smaltest bag size equipped +// Return smaltest bag size equipped uint32 ItemUsageValue::GetSmallestBagSize() { int8 curSlot = 0; @@ -318,7 +335,8 @@ bool ItemUsageValue::IsItemUsefulForQuest(Player* player, ItemTemplate const* pr if (quest->RequiredItemId[i] != proto->ItemId) continue; - if (GET_PLAYERBOT_AI(player) && AI_VALUE2(uint32, "item count", proto->Name1) >= quest->RequiredItemCount[i]) + if (GET_PLAYERBOT_AI(player) && + AI_VALUE2(uint32, "item count", proto->Name1) >= quest->RequiredItemCount[i]) continue; return true; @@ -332,29 +350,29 @@ bool ItemUsageValue::IsItemNeededForSkill(ItemTemplate const* proto) { switch (proto->ItemId) { - case 2901: //Mining pick + case 2901: // Mining pick return botAI->HasSkill(SKILL_MINING); - case 5956: //Blacksmith Hammer + case 5956: // Blacksmith Hammer return botAI->HasSkill(SKILL_BLACKSMITHING) || botAI->HasSkill(SKILL_ENGINEERING); - case 6219: //Arclight Spanner + case 6219: // Arclight Spanner return botAI->HasSkill(SKILL_ENGINEERING); - case 6218: // Runed copper rod + case 6218: // Runed copper rod return botAI->HasSkill(SKILL_ENCHANTING); - case 6339: // Runed silver rod + case 6339: // Runed silver rod return botAI->HasSkill(SKILL_ENCHANTING); - case 11130: // Runed golden rod + case 11130: // Runed golden rod return botAI->HasSkill(SKILL_ENCHANTING); - case 11145: // Runed truesilver rod + case 11145: // Runed truesilver rod return botAI->HasSkill(SKILL_ENCHANTING); - case 16207: //Runed Arcanite Rod + case 16207: // Runed Arcanite Rod return botAI->HasSkill(SKILL_ENCHANTING); - case 7005: //Skinning Knife + case 7005: // Skinning Knife return botAI->HasSkill(SKILL_SKINNING); - case 4471: //Flint and Tinder + case 4471: // Flint and Tinder return botAI->HasSkill(SKILL_COOKING); - case 4470: //Simple Wood + case 4470: // Simple Wood return botAI->HasSkill(SKILL_COOKING); - case 6256: //Fishing Rod + case 6256: // Fishing Rod return botAI->HasSkill(SKILL_FISHING); } @@ -390,12 +408,16 @@ bool ItemUsageValue::IsItemUsefulForSkill(ItemTemplate const* proto) return true; if (botAI->HasSkill(SKILL_JEWELCRAFTING) && RandomItemMgr::IsUsedBySkill(proto, SKILL_JEWELCRAFTING)) return true; - if (botAI->HasSkill(SKILL_MINING) && (RandomItemMgr::IsUsedBySkill(proto, SKILL_MINING) || RandomItemMgr::IsUsedBySkill(proto, SKILL_BLACKSMITHING) || - RandomItemMgr::IsUsedBySkill(proto, SKILL_JEWELCRAFTING) || RandomItemMgr::IsUsedBySkill(proto, SKILL_ENGINEERING))) + if (botAI->HasSkill(SKILL_MINING) && (RandomItemMgr::IsUsedBySkill(proto, SKILL_MINING) || + RandomItemMgr::IsUsedBySkill(proto, SKILL_BLACKSMITHING) || + RandomItemMgr::IsUsedBySkill(proto, SKILL_JEWELCRAFTING) || + RandomItemMgr::IsUsedBySkill(proto, SKILL_ENGINEERING))) return true; - if (botAI->HasSkill(SKILL_SKINNING) && (RandomItemMgr::IsUsedBySkill(proto, SKILL_SKINNING) || RandomItemMgr::IsUsedBySkill(proto, SKILL_LEATHERWORKING))) + if (botAI->HasSkill(SKILL_SKINNING) && (RandomItemMgr::IsUsedBySkill(proto, SKILL_SKINNING) || + RandomItemMgr::IsUsedBySkill(proto, SKILL_LEATHERWORKING))) return true; - if (botAI->HasSkill(SKILL_HERBALISM) && (RandomItemMgr::IsUsedBySkill(proto, SKILL_HERBALISM) || RandomItemMgr::IsUsedBySkill(proto, SKILL_ALCHEMY))) + if (botAI->HasSkill(SKILL_HERBALISM) && (RandomItemMgr::IsUsedBySkill(proto, SKILL_HERBALISM) || + RandomItemMgr::IsUsedBySkill(proto, SKILL_ALCHEMY))) return true; return false; @@ -451,7 +473,8 @@ bool ItemUsageValue::IsItemNeededForUsefullSpell(ItemTemplate const* proto, bool { ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", newItemId); - if (usage != ITEM_USAGE_REPLACE && usage != ITEM_USAGE_EQUIP && usage != ITEM_USAGE_AMMO && usage != ITEM_USAGE_QUEST && usage != ITEM_USAGE_SKILL && usage != ITEM_USAGE_USE) + if (usage != ITEM_USAGE_REPLACE && usage != ITEM_USAGE_EQUIP && usage != ITEM_USAGE_AMMO && + usage != ITEM_USAGE_QUEST && usage != ITEM_USAGE_SKILL && usage != ITEM_USAGE_USE) continue; return true; @@ -470,7 +493,9 @@ bool ItemUsageValue::HasItemsNeededForSpell(uint32 spellId, ItemTemplate const* for (uint8 i = 0; i < MAX_SPELL_REAGENTS; i++) if (spellInfo->ReagentCount[i] > 0 && spellInfo->Reagent[i]) { - if (proto && proto->ItemId == spellInfo->Reagent[i] && spellInfo->ReagentCount[i] == 1) //If we only need 1 item then current item does not need to be checked since we are looting/buying or already have it. + if (proto && proto->ItemId == spellInfo->Reagent[i] && + spellInfo->ReagentCount[i] == 1) // If we only need 1 item then current item does not need to be + // checked since we are looting/buying or already have it. continue; ItemTemplate const* reqProto = sObjectMgr->GetItemTemplate(spellInfo->Reagent[i]); @@ -601,7 +626,9 @@ bool ItemUsageValue::SpellGivesSkillUp(uint32 spellId, Player* bot) uint32 craft_skill_gain = sWorld->getIntConfig(CONFIG_SKILL_GAIN_CRAFTING); - if (SkillGainChance(SkillValue, skill->TrivialSkillLineRankHigh, (skill->TrivialSkillLineRankHigh + skill->TrivialSkillLineRankLow) / 2, skill->TrivialSkillLineRankLow) > 0) + if (SkillGainChance(SkillValue, skill->TrivialSkillLineRankHigh, + (skill->TrivialSkillLineRankHigh + skill->TrivialSkillLineRankLow) / 2, + skill->TrivialSkillLineRankLow) > 0) return true; } } diff --git a/src/strategy/values/ItemUsageValue.h b/src/strategy/values/ItemUsageValue.h index 6229567d..928b2b4a 100644 --- a/src/strategy/values/ItemUsageValue.h +++ b/src/strategy/values/ItemUsageValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ITEMUSAGEVALUE_H @@ -16,46 +17,48 @@ struct ItemTemplate; enum ItemUsage : uint32 { - ITEM_USAGE_NONE = 0, - ITEM_USAGE_EQUIP = 1, - ITEM_USAGE_REPLACE = 2, - ITEM_USAGE_BAD_EQUIP = 3, + ITEM_USAGE_NONE = 0, + ITEM_USAGE_EQUIP = 1, + ITEM_USAGE_REPLACE = 2, + ITEM_USAGE_BAD_EQUIP = 3, ITEM_USAGE_BROKEN_EQUIP = 4, - ITEM_USAGE_QUEST = 5, - ITEM_USAGE_SKILL = 6, - ITEM_USAGE_USE = 7, - ITEM_USAGE_GUILD_TASK = 8, - ITEM_USAGE_DISENCHANT = 9, - ITEM_USAGE_AH = 10, - ITEM_USAGE_KEEP = 11, - ITEM_USAGE_VENDOR = 12, - ITEM_USAGE_AMMO = 13 + ITEM_USAGE_QUEST = 5, + ITEM_USAGE_SKILL = 6, + ITEM_USAGE_USE = 7, + ITEM_USAGE_GUILD_TASK = 8, + ITEM_USAGE_DISENCHANT = 9, + ITEM_USAGE_AH = 10, + ITEM_USAGE_KEEP = 11, + ITEM_USAGE_VENDOR = 12, + ITEM_USAGE_AMMO = 13 }; class ItemUsageValue : public CalculatedValue, public Qualified { - public: - ItemUsageValue(PlayerbotAI* botAI, std::string const name = "item usage") : CalculatedValue(botAI, name) { } +public: + ItemUsageValue(PlayerbotAI* botAI, std::string const name = "item usage") : CalculatedValue(botAI, name) + { + } - ItemUsage Calculate() override; + ItemUsage Calculate() override; - private: - ItemUsage QueryItemUsageForEquip(ItemTemplate const* proto); - uint32 GetSmallestBagSize(); - bool IsItemUsefulForQuest(Player* player, ItemTemplate const* proto); - bool IsItemNeededForSkill(ItemTemplate const* proto); - bool IsItemUsefulForSkill(ItemTemplate const* proto); - bool IsItemNeededForUsefullSpell(ItemTemplate const* proto, bool checkAllReagents = false); - bool HasItemsNeededForSpell(uint32 spellId, ItemTemplate const* proto); - Item* CurrentItem(ItemTemplate const* proto); - float CurrentStacks(ItemTemplate const* proto); - float BetterStacks(ItemTemplate const* proto, std::string const usageType = ""); +private: + ItemUsage QueryItemUsageForEquip(ItemTemplate const* proto); + uint32 GetSmallestBagSize(); + bool IsItemUsefulForQuest(Player* player, ItemTemplate const* proto); + bool IsItemNeededForSkill(ItemTemplate const* proto); + bool IsItemUsefulForSkill(ItemTemplate const* proto); + bool IsItemNeededForUsefullSpell(ItemTemplate const* proto, bool checkAllReagents = false); + bool HasItemsNeededForSpell(uint32 spellId, ItemTemplate const* proto); + Item* CurrentItem(ItemTemplate const* proto); + float CurrentStacks(ItemTemplate const* proto); + float BetterStacks(ItemTemplate const* proto, std::string const usageType = ""); - public: - static std::vector SpellsUsingItem(uint32 itemId, Player* bot); - static bool SpellGivesSkillUp(uint32 spellId, Player* bot); +public: + static std::vector SpellsUsingItem(uint32 itemId, Player* bot); + static bool SpellGivesSkillUp(uint32 spellId, Player* bot); - static std::string const GetConsumableType(ItemTemplate const* proto, bool hasMana); + static std::string const GetConsumableType(ItemTemplate const* proto, bool hasMana); }; #endif diff --git a/src/strategy/values/LastMovementValue.cpp b/src/strategy/values/LastMovementValue.cpp index 2b8531d1..767bc89e 100644 --- a/src/strategy/values/LastMovementValue.cpp +++ b/src/strategy/values/LastMovementValue.cpp @@ -1,17 +1,24 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LastMovementValue.h" + #include "Playerbots.h" -LastMovement::LastMovement() -{ - clear(); -} +LastMovement::LastMovement() { clear(); } -LastMovement::LastMovement(LastMovement& other) : taxiNodes(other.taxiNodes), taxiMaster(other.taxiMaster), lastFollow(other.lastFollow), lastAreaTrigger(other.lastAreaTrigger), -lastMoveToX(other.lastMoveToX), lastMoveToY(other.lastMoveToY), lastMoveToZ(other.lastMoveToZ), lastMoveToOri(other.lastMoveToOri), lastFlee(other.lastFlee) +LastMovement::LastMovement(LastMovement& other) + : taxiNodes(other.taxiNodes), + taxiMaster(other.taxiMaster), + lastFollow(other.lastFollow), + lastAreaTrigger(other.lastAreaTrigger), + lastMoveToX(other.lastMoveToX), + lastMoveToY(other.lastMoveToY), + lastMoveToZ(other.lastMoveToZ), + lastMoveToOri(other.lastMoveToOri), + lastFlee(other.lastFlee) { lastMoveShort = other.lastMoveShort; nextTeleport = other.nextTeleport; @@ -54,10 +61,8 @@ void LastMovement::Set(uint32 mapId, float x, float y, float z, float ori) void LastMovement::setShort(WorldPosition point) { - lastMoveShort = point; lastFollow = nullptr; + lastMoveShort = point; + lastFollow = nullptr; } -void LastMovement::setPath(TravelPath path) -{ - lastPath = path; -} +void LastMovement::setPath(TravelPath path) { lastPath = path; } diff --git a/src/strategy/values/LastMovementValue.h b/src/strategy/values/LastMovementValue.h index 15f39608..89277014 100644 --- a/src/strategy/values/LastMovementValue.h +++ b/src/strategy/values/LastMovementValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LASTMOVEMENTVALUE_H @@ -14,60 +15,60 @@ class Unit; class LastMovement { - public: - LastMovement(); - LastMovement(LastMovement& other); +public: + LastMovement(); + LastMovement(LastMovement& other); - LastMovement& operator=(LastMovement const& other) - { - taxiNodes = other.taxiNodes; - taxiMaster = other.taxiMaster; - lastFollow = other.lastFollow; - lastAreaTrigger = other.lastAreaTrigger; - lastMoveShort = other.lastMoveShort; - lastPath = other.lastPath; - nextTeleport = other.nextTeleport; + LastMovement& operator=(LastMovement const& other) + { + taxiNodes = other.taxiNodes; + taxiMaster = other.taxiMaster; + lastFollow = other.lastFollow; + lastAreaTrigger = other.lastAreaTrigger; + lastMoveShort = other.lastMoveShort; + lastPath = other.lastPath; + nextTeleport = other.nextTeleport; - return *this; - }; + return *this; + }; - void clear(); + void clear(); - void Set(Unit* follow); - void Set(uint32 mapId, float x, float y, float z, float ori); + void Set(Unit* follow); + void Set(uint32 mapId, float x, float y, float z, float ori); - void setShort(WorldPosition point); - void setPath(TravelPath path); + void setShort(WorldPosition point); + void setPath(TravelPath path); - std::vector taxiNodes; - ObjectGuid taxiMaster; - Unit* lastFollow; - uint32 lastAreaTrigger; - time_t lastFlee; - uint32 lastMoveToMapId; - float lastMoveToX; - float lastMoveToY; - float lastMoveToZ; - float lastMoveToOri; - WorldPosition lastMoveShort; - TravelPath lastPath; - time_t nextTeleport; - std::future future; + std::vector taxiNodes; + ObjectGuid taxiMaster; + Unit* lastFollow; + uint32 lastAreaTrigger; + time_t lastFlee; + uint32 lastMoveToMapId; + float lastMoveToX; + float lastMoveToY; + float lastMoveToZ; + float lastMoveToOri; + WorldPosition lastMoveShort; + TravelPath lastPath; + time_t nextTeleport; + std::future future; }; class LastMovementValue : public ManualSetValue { - public: - LastMovementValue(PlayerbotAI* botAI) : ManualSetValue(botAI, data) { } +public: + LastMovementValue(PlayerbotAI* botAI) : ManualSetValue(botAI, data) {} - private: - LastMovement data = LastMovement(); +private: + LastMovement data = LastMovement(); }; class StayTimeValue : public ManualSetValue { - public: - StayTimeValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0) { } +public: + StayTimeValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0) {} }; #endif diff --git a/src/strategy/values/LastSaidValue.h b/src/strategy/values/LastSaidValue.h index e4355be9..6e498a96 100644 --- a/src/strategy/values/LastSaidValue.h +++ b/src/strategy/values/LastSaidValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LASTSAIDVALUE_H @@ -12,14 +13,14 @@ class PlayerbotAI; class LastSaidValue : public ManualSetValue, public Qualified { - public: - LastSaidValue(PlayerbotAI* botAI) : ManualSetValue(botAI, time(nullptr) - 120, "last said") { } +public: + LastSaidValue(PlayerbotAI* botAI) : ManualSetValue(botAI, time(nullptr) - 120, "last said") {} }; class LastEmoteValue : public ManualSetValue, public Qualified { - public: - LastEmoteValue(PlayerbotAI* botAI) : ManualSetValue(botAI, time(nullptr) - 120, "last emote") { } +public: + LastEmoteValue(PlayerbotAI* botAI) : ManualSetValue(botAI, time(nullptr) - 120, "last emote") {} }; #endif diff --git a/src/strategy/values/LastSpellCastTimeValue.h b/src/strategy/values/LastSpellCastTimeValue.h index fd3babc4..86cf1aba 100644 --- a/src/strategy/values/LastSpellCastTimeValue.h +++ b/src/strategy/values/LastSpellCastTimeValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LASTSPELLCASTTIMEVALUE_H @@ -12,8 +13,8 @@ class PlayerbotAI; class LastSpellCastTimeValue : public ManualSetValue, public Qualified { - public: - LastSpellCastTimeValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0), Qualified() { } +public: + LastSpellCastTimeValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0), Qualified() {} }; #endif diff --git a/src/strategy/values/LastSpellCastValue.cpp b/src/strategy/values/LastSpellCastValue.cpp index ae6f2804..5c8914c4 100644 --- a/src/strategy/values/LastSpellCastValue.cpp +++ b/src/strategy/values/LastSpellCastValue.cpp @@ -1,19 +1,19 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LastSpellCastValue.h" + #include "Playerbots.h" -LastSpellCast::LastSpellCast() : id(0), timer(0) -{ -} +LastSpellCast::LastSpellCast() : id(0), timer(0) {} void LastSpellCast::Set(uint32 newId, ObjectGuid newTarget, time_t newTime) { id = newId; target = newTarget; - timer = newTime; + timer = newTime; } void LastSpellCast::Reset() diff --git a/src/strategy/values/LastSpellCastValue.h b/src/strategy/values/LastSpellCastValue.h index 98880af8..ecfda769 100644 --- a/src/strategy/values/LastSpellCastValue.h +++ b/src/strategy/values/LastSpellCastValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LASTSPELLCASTVALUE_H @@ -11,24 +12,27 @@ class PlayerbotAI; class LastSpellCast { - public: - LastSpellCast(); +public: + LastSpellCast(); - void Set(uint32 id, ObjectGuid target, time_t time); - void Reset(); + void Set(uint32 id, ObjectGuid target, time_t time); + void Reset(); - uint32 id; - ObjectGuid target; - time_t timer; + uint32 id; + ObjectGuid target; + time_t timer; }; class LastSpellCastValue : public ManualSetValue { - public: - LastSpellCastValue(PlayerbotAI* botAI, std::string const name = "last spell cast") : ManualSetValue(botAI, data, name) { } +public: + LastSpellCastValue(PlayerbotAI* botAI, std::string const name = "last spell cast") + : ManualSetValue(botAI, data, name) + { + } - private: - LastSpellCast data; +private: + LastSpellCast data; }; #endif diff --git a/src/strategy/values/LeastHpTargetValue.cpp b/src/strategy/values/LeastHpTargetValue.cpp index 9b44f2a3..36f9b7eb 100644 --- a/src/strategy/values/LeastHpTargetValue.cpp +++ b/src/strategy/values/LeastHpTargetValue.cpp @@ -1,28 +1,30 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LeastHpTargetValue.h" + #include "AttackersValue.h" #include "Playerbots.h" class FindLeastHpTargetStrategy : public FindNonCcTargetStrategy { - public: - FindLeastHpTargetStrategy(PlayerbotAI* botAI) : FindNonCcTargetStrategy(botAI), minHealth(0) { } +public: + FindLeastHpTargetStrategy(PlayerbotAI* botAI) : FindNonCcTargetStrategy(botAI), minHealth(0) {} - void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override - { - Player* bot = botAI->GetBot(); - if (IsCcTarget(attacker)) - return; + void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + { + Player* bot = botAI->GetBot(); + if (IsCcTarget(attacker)) + return; - if (!result || result->GetHealth() > attacker->GetHealth()) - result = attacker; - } + if (!result || result->GetHealth() > attacker->GetHealth()) + result = attacker; + } - protected: - float minHealth; +protected: + float minHealth; }; Unit* LeastHpTargetValue::Calculate() diff --git a/src/strategy/values/LeastHpTargetValue.h b/src/strategy/values/LeastHpTargetValue.h index eed1a3cd..ba3fdaf7 100644 --- a/src/strategy/values/LeastHpTargetValue.h +++ b/src/strategy/values/LeastHpTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LEASTHPTARGETVALUE_H @@ -12,10 +13,10 @@ class Unit; class LeastHpTargetValue : public TargetValue { - public: - LeastHpTargetValue(PlayerbotAI* botAI, std::string const name = "least hp target") : TargetValue(botAI, name) { } +public: + LeastHpTargetValue(PlayerbotAI* botAI, std::string const name = "least hp target") : TargetValue(botAI, name) {} - Unit* Calculate() override; + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/LfgValues.h b/src/strategy/values/LfgValues.h index 558485e8..c387ddca 100644 --- a/src/strategy/values/LfgValues.h +++ b/src/strategy/values/LfgValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LFGVALUES_H @@ -11,8 +12,8 @@ class PlayerbotAI; class LfgProposalValue : public ManualSetValue { - public: - LfgProposalValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0, "lfg proposal") { } +public: + LfgProposalValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0, "lfg proposal") {} }; #endif diff --git a/src/strategy/values/LineTargetValue.cpp b/src/strategy/values/LineTargetValue.cpp index c98d91ec..06055998 100644 --- a/src/strategy/values/LineTargetValue.cpp +++ b/src/strategy/values/LineTargetValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LineTargetValue.h" + #include "Playerbots.h" Unit* LineTargetValue::Calculate() @@ -15,11 +17,11 @@ Unit* LineTargetValue::Calculate() if (!group) return nullptr; - Player *prev = master; + Player* prev = master; Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) { - Player *player = ObjectAccessor::FindPlayer(itr->guid); + Player* player = ObjectAccessor::FindPlayer(itr->guid); if (!player || !player->IsAlive() || player == master) continue; @@ -31,4 +33,3 @@ Unit* LineTargetValue::Calculate() return master; } - diff --git a/src/strategy/values/LineTargetValue.h b/src/strategy/values/LineTargetValue.h index 5681a2c4..2f10ffb0 100644 --- a/src/strategy/values/LineTargetValue.h +++ b/src/strategy/values/LineTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LINETARGETVALUE_H @@ -12,10 +13,10 @@ class Unit; class LineTargetValue : public UnitCalculatedValue { - public: - LineTargetValue(PlayerbotAI* botAI, std::string const name = "line target") : UnitCalculatedValue(botAI, name) { } +public: + LineTargetValue(PlayerbotAI* botAI, std::string const name = "line target") : UnitCalculatedValue(botAI, name) {} - Unit* Calculate() override; + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/LogLevelValue.h b/src/strategy/values/LogLevelValue.h index bd135c4f..2abe016d 100644 --- a/src/strategy/values/LogLevelValue.h +++ b/src/strategy/values/LogLevelValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LOGLEVELVALUE_H @@ -11,8 +12,11 @@ class PlayerbotAI; class LogLevelValue : public ManualSetValue { - public: - LogLevelValue(PlayerbotAI* botAI, std::string const name = "log level") : ManualSetValue(botAI, LOG_LEVEL_DEBUG, name) { } +public: + LogLevelValue(PlayerbotAI* botAI, std::string const name = "log level") + : ManualSetValue(botAI, LOG_LEVEL_DEBUG, name) + { + } }; #endif diff --git a/src/strategy/values/LootStrategyValue.cpp b/src/strategy/values/LootStrategyValue.cpp index 87dfc089..6d98efb2 100644 --- a/src/strategy/values/LootStrategyValue.cpp +++ b/src/strategy/values/LootStrategyValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LootStrategyValue.h" + #include "AiObjectContext.h" #include "ItemUsageValue.h" #include "LootObjectStack.h" @@ -10,62 +12,48 @@ class NormalLootStrategy : public LootStrategy { - public: - bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override - { - std::ostringstream out; - out << proto->ItemId; - ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", out.str()); - return usage != ITEM_USAGE_NONE; - } +public: + bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override + { + std::ostringstream out; + out << proto->ItemId; + ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", out.str()); + return usage != ITEM_USAGE_NONE; + } - std::string const GetName() override - { - return "normal"; - } + std::string const GetName() override { return "normal"; } }; class GrayLootStrategy : public NormalLootStrategy { - public: - bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override - { - return NormalLootStrategy::CanLoot(proto, context) || proto->Quality == ITEM_QUALITY_POOR; - } +public: + bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override + { + return NormalLootStrategy::CanLoot(proto, context) || proto->Quality == ITEM_QUALITY_POOR; + } - std::string const GetName() override - { - return "gray"; - } + std::string const GetName() override { return "gray"; } }; class DisenchantLootStrategy : public NormalLootStrategy { - public: - bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override - { - return NormalLootStrategy::CanLoot(proto, context) || (proto->Quality >= ITEM_QUALITY_UNCOMMON && proto->Bonding != BIND_WHEN_PICKED_UP && - (proto->Class == ITEM_CLASS_ARMOR || proto->Class == ITEM_CLASS_WEAPON)); - } +public: + bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override + { + return NormalLootStrategy::CanLoot(proto, context) || + (proto->Quality >= ITEM_QUALITY_UNCOMMON && proto->Bonding != BIND_WHEN_PICKED_UP && + (proto->Class == ITEM_CLASS_ARMOR || proto->Class == ITEM_CLASS_WEAPON)); + } - std::string const GetName() override - { - return "disenchant"; - } + std::string const GetName() override { return "disenchant"; } }; class AllLootStrategy : public LootStrategy { - public: - bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override - { - return true; - } +public: + bool CanLoot(ItemTemplate const* proto, AiObjectContext* context) override { return true; } - std::string const GetName() override - { - return "all"; - } + std::string const GetName() override { return "all"; } }; LootStrategyValue::~LootStrategyValue() @@ -92,10 +80,7 @@ LootStrategy* LootStrategyValue::instance(std::string const strategy) return normal; } -std::string const LootStrategyValue::Save() -{ - return value ? value->GetName() : "?"; -} +std::string const LootStrategyValue::Save() { return value ? value->GetName() : "?"; } bool LootStrategyValue::Load(std::string const text) { diff --git a/src/strategy/values/LootStrategyValue.h b/src/strategy/values/LootStrategyValue.h index 93ae94b1..aeb7ce38 100644 --- a/src/strategy/values/LootStrategyValue.h +++ b/src/strategy/values/LootStrategyValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LOOTSTRATEGYVALUE_H @@ -12,18 +13,21 @@ class PlayerbotAI; class LootStrategyValue : public ManualSetValue { - public: - LootStrategyValue(PlayerbotAI* botAI, std::string const name = "loot strategy") : ManualSetValue(botAI, normal, name) { } - virtual ~LootStrategyValue(); +public: + LootStrategyValue(PlayerbotAI* botAI, std::string const name = "loot strategy") + : ManualSetValue(botAI, normal, name) + { + } + virtual ~LootStrategyValue(); - std::string const Save() override; - bool Load(std::string const value) override; + std::string const Save() override; + bool Load(std::string const value) override; - static LootStrategy* normal; - static LootStrategy* gray; - static LootStrategy* all; - static LootStrategy* disenchant; - static LootStrategy* instance(std::string const name); + static LootStrategy* normal; + static LootStrategy* gray; + static LootStrategy* all; + static LootStrategy* disenchant; + static LootStrategy* instance(std::string const name); }; #endif diff --git a/src/strategy/values/LootValues.cpp b/src/strategy/values/LootValues.cpp index b744b10f..abf5a0a3 100644 --- a/src/strategy/values/LootValues.cpp +++ b/src/strategy/values/LootValues.cpp @@ -1,67 +1,69 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "LootValues.h" -#include "SharedValueContext.h" + #include "Playerbots.h" +#include "SharedValueContext.h" LootTemplateAccess const* DropMapValue::GetLootTemplate(ObjectGuid guid, LootType type) { - LootTemplate const* lTemplate = nullptr; + LootTemplate const* lTemplate = nullptr; - if (guid.IsCreature()) - { - CreatureTemplate const* info = sObjectMgr->GetCreatureTemplate(guid.GetEntry()); + if (guid.IsCreature()) + { + CreatureTemplate const* info = sObjectMgr->GetCreatureTemplate(guid.GetEntry()); - if (info) - { - if (type == LOOT_CORPSE) - lTemplate = LootTemplates_Creature.GetLootFor(info->lootid); - else if (type == LOOT_PICKPOCKETING && info->pickpocketLootId) - lTemplate = LootTemplates_Pickpocketing.GetLootFor(info->pickpocketLootId); - else if (type == LOOT_SKINNING && info->SkinLootId) - lTemplate = LootTemplates_Skinning.GetLootFor(info->SkinLootId); - } - } - else if (guid.IsGameObject()) - { - GameObjectTemplate const* info = sObjectMgr->GetGameObjectTemplate(guid.GetEntry()); - if (info && info->GetLootId() != 0) - { - if (type == LOOT_CORPSE) - lTemplate = LootTemplates_Gameobject.GetLootFor(info->GetLootId()); - else if (type == LOOT_FISHINGHOLE) - lTemplate = LootTemplates_Fishing.GetLootFor(info->GetLootId()); - } - } - else if (guid.IsItem()) - { - ItemTemplate const* proto = sObjectMgr->GetItemTemplate(guid.GetEntry()); + if (info) + { + if (type == LOOT_CORPSE) + lTemplate = LootTemplates_Creature.GetLootFor(info->lootid); + else if (type == LOOT_PICKPOCKETING && info->pickpocketLootId) + lTemplate = LootTemplates_Pickpocketing.GetLootFor(info->pickpocketLootId); + else if (type == LOOT_SKINNING && info->SkinLootId) + lTemplate = LootTemplates_Skinning.GetLootFor(info->SkinLootId); + } + } + else if (guid.IsGameObject()) + { + GameObjectTemplate const* info = sObjectMgr->GetGameObjectTemplate(guid.GetEntry()); + if (info && info->GetLootId() != 0) + { + if (type == LOOT_CORPSE) + lTemplate = LootTemplates_Gameobject.GetLootFor(info->GetLootId()); + else if (type == LOOT_FISHINGHOLE) + lTemplate = LootTemplates_Fishing.GetLootFor(info->GetLootId()); + } + } + else if (guid.IsItem()) + { + ItemTemplate const* proto = sObjectMgr->GetItemTemplate(guid.GetEntry()); - if (proto) - { - if (type == LOOT_CORPSE) - lTemplate = LootTemplates_Item.GetLootFor(proto->ItemId); - else if (type == LOOT_DISENCHANTING && proto->DisenchantID) - lTemplate = LootTemplates_Disenchant.GetLootFor(proto->DisenchantID); - if (type == LOOT_MILLING) - lTemplate = LootTemplates_Milling.GetLootFor(proto->ItemId); - if (type == LOOT_PROSPECTING) - lTemplate = LootTemplates_Prospecting.GetLootFor(proto->ItemId); - } - } + if (proto) + { + if (type == LOOT_CORPSE) + lTemplate = LootTemplates_Item.GetLootFor(proto->ItemId); + else if (type == LOOT_DISENCHANTING && proto->DisenchantID) + lTemplate = LootTemplates_Disenchant.GetLootFor(proto->DisenchantID); + if (type == LOOT_MILLING) + lTemplate = LootTemplates_Milling.GetLootFor(proto->ItemId); + if (type == LOOT_PROSPECTING) + lTemplate = LootTemplates_Prospecting.GetLootFor(proto->ItemId); + } + } - LootTemplateAccess const* lTemplateA = reinterpret_cast(lTemplate); + LootTemplateAccess const* lTemplateA = reinterpret_cast(lTemplate); - return lTemplateA; + return lTemplateA; } DropMap* DropMapValue::Calculate() { - DropMap* dropMap = new DropMap; + DropMap* dropMap = new DropMap; - int32 sEntry = 0; + int32 sEntry = 0; if (CreatureTemplateContainer const* creatures = sObjectMgr->GetCreatureTemplates()) { @@ -69,75 +71,78 @@ DropMap* DropMapValue::Calculate() { sEntry = itr->first; - if (LootTemplateAccess const* lTemplateA = GetLootTemplate(ObjectGuid::Create(sEntry, uint32(1)), LOOT_CORPSE)) + if (LootTemplateAccess const* lTemplateA = + GetLootTemplate(ObjectGuid::Create(sEntry, uint32(1)), LOOT_CORPSE)) for (auto const& lItem : lTemplateA->Entries) dropMap->insert(std::make_pair(lItem->itemid, sEntry)); } } - if (GameObjectTemplateContainer const* gameobjects = sObjectMgr->GetGameObjectTemplates()) + if (GameObjectTemplateContainer const* gameobjects = sObjectMgr->GetGameObjectTemplates()) { for (auto const& itr : *gameobjects) { sEntry = itr.first; - if (LootTemplateAccess const* lTemplateA = GetLootTemplate(ObjectGuid::Create(sEntry, uint32(1)), LOOT_CORPSE)) + if (LootTemplateAccess const* lTemplateA = + GetLootTemplate(ObjectGuid::Create(sEntry, uint32(1)), LOOT_CORPSE)) for (auto const& lItem : lTemplateA->Entries) dropMap->insert(std::make_pair(lItem->itemid, -sEntry)); } } - return dropMap; + return dropMap; } -//What items does this entry have in its loot list? +// What items does this entry have in its loot list? std::vector ItemDropListValue::Calculate() { - uint32 itemId = stoi(getQualifier()); + uint32 itemId = stoi(getQualifier()); - DropMap* dropMap = GAI_VALUE(DropMap*, "drop map"); + DropMap* dropMap = GAI_VALUE(DropMap*, "drop map"); - std::vector entries; + std::vector entries; - auto range = dropMap->equal_range(itemId); + auto range = dropMap->equal_range(itemId); - for (auto itr = range.first; itr != range.second; ++itr) - entries.push_back(itr->second); + for (auto itr = range.first; itr != range.second; ++itr) + entries.push_back(itr->second); - return entries; + return entries; } -//What items does this entry have in its loot list? +// What items does this entry have in its loot list? std::vector EntryLootListValue::Calculate() { - int32 entry = stoi(getQualifier()); + int32 entry = stoi(getQualifier()); - std::vector items; + std::vector items; - LootTemplateAccess const* lTemplateA; + LootTemplateAccess const* lTemplateA; - if (entry > 0) - lTemplateA = DropMapValue::GetLootTemplate(ObjectGuid::Create(entry, uint32(1)), LOOT_CORPSE); - else - lTemplateA = DropMapValue::GetLootTemplate(ObjectGuid::Create(entry, uint32(1)), LOOT_CORPSE); + if (entry > 0) + lTemplateA = DropMapValue::GetLootTemplate(ObjectGuid::Create(entry, uint32(1)), LOOT_CORPSE); + else + lTemplateA = + DropMapValue::GetLootTemplate(ObjectGuid::Create(entry, uint32(1)), LOOT_CORPSE); - if (lTemplateA) - for (auto const& lItem : lTemplateA->Entries) - items.push_back(lItem->itemid); + if (lTemplateA) + for (auto const& lItem : lTemplateA->Entries) + items.push_back(lItem->itemid); - return items; + return items; } itemUsageMap EntryLootUsageValue::Calculate() { - itemUsageMap items; + itemUsageMap items; - for (auto itemId : GAI_VALUE2(std::vector, "entry loot list", getQualifier())) - { - items[AI_VALUE2(ItemUsage, "item usage", itemId)].push_back(itemId); - } + for (auto itemId : GAI_VALUE2(std::vector, "entry loot list", getQualifier())) + { + items[AI_VALUE2(ItemUsage, "item usage", itemId)].push_back(itemId); + } - return items; + return items; }; bool HasUpgradeValue::Calculate() diff --git a/src/strategy/values/LootValues.h b/src/strategy/values/LootValues.h index a1215f8a..cec3599b 100644 --- a/src/strategy/values/LootValues.h +++ b/src/strategy/values/LootValues.h @@ -1,75 +1,76 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_LOOTVALUES_H #define _PLAYERBOT_LOOTVALUES_H +#include "ItemUsageValue.h" #include "LootMgr.h" #include "NamedObjectContext.h" -#include "ItemUsageValue.h" #include "Value.h" class PlayerbotAI; -//Cheat class copy to hack into the loot system +// Cheat class copy to hack into the loot system class LootTemplateAccess { - public: - class LootGroup; // A set of loot definitions for items (refs are not allowed inside) - typedef std::vector LootGroups; - LootStoreItemList Entries; // not grouped only - LootGroups Groups; // groups have own (optimized) processing, grouped entries go there +public: + class LootGroup; // A set of loot definitions for items (refs are not allowed inside) + typedef std::vector LootGroups; + LootStoreItemList Entries; // not grouped only + LootGroups Groups; // groups have own (optimized) processing, grouped entries go there }; // itemId, entry typedef std::unordered_map DropMap; -//Returns the loot map of all entries +// Returns the loot map of all entries class DropMapValue : public SingleCalculatedValue { - public: - DropMapValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "drop map") { } +public: + DropMapValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "drop map") {} - static LootTemplateAccess const* GetLootTemplate(ObjectGuid guid, LootType type = LOOT_CORPSE); + static LootTemplateAccess const* GetLootTemplate(ObjectGuid guid, LootType type = LOOT_CORPSE); - DropMap* Calculate() override; + DropMap* Calculate() override; }; -//Returns the entries that drop a specific item +// Returns the entries that drop a specific item class ItemDropListValue : public SingleCalculatedValue>, public Qualified { - public: - ItemDropListValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "item drop list") { } +public: + ItemDropListValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "item drop list") {} - std::vector Calculate() override; + std::vector Calculate() override; }; -//Returns the items a specific entry can drop +// Returns the items a specific entry can drop class EntryLootListValue : public SingleCalculatedValue>, public Qualified { - public: - EntryLootListValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "entry loot list") { } +public: + EntryLootListValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "entry loot list") {} - std::vector Calculate() override; + std::vector Calculate() override; }; typedef std::unordered_map> itemUsageMap; class EntryLootUsageValue : public CalculatedValue, public Qualified { - public: - EntryLootUsageValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "entry loot usage", 2 * 1000) { } +public: + EntryLootUsageValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "entry loot usage", 2 * 1000) {} - itemUsageMap Calculate() override; + itemUsageMap Calculate() override; }; class HasUpgradeValue : public BoolCalculatedValue, public Qualified { - public: - HasUpgradeValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "has upgrade", 2 * 1000) { } +public: + HasUpgradeValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "has upgrade", 2 * 1000) {} - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/MaintenanceValues.cpp b/src/strategy/values/MaintenanceValues.cpp index 93893e6c..2693dbb7 100644 --- a/src/strategy/values/MaintenanceValues.cpp +++ b/src/strategy/values/MaintenanceValues.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "MaintenanceValues.h" + #include "BudgetValues.h" #include "ItemUsageValue.h" #include "Playerbots.h" @@ -24,43 +26,35 @@ bool CanMoveAroundValue::Calculate() return true; } -bool ShouldHomeBindValue::Calculate() -{ - return AI_VALUE2(float, "distance", "home bind") > 1000.0f; -} +bool ShouldHomeBindValue::Calculate() { return AI_VALUE2(float, "distance", "home bind") > 1000.0f; } -bool ShouldRepairValue::Calculate() -{ - return AI_VALUE(uint8, "durability") < 80; -} +bool ShouldRepairValue::Calculate() { return AI_VALUE(uint8, "durability") < 80; } bool CanRepairValue::Calculate() { - return AI_VALUE(uint8, "durability") < 100 && AI_VALUE(uint32, "repair cost") < AI_VALUE2(uint32, "free money for", (uint32) NeedMoneyFor::repair); + return AI_VALUE(uint8, "durability") < 100 && + AI_VALUE(uint32, "repair cost") < AI_VALUE2(uint32, "free money for", (uint32)NeedMoneyFor::repair); } -bool ShouldSellValue::Calculate() -{ - return AI_VALUE(uint8, "bag space") > 80; -} +bool ShouldSellValue::Calculate() { return AI_VALUE(uint8, "bag space") > 80; } bool CanSellValue::Calculate() { - return (AI_VALUE2(uint32, "item count", "usage " + std::to_string(ITEM_USAGE_VENDOR)) + AI_VALUE2(uint32, "item count", "usage " + std::to_string(ITEM_USAGE_AH))) > 1; + return (AI_VALUE2(uint32, "item count", "usage " + std::to_string(ITEM_USAGE_VENDOR)) + + AI_VALUE2(uint32, "item count", "usage " + std::to_string(ITEM_USAGE_AH))) > 1; } -bool CanFightEqualValue::Calculate() -{ - return AI_VALUE(uint8, "durability") > 20; -} +bool CanFightEqualValue::Calculate() { return AI_VALUE(uint8, "durability") > 20; } bool CanFightEliteValue::Calculate() { - return bot->GetGroup() && AI_VALUE2(bool, "group and", "can fight equal") && AI_VALUE2(bool, "group and", "following party") && !AI_VALUE2(bool, "group or", "should sell,can sell"); + return bot->GetGroup() && AI_VALUE2(bool, "group and", "can fight equal") && + AI_VALUE2(bool, "group and", "following party") && !AI_VALUE2(bool, "group or", "should sell,can sell"); } bool CanFightBossValue::Calculate() { - return bot->GetGroup() && bot->GetGroup()->GetMembersCount() > 3 && AI_VALUE2(bool, "group and", "can fight equal") && AI_VALUE2(bool, "group and", "following party") && !AI_VALUE2(bool, "group or", "should sell,can sell"); + return bot->GetGroup() && bot->GetGroup()->GetMembersCount() > 3 && + AI_VALUE2(bool, "group and", "can fight equal") && AI_VALUE2(bool, "group and", "following party") && + !AI_VALUE2(bool, "group or", "should sell,can sell"); } - diff --git a/src/strategy/values/MaintenanceValues.h b/src/strategy/values/MaintenanceValues.h index 57913a7e..0c552fde 100644 --- a/src/strategy/values/MaintenanceValues.h +++ b/src/strategy/values/MaintenanceValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MAINTANCEVALUE_H @@ -11,74 +12,74 @@ class PlayerbotAI; class CanMoveAroundValue : public BoolCalculatedValue { - public: - CanMoveAroundValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can move around", 2 * 2000) { } +public: + CanMoveAroundValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can move around", 2 * 2000) {} - bool Calculate() override; + bool Calculate() override; }; class ShouldHomeBindValue : public BoolCalculatedValue { - public: - ShouldHomeBindValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should home bind", 2 * 2000) { } +public: + ShouldHomeBindValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should home bind", 2 * 2000) {} - bool Calculate() override; + bool Calculate() override; }; class ShouldRepairValue : public BoolCalculatedValue { - public: - ShouldRepairValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI,"should repair",2 * 2000) { } +public: + ShouldRepairValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should repair", 2 * 2000) {} - bool Calculate() override; + bool Calculate() override; }; class CanRepairValue : public BoolCalculatedValue { - public: - CanRepairValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can repair",2 * 2000) { } +public: + CanRepairValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can repair", 2 * 2000) {} - bool Calculate() override; + bool Calculate() override; }; class ShouldSellValue : public BoolCalculatedValue { - public: - ShouldSellValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should sell",2 * 2000) { } +public: + ShouldSellValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "should sell", 2 * 2000) {} - bool Calculate() override; + bool Calculate() override; }; class CanSellValue : public BoolCalculatedValue { - public: - CanSellValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can sell",2 * 2000) { } +public: + CanSellValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can sell", 2 * 2000) {} - bool Calculate() override; + bool Calculate() override; }; -class CanFightEqualValue: public BoolCalculatedValue +class CanFightEqualValue : public BoolCalculatedValue { - public: - CanFightEqualValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can fight equal",2 * 2000) { } +public: + CanFightEqualValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can fight equal", 2 * 2000) {} - bool Calculate() override; + bool Calculate() override; }; class CanFightEliteValue : public BoolCalculatedValue { - public: - CanFightEliteValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can fight elite") { } +public: + CanFightEliteValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can fight elite") {} - bool Calculate() override; + bool Calculate() override; }; class CanFightBossValue : public BoolCalculatedValue { - public: - CanFightBossValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can fight boss") { } +public: + CanFightBossValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can fight boss") {} - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/ManaSaveLevelValue.h b/src/strategy/values/ManaSaveLevelValue.h index 1f2e8b64..ced8bddc 100644 --- a/src/strategy/values/ManaSaveLevelValue.h +++ b/src/strategy/values/ManaSaveLevelValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MANASAVELEVELVALUE_H @@ -11,21 +12,21 @@ class PlayerbotAI; class ManaSaveLevelValue : public ManualSetValue { - public: - ManaSaveLevelValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 1.0, "mana save level") { } +public: + ManaSaveLevelValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 1.0, "mana save level") {} - std::string const Save() - { - std::ostringstream out; - out << value; - return out.str(); - } + std::string const Save() + { + std::ostringstream out; + out << value; + return out.str(); + } - bool Load(std::string const text) - { - value = atof(text.c_str()); - return true; - } + bool Load(std::string const text) + { + value = atof(text.c_str()); + return true; + } }; #endif diff --git a/src/strategy/values/MasterTargetValue.cpp b/src/strategy/values/MasterTargetValue.cpp index 29a7c7d5..a2241022 100644 --- a/src/strategy/values/MasterTargetValue.cpp +++ b/src/strategy/values/MasterTargetValue.cpp @@ -1,11 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "MasterTargetValue.h" + #include "Playerbots.h" -Unit* MasterTargetValue::Calculate() -{ - return botAI->GetGroupMaster(); -} +Unit* MasterTargetValue::Calculate() { return botAI->GetGroupMaster(); } diff --git a/src/strategy/values/MasterTargetValue.h b/src/strategy/values/MasterTargetValue.h index d41a0695..512db8fa 100644 --- a/src/strategy/values/MasterTargetValue.h +++ b/src/strategy/values/MasterTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_MASTERTARGETVALUE_H @@ -12,10 +13,12 @@ class Unit; class MasterTargetValue : public UnitCalculatedValue { - public: - MasterTargetValue(PlayerbotAI* botAI, std::string const name = "master target") : UnitCalculatedValue(botAI, name) { } +public: + MasterTargetValue(PlayerbotAI* botAI, std::string const name = "master target") : UnitCalculatedValue(botAI, name) + { + } - Unit* Calculate() override; + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/NearestAdsValue.cpp b/src/strategy/values/NearestAdsValue.cpp index 8afeb0f4..35ae587e 100644 --- a/src/strategy/values/NearestAdsValue.cpp +++ b/src/strategy/values/NearestAdsValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "NearestAdsValue.h" + #include "Playerbots.h" bool NearestAddsValue::AcceptUnit(Unit* unit) diff --git a/src/strategy/values/NearestAdsValue.h b/src/strategy/values/NearestAdsValue.h index 348db8f9..d422c7b6 100644 --- a/src/strategy/values/NearestAdsValue.h +++ b/src/strategy/values/NearestAdsValue.h @@ -1,22 +1,26 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_NEARESTADSVALUE_H #define _PLAYERBOT_NEARESTADSVALUE_H -#include "PossibleTargetsValue.h" #include "PlayerbotAIConfig.h" +#include "PossibleTargetsValue.h" class PlayerbotAI; class NearestAddsValue : public PossibleTargetsValue { - public: - NearestAddsValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->tooCloseDistance) : PossibleTargetsValue(botAI, "nearest adds", range, true) { } +public: + NearestAddsValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->tooCloseDistance) + : PossibleTargetsValue(botAI, "nearest adds", range, true) + { + } - protected: - bool AcceptUnit(Unit* unit) override; +protected: + bool AcceptUnit(Unit* unit) override; }; #endif diff --git a/src/strategy/values/NearestCorpsesValue.cpp b/src/strategy/values/NearestCorpsesValue.cpp index b3d4d98f..b79e7422 100644 --- a/src/strategy/values/NearestCorpsesValue.cpp +++ b/src/strategy/values/NearestCorpsesValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "NearestCorpsesValue.h" + #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" @@ -10,17 +12,14 @@ class AnyDeadUnitInObjectRangeCheck { - public: - AnyDeadUnitInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) { } - WorldObject const& GetFocusObject() const { return *i_obj; } - bool operator()(Unit* u) - { - return !u->IsAlive(); - } +public: + AnyDeadUnitInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {} + WorldObject const& GetFocusObject() const { return *i_obj; } + bool operator()(Unit* u) { return !u->IsAlive(); } - private: - WorldObject const* i_obj; - float i_range; +private: + WorldObject const* i_obj; + float i_range; }; void NearestCorpsesValue::FindUnits(std::list& targets) @@ -30,7 +29,4 @@ void NearestCorpsesValue::FindUnits(std::list& targets) Cell::VisitAllObjects(bot, searcher, range); } -bool NearestCorpsesValue::AcceptUnit(Unit* unit) -{ - return true; -} +bool NearestCorpsesValue::AcceptUnit(Unit* unit) { return true; } diff --git a/src/strategy/values/NearestCorpsesValue.h b/src/strategy/values/NearestCorpsesValue.h index 5a426b81..9bda863b 100644 --- a/src/strategy/values/NearestCorpsesValue.h +++ b/src/strategy/values/NearestCorpsesValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_NEARESTCORPSESVALUE_H @@ -12,12 +13,15 @@ class PlayerbotAI; class NearestCorpsesValue : public NearestUnitsValue { - public: - NearestCorpsesValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) : NearestUnitsValue(botAI, "nearest corpses", range) { } +public: + NearestCorpsesValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) + : NearestUnitsValue(botAI, "nearest corpses", range) + { + } - protected: - void FindUnits(std::list& targets) override; - bool AcceptUnit(Unit* unit) override; +protected: + void FindUnits(std::list& targets) override; + bool AcceptUnit(Unit* unit) override; }; #endif diff --git a/src/strategy/values/NearestFriendlyPlayersValue.cpp b/src/strategy/values/NearestFriendlyPlayersValue.cpp index 839bfb0a..2a0ee89e 100644 --- a/src/strategy/values/NearestFriendlyPlayersValue.cpp +++ b/src/strategy/values/NearestFriendlyPlayersValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "NearestFriendlyPlayersValue.h" + #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" diff --git a/src/strategy/values/NearestFriendlyPlayersValue.h b/src/strategy/values/NearestFriendlyPlayersValue.h index 14372aba..aeee2611 100644 --- a/src/strategy/values/NearestFriendlyPlayersValue.h +++ b/src/strategy/values/NearestFriendlyPlayersValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_NEARESTFRIENDLYPLAYERSVALUES_H @@ -12,13 +13,15 @@ class PlayerbotAI; class NearestFriendlyPlayersValue : public NearestUnitsValue { - public: - NearestFriendlyPlayersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) : - NearestUnitsValue(botAI, "nearest friendly players", range) { } +public: + NearestFriendlyPlayersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) + : NearestUnitsValue(botAI, "nearest friendly players", range) + { + } - protected: - void FindUnits(std::list& targets) override; - bool AcceptUnit(Unit* unit) override; +protected: + void FindUnits(std::list& targets) override; + bool AcceptUnit(Unit* unit) override; }; #endif diff --git a/src/strategy/values/NearestGameObjects.cpp b/src/strategy/values/NearestGameObjects.cpp index d15d0da4..29b3e45a 100644 --- a/src/strategy/values/NearestGameObjects.cpp +++ b/src/strategy/values/NearestGameObjects.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "NearestGameObjects.h" + #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" @@ -12,20 +14,20 @@ class AnyGameObjectInObjectRangeCheck { - public: - AnyGameObjectInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) { } - WorldObject const& GetFocusObject() const { return *i_obj; } - bool operator()(GameObject* u) - { - if (u && i_obj->IsWithinDistInMap(u, i_range) && u->isSpawned() && u->GetGOInfo()) - return true; +public: + AnyGameObjectInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {} + WorldObject const& GetFocusObject() const { return *i_obj; } + bool operator()(GameObject* u) + { + if (u && i_obj->IsWithinDistInMap(u, i_range) && u->isSpawned() && u->GetGOInfo()) + return true; - return false; - } + return false; + } - private: - WorldObject const* i_obj; - float i_range; +private: + WorldObject const* i_obj; + float i_range; }; GuidVector NearestGameObjects::Calculate() @@ -75,16 +77,22 @@ GuidVector NearestTrapWithDamageValue::Calculate() continue; } const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId); - if (spellInfo->IsPositive()) { + if (spellInfo->IsPositive()) + { continue; } - for (int i = 0; i < MAX_SPELL_EFFECTS; i++) { - if (spellInfo->Effects[i].Effect == SPELL_EFFECT_APPLY_AURA) { - if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE) { + for (int i = 0; i < MAX_SPELL_EFFECTS; i++) + { + if (spellInfo->Effects[i].Effect == SPELL_EFFECT_APPLY_AURA) + { + if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE) + { result.push_back(go->GetGUID()); break; } - } else if (spellInfo->Effects[i].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) { + } + else if (spellInfo->Effects[i].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) + { result.push_back(go->GetGUID()); break; } @@ -92,4 +100,3 @@ GuidVector NearestTrapWithDamageValue::Calculate() } return result; } - diff --git a/src/strategy/values/NearestGameObjects.h b/src/strategy/values/NearestGameObjects.h index 399222cc..04d16480 100644 --- a/src/strategy/values/NearestGameObjects.h +++ b/src/strategy/values/NearestGameObjects.h @@ -1,40 +1,46 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_NEARESTGAMEOBJECTS_H #define _PLAYERBOT_NEARESTGAMEOBJECTS_H -#include "Value.h" #include "PlayerbotAIConfig.h" +#include "Value.h" class PlayerbotAI; class NearestGameObjects : public ObjectGuidListCalculatedValue { - public: - NearestGameObjects(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance, bool ignoreLos = false, std::string const name = "nearest game objects") : - ObjectGuidListCalculatedValue(botAI, name, 2 * 1000), range(range) , ignoreLos(ignoreLos) { } +public: + NearestGameObjects(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance, bool ignoreLos = false, + std::string const name = "nearest game objects") + : ObjectGuidListCalculatedValue(botAI, name, 2 * 1000), range(range), ignoreLos(ignoreLos) + { + } - protected: - GuidVector Calculate() override; +protected: + GuidVector Calculate() override; - private: - float range; - bool ignoreLos; +private: + float range; + bool ignoreLos; }; class NearestTrapWithDamageValue : public ObjectGuidListCalculatedValue { - public: - NearestTrapWithDamageValue(PlayerbotAI* botAI, float range = 15.0f) : - ObjectGuidListCalculatedValue(botAI, "nearest trap with damage", 1 * 1000), range(range) { } +public: + NearestTrapWithDamageValue(PlayerbotAI* botAI, float range = 15.0f) + : ObjectGuidListCalculatedValue(botAI, "nearest trap with damage", 1 * 1000), range(range) + { + } - protected: - GuidVector Calculate() override; - - private: - float range; +protected: + GuidVector Calculate() override; + +private: + float range; }; #endif diff --git a/src/strategy/values/NearestNonBotPlayersValue.cpp b/src/strategy/values/NearestNonBotPlayersValue.cpp index 308d0ed2..6ab733e8 100644 --- a/src/strategy/values/NearestNonBotPlayersValue.cpp +++ b/src/strategy/values/NearestNonBotPlayersValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "NearestNonBotPlayersValue.h" + #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" @@ -18,6 +20,6 @@ void NearestNonBotPlayersValue::FindUnits(std::list& targets) bool NearestNonBotPlayersValue::AcceptUnit(Unit* unit) { ObjectGuid guid = unit->GetGUID(); - return guid.IsPlayer() && !GET_PLAYERBOT_AI(((Player*)unit)) && (!((Player*)unit)->IsGameMaster() || ((Player*)unit)->isGMVisible()); + return guid.IsPlayer() && !GET_PLAYERBOT_AI(((Player*)unit)) && + (!((Player*)unit)->IsGameMaster() || ((Player*)unit)->isGMVisible()); } - diff --git a/src/strategy/values/NearestNonBotPlayersValue.h b/src/strategy/values/NearestNonBotPlayersValue.h index 967804eb..87971203 100644 --- a/src/strategy/values/NearestNonBotPlayersValue.h +++ b/src/strategy/values/NearestNonBotPlayersValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_NEARESTNONBOTPLAYERSVALUE_H @@ -12,12 +13,15 @@ class PlayerbotAI; class NearestNonBotPlayersValue : public NearestUnitsValue { - public: - NearestNonBotPlayersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->grindDistance) : NearestUnitsValue(botAI, "nearest non bot players", range, true) { } +public: + NearestNonBotPlayersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->grindDistance) + : NearestUnitsValue(botAI, "nearest non bot players", range, true) + { + } - protected: - void FindUnits(std::list& targets) override; - bool AcceptUnit(Unit* unit) override; +protected: + void FindUnits(std::list& targets) override; + bool AcceptUnit(Unit* unit) override; }; #endif diff --git a/src/strategy/values/NearestNpcsValue.cpp b/src/strategy/values/NearestNpcsValue.cpp index efc73bb0..c0c21509 100644 --- a/src/strategy/values/NearestNpcsValue.cpp +++ b/src/strategy/values/NearestNpcsValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "NearestNpcsValue.h" + #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" @@ -16,10 +18,7 @@ void NearestNpcsValue::FindUnits(std::list& targets) Cell::VisitAllObjects(bot, searcher, range); } -bool NearestNpcsValue::AcceptUnit(Unit* unit) -{ - return !unit->IsHostileTo(bot) && !unit->IsPlayer(); -} +bool NearestNpcsValue::AcceptUnit(Unit* unit) { return !unit->IsHostileTo(bot) && !unit->IsPlayer(); } void NearestVehiclesValue::FindUnits(std::list& targets) { @@ -47,10 +46,7 @@ void NearestTriggersValue::FindUnits(std::list& targets) Cell::VisitAllObjects(bot, searcher, range); } -bool NearestTriggersValue::AcceptUnit(Unit* unit) -{ - return !unit->IsPlayer(); -} +bool NearestTriggersValue::AcceptUnit(Unit* unit) { return !unit->IsPlayer(); } void NearestTotemsValue::FindUnits(std::list& targets) { @@ -59,7 +55,4 @@ void NearestTotemsValue::FindUnits(std::list& targets) Cell::VisitAllObjects(bot, searcher, range); } -bool NearestTotemsValue::AcceptUnit(Unit* unit) -{ - return unit->IsTotem(); -} \ No newline at end of file +bool NearestTotemsValue::AcceptUnit(Unit* unit) { return unit->IsTotem(); } \ No newline at end of file diff --git a/src/strategy/values/NearestNpcsValue.h b/src/strategy/values/NearestNpcsValue.h index 419c5fa4..3915dde3 100644 --- a/src/strategy/values/NearestNpcsValue.h +++ b/src/strategy/values/NearestNpcsValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_NEARESTNPCSVALUE_H @@ -12,42 +13,54 @@ class PlayerbotAI; class NearestNpcsValue : public NearestUnitsValue { - public: - NearestNpcsValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) : NearestUnitsValue(botAI, "nearest npcs", range) { } +public: + NearestNpcsValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) + : NearestUnitsValue(botAI, "nearest npcs", range) + { + } - protected: - void FindUnits(std::list& targets) override; - bool AcceptUnit(Unit* unit) override; +protected: + void FindUnits(std::list& targets) override; + bool AcceptUnit(Unit* unit) override; }; class NearestVehiclesValue : public NearestUnitsValue { - public: - NearestVehiclesValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) : NearestUnitsValue(botAI, "nearest vehicles", range) { } +public: + NearestVehiclesValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) + : NearestUnitsValue(botAI, "nearest vehicles", range) + { + } - protected: - void FindUnits(std::list& targets) override; - bool AcceptUnit(Unit* unit) override; +protected: + void FindUnits(std::list& targets) override; + bool AcceptUnit(Unit* unit) override; }; class NearestTriggersValue : public NearestUnitsValue { - public: - NearestTriggersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) : NearestUnitsValue(botAI, "nearest triggers", range) { } +public: + NearestTriggersValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) + : NearestUnitsValue(botAI, "nearest triggers", range) + { + } - protected: - void FindUnits(std::list& targets) override; - bool AcceptUnit(Unit* unit) override; +protected: + void FindUnits(std::list& targets) override; + bool AcceptUnit(Unit* unit) override; }; class NearestTotemsValue : public NearestUnitsValue { - public: - NearestTotemsValue(PlayerbotAI* botAI, float range = 30.0f) : NearestUnitsValue(botAI, "nearest totems", range, true) { } +public: + NearestTotemsValue(PlayerbotAI* botAI, float range = 30.0f) + : NearestUnitsValue(botAI, "nearest totems", range, true) + { + } - protected: - void FindUnits(std::list& targets) override; - bool AcceptUnit(Unit* unit) override; +protected: + void FindUnits(std::list& targets) override; + bool AcceptUnit(Unit* unit) override; }; #endif diff --git a/src/strategy/values/NearestUnitsValue.cpp b/src/strategy/values/NearestUnitsValue.cpp index f0880b0d..d19605fa 100644 --- a/src/strategy/values/NearestUnitsValue.cpp +++ b/src/strategy/values/NearestUnitsValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "NearestUnitsValue.h" + #include "Playerbots.h" GuidVector NearestUnitsValue::Calculate() diff --git a/src/strategy/values/NearestUnitsValue.h b/src/strategy/values/NearestUnitsValue.h index 6f154e4e..f56ab6ac 100644 --- a/src/strategy/values/NearestUnitsValue.h +++ b/src/strategy/values/NearestUnitsValue.h @@ -1,30 +1,34 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_NEARESTUNITSVALUE_H #define _PLAYERBOT_NEARESTUNITSVALUE_H +#include "PlayerbotAIConfig.h" #include "Unit.h" #include "Value.h" -#include "PlayerbotAIConfig.h" class PlayerbotAI; class NearestUnitsValue : public ObjectGuidListCalculatedValue { - public: - NearestUnitsValue(PlayerbotAI* botAI, std::string const name = "nearest units", float range = sPlayerbotAIConfig->sightDistance, bool ignoreLos = false, uint32 checkInterval = 1) : - ObjectGuidListCalculatedValue(botAI, name, checkInterval), range(range), ignoreLos(ignoreLos) { } +public: + NearestUnitsValue(PlayerbotAI* botAI, std::string const name = "nearest units", + float range = sPlayerbotAIConfig->sightDistance, bool ignoreLos = false, uint32 checkInterval = 1) + : ObjectGuidListCalculatedValue(botAI, name, checkInterval), range(range), ignoreLos(ignoreLos) + { + } - GuidVector Calculate() override; + GuidVector Calculate() override; - protected: - virtual void FindUnits(std::list& targets) = 0; - virtual bool AcceptUnit(Unit* unit) = 0; +protected: + virtual void FindUnits(std::list& targets) = 0; + virtual bool AcceptUnit(Unit* unit) = 0; - float range; - bool ignoreLos; + float range; + bool ignoreLos; }; #endif diff --git a/src/strategy/values/NewPlayerNearbyValue.cpp b/src/strategy/values/NewPlayerNearbyValue.cpp index 35e5776b..17d68312 100644 --- a/src/strategy/values/NewPlayerNearbyValue.cpp +++ b/src/strategy/values/NewPlayerNearbyValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "NewPlayerNearbyValue.h" + #include "Playerbots.h" ObjectGuid NewPlayerNearbyValue::Calculate() diff --git a/src/strategy/values/NewPlayerNearbyValue.h b/src/strategy/values/NewPlayerNearbyValue.h index 58527919..8cb5048a 100644 --- a/src/strategy/values/NewPlayerNearbyValue.h +++ b/src/strategy/values/NewPlayerNearbyValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_NEWPLAYERNEARBYVALUE_H @@ -12,18 +13,18 @@ class PlayerbotAI; class NewPlayerNearbyValue : public CalculatedValue { - public: - NewPlayerNearbyValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "new player nearby") { } +public: + NewPlayerNearbyValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "new player nearby") {} - ObjectGuid Calculate() override; + ObjectGuid Calculate() override; }; class AlreadySeenPlayersValue : public ManualSetValue { - public: - AlreadySeenPlayersValue(PlayerbotAI* botAI) : ManualSetValue(botAI, data, "already seen players") { } +public: + AlreadySeenPlayersValue(PlayerbotAI* botAI) : ManualSetValue(botAI, data, "already seen players") {} - GuidSet data; + GuidSet data; }; #endif diff --git a/src/strategy/values/OutfitListValue.cpp b/src/strategy/values/OutfitListValue.cpp index 491bc74a..631953de 100644 --- a/src/strategy/values/OutfitListValue.cpp +++ b/src/strategy/values/OutfitListValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "OutfitListValue.h" + #include "Playerbots.h" std::string const OutfitListValue::Save() diff --git a/src/strategy/values/OutfitListValue.h b/src/strategy/values/OutfitListValue.h index 78c9120c..2f84aa44 100644 --- a/src/strategy/values/OutfitListValue.h +++ b/src/strategy/values/OutfitListValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_OUTFITLISTVALUE_H @@ -13,14 +14,17 @@ typedef std::vector Outfit; class OutfitListValue : public ManualSetValue { - public: - OutfitListValue(PlayerbotAI* botAI, std::string const name = "outfit list") : ManualSetValue(botAI, list, name) { } +public: + OutfitListValue(PlayerbotAI* botAI, std::string const name = "outfit list") + : ManualSetValue(botAI, list, name) + { + } - std::string const Save() override; - bool Load(std::string const value) override; + std::string const Save() override; + bool Load(std::string const value) override; - private: - Outfit list; +private: + Outfit list; }; #endif diff --git a/src/strategy/values/PartyMemberToDispel.cpp b/src/strategy/values/PartyMemberToDispel.cpp index eb964a13..665d6d8d 100644 --- a/src/strategy/values/PartyMemberToDispel.cpp +++ b/src/strategy/values/PartyMemberToDispel.cpp @@ -1,22 +1,24 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PartyMemberToDispel.h" + #include "Playerbots.h" class PartyMemberToDispelPredicate : public FindPlayerPredicate, public PlayerbotAIAware { - public: - PartyMemberToDispelPredicate(PlayerbotAI* botAI, uint32 dispelType) : PlayerbotAIAware(botAI), FindPlayerPredicate(), dispelType(dispelType) { } +public: + PartyMemberToDispelPredicate(PlayerbotAI* botAI, uint32 dispelType) + : PlayerbotAIAware(botAI), FindPlayerPredicate(), dispelType(dispelType) + { + } - bool Check(Unit* unit) override - { - return unit->IsAlive() && botAI->HasAuraToDispel(unit, dispelType); - } + bool Check(Unit* unit) override { return unit->IsAlive() && botAI->HasAuraToDispel(unit, dispelType); } - private: - uint32 dispelType; +private: + uint32 dispelType; }; Unit* PartyMemberToDispel::Calculate() diff --git a/src/strategy/values/PartyMemberToDispel.h b/src/strategy/values/PartyMemberToDispel.h index ac2c441f..2037d606 100644 --- a/src/strategy/values/PartyMemberToDispel.h +++ b/src/strategy/values/PartyMemberToDispel.h @@ -1,23 +1,27 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PARTYMEMBERTODISPEL_H #define _PLAYERBOT_PARTYMEMBERTODISPEL_H -#include "PartyMemberValue.h" #include "NamedObjectContext.h" +#include "PartyMemberValue.h" class PlayerbotAI; class Unit; class PartyMemberToDispel : public PartyMemberValue, public Qualified { - public: - PartyMemberToDispel(PlayerbotAI* botAI, std::string const name = "party member to dispel") : PartyMemberValue(botAI, name, 1000), Qualified() { } +public: + PartyMemberToDispel(PlayerbotAI* botAI, std::string const name = "party member to dispel") + : PartyMemberValue(botAI, name, 1000), Qualified() + { + } - protected: - Unit* Calculate() override; +protected: + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/PartyMemberToHeal.cpp b/src/strategy/values/PartyMemberToHeal.cpp index a7cba48e..31a8f00a 100644 --- a/src/strategy/values/PartyMemberToHeal.cpp +++ b/src/strategy/values/PartyMemberToHeal.cpp @@ -1,35 +1,34 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PartyMemberToHeal.h" + #include "Playerbots.h" #include "ServerFacade.h" class IsTargetOfHealingSpell : public SpellEntryPredicate { - public: - bool Check(SpellInfo const* spellInfo) override +public: + bool Check(SpellInfo const* spellInfo) override + { + for (uint8 i = 0; i < 3; ++i) { - for (uint8 i = 0; i < 3; ++i) - { - if (spellInfo->Effects[i].Effect == SPELL_EFFECT_HEAL || spellInfo->Effects[i].Effect == SPELL_EFFECT_HEAL_MAX_HEALTH || - spellInfo->Effects[i].Effect == SPELL_EFFECT_HEAL_MECHANICAL) - return true; - } - - return false; + if (spellInfo->Effects[i].Effect == SPELL_EFFECT_HEAL || + spellInfo->Effects[i].Effect == SPELL_EFFECT_HEAL_MAX_HEALTH || + spellInfo->Effects[i].Effect == SPELL_EFFECT_HEAL_MECHANICAL) + return true; } + + return false; + } }; -inline bool compareByHealth(Unit const* u1, Unit const* u2) -{ - return u1->GetHealthPct() < u2->GetHealthPct(); -} +inline bool compareByHealth(Unit const* u1, Unit const* u2) { return u1->GetHealthPct() < u2->GetHealthPct(); } Unit* PartyMemberToHeal::Calculate() { - IsTargetOfHealingSpell predicate; Group* group = bot->GetGroup(); @@ -38,30 +37,37 @@ Unit* PartyMemberToHeal::Calculate() bool isRaid = bot->GetGroup()->isRaidGroup(); MinValueCalculator calc(100); - - for (GroupReference *gref = group->GetFirstMember(); gref; gref = gref->next()) + + for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next()) { Player* player = gref->GetSource(); - if (player && Check(player) && player->IsAlive()) { + if (player && Check(player) && player->IsAlive()) + { uint8 health = player->GetHealthPct(); - if (isRaid || health < sPlayerbotAIConfig->mediumHealth || !IsTargetOfSpellCast(player, predicate)) { - if (player->GetDistance2d(bot) > sPlayerbotAIConfig->healDistance) { + if (isRaid || health < sPlayerbotAIConfig->mediumHealth || !IsTargetOfSpellCast(player, predicate)) + { + if (player->GetDistance2d(bot) > sPlayerbotAIConfig->healDistance) + { calc.probe(health + 30, player); - } else { + } + else + { calc.probe(health + player->GetDistance2d(bot) / 10, player); } } } Pet* pet = player->GetPet(); - if (pet && Check(pet) && pet->IsAlive()) { + if (pet && Check(pet) && pet->IsAlive()) + { uint8 health = ((Unit*)pet)->GetHealthPct(); if (isRaid || health < sPlayerbotAIConfig->mediumHealth) calc.probe(health + 30, pet); } Unit* charm = player->GetCharm(); - if (charm && Check(charm) && charm->IsAlive()) { + if (charm && Check(charm) && charm->IsAlive()) + { uint8 health = charm->GetHealthPct(); if (isRaid || health < sPlayerbotAIConfig->mediumHealth) calc.probe(health, charm); @@ -73,10 +79,11 @@ Unit* PartyMemberToHeal::Calculate() bool PartyMemberToHeal::Check(Unit* player) { // return player && player != bot && player->GetMapId() == bot->GetMapId() && player->IsInWorld() && - // sServerFacade->GetDistance2d(bot, player) < (player->IsPlayer() && botAI->IsTank((Player*)player) ? 50.0f : 40.0f); + // sServerFacade->GetDistance2d(bot, player) < (player->IsPlayer() && botAI->IsTank((Player*)player) ? 50.0f + // : 40.0f); return player->GetMapId() == bot->GetMapId() && !player->IsCharmed() && - bot->GetDistance2d(player) < sPlayerbotAIConfig->healDistance * 2 && - bot->IsWithinLOS(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); + bot->GetDistance2d(player) < sPlayerbotAIConfig->healDistance * 2 && + bot->IsWithinLOS(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); } Unit* PartyMemberToProtect::Calculate() @@ -115,11 +122,10 @@ Unit* PartyMemberToProtect::Calculate() needProtect.push_back(pVictim); } - if (needProtect.empty()) + if (needProtect.empty()) return nullptr; sort(needProtect.begin(), needProtect.end(), compareByHealth); return needProtect[0]; } - diff --git a/src/strategy/values/PartyMemberToHeal.h b/src/strategy/values/PartyMemberToHeal.h index 4f4852ca..b235edde 100644 --- a/src/strategy/values/PartyMemberToHeal.h +++ b/src/strategy/values/PartyMemberToHeal.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PARTYMEMBERTOHEAL_H @@ -13,21 +14,27 @@ class Unit; class PartyMemberToHeal : public PartyMemberValue { - public: - PartyMemberToHeal(PlayerbotAI* botAI, std::string const name = "party member to heal") : PartyMemberValue(botAI, name) { } +public: + PartyMemberToHeal(PlayerbotAI* botAI, std::string const name = "party member to heal") + : PartyMemberValue(botAI, name) + { + } - protected: - Unit* Calculate() override; - bool Check(Unit* player) override; +protected: + Unit* Calculate() override; + bool Check(Unit* player) override; }; class PartyMemberToProtect : public PartyMemberValue { - public: - PartyMemberToProtect(PlayerbotAI* botAI, std::string const name = "party member to protect") : PartyMemberValue(botAI, name) { } +public: + PartyMemberToProtect(PlayerbotAI* botAI, std::string const name = "party member to protect") + : PartyMemberValue(botAI, name) + { + } - protected: - Unit* Calculate() override; +protected: + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/PartyMemberToResurrect.cpp b/src/strategy/values/PartyMemberToResurrect.cpp index 3117d777..0d07cdae 100644 --- a/src/strategy/values/PartyMemberToResurrect.cpp +++ b/src/strategy/values/PartyMemberToResurrect.cpp @@ -1,44 +1,48 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PartyMemberToResurrect.h" + #include "Playerbots.h" class IsTargetOfResurrectSpell : public SpellEntryPredicate { - public: - bool Check(SpellInfo const* spellInfo) override +public: + bool Check(SpellInfo const* spellInfo) override + { + for (uint8 i = 0; i < 3; ++i) { - for (uint8 i = 0; i < 3; ++i) - { - if (spellInfo->Effects[i].Effect == SPELL_EFFECT_RESURRECT || spellInfo->Effects[i].Effect == SPELL_EFFECT_RESURRECT_NEW || - spellInfo->Effects[i].Effect == SPELL_EFFECT_SELF_RESURRECT) - return true; - } - - return false; + if (spellInfo->Effects[i].Effect == SPELL_EFFECT_RESURRECT || + spellInfo->Effects[i].Effect == SPELL_EFFECT_RESURRECT_NEW || + spellInfo->Effects[i].Effect == SPELL_EFFECT_SELF_RESURRECT) + return true; } + + return false; + } }; class FindDeadPlayer : public FindPlayerPredicate { - public: - FindDeadPlayer(PartyMemberValue* value) : value(value) { } +public: + FindDeadPlayer(PartyMemberValue* value) : value(value) {} - bool Check(Unit* unit) override - { - Player* player = unit->ToPlayer(); - return player && !player->isResurrectRequested() && player->getDeathState() == DeathState::Corpse && !value->IsTargetOfSpellCast(player, predicate); - } + bool Check(Unit* unit) override + { + Player* player = unit->ToPlayer(); + return player && !player->isResurrectRequested() && player->getDeathState() == DeathState::Corpse && + !value->IsTargetOfSpellCast(player, predicate); + } - private: - PartyMemberValue* value; - IsTargetOfResurrectSpell predicate; +private: + PartyMemberValue* value; + IsTargetOfResurrectSpell predicate; }; Unit* PartyMemberToResurrect::Calculate() { - FindDeadPlayer finder(this); + FindDeadPlayer finder(this); return FindPartyMember(finder); } diff --git a/src/strategy/values/PartyMemberToResurrect.h b/src/strategy/values/PartyMemberToResurrect.h index e3971fd6..1735e88d 100644 --- a/src/strategy/values/PartyMemberToResurrect.h +++ b/src/strategy/values/PartyMemberToResurrect.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PARTYMEMBERTORESURRECT_H @@ -12,11 +13,14 @@ class Unit; class PartyMemberToResurrect : public PartyMemberValue { - public: - PartyMemberToResurrect(PlayerbotAI* botAI, std::string const name = "party member to resurrect") : PartyMemberValue(botAI,name) { } +public: + PartyMemberToResurrect(PlayerbotAI* botAI, std::string const name = "party member to resurrect") + : PartyMemberValue(botAI, name) + { + } - protected: - Unit* Calculate() override; +protected: + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/PartyMemberValue.cpp b/src/strategy/values/PartyMemberValue.cpp index 7139ccb1..36f79e2e 100644 --- a/src/strategy/values/PartyMemberValue.cpp +++ b/src/strategy/values/PartyMemberValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PartyMemberValue.h" + #include "Playerbots.h" #include "ServerFacade.h" @@ -42,7 +44,9 @@ Unit* PartyMemberValue::FindPartyMember(FindPlayerPredicate& predicate, bool ign nearestGroupPlayers.push_front(ref->GetSource()->GetGUID()); } } - } else { + } + else + { std::vector vec; vec.push_back(bot); Unit* target = FindPartyMember(&vec, predicate); @@ -97,23 +101,25 @@ Unit* PartyMemberValue::FindPartyMember(FindPlayerPredicate& predicate, bool ign bool PartyMemberValue::Check(Unit* player) { - // return player && player != bot && player->GetMapId() == bot->GetMapId() && bot->IsWithinDistInMap(player, sPlayerbotAIConfig->sightDistance, false); + // return player && player != bot && player->GetMapId() == bot->GetMapId() && bot->IsWithinDistInMap(player, + // sPlayerbotAIConfig->sightDistance, false); return player && player->GetMapId() == bot->GetMapId() && - bot->GetDistance(player) < sPlayerbotAIConfig->spellDistance * 2 && - bot->IsWithinLOS(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); + bot->GetDistance(player) < sPlayerbotAIConfig->spellDistance * 2 && + bot->IsWithinLOS(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); } -bool PartyMemberValue::IsTargetOfSpellCast(Player* target, SpellEntryPredicate &predicate) +bool PartyMemberValue::IsTargetOfSpellCast(Player* target, SpellEntryPredicate& predicate) { // GuidVector nearestPlayers = AI_VALUE(GuidVector, "nearest friendly players"); ObjectGuid targetGuid = target ? target->GetGUID() : bot->GetGUID(); ObjectGuid corpseGuid = target && target->GetCorpse() ? target->GetCorpse()->GetGUID() : ObjectGuid::Empty; Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { return false; } - for (GroupReference *gref = group->GetFirstMember(); gref; gref = gref->next()) + for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next()) { Player* player = gref->GetSource(); if (!player || player == bot) @@ -148,7 +154,8 @@ public: virtual bool Check(Unit* unit) { Player* player = unit->ToPlayer(); - if (!player) { + if (!player) + { return false; } return botAI->IsMainTank(player); diff --git a/src/strategy/values/PartyMemberValue.h b/src/strategy/values/PartyMemberValue.h index 2924c99b..910ce810 100644 --- a/src/strategy/values/PartyMemberValue.h +++ b/src/strategy/values/PartyMemberValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PARTYMEMBERVALUE_H @@ -12,28 +13,31 @@ class PlayerbotAI; class FindPlayerPredicate { - public: - virtual ~FindPlayerPredicate() = default; - virtual bool Check(Unit* /*unit*/) = 0; +public: + virtual ~FindPlayerPredicate() = default; + virtual bool Check(Unit* /*unit*/) = 0; }; class SpellEntryPredicate { - public: - virtual bool Check(SpellInfo const* /*spellInfo*/) = 0; +public: + virtual bool Check(SpellInfo const* /*spellInfo*/) = 0; }; class PartyMemberValue : public UnitCalculatedValue { - public: - PartyMemberValue(PlayerbotAI* botAI, std::string const name = "party member", int checkInterval = 1) : UnitCalculatedValue(botAI, name, checkInterval) { } +public: + PartyMemberValue(PlayerbotAI* botAI, std::string const name = "party member", int checkInterval = 1) + : UnitCalculatedValue(botAI, name, checkInterval) + { + } - bool IsTargetOfSpellCast(Player* target, SpellEntryPredicate& predicate); + bool IsTargetOfSpellCast(Player* target, SpellEntryPredicate& predicate); - protected: - Unit* FindPartyMember(FindPlayerPredicate& predicate, bool ignoreOutOfGroup = false); - Unit* FindPartyMember(std::vector* party, FindPlayerPredicate& predicate); - virtual bool Check(Unit* player); +protected: + Unit* FindPartyMember(FindPlayerPredicate& predicate, bool ignoreOutOfGroup = false); + Unit* FindPartyMember(std::vector* party, FindPlayerPredicate& predicate); + virtual bool Check(Unit* player); }; class PartyMemberMainTankValue : public PartyMemberValue diff --git a/src/strategy/values/PartyMemberWithoutAuraValue.cpp b/src/strategy/values/PartyMemberWithoutAuraValue.cpp index 91a218ca..11ffa482 100644 --- a/src/strategy/values/PartyMemberWithoutAuraValue.cpp +++ b/src/strategy/values/PartyMemberWithoutAuraValue.cpp @@ -1,39 +1,43 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PartyMemberWithoutAuraValue.h" + #include "Playerbots.h" extern std::vector split(std::string const s, char delim); class PlayerWithoutAuraPredicate : public FindPlayerPredicate, public PlayerbotAIAware { - public: - PlayerWithoutAuraPredicate(PlayerbotAI* botAI, std::string const aura) : PlayerbotAIAware(botAI), FindPlayerPredicate(), auras(split(aura, ',')) { } +public: + PlayerWithoutAuraPredicate(PlayerbotAI* botAI, std::string const aura) + : PlayerbotAIAware(botAI), FindPlayerPredicate(), auras(split(aura, ',')) + { + } - public: - bool Check(Unit* unit) override +public: + bool Check(Unit* unit) override + { + if (!unit->IsAlive()) + return false; + + for (std::vector::iterator i = auras.begin(); i != auras.end(); ++i) { - if (!unit->IsAlive()) + if (botAI->HasAura(*i, unit)) return false; - - for (std::vector::iterator i = auras.begin(); i != auras.end(); ++i) - { - if (botAI->HasAura(*i, unit)) - return false; - } - - return true; } - private: - std::vector auras; + return true; + } + +private: + std::vector auras; }; Unit* PartyMemberWithoutAuraValue::Calculate() { - PlayerWithoutAuraPredicate predicate(botAI, qualifier); + PlayerWithoutAuraPredicate predicate(botAI, qualifier); return FindPartyMember(predicate); } - diff --git a/src/strategy/values/PartyMemberWithoutAuraValue.h b/src/strategy/values/PartyMemberWithoutAuraValue.h index 49da4c38..19bd6243 100644 --- a/src/strategy/values/PartyMemberWithoutAuraValue.h +++ b/src/strategy/values/PartyMemberWithoutAuraValue.h @@ -1,12 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PARTYMEMBERWITHOUTAURAVALUE_H #define _PLAYERBOT_PARTYMEMBERWITHOUTAURAVALUE_H -#include "PartyMemberValue.h" #include "NamedObjectContext.h" +#include "PartyMemberValue.h" #include "PlayerbotAIConfig.h" class PlayerbotAI; @@ -14,12 +15,15 @@ class Unit; class PartyMemberWithoutAuraValue : public PartyMemberValue, public Qualified { - public: - PartyMemberWithoutAuraValue(PlayerbotAI* botAI, std::string const name = "party member without aura", float range = sPlayerbotAIConfig->sightDistance) : - PartyMemberValue(botAI, name) { } +public: + PartyMemberWithoutAuraValue(PlayerbotAI* botAI, std::string const name = "party member without aura", + float range = sPlayerbotAIConfig->sightDistance) + : PartyMemberValue(botAI, name) + { + } - protected: - Unit* Calculate() override; +protected: + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/PartyMemberWithoutItemValue.cpp b/src/strategy/values/PartyMemberWithoutItemValue.cpp index 9206a86e..898af9bf 100644 --- a/src/strategy/values/PartyMemberWithoutItemValue.cpp +++ b/src/strategy/values/PartyMemberWithoutItemValue.cpp @@ -1,36 +1,41 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PartyMemberWithoutItemValue.h" + #include "Playerbots.h" class PlayerWithoutItemPredicate : public FindPlayerPredicate, public PlayerbotAIAware { - public: - PlayerWithoutItemPredicate(PlayerbotAI* botAI, std::string const item) : PlayerbotAIAware(botAI), FindPlayerPredicate(), item(item) { } +public: + PlayerWithoutItemPredicate(PlayerbotAI* botAI, std::string const item) + : PlayerbotAIAware(botAI), FindPlayerPredicate(), item(item) + { + } - bool Check(Unit* unit) override - { - if (!unit->IsAlive()) - return false; + bool Check(Unit* unit) override + { + if (!unit->IsAlive()) + return false; - Player* member = unit->ToPlayer(); - if (!member) - return false; + Player* member = unit->ToPlayer(); + if (!member) + return false; - if (!(member->IsInSameGroupWith(botAI->GetBot()) || member->IsInSameRaidWith(botAI->GetBot()))) - return false; + if (!(member->IsInSameGroupWith(botAI->GetBot()) || member->IsInSameRaidWith(botAI->GetBot()))) + return false; - PlayerbotAI* memberbotAI = GET_PLAYERBOT_AI(member); - if (!memberbotAI) - return false; + PlayerbotAI* memberbotAI = GET_PLAYERBOT_AI(member); + if (!memberbotAI) + return false; - return !memberbotAI->GetAiObjectContext()->GetValue("item count", item)->Get(); - } + return !memberbotAI->GetAiObjectContext()->GetValue("item count", item)->Get(); + } - private: - std::string const item; +private: + std::string const item; }; Unit* PartyMemberWithoutItemValue::Calculate() @@ -48,47 +53,42 @@ FindPlayerPredicate* PartyMemberWithoutItemValue::CreatePredicate() class PlayerWithoutFoodPredicate : public PlayerWithoutItemPredicate { - public: - PlayerWithoutFoodPredicate(PlayerbotAI* botAI) : PlayerWithoutItemPredicate(botAI, "conjured food") { } +public: + PlayerWithoutFoodPredicate(PlayerbotAI* botAI) : PlayerWithoutItemPredicate(botAI, "conjured food") {} - bool Check(Unit* unit) override - { - if (!PlayerWithoutItemPredicate::Check(unit)) - return false; + bool Check(Unit* unit) override + { + if (!PlayerWithoutItemPredicate::Check(unit)) + return false; - Player* member = unit->ToPlayer(); - if (!member) - return false; + Player* member = unit->ToPlayer(); + if (!member) + return false; - return member->getClass() != CLASS_MAGE; - } + return member->getClass() != CLASS_MAGE; + } }; class PlayerWithoutWaterPredicate : public PlayerWithoutItemPredicate { - public: - PlayerWithoutWaterPredicate(PlayerbotAI* botAI) : PlayerWithoutItemPredicate(botAI, "conjured water") { } +public: + PlayerWithoutWaterPredicate(PlayerbotAI* botAI) : PlayerWithoutItemPredicate(botAI, "conjured water") {} - bool Check(Unit* unit) override - { - if (!PlayerWithoutItemPredicate::Check(unit)) - return false; + bool Check(Unit* unit) override + { + if (!PlayerWithoutItemPredicate::Check(unit)) + return false; - Player* member = dynamic_cast(unit); - if (!member) - return false; + Player* member = dynamic_cast(unit); + if (!member) + return false; - uint8 cls = member->getClass(); - return cls == CLASS_DRUID || cls == CLASS_HUNTER || cls == CLASS_PALADIN ||cls == CLASS_PRIEST || cls == CLASS_SHAMAN || cls == CLASS_WARLOCK; - } + uint8 cls = member->getClass(); + return cls == CLASS_DRUID || cls == CLASS_HUNTER || cls == CLASS_PALADIN || cls == CLASS_PRIEST || + cls == CLASS_SHAMAN || cls == CLASS_WARLOCK; + } }; -FindPlayerPredicate* PartyMemberWithoutFoodValue::CreatePredicate() -{ - return new PlayerWithoutFoodPredicate(botAI); -} +FindPlayerPredicate* PartyMemberWithoutFoodValue::CreatePredicate() { return new PlayerWithoutFoodPredicate(botAI); } -FindPlayerPredicate* PartyMemberWithoutWaterValue::CreatePredicate() -{ - return new PlayerWithoutWaterPredicate(botAI); -} +FindPlayerPredicate* PartyMemberWithoutWaterValue::CreatePredicate() { return new PlayerWithoutWaterPredicate(botAI); } diff --git a/src/strategy/values/PartyMemberWithoutItemValue.h b/src/strategy/values/PartyMemberWithoutItemValue.h index 3bc3b4a4..61473c84 100644 --- a/src/strategy/values/PartyMemberWithoutItemValue.h +++ b/src/strategy/values/PartyMemberWithoutItemValue.h @@ -1,12 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PARTYMEMBERWITHOUTITEMVALUE_H #define _PLAYERBOT_PARTYMEMBERWITHOUTITEMVALUE_H -#include "PartyMemberValue.h" #include "NamedObjectContext.h" +#include "PartyMemberValue.h" #include "PlayerbotAIConfig.h" class PlayerbotAI; @@ -14,30 +15,40 @@ class Unit; class PartyMemberWithoutItemValue : public PartyMemberValue, public Qualified { - public: - PartyMemberWithoutItemValue(PlayerbotAI* botAI, std::string const name = "party member without item", float range = sPlayerbotAIConfig->farDistance) : PartyMemberValue(botAI, name) { } +public: + PartyMemberWithoutItemValue(PlayerbotAI* botAI, std::string const name = "party member without item", + float range = sPlayerbotAIConfig->farDistance) + : PartyMemberValue(botAI, name) + { + } - protected: - Unit* Calculate() override; - virtual FindPlayerPredicate* CreatePredicate(); +protected: + Unit* Calculate() override; + virtual FindPlayerPredicate* CreatePredicate(); }; class PartyMemberWithoutFoodValue : public PartyMemberWithoutItemValue { - public: - PartyMemberWithoutFoodValue(PlayerbotAI* botAI, std::string const name = "party member without food") : PartyMemberWithoutItemValue(botAI, name) { } +public: + PartyMemberWithoutFoodValue(PlayerbotAI* botAI, std::string const name = "party member without food") + : PartyMemberWithoutItemValue(botAI, name) + { + } - protected: - FindPlayerPredicate* CreatePredicate() override; +protected: + FindPlayerPredicate* CreatePredicate() override; }; class PartyMemberWithoutWaterValue : public PartyMemberWithoutItemValue { - public: - PartyMemberWithoutWaterValue(PlayerbotAI* botAI, std::string const name = "party member without water") : PartyMemberWithoutItemValue(botAI, name) { } +public: + PartyMemberWithoutWaterValue(PlayerbotAI* botAI, std::string const name = "party member without water") + : PartyMemberWithoutItemValue(botAI, name) + { + } - protected: - FindPlayerPredicate* CreatePredicate() override; +protected: + FindPlayerPredicate* CreatePredicate() override; }; #endif diff --git a/src/strategy/values/PetTargetValue.cpp b/src/strategy/values/PetTargetValue.cpp index 6b87193e..ae6f5cc9 100644 --- a/src/strategy/values/PetTargetValue.cpp +++ b/src/strategy/values/PetTargetValue.cpp @@ -1,11 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PetTargetValue.h" + #include "Playerbots.h" -Unit* PetTargetValue::Calculate() -{ - return botAI->GetBot()->GetPet(); -} +Unit* PetTargetValue::Calculate() { return botAI->GetBot()->GetPet(); } diff --git a/src/strategy/values/PetTargetValue.h b/src/strategy/values/PetTargetValue.h index 7c6d9d1b..bb2a7005 100644 --- a/src/strategy/values/PetTargetValue.h +++ b/src/strategy/values/PetTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PETTARGETVALUE_H @@ -12,10 +13,10 @@ class Unit; class PetTargetValue : public UnitCalculatedValue { - public: - PetTargetValue(PlayerbotAI* botAI, std::string const name = "pet target") : UnitCalculatedValue(botAI, name) { } +public: + PetTargetValue(PlayerbotAI* botAI, std::string const name = "pet target") : UnitCalculatedValue(botAI, name) {} - Unit* Calculate() override; + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/PositionValue.cpp b/src/strategy/values/PositionValue.cpp index 6f0dd87d..a914ef3f 100644 --- a/src/strategy/values/PositionValue.cpp +++ b/src/strategy/values/PositionValue.cpp @@ -1,11 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PositionValue.h" + #include "Playerbots.h" -PositionValue::PositionValue(PlayerbotAI* botAI, std::string const name) : ManualSetValue(botAI, positions, name) +PositionValue::PositionValue(PlayerbotAI* botAI, std::string const name) + : ManualSetValue(botAI, positions, name) { } @@ -59,7 +62,4 @@ bool PositionValue::Load(std::string const text) return true; } -WorldPosition CurrentPositionValue::Calculate() -{ - return WorldPosition(bot); -} +WorldPosition CurrentPositionValue::Calculate() { return WorldPosition(bot); } diff --git a/src/strategy/values/PositionValue.h b/src/strategy/values/PositionValue.h index e7bcabe3..42b0aaf8 100644 --- a/src/strategy/values/PositionValue.h +++ b/src/strategy/values/PositionValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_POSITIONVALUE_H @@ -12,65 +13,63 @@ class PlayerbotAI; class PositionInfo { - public: - PositionInfo() : valueSet(false), x(0), y(0), z(0), mapId(0) { } - PositionInfo(PositionInfo const& other) : valueSet(other.valueSet), x(other.x), y(other.y), z(other.z), mapId(other.mapId) { } +public: + PositionInfo() : valueSet(false), x(0), y(0), z(0), mapId(0) {} + PositionInfo(PositionInfo const& other) + : valueSet(other.valueSet), x(other.x), y(other.y), z(other.z), mapId(other.mapId) + { + } - void Set(float newX, float newY, float newZ, uint32 newMapId) - { - x = newX; - y = newY; - z = newZ; - mapId = newMapId; - valueSet = true; - } + void Set(float newX, float newY, float newZ, uint32 newMapId) + { + x = newX; + y = newY; + z = newZ; + mapId = newMapId; + valueSet = true; + } - void Reset() - { - valueSet = false; - } + void Reset() { valueSet = false; } - bool isSet() - { - return valueSet; - } + bool isSet() { return valueSet; } - float x; - float y; - float z; - bool valueSet; - uint32 mapId; + float x; + float y; + float z; + bool valueSet; + uint32 mapId; }; typedef std::map PositionMap; class PositionValue : public ManualSetValue { - public: - PositionValue(PlayerbotAI* botAI, std::string const name = "position"); +public: + PositionValue(PlayerbotAI* botAI, std::string const name = "position"); - std::string const Save() override; - bool Load(std::string const value) override; + std::string const Save() override; + bool Load(std::string const value) override; - private: - PositionMap positions; +private: + PositionMap positions; }; class CurrentPositionValue : public LogCalculatedValue { - public: - CurrentPositionValue(PlayerbotAI* botAI, std::string const name = "current position", uint32 checkInterval = 1) : LogCalculatedValue(botAI, name, checkInterval) - { - minChangeInterval = 60; - logLength = 30; - }; +public: + CurrentPositionValue(PlayerbotAI* botAI, std::string const name = "current position", uint32 checkInterval = 1) + : LogCalculatedValue(botAI, name, checkInterval) + { + minChangeInterval = 60; + logLength = 30; + }; - bool EqualToLast(WorldPosition value) override - { - return value.fDist(lastValue) < sPlayerbotAIConfig->tooCloseDistance; - } + bool EqualToLast(WorldPosition value) override + { + return value.fDist(lastValue) < sPlayerbotAIConfig->tooCloseDistance; + } - WorldPosition Calculate() override; + WorldPosition Calculate() override; }; #endif diff --git a/src/strategy/values/PossibleRpgTargetsValue.cpp b/src/strategy/values/PossibleRpgTargetsValue.cpp index acea1307..55ee94b3 100644 --- a/src/strategy/values/PossibleRpgTargetsValue.cpp +++ b/src/strategy/values/PossibleRpgTargetsValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PossibleRpgTargetsValue.h" + #include "CellImpl.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" @@ -11,7 +13,8 @@ std::vector PossibleRpgTargetsValue::allowedNpcFlags; -PossibleRpgTargetsValue::PossibleRpgTargetsValue(PlayerbotAI* botAI, float range) : NearestUnitsValue(botAI, "possible rpg targets", range, true) +PossibleRpgTargetsValue::PossibleRpgTargetsValue(PlayerbotAI* botAI, float range) + : NearestUnitsValue(botAI, "possible rpg targets", range, true) { if (allowedNpcFlags.empty()) { diff --git a/src/strategy/values/PossibleRpgTargetsValue.h b/src/strategy/values/PossibleRpgTargetsValue.h index f7663bfb..02df8701 100644 --- a/src/strategy/values/PossibleRpgTargetsValue.h +++ b/src/strategy/values/PossibleRpgTargetsValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_POSSIBLERPGTARGETSVALUE_H @@ -12,14 +13,14 @@ class PlayerbotAI; class PossibleRpgTargetsValue : public NearestUnitsValue { - public: - PossibleRpgTargetsValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->rpgDistance); +public: + PossibleRpgTargetsValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->rpgDistance); - static std::vector allowedNpcFlags; + static std::vector allowedNpcFlags; - protected: - void FindUnits(std::list& targets) override; - bool AcceptUnit(Unit* unit) override; +protected: + void FindUnits(std::list& targets) override; + bool AcceptUnit(Unit* unit) override; }; #endif diff --git a/src/strategy/values/PossibleTargetsValue.cpp b/src/strategy/values/PossibleTargetsValue.cpp index ddef5ccc..f4622298 100644 --- a/src/strategy/values/PossibleTargetsValue.cpp +++ b/src/strategy/values/PossibleTargetsValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PossibleTargetsValue.h" + #include "AttackersValue.h" #include "CellImpl.h" #include "DBCStructure.h" @@ -22,10 +24,7 @@ void PossibleTargetsValue::FindUnits(std::list& targets) Cell::VisitAllObjects(bot, searcher, range); } -bool PossibleTargetsValue::AcceptUnit(Unit* unit) -{ - return AttackersValue::IsPossibleTarget(unit, bot, range); -} +bool PossibleTargetsValue::AcceptUnit(Unit* unit) { return AttackersValue::IsPossibleTarget(unit, bot, range); } void PossibleTriggersValue::FindUnits(std::list& targets) { @@ -36,23 +35,30 @@ void PossibleTriggersValue::FindUnits(std::list& targets) bool PossibleTriggersValue::AcceptUnit(Unit* unit) { - if (!unit->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE)) { + if (!unit->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE)) + { return false; } - Unit::AuraEffectList const& aurasPeriodicTriggerSpell = unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL); - Unit::AuraEffectList const& aurasPeriodicTriggerWithValueSpell = unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE); - for (const Unit::AuraEffectList& list : {aurasPeriodicTriggerSpell, aurasPeriodicTriggerWithValueSpell}) { + Unit::AuraEffectList const& aurasPeriodicTriggerSpell = + unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL); + Unit::AuraEffectList const& aurasPeriodicTriggerWithValueSpell = + unit->GetAuraEffectsByType(SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE); + for (const Unit::AuraEffectList& list : {aurasPeriodicTriggerSpell, aurasPeriodicTriggerWithValueSpell}) + { for (auto i = list.begin(); i != list.end(); ++i) { AuraEffect* aurEff = *i; const SpellInfo* spellInfo = aurEff->GetSpellInfo(); if (!spellInfo) continue; - const SpellInfo* triggerSpellInfo = sSpellMgr->GetSpellInfo(spellInfo->Effects[aurEff->GetEffIndex()].TriggerSpell); + const SpellInfo* triggerSpellInfo = + sSpellMgr->GetSpellInfo(spellInfo->Effects[aurEff->GetEffIndex()].TriggerSpell); if (!triggerSpellInfo) continue; - for (int j = 0; j < MAX_SPELL_EFFECTS; j++) { - if (triggerSpellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) { + for (int j = 0; j < MAX_SPELL_EFFECTS; j++) + { + if (triggerSpellInfo->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) + { return true; } } diff --git a/src/strategy/values/PossibleTargetsValue.h b/src/strategy/values/PossibleTargetsValue.h index 1ffcdd51..02a07cad 100644 --- a/src/strategy/values/PossibleTargetsValue.h +++ b/src/strategy/values/PossibleTargetsValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_POSSIBLETARGETSVALUE_H @@ -12,29 +13,38 @@ class PlayerbotAI; class PossibleTargetsValue : public NearestUnitsValue { - public: - PossibleTargetsValue(PlayerbotAI* botAI, std::string const name = "possible targets", float range = sPlayerbotAIConfig->sightDistance, bool ignoreLos = false): - NearestUnitsValue(botAI, name, range, ignoreLos) { } +public: + PossibleTargetsValue(PlayerbotAI* botAI, std::string const name = "possible targets", + float range = sPlayerbotAIConfig->sightDistance, bool ignoreLos = false) + : NearestUnitsValue(botAI, name, range, ignoreLos) + { + } - protected: - void FindUnits(std::list& targets) override; - bool AcceptUnit(Unit* unit) override; +protected: + void FindUnits(std::list& targets) override; + bool AcceptUnit(Unit* unit) override; }; class AllTargetsValue : public PossibleTargetsValue { - public: - AllTargetsValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) : PossibleTargetsValue(botAI, "all targets", range, true) { } +public: + AllTargetsValue(PlayerbotAI* botAI, float range = sPlayerbotAIConfig->sightDistance) + : PossibleTargetsValue(botAI, "all targets", range, true) + { + } }; class PossibleTriggersValue : public NearestUnitsValue { - public: - PossibleTriggersValue(PlayerbotAI* botAI, std::string const name = "possible triggers", float range = 15.0f, bool ignoreLos = true): - NearestUnitsValue(botAI, name, range, ignoreLos, 1 * 1000) { } +public: + PossibleTriggersValue(PlayerbotAI* botAI, std::string const name = "possible triggers", float range = 15.0f, + bool ignoreLos = true) + : NearestUnitsValue(botAI, name, range, ignoreLos, 1 * 1000) + { + } - protected: - void FindUnits(std::list& targets) override; - bool AcceptUnit(Unit* unit) override; +protected: + void FindUnits(std::list& targets) override; + bool AcceptUnit(Unit* unit) override; }; #endif diff --git a/src/strategy/values/PvpValues.cpp b/src/strategy/values/PvpValues.cpp index b1cae34d..8a497add 100644 --- a/src/strategy/values/PvpValues.cpp +++ b/src/strategy/values/PvpValues.cpp @@ -1,10 +1,12 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "PvpValues.h" -#include "BattlegroundMgr.h" + #include "BattlegroundEY.h" +#include "BattlegroundMgr.h" #include "BattlegroundWS.h" #include "Playerbots.h" #include "ServerFacade.h" @@ -17,12 +19,14 @@ Unit* FlagCarrierValue::Calculate() { if (botAI->GetBot()->GetBattlegroundTypeId() == BattlegroundTypeId::BATTLEGROUND_WS) { - BattlegroundWS *bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); + BattlegroundWS* bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground(); - if ((!sameTeam && bot->GetTeamId() == TEAM_HORDE || (sameTeam && bot->GetTeamId() == TEAM_ALLIANCE)) && !bg->GetFlagPickerGUID(TEAM_HORDE).IsEmpty()) + if ((!sameTeam && bot->GetTeamId() == TEAM_HORDE || (sameTeam && bot->GetTeamId() == TEAM_ALLIANCE)) && + !bg->GetFlagPickerGUID(TEAM_HORDE).IsEmpty()) carrier = ObjectAccessor::GetPlayer(bg->GetBgMap(), bg->GetFlagPickerGUID(TEAM_HORDE)); - if ((!sameTeam && bot->GetTeamId() == TEAM_ALLIANCE || (sameTeam && bot->GetTeamId() == TEAM_HORDE)) && !bg->GetFlagPickerGUID(TEAM_ALLIANCE).IsEmpty()) + if ((!sameTeam && bot->GetTeamId() == TEAM_ALLIANCE || (sameTeam && bot->GetTeamId() == TEAM_HORDE)) && + !bg->GetFlagPickerGUID(TEAM_ALLIANCE).IsEmpty()) carrier = ObjectAccessor::GetPlayer(bg->GetBgMap(), bg->GetFlagPickerGUID(TEAM_ALLIANCE)); if (carrier) @@ -73,10 +77,14 @@ std::vector BgMastersValue::Calculate() BattlegroundTypeId bgTypeId = (BattlegroundTypeId)stoi(qualifier); std::vector entries; - std::map>> battleMastersCache = sRandomPlayerbotMgr->getBattleMastersCache(); - entries.insert(entries.end(), battleMastersCache[TEAM_NEUTRAL][bgTypeId].begin(), battleMastersCache[TEAM_NEUTRAL][bgTypeId].end()); - entries.insert(entries.end(), battleMastersCache[TEAM_ALLIANCE][bgTypeId].begin(), battleMastersCache[TEAM_ALLIANCE][bgTypeId].end()); - entries.insert(entries.end(), battleMastersCache[TEAM_HORDE][bgTypeId].begin(), battleMastersCache[TEAM_HORDE][bgTypeId].end()); + std::map>> battleMastersCache = + sRandomPlayerbotMgr->getBattleMastersCache(); + entries.insert(entries.end(), battleMastersCache[TEAM_NEUTRAL][bgTypeId].begin(), + battleMastersCache[TEAM_NEUTRAL][bgTypeId].end()); + entries.insert(entries.end(), battleMastersCache[TEAM_ALLIANCE][bgTypeId].begin(), + battleMastersCache[TEAM_ALLIANCE][bgTypeId].end()); + entries.insert(entries.end(), battleMastersCache[TEAM_HORDE][bgTypeId].begin(), + battleMastersCache[TEAM_HORDE][bgTypeId].end()); std::vector bmGuids; @@ -116,9 +124,9 @@ CreatureData const* BgMasterValue::NearestBm(bool allowDead) WorldPosition bmPos(bmPair->mapid, bmPair->posX, bmPair->posY, bmPair->posZ, bmPair->orientation); - float dist = botPos.distance(bmPos); //This is the aproximate travel distance. + float dist = botPos.distance(bmPos); // This is the aproximate travel distance. - //Did we already find a closer unit that is not dead? + // Did we already find a closer unit that is not dead? if (rbmPair && rDist <= dist) continue; @@ -128,7 +136,7 @@ CreatureData const* BgMasterValue::NearestBm(bool allowDead) FactionTemplateEntry const* bmFactionEntry = sFactionTemplateStore.LookupEntry(bmTemplate->faction); - //Is the unit hostile? + // Is the unit hostile? if (Unit::GetFactionReactionTo(bot->GetFactionTemplateEntry(), bmFactionEntry) < REP_NEUTRAL) continue; @@ -137,7 +145,7 @@ CreatureData const* BgMasterValue::NearestBm(bool allowDead) if (!area) continue; - //Is the area hostile? + // Is the area hostile? if (area->team == 4 && bot->GetTeamId() == TEAM_ALLIANCE) continue; if (area->team == 2 && bot->GetTeamId() == TEAM_HORDE) @@ -150,7 +158,7 @@ CreatureData const* BgMasterValue::NearestBm(bool allowDead) if (!unit) continue; - //Is the unit dead? + // Is the unit dead? if (unit->getDeathState() == DeathState::Dead) continue; } @@ -184,7 +192,8 @@ BattlegroundTypeId RpgBgTypeValue::Calculate() if (bot->InBattlegroundQueueForBattlegroundQueueType(queueTypeId)) continue; - std::map>> battleMastersCache = sRandomPlayerbotMgr->getBattleMastersCache(); + std::map>> battleMastersCache = + sRandomPlayerbotMgr->getBattleMastersCache(); for (auto& entry : battleMastersCache[TEAM_NEUTRAL][bgTypeId]) if (entry == guidPosition.GetEntry()) diff --git a/src/strategy/values/PvpValues.h b/src/strategy/values/PvpValues.h index e39c1b80..9f4a26bf 100644 --- a/src/strategy/values/PvpValues.h +++ b/src/strategy/values/PvpValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_PVPVALUES_H @@ -14,58 +15,60 @@ class Unit; class BgTypeValue : public ManualSetValue { - public: - BgTypeValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0, "bg type") { } +public: + BgTypeValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0, "bg type") {} }; class ArenaTypeValue : public ManualSetValue { - public: - ArenaTypeValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0, "arena type") { } +public: + ArenaTypeValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0, "arena type") {} }; class BgRoleValue : public ManualSetValue { - public: - BgRoleValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0, "bg role") { } +public: + BgRoleValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0, "bg role") {} }; class BgMastersValue : public SingleCalculatedValue>, public Qualified { - public: - BgMastersValue(PlayerbotAI* botAI) : SingleCalculatedValue>(botAI, "bg masters") { } +public: + BgMastersValue(PlayerbotAI* botAI) : SingleCalculatedValue>(botAI, "bg masters") {} - std::vector Calculate() override; + std::vector Calculate() override; }; class BgMasterValue : public CDPairCalculatedValue, public Qualified { - public: - BgMasterValue(PlayerbotAI* botAI) : CDPairCalculatedValue(botAI, "bg master", 60) { } +public: + BgMasterValue(PlayerbotAI* botAI) : CDPairCalculatedValue(botAI, "bg master", 60) {} - CreatureData const* Calculate() override; - CreatureData const* NearestBm(bool allowDead = true); + CreatureData const* Calculate() override; + CreatureData const* NearestBm(bool allowDead = true); }; class RpgBgTypeValue : public CalculatedValue { - public: - RpgBgTypeValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "rpg bg type") { } +public: + RpgBgTypeValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "rpg bg type") {} - BattlegroundTypeId Calculate() override; + BattlegroundTypeId Calculate() override; }; class FlagCarrierValue : public UnitCalculatedValue { - public: - FlagCarrierValue(PlayerbotAI* botAI, bool sameTeam = false, bool ignoreRange = false) : - UnitCalculatedValue(botAI), sameTeam(sameTeam), ignoreRange(ignoreRange) { } +public: + FlagCarrierValue(PlayerbotAI* botAI, bool sameTeam = false, bool ignoreRange = false) + : UnitCalculatedValue(botAI), sameTeam(sameTeam), ignoreRange(ignoreRange) + { + } - Unit* Calculate() override; + Unit* Calculate() override; - private: - bool sameTeam; - bool ignoreRange; +private: + bool sameTeam; + bool ignoreRange; }; #endif diff --git a/src/strategy/values/QuestValues.cpp b/src/strategy/values/QuestValues.cpp index 18ed7f41..072fdf58 100644 --- a/src/strategy/values/QuestValues.cpp +++ b/src/strategy/values/QuestValues.cpp @@ -1,440 +1,448 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "QuestValues.h" + #include "MapMgr.h" #include "Playerbots.h" #include "SharedValueContext.h" -//What kind of a relation does this entry have with this quest. +// What kind of a relation does this entry have with this quest. entryQuestRelationMap EntryQuestRelationMapValue::Calculate() { - entryQuestRelationMap rMap; + entryQuestRelationMap rMap; - for (auto relation : *sObjectMgr->GetCreatureQuestRelationMap()) - rMap[relation.first][relation.second] |= (int)QuestRelationFlag::questGiver; + for (auto relation : *sObjectMgr->GetCreatureQuestRelationMap()) + rMap[relation.first][relation.second] |= (int)QuestRelationFlag::questGiver; - for (auto relation : *sObjectMgr->GetCreatureQuestInvolvedRelationMap()) - rMap[relation.first][relation.second] |= (int)QuestRelationFlag::questTaker; + for (auto relation : *sObjectMgr->GetCreatureQuestInvolvedRelationMap()) + rMap[relation.first][relation.second] |= (int)QuestRelationFlag::questTaker; - for (auto relation : *sObjectMgr->GetGOQuestRelationMap()) - rMap[-(int32)relation.first][relation.second] |= (int)QuestRelationFlag::questGiver; + for (auto relation : *sObjectMgr->GetGOQuestRelationMap()) + rMap[-(int32)relation.first][relation.second] |= (int)QuestRelationFlag::questGiver; - for (auto relation : *sObjectMgr->GetGOQuestInvolvedRelationMap()) - rMap[-(int32)relation.first][relation.second] |= (int)QuestRelationFlag::questGiver; + for (auto relation : *sObjectMgr->GetGOQuestInvolvedRelationMap()) + rMap[-(int32)relation.first][relation.second] |= (int)QuestRelationFlag::questGiver; - //Quest objectives - ObjectMgr::QuestMap const& questMap = sObjectMgr->GetQuestTemplates(); + // Quest objectives + ObjectMgr::QuestMap const& questMap = sObjectMgr->GetQuestTemplates(); - for (auto& questItr : questMap) - { - uint32 questId = questItr.first; - Quest* quest = questItr.second; + for (auto& questItr : questMap) + { + uint32 questId = questItr.first; + Quest* quest = questItr.second; - for (uint32 objective = 0; objective < QUEST_OBJECTIVES_COUNT; objective++) - { - uint32 relationFlag = 1 << objective; + for (uint32 objective = 0; objective < QUEST_OBJECTIVES_COUNT; objective++) + { + uint32 relationFlag = 1 << objective; - //Kill objective - if (quest->RequiredNpcOrGo[objective]) - rMap[quest->RequiredNpcOrGo[objective]][questId] |= relationFlag; + // Kill objective + if (quest->RequiredNpcOrGo[objective]) + rMap[quest->RequiredNpcOrGo[objective]][questId] |= relationFlag; - //Loot objective - if (quest->RequiredItemId[objective]) - { - for (auto& entry : GAI_VALUE2(std::vector, "item drop list", quest->RequiredItemId[objective])) - rMap[entry][questId] |= relationFlag; - } - } - } + // Loot objective + if (quest->RequiredItemId[objective]) + { + for (auto& entry : GAI_VALUE2(std::vector, "item drop list", quest->RequiredItemId[objective])) + rMap[entry][questId] |= relationFlag; + } + } + } - return rMap; + return rMap; } -//Get all the objective entries for a specific quest. +// Get all the objective entries for a specific quest. void FindQuestObjectData::GetObjectiveEntries() { relationMap = GAI_VALUE(entryQuestRelationMap, "entry quest relation"); } -//Data worker. Checks for a specific creature what quest they are needed for and puts them in the proper place in the quest map. +// Data worker. Checks for a specific creature what quest they are needed for and puts them in the proper place in the +// quest map. void FindQuestObjectData::operator()(CreatureData const& creData) { uint32 entry = creData.id1; - for (auto& relation : relationMap[entry]) - { - uint32 questId = relation.first; - uint32 flag = relation.second; + for (auto& relation : relationMap[entry]) + { + uint32 questId = relation.first; + uint32 flag = relation.second; data[questId][flag][entry].push_back(GuidPosition(creData)); - } + } } -//GameObject data worker. Checks for a specific gameObject what quest they are needed for and puts them in the proper place in the quest map. +// GameObject data worker. Checks for a specific gameObject what quest they are needed for and puts them in the proper +// place in the quest map. void FindQuestObjectData::operator()(GameObjectData const& goData) { int32 entry = goData.id * -1; - for (auto& relation : relationMap[entry]) - { - uint32 questId = relation.first; - uint32 flag = relation.second; + for (auto& relation : relationMap[entry]) + { + uint32 questId = relation.first; + uint32 flag = relation.second; data[questId][flag][entry].push_back(GuidPosition(goData)); - } + } } -//Goes past all creatures and gameobjects and creatures the full quest guid map. +// Goes past all creatures and gameobjects and creatures the full quest guid map. questGuidpMap QuestGuidpMapValue::Calculate() { - FindQuestObjectData worker; + FindQuestObjectData worker; for (auto const& itr : sObjectMgr->GetAllCreatureData()) worker(itr.second); for (auto const& itr : sObjectMgr->GetAllGOData()) worker(itr.second); - return worker.GetResult(); + return worker.GetResult(); } -//Selects all questgivers for a specific level (range). +// Selects all questgivers for a specific level (range). questGiverMap QuestGiversValue::Calculate() { - uint32 level = 0; - std::string const q = getQualifier(); - bool hasQualifier = !q.empty(); + uint32 level = 0; + std::string const q = getQualifier(); + bool hasQualifier = !q.empty(); - if (hasQualifier) - level = stoi(q); + if (hasQualifier) + level = stoi(q); - questGuidpMap questMap = GAI_VALUE(questGuidpMap, "quest guidp map"); + questGuidpMap questMap = GAI_VALUE(questGuidpMap, "quest guidp map"); - questGiverMap guidps; + questGiverMap guidps; - for (auto& qPair : questMap) - { - for (auto& entry : qPair.second[(int)QuestRelationFlag::questGiver]) - { - for (auto& guidp : entry.second) - { - uint32 questId = qPair.first; + for (auto& qPair : questMap) + { + for (auto& entry : qPair.second[(int)QuestRelationFlag::questGiver]) + { + for (auto& guidp : entry.second) + { + uint32 questId = qPair.first; - if (hasQualifier) - { - Quest const* quest = sObjectMgr->GetQuestTemplate(questId); + if (hasQualifier) + { + Quest const* quest = sObjectMgr->GetQuestTemplate(questId); - if (quest && (level < quest->GetMinLevel() || (int)level > quest->GetQuestLevel() + 10)) - continue; - } + if (quest && (level < quest->GetMinLevel() || (int)level > quest->GetQuestLevel() + 10)) + continue; + } - guidps[questId].push_back(guidp); - } - } - } + guidps[questId].push_back(guidp); + } + } + } - return guidps; + return guidps; } std::vector ActiveQuestGiversValue::Calculate() { questGiverMap qGivers = GAI_VALUE2(questGiverMap, "quest givers", bot->GetLevel()); - std::vector retQuestGivers; + std::vector retQuestGivers; - for (auto& qGiver : qGivers) - { - uint32 questId = qGiver.first; - Quest const* quest = sObjectMgr->GetQuestTemplate(questId); - if (!quest) - { - continue; - } + for (auto& qGiver : qGivers) + { + uint32 questId = qGiver.first; + Quest const* quest = sObjectMgr->GetQuestTemplate(questId); + if (!quest) + { + continue; + } - if (!bot->CanTakeQuest(quest, false)) - continue; + if (!bot->CanTakeQuest(quest, false)) + continue; - QuestStatus status = bot->GetQuestStatus(questId); + QuestStatus status = bot->GetQuestStatus(questId); - if (status != QUEST_STATUS_NONE) - continue; + if (status != QUEST_STATUS_NONE) + continue; - for (auto& guidp : qGiver.second) - { - CreatureTemplate const* creatureTemplate = guidp.GetCreatureTemplate(); + for (auto& guidp : qGiver.second) + { + CreatureTemplate const* creatureTemplate = guidp.GetCreatureTemplate(); - if (creatureTemplate) - { - if (bot->GetFactionReactionTo(bot->GetFactionTemplateEntry(), sFactionTemplateStore.LookupEntry(creatureTemplate->faction)) < REP_FRIENDLY) - continue; - } + if (creatureTemplate) + { + if (bot->GetFactionReactionTo(bot->GetFactionTemplateEntry(), + sFactionTemplateStore.LookupEntry(creatureTemplate->faction)) < + REP_FRIENDLY) + continue; + } - if (guidp.isDead()) - continue; + if (guidp.isDead()) + continue; - retQuestGivers.push_back(guidp); - } - } + retQuestGivers.push_back(guidp); + } + } - return retQuestGivers; + return retQuestGivers; } std::vector ActiveQuestTakersValue::Calculate() { - questGuidpMap questMap = GAI_VALUE(questGuidpMap, "quest guidp map"); + questGuidpMap questMap = GAI_VALUE(questGuidpMap, "quest guidp map"); - std::vector retQuestTakers; + std::vector retQuestTakers; - QuestStatusMap& questStatusMap = bot->getQuestStatusMap(); + QuestStatusMap& questStatusMap = bot->getQuestStatusMap(); - for (auto& questStatus : questStatusMap) - { - uint32 questId = questStatus.first; + for (auto& questStatus : questStatusMap) + { + uint32 questId = questStatus.first; - Quest const* quest = sObjectMgr->GetQuestTemplate(questId); + Quest const* quest = sObjectMgr->GetQuestTemplate(questId); - if (!quest) - { - continue; - } + if (!quest) + { + continue; + } - QuestStatus status = questStatus.second.Status; - if ((status != QUEST_STATUS_COMPLETE || bot->GetQuestRewardStatus(questId)) && (!quest->IsAutoComplete() || !bot->CanTakeQuest(quest, false))) - continue; + QuestStatus status = questStatus.second.Status; + if ((status != QUEST_STATUS_COMPLETE || bot->GetQuestRewardStatus(questId)) && + (!quest->IsAutoComplete() || !bot->CanTakeQuest(quest, false))) + continue; - auto q = questMap.find(questId); + auto q = questMap.find(questId); - if (q == questMap.end()) - continue; + if (q == questMap.end()) + continue; - auto qt = q->second.find((int) QuestRelationFlag::questTaker); + auto qt = q->second.find((int)QuestRelationFlag::questTaker); - if (qt == q->second.end()) - continue; + if (qt == q->second.end()) + continue; - for (auto& entry : qt->second) - { - if (entry.first > 0) - { - if (CreatureTemplate const* info = sObjectMgr->GetCreatureTemplate(entry.first)) - { - if (bot->GetFactionReactionTo(bot->GetFactionTemplateEntry(), sFactionTemplateStore.LookupEntry(info->faction)) < REP_FRIENDLY) + for (auto& entry : qt->second) + { + if (entry.first > 0) + { + if (CreatureTemplate const* info = sObjectMgr->GetCreatureTemplate(entry.first)) + { + if (bot->GetFactionReactionTo(bot->GetFactionTemplateEntry(), + sFactionTemplateStore.LookupEntry(info->faction)) < REP_FRIENDLY) continue; - } - } + } + } - for (auto& guidp : entry.second) - { - if (guidp.isDead()) - continue; + for (auto& guidp : entry.second) + { + if (guidp.isDead()) + continue; - retQuestTakers.push_back(guidp); - } - } - } + retQuestTakers.push_back(guidp); + } + } + } - return retQuestTakers; + return retQuestTakers; } std::vector ActiveQuestObjectivesValue::Calculate() { - questGuidpMap questMap = GAI_VALUE(questGuidpMap, "quest guidp map"); + questGuidpMap questMap = GAI_VALUE(questGuidpMap, "quest guidp map"); - std::vector retQuestObjectives; + std::vector retQuestObjectives; - QuestStatusMap& questStatusMap = bot->getQuestStatusMap(); + QuestStatusMap& questStatusMap = bot->getQuestStatusMap(); - for (auto& questStatus : questStatusMap) - { - uint32 questId = questStatus.first; + for (auto& questStatus : questStatusMap) + { + uint32 questId = questStatus.first; - Quest const* quest = sObjectMgr->GetQuestTemplate(questId); - if (!quest) - { - continue; - } + Quest const* quest = sObjectMgr->GetQuestTemplate(questId); + if (!quest) + { + continue; + } - QuestStatusData statusData = questStatus.second; - if (statusData.Status != QUEST_STATUS_INCOMPLETE) - continue; + QuestStatusData statusData = questStatus.second; + if (statusData.Status != QUEST_STATUS_INCOMPLETE) + continue; - for (uint32 objective = 0; objective < QUEST_OBJECTIVES_COUNT; objective++) - { - if (quest->RequiredItemCount[objective]) - { - uint32 reqCount = quest->RequiredItemCount[objective]; - uint32 hasCount = statusData.ItemCount[objective]; + for (uint32 objective = 0; objective < QUEST_OBJECTIVES_COUNT; objective++) + { + if (quest->RequiredItemCount[objective]) + { + uint32 reqCount = quest->RequiredItemCount[objective]; + uint32 hasCount = statusData.ItemCount[objective]; - if (!reqCount || hasCount >= reqCount) - continue; - } + if (!reqCount || hasCount >= reqCount) + continue; + } if (quest->RequiredNpcOrGoCount[objective]) - { - uint32 reqCount = quest->RequiredItemCount[objective]; - uint32 hasCount = statusData.CreatureOrGOCount[objective]; + { + uint32 reqCount = quest->RequiredItemCount[objective]; + uint32 hasCount = statusData.CreatureOrGOCount[objective]; - if (!reqCount || hasCount >= reqCount) - continue; - } + if (!reqCount || hasCount >= reqCount) + continue; + } - auto q = questMap.find(questId); + auto q = questMap.find(questId); - if (q == questMap.end()) - continue; + if (q == questMap.end()) + continue; - auto qt = q->second.find((int) QuestRelationFlag(1 << objective)); + auto qt = q->second.find((int)QuestRelationFlag(1 << objective)); - if (qt == q->second.end()) - continue; + if (qt == q->second.end()) + continue; - for (auto& entry : qt->second) - { - for (auto& guidp : entry.second) - { - if (guidp.isDead()) - continue; + for (auto& entry : qt->second) + { + for (auto& guidp : entry.second) + { + if (guidp.isDead()) + continue; - retQuestObjectives.push_back(guidp); + retQuestObjectives.push_back(guidp); } - } - } - } + } + } + } - return retQuestObjectives; + return retQuestObjectives; } uint8 FreeQuestLogSlotValue::Calculate() { - uint8 numQuest = 0; - for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) - { - uint32 questId = bot->GetQuestSlotQuestId(slot); + uint8 numQuest = 0; + for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) + { + uint32 questId = bot->GetQuestSlotQuestId(slot); - if (!questId) - continue; + if (!questId) + continue; - Quest const* quest = sObjectMgr->GetQuestTemplate(questId); - if (!quest) - continue; + Quest const* quest = sObjectMgr->GetQuestTemplate(questId); + if (!quest) + continue; - numQuest++; - } + numQuest++; + } - return MAX_QUEST_LOG_SIZE - numQuest; + return MAX_QUEST_LOG_SIZE - numQuest; } uint32 DialogStatusValue::getDialogStatus(Player* bot, int32 questgiver, uint32 questId) { - uint32 dialogStatus = DIALOG_STATUS_NONE; + uint32 dialogStatus = DIALOG_STATUS_NONE; - QuestRelationBounds rbounds; // QuestRelations (quest-giver) - QuestRelationBounds irbounds; // InvolvedRelations (quest-finisher) + QuestRelationBounds rbounds; // QuestRelations (quest-giver) + QuestRelationBounds irbounds; // InvolvedRelations (quest-finisher) - if (questgiver > 0) - { - rbounds = sObjectMgr->GetCreatureQuestRelationBounds(questgiver); - irbounds = sObjectMgr->GetCreatureQuestInvolvedRelationBounds(questgiver); - } - else - { - rbounds = sObjectMgr->GetGOQuestRelationBounds(questgiver * -1); - irbounds = sObjectMgr->GetGOQuestInvolvedRelationBounds(questgiver * -1); - } + if (questgiver > 0) + { + rbounds = sObjectMgr->GetCreatureQuestRelationBounds(questgiver); + irbounds = sObjectMgr->GetCreatureQuestInvolvedRelationBounds(questgiver); + } + else + { + rbounds = sObjectMgr->GetGOQuestRelationBounds(questgiver * -1); + irbounds = sObjectMgr->GetGOQuestInvolvedRelationBounds(questgiver * -1); + } - // Check markings for quest-finisher - for (QuestRelations::const_iterator itr = irbounds.first; itr != irbounds.second; ++itr) - { - if (questId && itr->second != questId) - continue; + // Check markings for quest-finisher + for (QuestRelations::const_iterator itr = irbounds.first; itr != irbounds.second; ++itr) + { + if (questId && itr->second != questId) + continue; - Quest const* pQuest = sObjectMgr->GetQuestTemplate(itr->second); - if (!pQuest) - { - continue; - } + Quest const* pQuest = sObjectMgr->GetQuestTemplate(itr->second); + if (!pQuest) + { + continue; + } uint32 dialogStatusNew = DIALOG_STATUS_NONE; - QuestStatus status = bot->GetQuestStatus(itr->second); + QuestStatus status = bot->GetQuestStatus(itr->second); - if ((status == QUEST_STATUS_COMPLETE && !bot->GetQuestRewardStatus(itr->second)) || - (pQuest->IsAutoComplete() && bot->CanTakeQuest(pQuest, false))) - { - if (pQuest->IsAutoComplete() && pQuest->IsRepeatable()) - { - dialogStatusNew = DIALOG_STATUS_REWARD_REP; - } - else - { - dialogStatusNew = DIALOG_STATUS_REWARD2; - } - } - else if (status == QUEST_STATUS_INCOMPLETE) - { - dialogStatusNew = DIALOG_STATUS_INCOMPLETE; - } + if ((status == QUEST_STATUS_COMPLETE && !bot->GetQuestRewardStatus(itr->second)) || + (pQuest->IsAutoComplete() && bot->CanTakeQuest(pQuest, false))) + { + if (pQuest->IsAutoComplete() && pQuest->IsRepeatable()) + { + dialogStatusNew = DIALOG_STATUS_REWARD_REP; + } + else + { + dialogStatusNew = DIALOG_STATUS_REWARD2; + } + } + else if (status == QUEST_STATUS_INCOMPLETE) + { + dialogStatusNew = DIALOG_STATUS_INCOMPLETE; + } - if (dialogStatusNew > dialogStatus) - { - dialogStatus = dialogStatusNew; - } - } + if (dialogStatusNew > dialogStatus) + { + dialogStatus = dialogStatusNew; + } + } - // check markings for quest-giver - for (QuestRelations::const_iterator itr = rbounds.first; itr != rbounds.second; ++itr) - { - if (questId && itr->second != questId) - continue; + // check markings for quest-giver + for (QuestRelations::const_iterator itr = rbounds.first; itr != rbounds.second; ++itr) + { + if (questId && itr->second != questId) + continue; - Quest const* pQuest = sObjectMgr->GetQuestTemplate(itr->second); - if (!pQuest) - { - continue; - } + Quest const* pQuest = sObjectMgr->GetQuestTemplate(itr->second); + if (!pQuest) + { + continue; + } uint32 dialogStatusNew = DIALOG_STATUS_NONE; - QuestStatus status = bot->GetQuestStatus(itr->second); + QuestStatus status = bot->GetQuestStatus(itr->second); - if (status == QUEST_STATUS_NONE) // For all other cases the mark is handled either at some place else, or with involved-relations already - { - if (bot->CanSeeStartQuest(pQuest)) - { - if (bot->SatisfyQuestLevel(pQuest, false)) - { - int32 lowLevelDiff = sWorld->getIntConfig(CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF); - if (pQuest->IsAutoComplete() || (pQuest->IsRepeatable() && bot->getQuestStatusMap()[itr->second].Status == QUEST_STATUS_REWARDED)) - { - dialogStatusNew = DIALOG_STATUS_REWARD_REP; - } - else if (lowLevelDiff < 0 || bot->GetLevel() <= bot->GetQuestLevel(pQuest) + uint32(lowLevelDiff)) - { - dialogStatusNew = DIALOG_STATUS_AVAILABLE; - } - else - { - dialogStatusNew = DIALOG_STATUS_LOW_LEVEL_AVAILABLE; - } - } - else - { - dialogStatusNew = DIALOG_STATUS_UNAVAILABLE; - } - } - } + if (status == QUEST_STATUS_NONE) // For all other cases the mark is handled either at some place else, or with + // involved-relations already + { + if (bot->CanSeeStartQuest(pQuest)) + { + if (bot->SatisfyQuestLevel(pQuest, false)) + { + int32 lowLevelDiff = sWorld->getIntConfig(CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF); + if (pQuest->IsAutoComplete() || + (pQuest->IsRepeatable() && + bot->getQuestStatusMap()[itr->second].Status == QUEST_STATUS_REWARDED)) + { + dialogStatusNew = DIALOG_STATUS_REWARD_REP; + } + else if (lowLevelDiff < 0 || bot->GetLevel() <= bot->GetQuestLevel(pQuest) + uint32(lowLevelDiff)) + { + dialogStatusNew = DIALOG_STATUS_AVAILABLE; + } + else + { + dialogStatusNew = DIALOG_STATUS_LOW_LEVEL_AVAILABLE; + } + } + else + { + dialogStatusNew = DIALOG_STATUS_UNAVAILABLE; + } + } + } - if (dialogStatusNew > dialogStatus) - { - dialogStatus = dialogStatusNew; - } - } + if (dialogStatusNew > dialogStatus) + { + dialogStatus = dialogStatusNew; + } + } - return dialogStatus; + return dialogStatus; } -uint32 DialogStatusValue::Calculate() -{ - return getDialogStatus(bot, stoi(getQualifier())); -} +uint32 DialogStatusValue::Calculate() { return getDialogStatus(bot, stoi(getQualifier())); } uint32 DialogStatusQuestValue::Calculate() { @@ -455,5 +463,6 @@ bool CanAcceptQuestLowLevelValue::Calculate() bool CanTurnInQuestValue::Calculate() { uint32 dialogStatus = AI_VALUE2(uint32, "dialog status", getQualifier()); - return dialogStatus == DIALOG_STATUS_REWARD2 || dialogStatus == DIALOG_STATUS_REWARD || dialogStatus == DIALOG_STATUS_REWARD_REP; + return dialogStatus == DIALOG_STATUS_REWARD2 || dialogStatus == DIALOG_STATUS_REWARD || + dialogStatus == DIALOG_STATUS_REWARD_REP; }; diff --git a/src/strategy/values/QuestValues.h b/src/strategy/values/QuestValues.h index 2facaa02..62e73b89 100644 --- a/src/strategy/values/QuestValues.h +++ b/src/strategy/values/QuestValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_QUESTVALUES_H @@ -17,13 +18,13 @@ struct GameObjectData; enum class QuestRelationFlag : uint32 { - none = 0, - objective1 = 1, - objective2 = 2, - objective3 = 4, - objective4 = 8, - questGiver = 16, - questTaker = 32, + none = 0, + objective1 = 1, + objective2 = 2, + objective3 = 4, + objective4 = 8, + questGiver = 16, + questTaker = 32, maxQuestRelationFlag = 64 }; @@ -44,135 +45,137 @@ typedef std::unordered_map questGuidpMap; // questId typedef std::unordered_map> questGiverMap; - -//Returns the quest relation Flags for all entries and quests +// Returns the quest relation Flags for all entries and quests class EntryQuestRelationMapValue : public SingleCalculatedValue { - public: - EntryQuestRelationMapValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "entry quest relation map") { } +public: + EntryQuestRelationMapValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "entry quest relation map") {} - entryQuestRelationMap Calculate() override; + entryQuestRelationMap Calculate() override; }; -//Generic quest object finder +// Generic quest object finder class FindQuestObjectData { - public: - FindQuestObjectData() { GetObjectiveEntries(); } +public: + FindQuestObjectData() { GetObjectiveEntries(); } - void GetObjectiveEntries(); - void operator()(CreatureData const& creatureData); - void operator()(GameObjectData const& gameobjectData); - questGuidpMap GetResult() const { return data; }; + void GetObjectiveEntries(); + void operator()(CreatureData const& creatureData); + void operator()(GameObjectData const& gameobjectData); + questGuidpMap GetResult() const { return data; }; - private: - std::unordered_map>> entryMap; - std::unordered_map>> itemMap; +private: + std::unordered_map>> entryMap; + std::unordered_map>> itemMap; - entryQuestRelationMap relationMap; + entryQuestRelationMap relationMap; - questGuidpMap data; + questGuidpMap data; }; -//All objects to start, do or finish a quest. +// All objects to start, do or finish a quest. class QuestGuidpMapValue : public SingleCalculatedValue { - public: - QuestGuidpMapValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "quest guidp map") { } +public: + QuestGuidpMapValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "quest guidp map") {} - questGuidpMap Calculate() override; + questGuidpMap Calculate() override; }; -//All questgivers and their quests that are Useful for a specific level +// All questgivers and their quests that are Useful for a specific level class QuestGiversValue : public SingleCalculatedValue, public Qualified { - public: - QuestGiversValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "quest givers") { } +public: + QuestGiversValue(PlayerbotAI* botAI) : SingleCalculatedValue(botAI, "quest givers") {} - questGiverMap Calculate() override; + questGiverMap Calculate() override; }; -//All questgivers that have a quest for the bot. +// All questgivers that have a quest for the bot. class ActiveQuestGiversValue : public CalculatedValue> { - public: - ActiveQuestGiversValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "active quest givers", 5) { } +public: + ActiveQuestGiversValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "active quest givers", 5) {} - std::vector Calculate() override; + std::vector Calculate() override; }; -//All quest takers that the bot has a quest for. +// All quest takers that the bot has a quest for. class ActiveQuestTakersValue : public CalculatedValue> { - public: - ActiveQuestTakersValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "active quest takers", 5) { } +public: + ActiveQuestTakersValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "active quest takers", 5) {} - std::vector Calculate() override; + std::vector Calculate() override; }; -//All objectives that the bot still has to complete. +// All objectives that the bot still has to complete. class ActiveQuestObjectivesValue : public CalculatedValue> { - public: - ActiveQuestObjectivesValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "active quest objectives", 5) { } +public: + ActiveQuestObjectivesValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "active quest objectives", 5) {} - std::vector Calculate() override; + std::vector Calculate() override; }; -//Free quest log slots +// Free quest log slots class FreeQuestLogSlotValue : public Uint8CalculatedValue { - public: - FreeQuestLogSlotValue(PlayerbotAI* botAI) : Uint8CalculatedValue(botAI, "free quest log slots", 2) { } +public: + FreeQuestLogSlotValue(PlayerbotAI* botAI) : Uint8CalculatedValue(botAI, "free quest log slots", 2) {} - uint8 Calculate() override; + uint8 Calculate() override; }; -//Dialog status npc +// Dialog status npc class DialogStatusValue : public Uint32CalculatedValue, public Qualified { - public: - DialogStatusValue(PlayerbotAI* botAI, std::string const name = "dialog status") : Uint32CalculatedValue(botAI, name , 2) { } +public: + DialogStatusValue(PlayerbotAI* botAI, std::string const name = "dialog status") + : Uint32CalculatedValue(botAI, name, 2) + { + } - static uint32 getDialogStatus(Player* bot, int32 questgiver, uint32 questId = 0); + static uint32 getDialogStatus(Player* bot, int32 questgiver, uint32 questId = 0); - uint32 Calculate() override; + uint32 Calculate() override; }; -//Dialog status npc quest +// Dialog status npc quest class DialogStatusQuestValue : public DialogStatusValue { - public: - DialogStatusQuestValue(PlayerbotAI* botAI) : DialogStatusValue(botAI, "dialog status quest") { } +public: + DialogStatusQuestValue(PlayerbotAI* botAI) : DialogStatusValue(botAI, "dialog status quest") {} - uint32 Calculate() override; + uint32 Calculate() override; }; -//Can accept quest from npc +// Can accept quest from npc class CanAcceptQuestValue : public BoolCalculatedValue, public Qualified { - public: - CanAcceptQuestValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can accept quest npc") { } +public: + CanAcceptQuestValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can accept quest npc") {} - bool Calculate() override; + bool Calculate() override; }; -//Can accept low level quest from npc +// Can accept low level quest from npc class CanAcceptQuestLowLevelValue : public BoolCalculatedValue, public Qualified { - public: - CanAcceptQuestLowLevelValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can accept quest low level npc") { } +public: + CanAcceptQuestLowLevelValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can accept quest low level npc") {} - bool Calculate() override; + bool Calculate() override; }; -//Can hand in quest to npc +// Can hand in quest to npc class CanTurnInQuestValue : public BoolCalculatedValue, public Qualified { - public: - CanTurnInQuestValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can turn in quest npc") { } +public: + CanTurnInQuestValue(PlayerbotAI* botAI) : BoolCalculatedValue(botAI, "can turn in quest npc") {} - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/RTSCValues.cpp b/src/strategy/values/RTSCValues.cpp index c19ae600..6f404af4 100644 --- a/src/strategy/values/RTSCValues.cpp +++ b/src/strategy/values/RTSCValues.cpp @@ -1,24 +1,17 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RTSCValues.h" + #include "Playerbots.h" -bool SeeSpellLocationValue::EqualToLast(WorldPosition value) -{ - return value == lastValue; -} +bool SeeSpellLocationValue::EqualToLast(WorldPosition value) { return value == lastValue; } -WorldPosition SeeSpellLocationValue::Calculate() -{ - return value; -} +WorldPosition SeeSpellLocationValue::Calculate() { return value; } -std::string const RTSCSavedLocationValue::Save() -{ - return value.to_string(); -} +std::string const RTSCSavedLocationValue::Save() { return value.to_string(); } bool RTSCSavedLocationValue::Load(std::string const text) { diff --git a/src/strategy/values/RTSCValues.h b/src/strategy/values/RTSCValues.h index c625c152..0c7e0c05 100644 --- a/src/strategy/values/RTSCValues.h +++ b/src/strategy/values/RTSCValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RTSCVALUE_H @@ -13,32 +14,38 @@ class PlayerbotAI; class SeeSpellLocationValue : public LogCalculatedValue { - public: - SeeSpellLocationValue(PlayerbotAI* botAI, std::string const name = "see spell location") : LogCalculatedValue(botAI, name) { }; +public: + SeeSpellLocationValue(PlayerbotAI* botAI, std::string const name = "see spell location") + : LogCalculatedValue(botAI, name){}; - bool EqualToLast(WorldPosition value) override; - WorldPosition Calculate() override; + bool EqualToLast(WorldPosition value) override; + WorldPosition Calculate() override; }; class RTSCSelectedValue : public ManualSetValue { - public: - RTSCSelectedValue(PlayerbotAI* botAI, bool defaultvalue = false, std::string const name = "RTSC selected") : ManualSetValue(botAI, defaultvalue,name) { }; +public: + RTSCSelectedValue(PlayerbotAI* botAI, bool defaultvalue = false, std::string const name = "RTSC selected") + : ManualSetValue(botAI, defaultvalue, name){}; }; class RTSCNextSpellActionValue : public ManualSetValue { - public: - RTSCNextSpellActionValue(PlayerbotAI* botAI, std::string const defaultvalue = "", std::string const name = "RTSC next spell action") : ManualSetValue(botAI, defaultvalue, name) { }; +public: + RTSCNextSpellActionValue(PlayerbotAI* botAI, std::string const defaultvalue = "", + std::string const name = "RTSC next spell action") + : ManualSetValue(botAI, defaultvalue, name){}; }; class RTSCSavedLocationValue : public ManualSetValue, public Qualified { - public: - RTSCSavedLocationValue(PlayerbotAI* botAI, WorldPosition defaultvalue = WorldPosition(), std::string const name = "RTSC saved location") : ManualSetValue(botAI, defaultvalue, name) { }; +public: + RTSCSavedLocationValue(PlayerbotAI* botAI, WorldPosition defaultvalue = WorldPosition(), + std::string const name = "RTSC saved location") + : ManualSetValue(botAI, defaultvalue, name){}; - std::string const Save() override; - bool Load(std::string const text) override; + std::string const Save() override; + bool Load(std::string const text) override; }; #endif diff --git a/src/strategy/values/RandomBotUpdateValue.h b/src/strategy/values/RandomBotUpdateValue.h index c011c16a..d507a20f 100644 --- a/src/strategy/values/RandomBotUpdateValue.h +++ b/src/strategy/values/RandomBotUpdateValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RANDOMBOTUPDATEVALUE_H @@ -11,8 +12,11 @@ class PlayerbotAI; class RandomBotUpdateValue : public ManualSetValue { - public: - RandomBotUpdateValue(PlayerbotAI* botAI, std::string const name = "random bot update") : ManualSetValue(botAI, false, name) { } +public: + RandomBotUpdateValue(PlayerbotAI* botAI, std::string const name = "random bot update") + : ManualSetValue(botAI, false, name) + { + } }; #endif diff --git a/src/strategy/values/RangeValues.cpp b/src/strategy/values/RangeValues.cpp index 2a5bc379..ee537e9d 100644 --- a/src/strategy/values/RangeValues.cpp +++ b/src/strategy/values/RangeValues.cpp @@ -1,13 +1,13 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RangeValues.h" + #include "Playerbots.h" -RangeValue::RangeValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0.f, "range"), Qualified() -{ -} +RangeValue::RangeValue(PlayerbotAI* botAI) : ManualSetValue(botAI, 0.f, "range"), Qualified() {} std::string const RangeValue::Save() { diff --git a/src/strategy/values/RangeValues.h b/src/strategy/values/RangeValues.h index 0c3a5709..073e74d2 100644 --- a/src/strategy/values/RangeValues.h +++ b/src/strategy/values/RangeValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RANGEVALUES_H @@ -12,11 +13,11 @@ class PlayerbotAI; class RangeValue : public ManualSetValue, public Qualified { - public: - RangeValue(PlayerbotAI* botAI); +public: + RangeValue(PlayerbotAI* botAI); - std::string const Save() override; - bool Load(std::string const value) override; + std::string const Save() override; + bool Load(std::string const value) override; }; #endif diff --git a/src/strategy/values/RtiTargetValue.cpp b/src/strategy/values/RtiTargetValue.cpp index f8f2c714..c3d3ae34 100644 --- a/src/strategy/values/RtiTargetValue.cpp +++ b/src/strategy/values/RtiTargetValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RtiTargetValue.h" + #include "Playerbots.h" #include "ServerFacade.h" @@ -49,7 +51,7 @@ Unit* RtiTargetValue::Calculate() return nullptr; //////////////////////////////////////////////////////begin: delete below check - // Some units that need to be killed in battle are not on the list of attackers, + // Some units that need to be killed in battle are not on the list of attackers, // such as the Kor'kron Battle-Mage in Icecrown Citadel. // GuidVector attackers = context->GetValue("attackers")->Get(); @@ -59,7 +61,9 @@ Unit* RtiTargetValue::Calculate() //////////////////////////////////////////////////////end: delete below check Unit* unit = botAI->GetUnit(guid); - if (!unit || unit->isDead() || !bot->IsWithinLOSInMap(unit) || sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, unit), sPlayerbotAIConfig->sightDistance)) + if (!unit || unit->isDead() || !bot->IsWithinLOSInMap(unit) || + sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, unit), + sPlayerbotAIConfig->sightDistance)) return nullptr; return unit; diff --git a/src/strategy/values/RtiTargetValue.h b/src/strategy/values/RtiTargetValue.h index 5fd26112..94a8ac3d 100644 --- a/src/strategy/values/RtiTargetValue.h +++ b/src/strategy/values/RtiTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RTITARGETVALUE_H @@ -12,20 +13,26 @@ class Unit; class RtiTargetValue : public TargetValue { - public: - RtiTargetValue(PlayerbotAI* botAI, std::string const type = "rti", std::string const name = "rti target") : TargetValue(botAI, name), type(type) { } +public: + RtiTargetValue(PlayerbotAI* botAI, std::string const type = "rti", std::string const name = "rti target") + : TargetValue(botAI, name), type(type) + { + } - static int32 GetRtiIndex(std::string const rti); - Unit* Calculate() override; + static int32 GetRtiIndex(std::string const rti); + Unit* Calculate() override; - private: - std::string const type; +private: + std::string const type; }; class RtiCcTargetValue : public RtiTargetValue { - public: - RtiCcTargetValue(PlayerbotAI* botAI, std::string const name = "rti cc target") : RtiTargetValue(botAI, "rti cc", name) { } +public: + RtiCcTargetValue(PlayerbotAI* botAI, std::string const name = "rti cc target") + : RtiTargetValue(botAI, "rti cc", name) + { + } }; #endif diff --git a/src/strategy/values/RtiValue.cpp b/src/strategy/values/RtiValue.cpp index 442b784c..7161ecb7 100644 --- a/src/strategy/values/RtiValue.cpp +++ b/src/strategy/values/RtiValue.cpp @@ -1,18 +1,15 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "RtiValue.h" + #include "Playerbots.h" -RtiValue::RtiValue(PlayerbotAI* botAI) : ManualSetValue(botAI, "skull", "rti") -{ -} +RtiValue::RtiValue(PlayerbotAI* botAI) : ManualSetValue(botAI, "skull", "rti") {} -std::string const RtiValue::Save() -{ - return value; -} +std::string const RtiValue::Save() { return value; } bool RtiValue::Load(std::string const text) { @@ -20,14 +17,9 @@ bool RtiValue::Load(std::string const text) return true; } -RtiCcValue::RtiCcValue(PlayerbotAI* botAI) : ManualSetValue(botAI, "moon", "rti cc") -{ -} +RtiCcValue::RtiCcValue(PlayerbotAI* botAI) : ManualSetValue(botAI, "moon", "rti cc") {} -std::string const RtiCcValue::Save() -{ - return value; -} +std::string const RtiCcValue::Save() { return value; } bool RtiCcValue::Load(std::string const text) { diff --git a/src/strategy/values/RtiValue.h b/src/strategy/values/RtiValue.h index 8c423611..188e0957 100644 --- a/src/strategy/values/RtiValue.h +++ b/src/strategy/values/RtiValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_RTIVALUE_H @@ -11,20 +12,20 @@ class PlayerbotAI; class RtiValue : public ManualSetValue { - public: - RtiValue(PlayerbotAI* botAI); +public: + RtiValue(PlayerbotAI* botAI); - std::string const Save() override; - bool Load(std::string const text) override; + std::string const Save() override; + bool Load(std::string const text) override; }; class RtiCcValue : public ManualSetValue { - public: - RtiCcValue(PlayerbotAI* botAI); +public: + RtiCcValue(PlayerbotAI* botAI); - std::string const Save() override; - bool Load(std::string const text) override; + std::string const Save() override; + bool Load(std::string const text) override; }; #endif diff --git a/src/strategy/values/SelfTargetValue.cpp b/src/strategy/values/SelfTargetValue.cpp index 76e5c8d2..db5f5612 100644 --- a/src/strategy/values/SelfTargetValue.cpp +++ b/src/strategy/values/SelfTargetValue.cpp @@ -1,11 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SelfTargetValue.h" + #include "Playerbots.h" -Unit* SelfTargetValue::Calculate() -{ - return botAI->GetBot(); -} +Unit* SelfTargetValue::Calculate() { return botAI->GetBot(); } diff --git a/src/strategy/values/SelfTargetValue.h b/src/strategy/values/SelfTargetValue.h index 505fa50c..dbf84208 100644 --- a/src/strategy/values/SelfTargetValue.h +++ b/src/strategy/values/SelfTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SELFTARGETVALUE_H @@ -12,10 +13,10 @@ class Unit; class SelfTargetValue : public UnitCalculatedValue { - public: - SelfTargetValue(PlayerbotAI* botAI, std::string const name = "self target") : UnitCalculatedValue(botAI, name) { } +public: + SelfTargetValue(PlayerbotAI* botAI, std::string const name = "self target") : UnitCalculatedValue(botAI, name) {} - Unit* Calculate() override; + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/SharedValueContext.h b/src/strategy/values/SharedValueContext.h index 72ceca85..5edb41f4 100644 --- a/src/strategy/values/SharedValueContext.h +++ b/src/strategy/values/SharedValueContext.h @@ -1,75 +1,76 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SHAREDVALUECONTEXT_H #define _PLAYERBOT_SHAREDVALUECONTEXT_H -#include "NamedObjectContext.h" #include "LootValues.h" +#include "NamedObjectContext.h" +#include "Playerbots.h" #include "PvpValues.h" #include "QuestValues.h" -#include "Playerbots.h" class PlayerbotAI; class SharedValueContext : public NamedObjectContext { - public: - SharedValueContext() : NamedObjectContext(true) - { - creators["bg masters"] = &SharedValueContext::bg_masters; - creators["drop map"] = &SharedValueContext::drop_map; - creators["item drop list"] = &SharedValueContext::item_drop_list; - creators["entry loot list"] = &SharedValueContext::entry_loot_list; +public: + SharedValueContext() : NamedObjectContext(true) + { + creators["bg masters"] = &SharedValueContext::bg_masters; + creators["drop map"] = &SharedValueContext::drop_map; + creators["item drop list"] = &SharedValueContext::item_drop_list; + creators["entry loot list"] = &SharedValueContext::entry_loot_list; - creators["entry quest relation"] = &SharedValueContext::entry_quest_relation; - creators["quest guidp map"] = &SharedValueContext::quest_guidp_map; - creators["quest givers"] = &SharedValueContext::quest_givers; - } + creators["entry quest relation"] = &SharedValueContext::entry_quest_relation; + creators["quest guidp map"] = &SharedValueContext::quest_guidp_map; + creators["quest givers"] = &SharedValueContext::quest_givers; + } - private: - static UntypedValue* bg_masters(PlayerbotAI* botAI) { return new BgMastersValue(botAI); } - static UntypedValue* drop_map(PlayerbotAI* botAI) { return new DropMapValue(botAI); } - static UntypedValue* item_drop_list(PlayerbotAI* botAI) { return new ItemDropListValue(botAI); } - static UntypedValue* entry_loot_list(PlayerbotAI* botAI) { return new EntryLootListValue(botAI); } +private: + static UntypedValue* bg_masters(PlayerbotAI* botAI) { return new BgMastersValue(botAI); } + static UntypedValue* drop_map(PlayerbotAI* botAI) { return new DropMapValue(botAI); } + static UntypedValue* item_drop_list(PlayerbotAI* botAI) { return new ItemDropListValue(botAI); } + static UntypedValue* entry_loot_list(PlayerbotAI* botAI) { return new EntryLootListValue(botAI); } - static UntypedValue* entry_quest_relation(PlayerbotAI* botAI) { return new EntryQuestRelationMapValue(botAI); } - static UntypedValue* quest_guidp_map(PlayerbotAI* botAI) { return new QuestGuidpMapValue(botAI); } - static UntypedValue* quest_givers(PlayerbotAI* botAI) { return new QuestGiversValue(botAI); } + static UntypedValue* entry_quest_relation(PlayerbotAI* botAI) { return new EntryQuestRelationMapValue(botAI); } + static UntypedValue* quest_guidp_map(PlayerbotAI* botAI) { return new QuestGuidpMapValue(botAI); } + static UntypedValue* quest_givers(PlayerbotAI* botAI) { return new QuestGiversValue(botAI); } - //Global acess functions - public: - static SharedValueContext* instance() - { - static SharedValueContext instance; - return &instance; - } + // Global acess functions +public: + static SharedValueContext* instance() + { + static SharedValueContext instance; + return &instance; + } - template - Value* getGlobalValue(std::string const name) - { - NamedObjectContextList valueContexts; - valueContexts.Add(this); - PlayerbotAI* botAI = new PlayerbotAI(); - UntypedValue* value = valueContexts.GetContextObject(name, botAI); - delete botAI; - return dynamic_cast*>(value); - } + template + Value* getGlobalValue(std::string const name) + { + NamedObjectContextList valueContexts; + valueContexts.Add(this); + PlayerbotAI* botAI = new PlayerbotAI(); + UntypedValue* value = valueContexts.GetContextObject(name, botAI); + delete botAI; + return dynamic_cast*>(value); + } - template - Value* getGlobalValue(std::string const name, std::string const param) - { - return getGlobalValue((std::string(name) + "::" + param)); - } + template + Value* getGlobalValue(std::string const name, std::string const param) + { + return getGlobalValue((std::string(name) + "::" + param)); + } - template - Value* getGlobalValue(std::string const name, uint32 param) - { - std::ostringstream out; - out << param; - return getGlobalValue(name, out.str()); - } + template + Value* getGlobalValue(std::string const name, uint32 param) + { + std::ostringstream out; + out << param; + return getGlobalValue(name, out.str()); + } }; #define sSharedValueContext SharedValueContext::instance() diff --git a/src/strategy/values/SkipSpellsListValue.cpp b/src/strategy/values/SkipSpellsListValue.cpp index a41d22a7..12a28a9a 100644 --- a/src/strategy/values/SkipSpellsListValue.cpp +++ b/src/strategy/values/SkipSpellsListValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SkipSpellsListValue.h" + #include "Playerbots.h" std::string const SkipSpellsListValue::Save() diff --git a/src/strategy/values/SkipSpellsListValue.h b/src/strategy/values/SkipSpellsListValue.h index 584860d2..d1b55f67 100644 --- a/src/strategy/values/SkipSpellsListValue.h +++ b/src/strategy/values/SkipSpellsListValue.h @@ -1,26 +1,30 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SKIPSPELLSLISTVALUE_H #define _PLAYERBOT_SKIPSPELLSLISTVALUE_H -#include "Value.h" - #include +#include "Value.h" + class PlayerbotAI; class SkipSpellsListValue : public ManualSetValue&> { - public: - SkipSpellsListValue(PlayerbotAI* botAI, std::string const name = "skip spells list") : ManualSetValue&>(botAI, list, name) { } +public: + SkipSpellsListValue(PlayerbotAI* botAI, std::string const name = "skip spells list") + : ManualSetValue&>(botAI, list, name) + { + } - std::string const Save() override; - bool Load(std::string const value) override; + std::string const Save() override; + bool Load(std::string const value) override; - private: - std::set list; +private: + std::set list; }; #endif diff --git a/src/strategy/values/SnareTargetValue.cpp b/src/strategy/values/SnareTargetValue.cpp index 61862134..e3ec057c 100644 --- a/src/strategy/values/SnareTargetValue.cpp +++ b/src/strategy/values/SnareTargetValue.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SnareTargetValue.h" + #include "Playerbots.h" #include "ServerFacade.h" diff --git a/src/strategy/values/SnareTargetValue.h b/src/strategy/values/SnareTargetValue.h index 744743be..a637f369 100644 --- a/src/strategy/values/SnareTargetValue.h +++ b/src/strategy/values/SnareTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SNARETARGETVALUE_H @@ -13,11 +14,11 @@ class Unit; class SnareTargetValue : public UnitCalculatedValue, public Qualified { - public: - SnareTargetValue(PlayerbotAI* botAI) : UnitCalculatedValue(botAI, "snare target", 1) { } +public: + SnareTargetValue(PlayerbotAI* botAI) : UnitCalculatedValue(botAI, "snare target", 1) {} - protected: - Unit* Calculate() override; +protected: + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/SpellCastUsefulValue.cpp b/src/strategy/values/SpellCastUsefulValue.cpp index 277eff43..a0b4f68f 100644 --- a/src/strategy/values/SpellCastUsefulValue.cpp +++ b/src/strategy/values/SpellCastUsefulValue.cpp @@ -1,36 +1,41 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SpellCastUsefulValue.h" + #include "LastSpellCastValue.h" #include "Playerbots.h" bool SpellCastUsefulValue::Calculate() { uint32 spellid = AI_VALUE2(uint32, "spell id", qualifier); - if (!spellid) - return true; // there can be known alternatives + if (!spellid) + return true; // there can be known alternatives - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); - if (!spellInfo) - return true; // there can be known alternatives + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid); + if (!spellInfo) + return true; // there can be known alternatives - if ((spellInfo->Attributes & SPELL_ATTR0_ON_NEXT_SWING_NO_DAMAGE) != 0 || (spellInfo->Attributes & SPELL_ATTR0_ON_NEXT_SWING) != 0) - { - if (Spell* spell = bot->GetCurrentSpell(CURRENT_MELEE_SPELL)) - if (spell->m_spellInfo->Id == spellid && spell->IsNextMeleeSwingSpell() && bot->HasUnitState(UNIT_STATE_MELEE_ATTACKING)) - return false; - } - else - { + if ((spellInfo->Attributes & SPELL_ATTR0_ON_NEXT_SWING_NO_DAMAGE) != 0 || + (spellInfo->Attributes & SPELL_ATTR0_ON_NEXT_SWING) != 0) + { + if (Spell* spell = bot->GetCurrentSpell(CURRENT_MELEE_SPELL)) + if (spell->m_spellInfo->Id == spellid && spell->IsNextMeleeSwingSpell() && + bot->HasUnitState(UNIT_STATE_MELEE_ATTACKING)) + return false; + } + else + { // uint32 lastSpellId = AI_VALUE(LastSpellCast&, "last spell cast").id; // if (spellid == lastSpellId) // if (Spell* const pSpell = bot->FindCurrentSpellBySpellId(lastSpellId)) // return false; - } + } - if (spellInfo->IsAutoRepeatRangedSpell() && bot->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL) && bot->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)->m_spellInfo->Id == spellid) + if (spellInfo->IsAutoRepeatRangedSpell() && bot->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL) && + bot->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)->m_spellInfo->Id == spellid) { return false; } @@ -64,5 +69,5 @@ bool SpellCastUsefulValue::Calculate() return false; } - return true; + return true; } diff --git a/src/strategy/values/SpellCastUsefulValue.h b/src/strategy/values/SpellCastUsefulValue.h index 52879395..7064456e 100644 --- a/src/strategy/values/SpellCastUsefulValue.h +++ b/src/strategy/values/SpellCastUsefulValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SPELLCASTUSEFULVALUE_H @@ -12,10 +13,13 @@ class PlayerbotAI; class SpellCastUsefulValue : public BoolCalculatedValue, public Qualified { - public: - SpellCastUsefulValue(PlayerbotAI* botAI, std::string const name = "spell cast useful") : BoolCalculatedValue(botAI, name) { } +public: + SpellCastUsefulValue(PlayerbotAI* botAI, std::string const name = "spell cast useful") + : BoolCalculatedValue(botAI, name) + { + } - bool Calculate() override; + bool Calculate() override; }; #endif diff --git a/src/strategy/values/SpellIdValue.cpp b/src/strategy/values/SpellIdValue.cpp index 8cb8198f..859fa329 100644 --- a/src/strategy/values/SpellIdValue.cpp +++ b/src/strategy/values/SpellIdValue.cpp @@ -1,20 +1,18 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "SpellIdValue.h" + #include "ChatHelper.h" #include "Playerbots.h" #include "Vehicle.h" #include "World.h" -SpellIdValue::SpellIdValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "spell id", 20 * 1000) -{ -} +SpellIdValue::SpellIdValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "spell id", 20 * 1000) {} -VehicleSpellIdValue::VehicleSpellIdValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "vehicle spell id") -{ -} +VehicleSpellIdValue::VehicleSpellIdValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "vehicle spell id") {} uint32 SpellIdValue::Calculate() { @@ -55,7 +53,8 @@ uint32 SpellIdValue::Calculate() bool useByItem = false; for (uint8 i = 0; i < 3; ++i) { - if (spellInfo->Effects[i].Effect == SPELL_EFFECT_CREATE_ITEM && itemIds.find(spellInfo->Effects[i].ItemType) != itemIds.end()) + if (spellInfo->Effects[i].Effect == SPELL_EFFECT_CREATE_ITEM && + itemIds.find(spellInfo->Effects[i].ItemType) != itemIds.end()) { useByItem = true; break; @@ -63,7 +62,8 @@ uint32 SpellIdValue::Calculate() } char const* spellName = spellInfo->SpellName[loc]; - if (!useByItem && (tolower(spellName[0]) != firstSymbol || strlen(spellName) != spellLength || !Utf8FitTo(spellName, wnamepart))) + if (!useByItem && (tolower(spellName[0]) != firstSymbol || strlen(spellName) != spellLength || + !Utf8FitTo(spellName, wnamepart))) continue; spellIds.insert(spellId); @@ -86,14 +86,16 @@ uint32 SpellIdValue::Calculate() continue; char const* spellName = spellInfo->SpellName[loc]; - if (tolower(spellName[0]) != firstSymbol || strlen(spellName) != spellLength || !Utf8FitTo(spellName, wnamepart)) + if (tolower(spellName[0]) != firstSymbol || strlen(spellName) != spellLength || + !Utf8FitTo(spellName, wnamepart)) continue; spellIds.insert(spellId); } } - if (spellIds.empty()) return 0; + if (spellIds.empty()) + return 0; int32 saveMana = (int32)round(AI_VALUE(double, "mana save level")); uint32 rank = 1; @@ -106,7 +108,7 @@ uint32 SpellIdValue::Calculate() for (auto it = spellIds.rbegin(); it != spellIds.rend(); ++it) { auto spellId = *it; - const SpellInfo *pSpellInfo = sSpellMgr->GetSpellInfo(spellId); + const SpellInfo* pSpellInfo = sSpellMgr->GetSpellInfo(spellId); if (!pSpellInfo) continue; @@ -115,7 +117,10 @@ uint32 SpellIdValue::Calculate() // For atoi, the input string has to start with a digit, so lets search for the first digit size_t i = 0; for (; i < spellName.length(); i++) - { if (isdigit(spellName[i])) break; } + { + if (isdigit(spellName[i])) + break; + } // remove the first chars, which aren't digits spellName = spellName.substr(i, spellName.length() - i); @@ -156,7 +161,7 @@ uint32 SpellIdValue::Calculate() } } - return saveMana > 1 ? lowestSpellId : highestSpellId; + return saveMana > 1 ? lowestSpellId : highestSpellId; } uint32 VehicleSpellIdValue::Calculate() @@ -204,7 +209,8 @@ uint32 VehicleSpellIdValue::Calculate() continue; char const* spellName = spellInfo->SpellName[loc]; - if (tolower(spellName[0]) != firstSymbol || strlen(spellName) != spellLength || !Utf8FitTo(spellName, wnamepart)) + if (tolower(spellName[0]) != firstSymbol || strlen(spellName) != spellLength || + !Utf8FitTo(spellName, wnamepart)) continue; return spellId; diff --git a/src/strategy/values/SpellIdValue.h b/src/strategy/values/SpellIdValue.h index 685ce3d2..2e813c5e 100644 --- a/src/strategy/values/SpellIdValue.h +++ b/src/strategy/values/SpellIdValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_SPELLIDVALUE_H @@ -12,18 +13,18 @@ class PlayerbotAI; class SpellIdValue : public CalculatedValue, public Qualified { - public: - SpellIdValue(PlayerbotAI* botAI); +public: + SpellIdValue(PlayerbotAI* botAI); - uint32 Calculate() override; + uint32 Calculate() override; }; class VehicleSpellIdValue : public CalculatedValue, public Qualified { - public: - VehicleSpellIdValue(PlayerbotAI* botAI); +public: + VehicleSpellIdValue(PlayerbotAI* botAI); - uint32 Calculate() override; + uint32 Calculate() override; }; #endif diff --git a/src/strategy/values/Stances.cpp b/src/strategy/values/Stances.cpp index 27f5f34f..1cd97a39 100644 --- a/src/strategy/values/Stances.cpp +++ b/src/strategy/values/Stances.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "Stances.h" + #include "Arrow.h" #include "Event.h" #include "Playerbots.h" @@ -35,7 +37,7 @@ WorldLocation Stance::GetNearLocation(float angle, float distance) float x = target->GetPositionX() + cos(angle) * distance; float y = target->GetPositionY() + sin(angle) * distance; - float z = target->GetPositionZ(); + float z = target->GetPositionZ(); if (bot->IsWithinLOS(x, y, z)) return WorldLocation(bot->GetMapId(), x, y, z); @@ -52,15 +54,9 @@ WorldLocation MoveStance::GetLocationInternal() return GetNearLocation(angle, distance); } -std::string const Stance::GetTargetName() -{ - return "current target"; -} +std::string const Stance::GetTargetName() { return "current target"; } -float Stance::GetMaxDistance() -{ - return sPlayerbotAIConfig->contactDistance; -} +float Stance::GetMaxDistance() { return sPlayerbotAIConfig->contactDistance; } StanceValue::~StanceValue() { @@ -73,117 +69,32 @@ StanceValue::~StanceValue() class NearStance : public MoveStance { - public: - NearStance(PlayerbotAI* botAI) : MoveStance(botAI, "near") { } +public: + NearStance(PlayerbotAI* botAI) : MoveStance(botAI, "near") {} - float GetAngle() override - { - Unit* target = GetTarget(); + float GetAngle() override + { + Unit* target = GetTarget(); - if (target->GetVictim() && target->GetVictim()->GetGUID() == bot->GetGUID()) - return target->GetOrientation(); - - if (botAI->HasStrategy("behind", BOT_STATE_COMBAT)) - { - Unit* target = GetTarget(); - Group* group = bot->GetGroup(); - uint32 index = 0; - uint32 count = 0; - if (group) - { - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) - { - Player* member = ref->GetSource(); - if (member == bot) - index = count; - - if (member && !botAI->IsRanged(member) && !botAI->IsTank(member)) - count++; - } - } - - float angle = target->GetOrientation() + M_PI; - if (!count) - return angle; - - float increment = M_PI / 4 / count; - return round((angle + index * increment - M_PI / 4) * 10.0f) / 10.0f; - } - - float angle = GetFollowAngle() + target->GetOrientation(); - if (Player* master = GetMaster()) - angle -= master->GetOrientation(); - - return angle; - } -}; - -class TankStance : public MoveStance -{ - public: - TankStance(PlayerbotAI* botAI) : MoveStance(botAI, "tank") { } - - float GetAngle() override - { - Unit* target = GetTarget(); + if (target->GetVictim() && target->GetVictim()->GetGUID() == bot->GetGUID()) return target->GetOrientation(); - } -}; -class TurnBackStance : public MoveStance -{ - public: - TurnBackStance(PlayerbotAI* botAI) : MoveStance(botAI, "turnback") { } - - float GetAngle() override + if (botAI->HasStrategy("behind", BOT_STATE_COMBAT)) { Unit* target = GetTarget(); - - uint32 count = 0; - float angle = 0.0f; - if (Group* group = bot->GetGroup()) - { - for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) - { - if (Player* member = ref->GetSource()) - if (member != bot && botAI->IsRanged(member)) - { - angle += target->GetAngle(member); - ++count; - } - } - } - - if (!count) - return target->GetOrientation(); - - return std::round((angle / count) * 10.0f) / 10.0f + M_PI; - } -}; - -class BehindStance : public MoveStance -{ - public: - BehindStance(PlayerbotAI* botAI) : MoveStance(botAI, "behind") { } - - float GetAngle() override - { - Unit* target = GetTarget(); - + Group* group = bot->GetGroup(); uint32 index = 0; uint32 count = 0; - if (Group* group = bot->GetGroup()) + if (group) { for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { - if (Player* member = ref->GetSource()) - { - if (member == bot) - index = count; + Player* member = ref->GetSource(); + if (member == bot) + index = count; - if (!botAI->IsRanged(member) && !botAI->IsTank(member)) - ++count; - } + if (member && !botAI->IsRanged(member) && !botAI->IsTank(member)) + count++; } } @@ -192,18 +103,98 @@ class BehindStance : public MoveStance return angle; float increment = M_PI / 4 / count; - return std::round((angle + index * increment - M_PI / 4) * 10.0f) / 10.0f; + return round((angle + index * increment - M_PI / 4) * 10.0f) / 10.0f; } + + float angle = GetFollowAngle() + target->GetOrientation(); + if (Player* master = GetMaster()) + angle -= master->GetOrientation(); + + return angle; + } }; -StanceValue::StanceValue(PlayerbotAI* botAI) : ManualSetValue(botAI, new NearStance(botAI), "stance") +class TankStance : public MoveStance { -} +public: + TankStance(PlayerbotAI* botAI) : MoveStance(botAI, "tank") {} -std::string const StanceValue::Save() + float GetAngle() override + { + Unit* target = GetTarget(); + return target->GetOrientation(); + } +}; + +class TurnBackStance : public MoveStance { - return value ? value->getName() : "?"; -} +public: + TurnBackStance(PlayerbotAI* botAI) : MoveStance(botAI, "turnback") {} + + float GetAngle() override + { + Unit* target = GetTarget(); + + uint32 count = 0; + float angle = 0.0f; + if (Group* group = bot->GetGroup()) + { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { + if (Player* member = ref->GetSource()) + if (member != bot && botAI->IsRanged(member)) + { + angle += target->GetAngle(member); + ++count; + } + } + } + + if (!count) + return target->GetOrientation(); + + return std::round((angle / count) * 10.0f) / 10.0f + M_PI; + } +}; + +class BehindStance : public MoveStance +{ +public: + BehindStance(PlayerbotAI* botAI) : MoveStance(botAI, "behind") {} + + float GetAngle() override + { + Unit* target = GetTarget(); + + uint32 index = 0; + uint32 count = 0; + if (Group* group = bot->GetGroup()) + { + for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) + { + if (Player* member = ref->GetSource()) + { + if (member == bot) + index = count; + + if (!botAI->IsRanged(member) && !botAI->IsTank(member)) + ++count; + } + } + } + + float angle = target->GetOrientation() + M_PI; + if (!count) + return angle; + + float increment = M_PI / 4 / count; + return std::round((angle + index * increment - M_PI / 4) * 10.0f) / 10.0f; + } +}; + +StanceValue::StanceValue(PlayerbotAI* botAI) : ManualSetValue(botAI, new NearStance(botAI), "stance") {} + +std::string const StanceValue::Save() { return value ? value->getName() : "?"; } bool StanceValue::Load(std::string const name) { diff --git a/src/strategy/values/Stances.h b/src/strategy/values/Stances.h index e599ef92..a5a5e4dd 100644 --- a/src/strategy/values/Stances.h +++ b/src/strategy/values/Stances.h @@ -1,57 +1,58 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_STANCES_H #define _PLAYERBOT_STANCES_H -#include "Formations.h" #include "Action.h" +#include "Formations.h" class PlayerbotAI; class Unit; class Stance : public Formation { - public: - Stance(PlayerbotAI* botAI, std::string const name) : Formation(botAI, name) { } +public: + Stance(PlayerbotAI* botAI, std::string const name) : Formation(botAI, name) {} - WorldLocation GetLocation() override; - std::string const GetTargetName() override; - float GetMaxDistance() override; + WorldLocation GetLocation() override; + std::string const GetTargetName() override; + float GetMaxDistance() override; - protected: - virtual Unit* GetTarget(); - virtual WorldLocation GetLocationInternal() = 0; - virtual WorldLocation GetNearLocation(float angle, float distance); +protected: + virtual Unit* GetTarget(); + virtual WorldLocation GetLocationInternal() = 0; + virtual WorldLocation GetNearLocation(float angle, float distance); }; class MoveStance : public Stance { - public: - MoveStance(PlayerbotAI* botAI, std::string const name) : Stance(botAI, name) { } +public: + MoveStance(PlayerbotAI* botAI, std::string const name) : Stance(botAI, name) {} - protected: - WorldLocation GetLocationInternal(); - virtual float GetAngle() = 0; +protected: + WorldLocation GetLocationInternal(); + virtual float GetAngle() = 0; }; class StanceValue : public ManualSetValue { - public: - StanceValue(PlayerbotAI* botAI); - ~StanceValue(); +public: + StanceValue(PlayerbotAI* botAI); + ~StanceValue(); - std::string const Save() override; - bool Load(std::string const value) override; + std::string const Save() override; + bool Load(std::string const value) override; }; class SetStanceAction : public Action { - public: - SetStanceAction(PlayerbotAI* botAI) : Action(botAI, "set Stance") { } +public: + SetStanceAction(PlayerbotAI* botAI) : Action(botAI, "set Stance") {} - bool Execute(Event event) override; + bool Execute(Event event) override; }; #endif diff --git a/src/strategy/values/StatsValues.cpp b/src/strategy/values/StatsValues.cpp index 9ebc1468..ef80e79e 100644 --- a/src/strategy/values/StatsValues.cpp +++ b/src/strategy/values/StatsValues.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "StatsValues.h" + #include "Playerbots.h" #include "ServerFacade.h" @@ -18,7 +20,7 @@ uint8 HealthValue::Calculate() if (!target) return 100; - return (static_cast (target->GetHealth()) / target->GetMaxHealth()) * 100; + return (static_cast(target->GetHealth()) / target->GetMaxHealth()) * 100; } Unit* IsDeadValue::GetTarget() @@ -54,10 +56,7 @@ bool PetIsDeadValue::Calculate() return bot->GetPet() && bot->GetPet()->getDeathState() != DeathState::Alive; } -bool PetIsHappyValue::Calculate() -{ - return !bot->GetPet() || bot->GetPet()->GetHappinessState() == HAPPY; -} +bool PetIsHappyValue::Calculate() { return !bot->GetPet() || bot->GetPet()->GetHappinessState() == HAPPY; } Unit* RageValue::GetTarget() { @@ -86,7 +85,7 @@ uint8 EnergyValue::Calculate() if (!target) return 0; - return (static_cast (target->GetPower(POWER_ENERGY))); + return (static_cast(target->GetPower(POWER_ENERGY))); } Unit* ManaValue::GetTarget() @@ -101,7 +100,7 @@ uint8 ManaValue::Calculate() if (!target) return 100; - return (static_cast (target->GetPower(POWER_MANA)) / target->GetMaxPower(POWER_MANA)) * 100; + return (static_cast(target->GetPower(POWER_MANA)) / target->GetMaxPower(POWER_MANA)) * 100; } Unit* HasManaValue::GetTarget() @@ -128,8 +127,8 @@ Unit* ComboPointsValue::GetTarget() uint8 ComboPointsValue::Calculate() { Unit* target = GetTarget(); - if (!target || target->GetGUID() != bot->GetComboTargetGUID()) - return 0; + if (!target || target->GetGUID() != bot->GetComboTargetGUID()) + return 0; return bot->GetComboPoints(); } @@ -171,11 +170,13 @@ bool IsInCombatValue::Calculate() Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) { - Player *member = ObjectAccessor::FindPlayer(itr->guid); + Player* member = ObjectAccessor::FindPlayer(itr->guid); if (!member || member == bot) continue; - if (member->IsInCombat() && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(member, bot), sPlayerbotAIConfig->reactDistance)) + if (member->IsInCombat() && + sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(member, bot), + sPlayerbotAIConfig->reactDistance)) return true; } } @@ -184,10 +185,7 @@ bool IsInCombatValue::Calculate() return false; } -bool IsInCombatValue::EqualToLast(bool value) -{ - return value == lastValue; -} +bool IsInCombatValue::EqualToLast(bool value) { return value == lastValue; } uint8 BagSpaceValue::Calculate() { @@ -212,10 +210,9 @@ uint8 BagSpaceValue::Calculate() totalused += pBag->GetBagSize() - pBag->GetFreeSlots(); } } - } - return (static_cast (totalused) / total) * 100; + return (static_cast(totalused) / total) * 100; } uint8 DurabilityValue::Calculate() @@ -244,7 +241,7 @@ uint8 DurabilityValue::Calculate() if (total == 0) return 0; - return (static_cast (total) / totalMax) * 100; + return (static_cast(total) / totalMax) * 100; } Unit* SpeedValue::GetTarget() @@ -259,20 +256,11 @@ uint8 SpeedValue::Calculate() if (!target) return 100; - return (uint8) (100.0f * target->GetSpeedRate(MOVE_RUN)); + return (uint8)(100.0f * target->GetSpeedRate(MOVE_RUN)); } -bool IsInGroupValue::Calculate() -{ - return bot->GetGroup(); -} +bool IsInGroupValue::Calculate() { return bot->GetGroup(); } -bool ExperienceValue::EqualToLast(uint32 value) -{ - return value != lastValue; -} +bool ExperienceValue::EqualToLast(uint32 value) { return value != lastValue; } -uint32 ExperienceValue::Calculate() -{ - return bot->GetUInt32Value(PLAYER_XP); -} +uint32 ExperienceValue::Calculate() { return bot->GetUInt32Value(PLAYER_XP); } diff --git a/src/strategy/values/StatsValues.h b/src/strategy/values/StatsValues.h index 33e80fd7..f8e44740 100644 --- a/src/strategy/values/StatsValues.h +++ b/src/strategy/values/StatsValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_STATSVALUE_H @@ -13,148 +14,155 @@ class Unit; class HealthValue : public Uint8CalculatedValue, public Qualified { - public: - HealthValue(PlayerbotAI* botAI, std::string const name = "health") : Uint8CalculatedValue(botAI, name) { } +public: + HealthValue(PlayerbotAI* botAI, std::string const name = "health") : Uint8CalculatedValue(botAI, name) {} - Unit* GetTarget(); - uint8 Calculate() override; + Unit* GetTarget(); + uint8 Calculate() override; }; class IsDeadValue : public BoolCalculatedValue, public Qualified { - public: - IsDeadValue(PlayerbotAI* botAI, std::string const name = "dead") : BoolCalculatedValue(botAI, name) { } +public: + IsDeadValue(PlayerbotAI* botAI, std::string const name = "dead") : BoolCalculatedValue(botAI, name) {} - Unit* GetTarget(); - bool Calculate() override; + Unit* GetTarget(); + bool Calculate() override; }; class PetIsDeadValue : public BoolCalculatedValue { - public: - PetIsDeadValue(PlayerbotAI* botAI, std::string const name = "pet dead") : BoolCalculatedValue(botAI, name) { } +public: + PetIsDeadValue(PlayerbotAI* botAI, std::string const name = "pet dead") : BoolCalculatedValue(botAI, name) {} - bool Calculate() override; + bool Calculate() override; }; class PetIsHappyValue : public BoolCalculatedValue { - public: - PetIsHappyValue(PlayerbotAI* botAI, std::string const name = "pet happy") : BoolCalculatedValue(botAI, name) { } +public: + PetIsHappyValue(PlayerbotAI* botAI, std::string const name = "pet happy") : BoolCalculatedValue(botAI, name) {} - bool Calculate() override; + bool Calculate() override; }; class RageValue : public Uint8CalculatedValue, public Qualified { - public: - RageValue(PlayerbotAI* botAI, std::string const name = "rage") : Uint8CalculatedValue(botAI, name) { } +public: + RageValue(PlayerbotAI* botAI, std::string const name = "rage") : Uint8CalculatedValue(botAI, name) {} - Unit* GetTarget(); - uint8 Calculate() override; + Unit* GetTarget(); + uint8 Calculate() override; }; class EnergyValue : public Uint8CalculatedValue, public Qualified { - public: - EnergyValue(PlayerbotAI* botAI, std::string const name = "energy") : Uint8CalculatedValue(botAI, name) { } +public: + EnergyValue(PlayerbotAI* botAI, std::string const name = "energy") : Uint8CalculatedValue(botAI, name) {} - Unit* GetTarget(); - uint8 Calculate() override; + Unit* GetTarget(); + uint8 Calculate() override; }; class ManaValue : public Uint8CalculatedValue, public Qualified { - public: - ManaValue(PlayerbotAI* botAI, std::string const name = "mana") : Uint8CalculatedValue(botAI, name) { } +public: + ManaValue(PlayerbotAI* botAI, std::string const name = "mana") : Uint8CalculatedValue(botAI, name) {} - Unit* GetTarget(); - uint8 Calculate() override; + Unit* GetTarget(); + uint8 Calculate() override; }; class HasManaValue : public BoolCalculatedValue, public Qualified { - public: - HasManaValue(PlayerbotAI* botAI, std::string const name = "has mana") : BoolCalculatedValue(botAI, name, 2 * 1000) { } +public: + HasManaValue(PlayerbotAI* botAI, std::string const name = "has mana") : BoolCalculatedValue(botAI, name, 2 * 1000) + { + } - Unit* GetTarget(); - bool Calculate() override; + Unit* GetTarget(); + bool Calculate() override; }; class ComboPointsValue : public Uint8CalculatedValue, public Qualified { - public: - ComboPointsValue(PlayerbotAI* botAI, std::string const name = "combo points") : Uint8CalculatedValue(botAI, name) { } +public: + ComboPointsValue(PlayerbotAI* botAI, std::string const name = "combo points") : Uint8CalculatedValue(botAI, name) {} - Unit* GetTarget(); - uint8 Calculate() override; + Unit* GetTarget(); + uint8 Calculate() override; }; class IsMountedValue : public BoolCalculatedValue, public Qualified { - public: - IsMountedValue(PlayerbotAI* botAI, std::string const name = "mounted") : BoolCalculatedValue(botAI, name) { } +public: + IsMountedValue(PlayerbotAI* botAI, std::string const name = "mounted") : BoolCalculatedValue(botAI, name) {} - Unit* GetTarget(); - bool Calculate() override; + Unit* GetTarget(); + bool Calculate() override; }; class IsInCombatValue : public MemoryCalculatedValue, public Qualified { - public: - IsInCombatValue(PlayerbotAI* botAI, std::string const name = "combat") : MemoryCalculatedValue(botAI, name) { } +public: + IsInCombatValue(PlayerbotAI* botAI, std::string const name = "combat") : MemoryCalculatedValue(botAI, name) {} - Unit* GetTarget(); - bool Calculate() override; - bool EqualToLast(bool value) override; + Unit* GetTarget(); + bool Calculate() override; + bool EqualToLast(bool value) override; }; class BagSpaceValue : public Uint8CalculatedValue { - public: - BagSpaceValue(PlayerbotAI* botAI, std::string const name = "bag space") : Uint8CalculatedValue(botAI, name) { } +public: + BagSpaceValue(PlayerbotAI* botAI, std::string const name = "bag space") : Uint8CalculatedValue(botAI, name) {} - uint8 Calculate() override; + uint8 Calculate() override; }; class DurabilityValue : public Uint8CalculatedValue { - public: - DurabilityValue(PlayerbotAI* botAI, std::string const name = "durability") : Uint8CalculatedValue(botAI, name) { } +public: + DurabilityValue(PlayerbotAI* botAI, std::string const name = "durability") : Uint8CalculatedValue(botAI, name) {} - uint8 Calculate() override; + uint8 Calculate() override; }; class SpeedValue : public Uint8CalculatedValue, public Qualified { - public: - SpeedValue(PlayerbotAI* botAI, std::string const name = "speed") : Uint8CalculatedValue(botAI, name) { } +public: + SpeedValue(PlayerbotAI* botAI, std::string const name = "speed") : Uint8CalculatedValue(botAI, name) {} - Unit* GetTarget(); - uint8 Calculate() override; + Unit* GetTarget(); + uint8 Calculate() override; }; class IsInGroupValue : public BoolCalculatedValue { - public: - IsInGroupValue(PlayerbotAI* botAI, std::string const name = "in group") : BoolCalculatedValue(botAI, name) { } +public: + IsInGroupValue(PlayerbotAI* botAI, std::string const name = "in group") : BoolCalculatedValue(botAI, name) {} - bool Calculate() override; + bool Calculate() override; }; class DeathCountValue : public ManualSetValue { - public: - DeathCountValue(PlayerbotAI* botAI, std::string const name = "death count") : ManualSetValue(botAI, 0, name) { } +public: + DeathCountValue(PlayerbotAI* botAI, std::string const name = "death count") : ManualSetValue(botAI, 0, name) + { + } }; class ExperienceValue : public MemoryCalculatedValue { - public: - ExperienceValue(PlayerbotAI* botAI, std::string const name = "experience", uint32 checkInterval = 60) : MemoryCalculatedValue(botAI, name, checkInterval) { } +public: + ExperienceValue(PlayerbotAI* botAI, std::string const name = "experience", uint32 checkInterval = 60) + : MemoryCalculatedValue(botAI, name, checkInterval) + { + } - bool EqualToLast(uint32 value) override; - uint32 Calculate() override; + bool EqualToLast(uint32 value) override; + uint32 Calculate() override; }; #endif diff --git a/src/strategy/values/TankTargetValue.cpp b/src/strategy/values/TankTargetValue.cpp index 173c84da..c1c55466 100644 --- a/src/strategy/values/TankTargetValue.cpp +++ b/src/strategy/values/TankTargetValue.cpp @@ -1,89 +1,102 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ +#include "TankTargetValue.h" + #include "AttackersValue.h" #include "PlayerbotAIConfig.h" -#include "TankTargetValue.h" #include "Playerbots.h" class FindTargetForTankStrategy : public FindNonCcTargetStrategy { - public: - FindTargetForTankStrategy(PlayerbotAI* botAI) : FindNonCcTargetStrategy(botAI), minThreat(0) { } +public: + FindTargetForTankStrategy(PlayerbotAI* botAI) : FindNonCcTargetStrategy(botAI), minThreat(0) {} - void CheckAttacker(Unit* creature, ThreatMgr* threatMgr) override + void CheckAttacker(Unit* creature, ThreatMgr* threatMgr) override + { + if (!creature || !creature->IsAlive()) { - if (!creature || !creature->IsAlive()) { + return; + } + Player* bot = botAI->GetBot(); + float threat = threatMgr->GetThreat(bot); + if (!result) + { + minThreat = threat; + result = creature; + } + // neglect if victim is main tank, or no victim (for untauntable target) + if (threatMgr->getCurrentVictim()) + { + // float max_threat = threatMgr->GetThreat(threatMgr->getCurrentVictim()->getTarget()); + Unit* victim = threatMgr->getCurrentVictim()->getTarget(); + if (victim && victim->ToPlayer() && botAI->IsMainTank(victim->ToPlayer())) + { return; } - Player* bot = botAI->GetBot(); - float threat = threatMgr->GetThreat(bot); - if (!result) { - minThreat = threat; - result = creature; - } - // neglect if victim is main tank, or no victim (for untauntable target) - if (threatMgr->getCurrentVictim()) { - // float max_threat = threatMgr->GetThreat(threatMgr->getCurrentVictim()->getTarget()); - Unit* victim = threatMgr->getCurrentVictim()->getTarget(); - if (victim && victim->ToPlayer() && botAI->IsMainTank(victim->ToPlayer())) { - return; - } - } - if (minThreat >= threat) - { - minThreat = threat; - result = creature; - } } + if (minThreat >= threat) + { + minThreat = threat; + result = creature; + } + } - protected: - float minThreat; +protected: + float minThreat; }; class FindTankTargetSmartStrategy : public FindTargetStrategy { - public: - FindTankTargetSmartStrategy(PlayerbotAI* botAI) : FindTargetStrategy(botAI) { } +public: + FindTankTargetSmartStrategy(PlayerbotAI* botAI) : FindTargetStrategy(botAI) {} - void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override + { + if (Group* group = botAI->GetBot()->GetGroup()) { - if (Group* group = botAI->GetBot()->GetGroup()) - { - ObjectGuid guid = group->GetTargetIcon(4); - if (guid && attacker->GetGUID() == guid) - return; - } - if (!attacker->IsAlive()) { + ObjectGuid guid = group->GetTargetIcon(4); + if (guid && attacker->GetGUID() == guid) return; - } - if (!result || IsBetter(attacker, result)) { - result = attacker; - } } - bool IsBetter(Unit* new_unit, Unit* old_unit) { - Player* bot = botAI->GetBot(); - float new_threat = new_unit->GetThreatMgr().GetThreat(bot); - float old_threat = old_unit->GetThreatMgr().GetThreat(bot); - float new_dis = bot->GetDistance(new_unit); - float old_dis = bot->GetDistance(old_unit); - // hasAggro? -> withinMelee? -> threat - if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit)) { - return true; - } - int32_t interval = GetIntervalLevel(new_unit); - if (interval == 1) { - return new_dis < old_dis; - } - return new_threat < old_threat; + if (!attacker->IsAlive()) + { + return; } - int32_t GetIntervalLevel(Unit* unit) { - if (!botAI->HasAggro(unit)) { - return 1; - } - return 0; + if (!result || IsBetter(attacker, result)) + { + result = attacker; } + } + bool IsBetter(Unit* new_unit, Unit* old_unit) + { + Player* bot = botAI->GetBot(); + float new_threat = new_unit->GetThreatMgr().GetThreat(bot); + float old_threat = old_unit->GetThreatMgr().GetThreat(bot); + float new_dis = bot->GetDistance(new_unit); + float old_dis = bot->GetDistance(old_unit); + // hasAggro? -> withinMelee? -> threat + if (GetIntervalLevel(new_unit) > GetIntervalLevel(old_unit)) + { + return true; + } + int32_t interval = GetIntervalLevel(new_unit); + if (interval == 1) + { + return new_dis < old_dis; + } + return new_threat < old_threat; + } + int32_t GetIntervalLevel(Unit* unit) + { + if (!botAI->HasAggro(unit)) + { + return 1; + } + return 0; + } }; Unit* TankTargetValue::Calculate() diff --git a/src/strategy/values/TankTargetValue.h b/src/strategy/values/TankTargetValue.h index 06e668fa..9769910e 100644 --- a/src/strategy/values/TankTargetValue.h +++ b/src/strategy/values/TankTargetValue.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TANKTARGETVALUE_H @@ -11,10 +12,10 @@ class PlayerbotAI; class TankTargetValue : public TargetValue { - public: - TankTargetValue(PlayerbotAI* botAI, std::string const name = "tank target") : TargetValue(botAI, name) { } +public: + TankTargetValue(PlayerbotAI* botAI, std::string const name = "tank target") : TargetValue(botAI, name) {} - Unit* Calculate() override; + Unit* Calculate() override; }; #endif diff --git a/src/strategy/values/TargetValue.cpp b/src/strategy/values/TargetValue.cpp index 7c515a8a..ebffd328 100644 --- a/src/strategy/values/TargetValue.cpp +++ b/src/strategy/values/TargetValue.cpp @@ -1,19 +1,18 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TargetValue.h" + #include "LastMovementValue.h" #include "ObjectGuid.h" -#include "RtiTargetValue.h" #include "Playerbots.h" +#include "RtiTargetValue.h" #include "ScriptedCreature.h" #include "ThreatMgr.h" -Unit* FindTargetStrategy::GetResult() -{ - return result; -} +Unit* FindTargetStrategy::GetResult() { return result; } Unit* TargetValue::FindTarget(FindTargetStrategy* strategy) { @@ -24,14 +23,13 @@ Unit* TargetValue::FindTarget(FindTargetStrategy* strategy) if (!unit) continue; - ThreatMgr &ThreatMgr = unit->GetThreatMgr(); + ThreatMgr& ThreatMgr = unit->GetThreatMgr(); strategy->CheckAttacker(unit, &ThreatMgr); } return strategy->GetResult(); } - bool FindNonCcTargetStrategy::IsCcTarget(Unit* attacker) { if (Group* group = botAI->GetBot()->GetGroup()) @@ -39,7 +37,7 @@ bool FindNonCcTargetStrategy::IsCcTarget(Unit* attacker) Group::MemberSlotList const& groupSlot = group->GetMemberSlots(); for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++) { - Player *member = ObjectAccessor::FindPlayer(itr->guid); + Player* member = ObjectAccessor::FindPlayer(itr->guid); if (!member || !member->IsAlive()) continue; @@ -105,13 +103,16 @@ bool FindTargetStrategy::IsHighPriority(Unit* attacker) if (Group* group = botAI->GetBot()->GetGroup()) { ObjectGuid guid = group->GetTargetIcon(7); - if (guid && attacker->GetGUID() == guid) { + if (guid && attacker->GetGUID() == guid) + { return true; } } GuidVector prioritizedTargets = botAI->GetAiObjectContext()->GetValue("prioritized targets")->Get(); - for (ObjectGuid targetGuid : prioritizedTargets) { - if (targetGuid && attacker->GetGUID() == targetGuid) { + for (ObjectGuid targetGuid : prioritizedTargets) + { + if (targetGuid && attacker->GetGUID() == targetGuid) + { return true; } } @@ -127,7 +128,6 @@ WorldPosition LastLongMoveValue::Calculate() return lastMove.lastPath.getBack(); } - WorldPosition HomeBindValue::Calculate() { return WorldPosition(bot->m_homebindMapId, bot->m_homebindX, bot->m_homebindY, bot->m_homebindZ, 0.f); @@ -135,22 +135,25 @@ WorldPosition HomeBindValue::Calculate() Unit* FindTargetValue::Calculate() { - if (qualifier == "") { + if (qualifier == "") + { return nullptr; } Group* group = bot->GetGroup(); - if (!group) { + if (!group) + { return nullptr; } - HostileReference *ref = bot->getHostileRefMgr().getFirst(); + HostileReference* ref = bot->getHostileRefMgr().getFirst(); while (ref) { - ThreatMgr *threatManager = ref->GetSource(); - Unit *unit = threatManager->GetOwner(); + ThreatMgr* threatManager = ref->GetSource(); + Unit* unit = threatManager->GetOwner(); std::wstring wnamepart; Utf8toWStr(unit->GetName(), wnamepart); wstrToLower(wnamepart); - if (!qualifier.empty() && qualifier.length() == wnamepart.length() && Utf8FitTo(qualifier, wnamepart)) { + if (!qualifier.empty() && qualifier.length() == wnamepart.length() && Utf8FitTo(qualifier, wnamepart)) + { return unit; } ref = ref->next(); @@ -162,7 +165,8 @@ void FindBossTargetStrategy::CheckAttacker(Unit* attacker, ThreatMgr* threatMana { UnitAI* unitAI = attacker->GetAI(); BossAI* bossAI = dynamic_cast(unitAI); - if (bossAI) { + if (bossAI) + { result = attacker; } } diff --git a/src/strategy/values/TargetValue.h b/src/strategy/values/TargetValue.h index b4ed6af6..029551ce 100644 --- a/src/strategy/values/TargetValue.h +++ b/src/strategy/values/TargetValue.h @@ -1,13 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TARGETVALUE_H #define _PLAYERBOT_TARGETVALUE_H +#include "NamedObjectContext.h" #include "TravelMgr.h" #include "Value.h" -#include "NamedObjectContext.h" class PlayerbotAI; class ThreatMgr; @@ -15,106 +16,121 @@ class Unit; class FindTargetStrategy { - public: - FindTargetStrategy(PlayerbotAI* botAI) : result(nullptr), botAI(botAI) { } +public: + FindTargetStrategy(PlayerbotAI* botAI) : result(nullptr), botAI(botAI) {} - Unit* GetResult(); - virtual void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) = 0; - void GetPlayerCount(Unit* creature, uint32* tankCount, uint32* dpsCount); - bool IsHighPriority(Unit* attacker); + Unit* GetResult(); + virtual void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) = 0; + void GetPlayerCount(Unit* creature, uint32* tankCount, uint32* dpsCount); + bool IsHighPriority(Unit* attacker); - protected: - Unit* result; - PlayerbotAI* botAI; - std::map tankCountCache; - std::map dpsCountCache; - bool foundHighPriority = false; +protected: + Unit* result; + PlayerbotAI* botAI; + std::map tankCountCache; + std::map dpsCountCache; + bool foundHighPriority = false; }; class FindNonCcTargetStrategy : public FindTargetStrategy { - public: - FindNonCcTargetStrategy(PlayerbotAI* botAI) : FindTargetStrategy(botAI) { } +public: + FindNonCcTargetStrategy(PlayerbotAI* botAI) : FindTargetStrategy(botAI) {} - protected: - virtual bool IsCcTarget(Unit* attacker); +protected: + virtual bool IsCcTarget(Unit* attacker); }; class TargetValue : public UnitCalculatedValue { - public: - TargetValue(PlayerbotAI* botAI, std::string const name = "target", int checkInterval = 1) : UnitCalculatedValue(botAI, name, checkInterval) { } +public: + TargetValue(PlayerbotAI* botAI, std::string const name = "target", int checkInterval = 1) + : UnitCalculatedValue(botAI, name, checkInterval) + { + } - protected: - Unit* FindTarget(FindTargetStrategy* strategy); +protected: + Unit* FindTarget(FindTargetStrategy* strategy); }; class RpgTargetValue : public ManualSetValue { - public: - RpgTargetValue(PlayerbotAI* botAI, std::string const name = "rpg target") : ManualSetValue(botAI, GuidPosition(), name) { } +public: + RpgTargetValue(PlayerbotAI* botAI, std::string const name = "rpg target") + : ManualSetValue(botAI, GuidPosition(), name) + { + } }; class TravelTargetValue : public ManualSetValue { - public: - TravelTargetValue(PlayerbotAI* botAI, std::string const name = "travel target") : ManualSetValue(botAI, new TravelTarget(botAI), name) { } +public: + TravelTargetValue(PlayerbotAI* botAI, std::string const name = "travel target") + : ManualSetValue(botAI, new TravelTarget(botAI), name) + { + } - virtual ~TravelTargetValue() { delete value; } + virtual ~TravelTargetValue() { delete value; } }; class LastLongMoveValue : public CalculatedValue { - public: - LastLongMoveValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "last long move", 30 * 1000) { } +public: + LastLongMoveValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "last long move", 30 * 1000) {} - WorldPosition Calculate() override; + WorldPosition Calculate() override; }; class HomeBindValue : public CalculatedValue { - public: - HomeBindValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "home bind", 30 * 1000) { } +public: + HomeBindValue(PlayerbotAI* botAI) : CalculatedValue(botAI, "home bind", 30 * 1000) {} - WorldPosition Calculate() override; + WorldPosition Calculate() override; }; class IgnoreRpgTargetValue : public ManualSetValue { - public: - IgnoreRpgTargetValue(PlayerbotAI* botAI) : ManualSetValue(botAI, data, "ignore rpg targets") { } +public: + IgnoreRpgTargetValue(PlayerbotAI* botAI) : ManualSetValue(botAI, data, "ignore rpg targets") {} - private: - GuidSet data; +private: + GuidSet data; }; class TalkTargetValue : public ManualSetValue { - public: - TalkTargetValue(PlayerbotAI* botAI, std::string const name = "talk target") : ManualSetValue(botAI, ObjectGuid::Empty, name) { } +public: + TalkTargetValue(PlayerbotAI* botAI, std::string const name = "talk target") + : ManualSetValue(botAI, ObjectGuid::Empty, name) + { + } }; class PullTargetValue : public ManualSetValue { - public: - PullTargetValue(PlayerbotAI* botAI, std::string const name = "pull target") : ManualSetValue(botAI, ObjectGuid::Empty, name) { } +public: + PullTargetValue(PlayerbotAI* botAI, std::string const name = "pull target") + : ManualSetValue(botAI, ObjectGuid::Empty, name) + { + } }; class FindTargetValue : public UnitCalculatedValue, public Qualified { public: - FindTargetValue(PlayerbotAI* ai) : UnitCalculatedValue(ai, "find target", /*2 * 1000*/1) {} + FindTargetValue(PlayerbotAI* ai) : UnitCalculatedValue(ai, "find target", /*2 * 1000*/ 1) {} public: Unit* Calculate(); }; class FindBossTargetStrategy : public FindTargetStrategy - { - public: - FindBossTargetStrategy(PlayerbotAI* ai) : FindTargetStrategy(ai) {} - virtual void CheckAttacker(Unit* attacker, ThreatMgr* threatManager); - }; +{ +public: + FindBossTargetStrategy(PlayerbotAI* ai) : FindTargetStrategy(ai) {} + virtual void CheckAttacker(Unit* attacker, ThreatMgr* threatManager); +}; class BossTargetValue : public TargetValue, public Qualified { diff --git a/src/strategy/values/ThreatValues.cpp b/src/strategy/values/ThreatValues.cpp index 1d3b6394..fcd915b0 100644 --- a/src/strategy/values/ThreatValues.cpp +++ b/src/strategy/values/ThreatValues.cpp @@ -1,17 +1,19 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ThreatValues.h" -#include "ThreatMgr.h" + #include "Playerbots.h" +#include "ThreatMgr.h" uint8 ThreatValue::Calculate() { if (qualifier == "aoe") { uint8 maxThreat = 0; - GuidVector attackers = context->GetValue("attackers")->Get(); + GuidVector attackers = context->GetValue("attackers")->Get(); for (ObjectGuid const guid : attackers) { Unit* unit = botAI->GetUnit(guid); @@ -66,7 +68,7 @@ uint8 ThreatValue::Calculate(Unit* target) // calculate normal threat for fleeing targets bool fleeing = target->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLEEING_MOTION_TYPE || - target->GetMotionMaster()->GetCurrentMovementGeneratorType() == TIMED_FLEEING_MOTION_TYPE; + target->GetMotionMaster()->GetCurrentMovementGeneratorType() == TIMED_FLEEING_MOTION_TYPE; // return high threat if tank has no threat if (target->IsInCombat() && maxThreat <= 0 && botThreat <= 0 && hasTank && !fleeing) diff --git a/src/strategy/values/ThreatValues.h b/src/strategy/values/ThreatValues.h index a7186318..d163532f 100644 --- a/src/strategy/values/ThreatValues.h +++ b/src/strategy/values/ThreatValues.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_THREATVALUES_H @@ -13,25 +14,28 @@ class Unit; class ThreatValue : public Uint8CalculatedValue, public Qualified { - public: - ThreatValue(PlayerbotAI* botAI, std::string const name = "threat") : Uint8CalculatedValue(botAI, name) { } +public: + ThreatValue(PlayerbotAI* botAI, std::string const name = "threat") : Uint8CalculatedValue(botAI, name) {} - uint8 Calculate() override; + uint8 Calculate() override; - protected: - uint8 Calculate(Unit* target); +protected: + uint8 Calculate(Unit* target); }; class NeglectThreatResetValue : public ManualSetValue { - public: - NeglectThreatResetValue(PlayerbotAI* ai, bool defaultValue = false, std::string name = "neglect threat") : - ManualSetValue(ai, defaultValue, name) {} - virtual bool Get() { - bool ret = value; - Reset(); - return ret; - } +public: + NeglectThreatResetValue(PlayerbotAI* ai, bool defaultValue = false, std::string name = "neglect threat") + : ManualSetValue(ai, defaultValue, name) + { + } + virtual bool Get() + { + bool ret = value; + Reset(); + return ret; + } }; #endif diff --git a/src/strategy/values/ValueContext.h b/src/strategy/values/ValueContext.h index 2888b246..3f3e4f3a 100644 --- a/src/strategy/values/ValueContext.h +++ b/src/strategy/values/ValueContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_VALUECONTEXT_H @@ -10,8 +11,8 @@ #include "AoeHealValues.h" #include "AoeValues.h" #include "AttackerCountValues.h" -#include "AttackersValue.h" #include "AttackerWithoutAuraTargetValue.h" +#include "AttackersValue.h" #include "AvailableLootValue.h" #include "BudgetValues.h" #include "CcTargetValue.h" @@ -20,29 +21,29 @@ #include "CraftValue.h" #include "CurrentCcTargetValue.h" #include "CurrentTargetValue.h" +#include "DistanceValue.h" #include "DpsTargetValue.h" #include "DuelTargetValue.h" -#include "DistanceValue.h" #include "EnemyHealerTargetValue.h" #include "EnemyPlayerValue.h" #include "ExpectedLifetimeValue.h" #include "Formations.h" -#include "GroupValues.h" #include "GrindTargetValue.h" +#include "GroupValues.h" #include "GuildValues.h" #include "HasAvailableLootValue.h" #include "HasTotemValue.h" #include "InvalidTargetValue.h" -#include "ItemUsageValue.h" #include "IsBehindValue.h" #include "IsFacingValue.h" #include "IsMovingValue.h" #include "ItemCountValue.h" #include "ItemForSpellValue.h" +#include "ItemUsageValue.h" #include "LastMovementValue.h" #include "LastSaidValue.h" -#include "LastSpellCastValue.h" #include "LastSpellCastTimeValue.h" +#include "LastSpellCastValue.h" #include "LeastHpTargetValue.h" #include "LfgValues.h" #include "LineTargetValue.h" @@ -59,23 +60,23 @@ #include "NearestNpcsValue.h" #include "NewPlayerNearbyValue.h" #include "OutfitListValue.h" -#include "QuestValues.h" -#include "PartyMemberWithoutAuraValue.h" -#include "PartyMemberWithoutItemValue.h" #include "PartyMemberToDispel.h" #include "PartyMemberToHeal.h" #include "PartyMemberToResurrect.h" +#include "PartyMemberWithoutAuraValue.h" +#include "PartyMemberWithoutItemValue.h" #include "PetTargetValue.h" #include "PositionValue.h" #include "PossibleRpgTargetsValue.h" #include "PossibleTargetsValue.h" #include "PvpValues.h" +#include "QuestValues.h" +#include "RTSCValues.h" #include "RandomBotUpdateValue.h" #include "RangeValues.h" +#include "RpgValues.h" #include "RtiTargetValue.h" #include "RtiValue.h" -#include "RTSCValues.h" -#include "RpgValues.h" #include "SelfTargetValue.h" #include "SkipSpellsListValue.h" #include "SnareTargetValue.h" @@ -92,427 +93,457 @@ class PlayerbotAI; class ValueContext : public NamedObjectContext { - public: - ValueContext() - { - creators["active spell"] = &ValueContext::active_spell; - creators["craft"] = &ValueContext::craft; - creators["collision"] = &ValueContext::collision; - creators["skip spells list"] = &ValueContext::skip_spells_list_value; - creators["nearest game objects"] = &ValueContext::nearest_game_objects; - creators["nearest game objects no los"] = &ValueContext::nearest_game_objects_no_los; - creators["closest game objects"] = &ValueContext::closest_game_objects; - creators["nearest npcs"] = &ValueContext::nearest_npcs; - creators["nearest totems"] = &ValueContext::nearest_totems; - creators["nearest vehicles"] = &ValueContext::nearest_vehicles; - creators["nearest friendly players"] = &ValueContext::nearest_friendly_players; - creators["closest friendly players"] = &ValueContext::closest_friendly_players; - creators["nearest enemy players"] = &ValueContext::nearest_enemy_players; - creators["possible targets"] = &ValueContext::possible_targets; - creators["possible targets no los"] = &ValueContext::possible_targets_no_los; - creators["possible triggers"] = &ValueContext::possible_triggers; - creators["possible adds"] = &ValueContext::possible_adds; - creators["prioritized targets"] = &ValueContext::prioritized_targets; - creators["all targets"] = &ValueContext::all_targets; - creators["possible rpg targets"] = &ValueContext::possible_rpg_targets; - creators["nearest adds"] = &ValueContext::nearest_adds; - creators["nearest corpses"] = &ValueContext::nearest_corpses; - creators["log level"] = &ValueContext::log_level; - creators["party member without aura"] = &ValueContext::party_member_without_aura; - creators["attacker without aura"] = &ValueContext::attacker_without_aura; - creators["melee attacker without aura"] = &ValueContext::melee_attacker_without_aura; - creators["party member to heal"] = &ValueContext::party_member_to_heal; - creators["party member to resurrect"] = &ValueContext::party_member_to_resurrect; - creators["current target"] = &ValueContext::current_target; - creators["self target"] = &ValueContext::self_target; - creators["master target"] = &ValueContext::master; - creators["line target"] = &ValueContext::line_target; - creators["tank target"] = &ValueContext::tank_target; - creators["dps target"] = &ValueContext::dps_target; - creators["dps aoe target"] = &ValueContext::dps_aoe_target; - creators["least hp target"] = &ValueContext::least_hp_target; - creators["enemy player target"] = &ValueContext::enemy_player_target; - creators["cc target"] = &ValueContext::cc_target; - creators["current cc target"] = &ValueContext::current_cc_target; - creators["pet target"] = &ValueContext::pet_target; - creators["old target"] = &ValueContext::old_target; - creators["grind target"] = &ValueContext::grind_target; - creators["rti target"] = &ValueContext::rti_target; - creators["rti cc target"] = &ValueContext::rti_cc_target; - creators["duel target"] = &ValueContext::duel_target; - creators["party member to dispel"] = &ValueContext::party_member_to_dispel; - creators["party member to protect"] = &ValueContext::party_member_to_protect; - creators["health"] = &ValueContext::health; - creators["rage"] = &ValueContext::rage; - creators["energy"] = &ValueContext::energy; - creators["mana"] = &ValueContext::mana; - creators["combo"] = &ValueContext::combo; - creators["dead"] = &ValueContext::dead; - creators["pet dead"] = &ValueContext::pet_dead; - creators["pet happy"] = &ValueContext::pet_happy; - creators["has mana"] = &ValueContext::has_mana; - creators["attacker count"] = &ValueContext::attacker_count; - creators["my attacker count"] = &ValueContext::my_attacker_count; - creators["has aggro"] = &ValueContext::has_aggro; - creators["mounted"] = &ValueContext::mounted; +public: + ValueContext() + { + creators["active spell"] = &ValueContext::active_spell; + creators["craft"] = &ValueContext::craft; + creators["collision"] = &ValueContext::collision; + creators["skip spells list"] = &ValueContext::skip_spells_list_value; + creators["nearest game objects"] = &ValueContext::nearest_game_objects; + creators["nearest game objects no los"] = &ValueContext::nearest_game_objects_no_los; + creators["closest game objects"] = &ValueContext::closest_game_objects; + creators["nearest npcs"] = &ValueContext::nearest_npcs; + creators["nearest totems"] = &ValueContext::nearest_totems; + creators["nearest vehicles"] = &ValueContext::nearest_vehicles; + creators["nearest friendly players"] = &ValueContext::nearest_friendly_players; + creators["closest friendly players"] = &ValueContext::closest_friendly_players; + creators["nearest enemy players"] = &ValueContext::nearest_enemy_players; + creators["possible targets"] = &ValueContext::possible_targets; + creators["possible targets no los"] = &ValueContext::possible_targets_no_los; + creators["possible triggers"] = &ValueContext::possible_triggers; + creators["possible adds"] = &ValueContext::possible_adds; + creators["prioritized targets"] = &ValueContext::prioritized_targets; + creators["all targets"] = &ValueContext::all_targets; + creators["possible rpg targets"] = &ValueContext::possible_rpg_targets; + creators["nearest adds"] = &ValueContext::nearest_adds; + creators["nearest corpses"] = &ValueContext::nearest_corpses; + creators["log level"] = &ValueContext::log_level; + creators["party member without aura"] = &ValueContext::party_member_without_aura; + creators["attacker without aura"] = &ValueContext::attacker_without_aura; + creators["melee attacker without aura"] = &ValueContext::melee_attacker_without_aura; + creators["party member to heal"] = &ValueContext::party_member_to_heal; + creators["party member to resurrect"] = &ValueContext::party_member_to_resurrect; + creators["current target"] = &ValueContext::current_target; + creators["self target"] = &ValueContext::self_target; + creators["master target"] = &ValueContext::master; + creators["line target"] = &ValueContext::line_target; + creators["tank target"] = &ValueContext::tank_target; + creators["dps target"] = &ValueContext::dps_target; + creators["dps aoe target"] = &ValueContext::dps_aoe_target; + creators["least hp target"] = &ValueContext::least_hp_target; + creators["enemy player target"] = &ValueContext::enemy_player_target; + creators["cc target"] = &ValueContext::cc_target; + creators["current cc target"] = &ValueContext::current_cc_target; + creators["pet target"] = &ValueContext::pet_target; + creators["old target"] = &ValueContext::old_target; + creators["grind target"] = &ValueContext::grind_target; + creators["rti target"] = &ValueContext::rti_target; + creators["rti cc target"] = &ValueContext::rti_cc_target; + creators["duel target"] = &ValueContext::duel_target; + creators["party member to dispel"] = &ValueContext::party_member_to_dispel; + creators["party member to protect"] = &ValueContext::party_member_to_protect; + creators["health"] = &ValueContext::health; + creators["rage"] = &ValueContext::rage; + creators["energy"] = &ValueContext::energy; + creators["mana"] = &ValueContext::mana; + creators["combo"] = &ValueContext::combo; + creators["dead"] = &ValueContext::dead; + creators["pet dead"] = &ValueContext::pet_dead; + creators["pet happy"] = &ValueContext::pet_happy; + creators["has mana"] = &ValueContext::has_mana; + creators["attacker count"] = &ValueContext::attacker_count; + creators["my attacker count"] = &ValueContext::my_attacker_count; + creators["has aggro"] = &ValueContext::has_aggro; + creators["mounted"] = &ValueContext::mounted; - creators["can loot"] = &ValueContext::can_loot; - creators["loot target"] = &ValueContext::loot_target; - creators["available loot"] = &ValueContext::available_loot; - creators["has available loot"] = &ValueContext::has_available_loot; - creators["always loot list"] = &ValueContext::always_loot_list; - creators["loot strategy"] = &ValueContext::loot_strategy; - creators["last movement"] = &ValueContext::last_movement; - creators["stay time"] = &ValueContext::stay_time; - creators["last taxi"] = &ValueContext::last_movement; - creators["last area trigger"] = &ValueContext::last_movement; - creators["distance"] = &ValueContext::distance; - creators["moving"] = &ValueContext::moving; - creators["swimming"] = &ValueContext::swimming; - creators["behind"] = &ValueContext::behind; - creators["facing"] = &ValueContext::facing; + creators["can loot"] = &ValueContext::can_loot; + creators["loot target"] = &ValueContext::loot_target; + creators["available loot"] = &ValueContext::available_loot; + creators["has available loot"] = &ValueContext::has_available_loot; + creators["always loot list"] = &ValueContext::always_loot_list; + creators["loot strategy"] = &ValueContext::loot_strategy; + creators["last movement"] = &ValueContext::last_movement; + creators["stay time"] = &ValueContext::stay_time; + creators["last taxi"] = &ValueContext::last_movement; + creators["last area trigger"] = &ValueContext::last_movement; + creators["distance"] = &ValueContext::distance; + creators["moving"] = &ValueContext::moving; + creators["swimming"] = &ValueContext::swimming; + creators["behind"] = &ValueContext::behind; + creators["facing"] = &ValueContext::facing; - creators["item count"] = &ValueContext::item_count; - creators["inventory items"] = &ValueContext::inventory_item; + creators["item count"] = &ValueContext::item_count; + creators["inventory items"] = &ValueContext::inventory_item; - creators["spell id"] = &ValueContext::spell_id; - creators["vehicle spell id"] = &ValueContext::vehicle_spell_id; - creators["item for spell"] = &ValueContext::item_for_spell; - creators["spell cast useful"] = &ValueContext::spell_cast_useful; - creators["last spell cast"] = &ValueContext::last_spell_cast; - creators["last spell cast time"] = &ValueContext::last_spell_cast_time; - creators["chat"] = &ValueContext::chat; - creators["has totem"] = &ValueContext::has_totem; + creators["spell id"] = &ValueContext::spell_id; + creators["vehicle spell id"] = &ValueContext::vehicle_spell_id; + creators["item for spell"] = &ValueContext::item_for_spell; + creators["spell cast useful"] = &ValueContext::spell_cast_useful; + creators["last spell cast"] = &ValueContext::last_spell_cast; + creators["last spell cast time"] = &ValueContext::last_spell_cast_time; + creators["chat"] = &ValueContext::chat; + creators["has totem"] = &ValueContext::has_totem; - creators["aoe heal"] = &ValueContext::aoe_heal; + creators["aoe heal"] = &ValueContext::aoe_heal; - creators["rti cc"] = &ValueContext::rti_cc; - creators["rti"] = &ValueContext::rti; - creators["position"] = &ValueContext::position; - creators["current position"] = &ValueContext::current_position; - creators["threat"] = &ValueContext::threat; + creators["rti cc"] = &ValueContext::rti_cc; + creators["rti"] = &ValueContext::rti; + creators["position"] = &ValueContext::position; + creators["current position"] = &ValueContext::current_position; + creators["threat"] = &ValueContext::threat; - creators["balance"] = &ValueContext::balance; - creators["attackers"] = &ValueContext::attackers; - creators["invalid target"] = &ValueContext::invalid_target; - creators["mana save level"] = &ValueContext::mana_save_level; - creators["combat"] = &ValueContext::combat; - creators["lfg proposal"] = &ValueContext::lfg_proposal; - creators["bag space"] = &ValueContext::bag_space; - creators["durability"] = &ValueContext::durability; - creators["max repair cost"] = &ValueContext::max_repair_cost; - creators["repair cost"] = &ValueContext::repair_cost; - creators["train cost"] = &ValueContext::train_cost; - creators["enemy healer target"] = &ValueContext::enemy_healer_target; - creators["snare target"] = &ValueContext::snare_target; - creators["formation"] = &ValueContext::formation; - creators["stance"] = &ValueContext::stance; - creators["item usage"] = &ValueContext::item_usage; - creators["speed"] = &ValueContext::speed; - creators["last said"] = &ValueContext::last_said; - creators["last emote"] = &ValueContext::last_emote; + creators["balance"] = &ValueContext::balance; + creators["attackers"] = &ValueContext::attackers; + creators["invalid target"] = &ValueContext::invalid_target; + creators["mana save level"] = &ValueContext::mana_save_level; + creators["combat"] = &ValueContext::combat; + creators["lfg proposal"] = &ValueContext::lfg_proposal; + creators["bag space"] = &ValueContext::bag_space; + creators["durability"] = &ValueContext::durability; + creators["max repair cost"] = &ValueContext::max_repair_cost; + creators["repair cost"] = &ValueContext::repair_cost; + creators["train cost"] = &ValueContext::train_cost; + creators["enemy healer target"] = &ValueContext::enemy_healer_target; + creators["snare target"] = &ValueContext::snare_target; + creators["formation"] = &ValueContext::formation; + creators["stance"] = &ValueContext::stance; + creators["item usage"] = &ValueContext::item_usage; + creators["speed"] = &ValueContext::speed; + creators["last said"] = &ValueContext::last_said; + creators["last emote"] = &ValueContext::last_emote; - creators["aoe count"] = &ValueContext::aoe_count; - creators["aoe position"] = &ValueContext::aoe_position; - creators["outfit list"] = &ValueContext::outfit_list_value; + creators["aoe count"] = &ValueContext::aoe_count; + creators["aoe position"] = &ValueContext::aoe_position; + creators["outfit list"] = &ValueContext::outfit_list_value; - creators["random bot update"] = &ValueContext::random_bot_update_value; - creators["nearest non bot players"] = &ValueContext::nearest_non_bot_players; - creators["new player nearby"] = &ValueContext::new_player_nearby; - creators["already seen players"] = &ValueContext::already_seen_players; - creators["rpg target"] = &ValueContext::rpg_target; - creators["ignore rpg target"] = &ValueContext::ignore_rpg_target; - creators["next rpg action"] = &ValueContext::next_rpg_action; - creators["travel target"] = &ValueContext::travel_target; - creators["talk target"] = &ValueContext::talk_target; - creators["pull target"] = &ValueContext::pull_target; - creators["group"] = &ValueContext::group; - creators["range"] = &ValueContext::range; - creators["inside target"] = &ValueContext::inside_target; - creators["party member without item"] = &ValueContext::party_member_without_item; - creators["party member without food"] = &ValueContext::party_member_without_food; - creators["party member without water"] = &ValueContext::party_member_without_water; - creators["death count"] = &ValueContext::death_count; + creators["random bot update"] = &ValueContext::random_bot_update_value; + creators["nearest non bot players"] = &ValueContext::nearest_non_bot_players; + creators["new player nearby"] = &ValueContext::new_player_nearby; + creators["already seen players"] = &ValueContext::already_seen_players; + creators["rpg target"] = &ValueContext::rpg_target; + creators["ignore rpg target"] = &ValueContext::ignore_rpg_target; + creators["next rpg action"] = &ValueContext::next_rpg_action; + creators["travel target"] = &ValueContext::travel_target; + creators["talk target"] = &ValueContext::talk_target; + creators["pull target"] = &ValueContext::pull_target; + creators["group"] = &ValueContext::group; + creators["range"] = &ValueContext::range; + creators["inside target"] = &ValueContext::inside_target; + creators["party member without item"] = &ValueContext::party_member_without_item; + creators["party member without food"] = &ValueContext::party_member_without_food; + creators["party member without water"] = &ValueContext::party_member_without_water; + creators["death count"] = &ValueContext::death_count; - creators["bg type"] = &ValueContext::bg_type; - creators["rpg bg type"] = &ValueContext::rpg_bg_type; - creators["arena type"] = &ValueContext::arena_type; - creators["bg role"] = &ValueContext::bg_role; - creators["bg master"] = &ValueContext::bg_master; - creators["enemy flag carrier"] = &ValueContext::enemy_fc; - creators["team flag carrier"] = &ValueContext::team_fc; + creators["bg type"] = &ValueContext::bg_type; + creators["rpg bg type"] = &ValueContext::rpg_bg_type; + creators["arena type"] = &ValueContext::arena_type; + creators["bg role"] = &ValueContext::bg_role; + creators["bg master"] = &ValueContext::bg_master; + creators["enemy flag carrier"] = &ValueContext::enemy_fc; + creators["team flag carrier"] = &ValueContext::team_fc; - creators["home bind"] = &ValueContext::home_bind; - creators["last long move"] = &ValueContext::last_long_move; + creators["home bind"] = &ValueContext::home_bind; + creators["last long move"] = &ValueContext::last_long_move; - creators["free quest log slots"] = &ValueContext::free_quest_log_slots; - creators["dialog status"] = &ValueContext::dialog_status; - creators["dialog status quest"] = &ValueContext::dialog_status_quest; - creators["can accept quest npc"] = &ValueContext::can_accept_quest_npc; - creators["can accept quest low level npc"] = &ValueContext::can_accept_quest_low_level_npc; - creators["can turn in quest npc"] = &ValueContext::can_turn_in_quest_npc; + creators["free quest log slots"] = &ValueContext::free_quest_log_slots; + creators["dialog status"] = &ValueContext::dialog_status; + creators["dialog status quest"] = &ValueContext::dialog_status_quest; + creators["can accept quest npc"] = &ValueContext::can_accept_quest_npc; + creators["can accept quest low level npc"] = &ValueContext::can_accept_quest_low_level_npc; + creators["can turn in quest npc"] = &ValueContext::can_turn_in_quest_npc; - creators["money needed for"] = &ValueContext::money_needed_for; - creators["total money needed for"] = &ValueContext::total_money_needed_for; - creators["free money for"] = &ValueContext::free_money_for; - creators["should get money"] = &ValueContext::should_get_money; + creators["money needed for"] = &ValueContext::money_needed_for; + creators["total money needed for"] = &ValueContext::total_money_needed_for; + creators["free money for"] = &ValueContext::free_money_for; + creators["should get money"] = &ValueContext::should_get_money; - creators["can move around"] = &ValueContext::can_move_around; - creators["should home bind"] = &ValueContext::should_home_bind; - creators["should repair"] = &ValueContext::should_repair; - creators["can repair"] = &ValueContext::can_repair; - creators["should sell"] = &ValueContext::should_sell; - creators["can sell"] = &ValueContext::can_sell; - creators["can fight equal"] = &ValueContext::can_fight_equal; - creators["can fight elite"] = &ValueContext::can_fight_elite; - creators["can fight boss"] = &ValueContext::can_fight_boss; + creators["can move around"] = &ValueContext::can_move_around; + creators["should home bind"] = &ValueContext::should_home_bind; + creators["should repair"] = &ValueContext::should_repair; + creators["can repair"] = &ValueContext::can_repair; + creators["should sell"] = &ValueContext::should_sell; + creators["can sell"] = &ValueContext::can_sell; + creators["can fight equal"] = &ValueContext::can_fight_equal; + creators["can fight elite"] = &ValueContext::can_fight_elite; + creators["can fight boss"] = &ValueContext::can_fight_boss; - creators["group members"] = &ValueContext::group_members; - creators["following party"] = &ValueContext::following_party; - creators["near leader"] = &ValueContext::near_leader; + creators["group members"] = &ValueContext::group_members; + creators["following party"] = &ValueContext::following_party; + creators["near leader"] = &ValueContext::near_leader; - creators["and"] = &ValueContext::and_value; - creators["group count"] = &ValueContext::group_count; - creators["group and"] = &ValueContext::group_and; - creators["group or"] = &ValueContext::group_or; - creators["group ready"] = &ValueContext::group_ready; + creators["and"] = &ValueContext::and_value; + creators["group count"] = &ValueContext::group_count; + creators["group and"] = &ValueContext::group_and; + creators["group or"] = &ValueContext::group_or; + creators["group ready"] = &ValueContext::group_ready; - creators["petition signs"] = &ValueContext::petition_signs; + creators["petition signs"] = &ValueContext::petition_signs; - creators["experience"] = &ValueContext::experience; + creators["experience"] = &ValueContext::experience; - creators["entry loot usage"] = &ValueContext::entry_loot_usage; - creators["has upgrade"] = &ValueContext::has_upgrade; - creators["items useful to give"] = &ValueContext::items_useful_to_give; + creators["entry loot usage"] = &ValueContext::entry_loot_usage; + creators["has upgrade"] = &ValueContext::has_upgrade; + creators["items useful to give"] = &ValueContext::items_useful_to_give; - creators["see spell location"] = &ValueContext::see_spell_location; - creators["RTSC selected"] = &ValueContext::RTSC_selected; - creators["RTSC next spell action"] = &ValueContext::RTSC_next_spell_action; - creators["RTSC saved location"] = &ValueContext::RTSC_saved_location; + creators["see spell location"] = &ValueContext::see_spell_location; + creators["RTSC selected"] = &ValueContext::RTSC_selected; + creators["RTSC next spell action"] = &ValueContext::RTSC_next_spell_action; + creators["RTSC saved location"] = &ValueContext::RTSC_saved_location; - creators["has area debuff"] = &ValueContext::has_area_debuff; + creators["has area debuff"] = &ValueContext::has_area_debuff; - creators["main tank"] = &ValueContext::main_tank; - creators["find target"] = &ValueContext::find_target; - creators["boss target"] = &ValueContext::boss_target; - creators["nearest triggers"] = &ValueContext::nearest_triggers; - creators["neglect threat"] = &ValueContext::neglect_threat; - creators["expected lifetime"] = &ValueContext::expected_lifetime; - creators["expected group dps"] = &ValueContext::expected_group_dps; - creators["area debuff"] = &ValueContext::area_debuff; - creators["nearest trap with damage"] = &ValueContext::nearest_trap_with_damange; - creators["disperse distance"] = &ValueContext::disperse_distance; - creators["last flee angle"] = &ValueContext::last_flee_angle; - creators["last flee timestamp"] = &ValueContext::last_flee_timestamp; - creators["recently flee info"] = &ValueContext::recently_flee_info; - } + creators["main tank"] = &ValueContext::main_tank; + creators["find target"] = &ValueContext::find_target; + creators["boss target"] = &ValueContext::boss_target; + creators["nearest triggers"] = &ValueContext::nearest_triggers; + creators["neglect threat"] = &ValueContext::neglect_threat; + creators["expected lifetime"] = &ValueContext::expected_lifetime; + creators["expected group dps"] = &ValueContext::expected_group_dps; + creators["area debuff"] = &ValueContext::area_debuff; + creators["nearest trap with damage"] = &ValueContext::nearest_trap_with_damange; + creators["disperse distance"] = &ValueContext::disperse_distance; + creators["last flee angle"] = &ValueContext::last_flee_angle; + creators["last flee timestamp"] = &ValueContext::last_flee_timestamp; + creators["recently flee info"] = &ValueContext::recently_flee_info; + } - private: - static UntypedValue* party_member_without_water(PlayerbotAI* botAI) { return new PartyMemberWithoutWaterValue(botAI); } - static UntypedValue* party_member_without_food(PlayerbotAI* botAI) { return new PartyMemberWithoutFoodValue(botAI); } - static UntypedValue* party_member_without_item(PlayerbotAI* botAI) { return new PartyMemberWithoutItemValue(botAI); } - static UntypedValue* inside_target(PlayerbotAI* botAI) { return new InsideTargetValue(botAI); } - static UntypedValue* range(PlayerbotAI* botAI) { return new RangeValue(botAI); } - static UntypedValue* active_spell(PlayerbotAI* botAI) { return new ActiveSpellValue(botAI); } - static UntypedValue* group(PlayerbotAI* botAI) { return new IsInGroupValue(botAI); } - static UntypedValue* craft(PlayerbotAI* botAI) { return new CraftValue(botAI); } - static UntypedValue* collision(PlayerbotAI* botAI) { return new CollisionValue(botAI); } - static UntypedValue* already_seen_players(PlayerbotAI* botAI) { return new AlreadySeenPlayersValue(botAI); } - static UntypedValue* new_player_nearby(PlayerbotAI* botAI) { return new NewPlayerNearbyValue(botAI); } - static UntypedValue* item_usage(PlayerbotAI* botAI) { return new ItemUsageValue(botAI); } - static UntypedValue* formation(PlayerbotAI* botAI) { return new FormationValue(botAI); } - static UntypedValue* stance(PlayerbotAI* botAI) { return new StanceValue(botAI); } - static UntypedValue* mana_save_level(PlayerbotAI* botAI) { return new ManaSaveLevelValue(botAI); } - static UntypedValue* invalid_target(PlayerbotAI* botAI) { return new InvalidTargetValue(botAI); } - static UntypedValue* balance(PlayerbotAI* botAI) { return new BalancePercentValue(botAI); } - static UntypedValue* attackers(PlayerbotAI* botAI) { return new AttackersValue(botAI); } +private: + static UntypedValue* party_member_without_water(PlayerbotAI* botAI) + { + return new PartyMemberWithoutWaterValue(botAI); + } + static UntypedValue* party_member_without_food(PlayerbotAI* botAI) + { + return new PartyMemberWithoutFoodValue(botAI); + } + static UntypedValue* party_member_without_item(PlayerbotAI* botAI) + { + return new PartyMemberWithoutItemValue(botAI); + } + static UntypedValue* inside_target(PlayerbotAI* botAI) { return new InsideTargetValue(botAI); } + static UntypedValue* range(PlayerbotAI* botAI) { return new RangeValue(botAI); } + static UntypedValue* active_spell(PlayerbotAI* botAI) { return new ActiveSpellValue(botAI); } + static UntypedValue* group(PlayerbotAI* botAI) { return new IsInGroupValue(botAI); } + static UntypedValue* craft(PlayerbotAI* botAI) { return new CraftValue(botAI); } + static UntypedValue* collision(PlayerbotAI* botAI) { return new CollisionValue(botAI); } + static UntypedValue* already_seen_players(PlayerbotAI* botAI) { return new AlreadySeenPlayersValue(botAI); } + static UntypedValue* new_player_nearby(PlayerbotAI* botAI) { return new NewPlayerNearbyValue(botAI); } + static UntypedValue* item_usage(PlayerbotAI* botAI) { return new ItemUsageValue(botAI); } + static UntypedValue* formation(PlayerbotAI* botAI) { return new FormationValue(botAI); } + static UntypedValue* stance(PlayerbotAI* botAI) { return new StanceValue(botAI); } + static UntypedValue* mana_save_level(PlayerbotAI* botAI) { return new ManaSaveLevelValue(botAI); } + static UntypedValue* invalid_target(PlayerbotAI* botAI) { return new InvalidTargetValue(botAI); } + static UntypedValue* balance(PlayerbotAI* botAI) { return new BalancePercentValue(botAI); } + static UntypedValue* attackers(PlayerbotAI* botAI) { return new AttackersValue(botAI); } - static UntypedValue* position(PlayerbotAI* botAI) { return new PositionValue(botAI); } - static UntypedValue* current_position(PlayerbotAI* botAI) { return new CurrentPositionValue(botAI); } - static UntypedValue* rti(PlayerbotAI* botAI) { return new RtiValue(botAI); } - static UntypedValue* rti_cc(PlayerbotAI* botAI) { return new RtiCcValue(botAI); } + static UntypedValue* position(PlayerbotAI* botAI) { return new PositionValue(botAI); } + static UntypedValue* current_position(PlayerbotAI* botAI) { return new CurrentPositionValue(botAI); } + static UntypedValue* rti(PlayerbotAI* botAI) { return new RtiValue(botAI); } + static UntypedValue* rti_cc(PlayerbotAI* botAI) { return new RtiCcValue(botAI); } - static UntypedValue* aoe_heal(PlayerbotAI* botAI) { return new AoeHealValue(botAI); } + static UntypedValue* aoe_heal(PlayerbotAI* botAI) { return new AoeHealValue(botAI); } - static UntypedValue* chat(PlayerbotAI* botAI) { return new ChatValue(botAI); } - static UntypedValue* last_spell_cast(PlayerbotAI* botAI) { return new LastSpellCastValue(botAI); } - static UntypedValue* last_spell_cast_time(PlayerbotAI* botAI) { return new LastSpellCastTimeValue(botAI); } - static UntypedValue* spell_cast_useful(PlayerbotAI* botAI) { return new SpellCastUsefulValue(botAI); } - static UntypedValue* item_for_spell(PlayerbotAI* botAI) { return new ItemForSpellValue(botAI); } - static UntypedValue* spell_id(PlayerbotAI* botAI) { return new SpellIdValue(botAI); } - static UntypedValue* vehicle_spell_id(PlayerbotAI* botAI) { return new VehicleSpellIdValue(botAI); } - static UntypedValue* inventory_item(PlayerbotAI* botAI) { return new InventoryItemValue(botAI); } - static UntypedValue* item_count(PlayerbotAI* botAI) { return new ItemCountValue(botAI); } - static UntypedValue* behind(PlayerbotAI* botAI) { return new IsBehindValue(botAI); } - static UntypedValue* facing(PlayerbotAI* botAI) { return new IsFacingValue(botAI); } - static UntypedValue* moving(PlayerbotAI* botAI) { return new IsMovingValue(botAI); } - static UntypedValue* swimming(PlayerbotAI* botAI) { return new IsSwimmingValue(botAI); } - static UntypedValue* distance(PlayerbotAI* botAI) { return new DistanceValue(botAI); } - static UntypedValue* last_movement(PlayerbotAI* botAI) { return new LastMovementValue(botAI); } - static UntypedValue* stay_time(PlayerbotAI* botAI) { return new StayTimeValue(botAI); } + static UntypedValue* chat(PlayerbotAI* botAI) { return new ChatValue(botAI); } + static UntypedValue* last_spell_cast(PlayerbotAI* botAI) { return new LastSpellCastValue(botAI); } + static UntypedValue* last_spell_cast_time(PlayerbotAI* botAI) { return new LastSpellCastTimeValue(botAI); } + static UntypedValue* spell_cast_useful(PlayerbotAI* botAI) { return new SpellCastUsefulValue(botAI); } + static UntypedValue* item_for_spell(PlayerbotAI* botAI) { return new ItemForSpellValue(botAI); } + static UntypedValue* spell_id(PlayerbotAI* botAI) { return new SpellIdValue(botAI); } + static UntypedValue* vehicle_spell_id(PlayerbotAI* botAI) { return new VehicleSpellIdValue(botAI); } + static UntypedValue* inventory_item(PlayerbotAI* botAI) { return new InventoryItemValue(botAI); } + static UntypedValue* item_count(PlayerbotAI* botAI) { return new ItemCountValue(botAI); } + static UntypedValue* behind(PlayerbotAI* botAI) { return new IsBehindValue(botAI); } + static UntypedValue* facing(PlayerbotAI* botAI) { return new IsFacingValue(botAI); } + static UntypedValue* moving(PlayerbotAI* botAI) { return new IsMovingValue(botAI); } + static UntypedValue* swimming(PlayerbotAI* botAI) { return new IsSwimmingValue(botAI); } + static UntypedValue* distance(PlayerbotAI* botAI) { return new DistanceValue(botAI); } + static UntypedValue* last_movement(PlayerbotAI* botAI) { return new LastMovementValue(botAI); } + static UntypedValue* stay_time(PlayerbotAI* botAI) { return new StayTimeValue(botAI); } - static UntypedValue* can_loot(PlayerbotAI* botAI) { return new CanLootValue(botAI); } - static UntypedValue* available_loot(PlayerbotAI* botAI) { return new AvailableLootValue(botAI); } - static UntypedValue* loot_target(PlayerbotAI* botAI) { return new LootTargetValue(botAI); } - static UntypedValue* has_available_loot(PlayerbotAI* botAI) { return new HasAvailableLootValue(botAI); } - static UntypedValue* always_loot_list(PlayerbotAI* botAI) { return new AlwaysLootListValue(botAI); } - static UntypedValue* loot_strategy(PlayerbotAI* botAI) { return new LootStrategyValue(botAI); } + static UntypedValue* can_loot(PlayerbotAI* botAI) { return new CanLootValue(botAI); } + static UntypedValue* available_loot(PlayerbotAI* botAI) { return new AvailableLootValue(botAI); } + static UntypedValue* loot_target(PlayerbotAI* botAI) { return new LootTargetValue(botAI); } + static UntypedValue* has_available_loot(PlayerbotAI* botAI) { return new HasAvailableLootValue(botAI); } + static UntypedValue* always_loot_list(PlayerbotAI* botAI) { return new AlwaysLootListValue(botAI); } + static UntypedValue* loot_strategy(PlayerbotAI* botAI) { return new LootStrategyValue(botAI); } - static UntypedValue* attacker_count(PlayerbotAI* botAI) { return new AttackerCountValue(botAI); } - static UntypedValue* my_attacker_count(PlayerbotAI* botAI) { return new MyAttackerCountValue(botAI); } - static UntypedValue* has_aggro(PlayerbotAI* botAI) { return new HasAggroValue(botAI); } - static UntypedValue* mounted(PlayerbotAI* botAI) { return new IsMountedValue(botAI); } - static UntypedValue* health(PlayerbotAI* botAI) { return new HealthValue(botAI); } - static UntypedValue* rage(PlayerbotAI* botAI) { return new RageValue(botAI); } - static UntypedValue* energy(PlayerbotAI* botAI) { return new EnergyValue(botAI); } - static UntypedValue* mana(PlayerbotAI* botAI) { return new ManaValue(botAI); } - static UntypedValue* combo(PlayerbotAI* botAI) { return new ComboPointsValue(botAI); } - static UntypedValue* dead(PlayerbotAI* botAI) { return new IsDeadValue(botAI); } - static UntypedValue* pet_happy(PlayerbotAI* botAI) { return new PetIsHappyValue(botAI); } - static UntypedValue* pet_dead(PlayerbotAI* botAI) { return new PetIsDeadValue(botAI); } - static UntypedValue* has_mana(PlayerbotAI* botAI) { return new HasManaValue(botAI); } - static UntypedValue* nearest_game_objects(PlayerbotAI* botAI) { return new NearestGameObjects(botAI); } - static UntypedValue* nearest_game_objects_no_los(PlayerbotAI* botAI) { return new NearestGameObjects(botAI, sPlayerbotAIConfig->sightDistance, true); } - static UntypedValue* closest_game_objects(PlayerbotAI* botAI) { return new NearestGameObjects(botAI, INTERACTION_DISTANCE); } - static UntypedValue* log_level(PlayerbotAI* botAI) { return new LogLevelValue(botAI); } - static UntypedValue* nearest_npcs(PlayerbotAI* botAI) { return new NearestNpcsValue(botAI); } - static UntypedValue* nearest_totems(PlayerbotAI* botAI) { return new NearestTotemsValue(botAI); } - static UntypedValue* nearest_vehicles(PlayerbotAI* botAI) { return new NearestVehiclesValue(botAI); } - static UntypedValue* nearest_friendly_players(PlayerbotAI* botAI) { return new NearestFriendlyPlayersValue(botAI); } - static UntypedValue* closest_friendly_players(PlayerbotAI* botAI) { return new NearestFriendlyPlayersValue(botAI, INTERACTION_DISTANCE); } - static UntypedValue* nearest_enemy_players(PlayerbotAI* botAI) { return new NearestEnemyPlayersValue(botAI); } - static UntypedValue* nearest_corpses(PlayerbotAI* botAI) { return new NearestCorpsesValue(botAI); } - static UntypedValue* possible_rpg_targets(PlayerbotAI* botAI) { return new PossibleRpgTargetsValue(botAI); } - static UntypedValue* possible_targets(PlayerbotAI* botAI) { return new PossibleTargetsValue(botAI); } - static UntypedValue* possible_triggers(PlayerbotAI* botAI) { return new PossibleTriggersValue(botAI); } - static UntypedValue* possible_targets_no_los(PlayerbotAI* botAI) { return new PossibleTargetsValue(botAI, "possible targets", sPlayerbotAIConfig->sightDistance, true); } - static UntypedValue* possible_adds(PlayerbotAI* botAI) { return new PossibleAddsValue(botAI); } - static UntypedValue* prioritized_targets(PlayerbotAI* botAI) { return new PrioritizedTargetsValue(botAI); } - static UntypedValue* all_targets(PlayerbotAI* botAI) { return new AllTargetsValue(botAI); } - static UntypedValue* nearest_adds(PlayerbotAI* botAI) { return new NearestAddsValue(botAI); } - static UntypedValue* party_member_without_aura(PlayerbotAI* botAI) { return new PartyMemberWithoutAuraValue(botAI); } - static UntypedValue* attacker_without_aura(PlayerbotAI* botAI) { return new AttackerWithoutAuraTargetValue(botAI); } - static UntypedValue* melee_attacker_without_aura(PlayerbotAI* botAI) { return new MeleeAttackerWithoutAuraTargetValue(botAI); } - static UntypedValue* party_member_to_heal(PlayerbotAI* botAI) { return new PartyMemberToHeal(botAI); } - static UntypedValue* party_member_to_resurrect(PlayerbotAI* botAI) { return new PartyMemberToResurrect(botAI); } - static UntypedValue* party_member_to_dispel(PlayerbotAI* botAI) { return new PartyMemberToDispel(botAI); } - static UntypedValue* party_member_to_protect(PlayerbotAI* botAI) { return new PartyMemberToProtect(botAI); } - static UntypedValue* current_target(PlayerbotAI* botAI) { return new CurrentTargetValue(botAI); } - static UntypedValue* old_target(PlayerbotAI* botAI) { return new CurrentTargetValue(botAI); } - static UntypedValue* self_target(PlayerbotAI* botAI) { return new SelfTargetValue(botAI); } - static UntypedValue* master(PlayerbotAI* botAI) { return new MasterTargetValue(botAI); } - static UntypedValue* line_target(PlayerbotAI* botAI) { return new LineTargetValue(botAI); } - static UntypedValue* tank_target(PlayerbotAI* botAI) { return new TankTargetValue(botAI); } - static UntypedValue* dps_target(PlayerbotAI* botAI) { return new DpsTargetValue(botAI); } - static UntypedValue* dps_aoe_target(PlayerbotAI* botAI) { return new DpsAoeTargetValue(botAI); } - static UntypedValue* least_hp_target(PlayerbotAI* botAI) { return new LeastHpTargetValue(botAI); } - static UntypedValue* enemy_player_target(PlayerbotAI* botAI) { return new EnemyPlayerValue(botAI); } - static UntypedValue* cc_target(PlayerbotAI* botAI) { return new CcTargetValue(botAI); } - static UntypedValue* current_cc_target(PlayerbotAI* botAI) { return new CurrentCcTargetValue(botAI); } - static UntypedValue* pet_target(PlayerbotAI* botAI) { return new PetTargetValue(botAI); } - static UntypedValue* grind_target(PlayerbotAI* botAI) { return new GrindTargetValue(botAI); } - static UntypedValue* rti_target(PlayerbotAI* botAI) { return new RtiTargetValue(botAI); } - static UntypedValue* rti_cc_target(PlayerbotAI* botAI) { return new RtiCcTargetValue(botAI); } - static UntypedValue* duel_target(PlayerbotAI* botAI) { return new DuelTargetValue(botAI); } - static UntypedValue* has_totem(PlayerbotAI* botAI) { return new HasTotemValue(botAI); } - static UntypedValue* threat(PlayerbotAI* botAI) { return new ThreatValue(botAI); } - static UntypedValue* combat(PlayerbotAI* botAI) { return new IsInCombatValue(botAI); } - static UntypedValue* lfg_proposal(PlayerbotAI* botAI) { return new LfgProposalValue(botAI); } - static UntypedValue* bag_space(PlayerbotAI* botAI) { return new BagSpaceValue(botAI); } - static UntypedValue* durability(PlayerbotAI* botAI) { return new DurabilityValue(botAI); } - static UntypedValue* max_repair_cost(PlayerbotAI* botAI) { return new MaxGearRepairCostValue(botAI); } - static UntypedValue* repair_cost(PlayerbotAI* botAI) { return new RepairCostValue(botAI); } - static UntypedValue* train_cost(PlayerbotAI* botAI) { return new TrainCostValue(botAI); } - static UntypedValue* enemy_healer_target(PlayerbotAI* botAI) { return new EnemyHealerTargetValue(botAI); } - static UntypedValue* snare_target(PlayerbotAI* botAI) { return new SnareTargetValue(botAI); } - static UntypedValue* speed(PlayerbotAI* botAI) { return new SpeedValue(botAI); } - static UntypedValue* last_said(PlayerbotAI* botAI) { return new LastSaidValue(botAI); } - static UntypedValue* last_emote(PlayerbotAI* botAI) { return new LastEmoteValue(botAI); } - static UntypedValue* aoe_count(PlayerbotAI* botAI) { return new AoeCountValue(botAI); } - static UntypedValue* aoe_position(PlayerbotAI* botAI) { return new AoePositionValue(botAI); } - static UntypedValue* outfit_list_value(PlayerbotAI* botAI) { return new OutfitListValue(botAI); } - static UntypedValue* random_bot_update_value(PlayerbotAI* botAI) { return new RandomBotUpdateValue(botAI); } - static UntypedValue* nearest_non_bot_players(PlayerbotAI* botAI) { return new NearestNonBotPlayersValue(botAI); } - static UntypedValue* skip_spells_list_value(PlayerbotAI* botAI) { return new SkipSpellsListValue(botAI); } - static UntypedValue* rpg_target(PlayerbotAI* botAI) { return new RpgTargetValue(botAI); } - static UntypedValue* ignore_rpg_target(PlayerbotAI* botAI) { return new IgnoreRpgTargetValue(botAI); } - static UntypedValue* talk_target(PlayerbotAI* botAI) { return new TalkTargetValue(botAI); } - static UntypedValue* next_rpg_action(PlayerbotAI* botAI) { return new NextRpgActionValue(botAI); } - static UntypedValue* travel_target(PlayerbotAI* botAI) { return new TravelTargetValue(botAI); } - static UntypedValue* pull_target(PlayerbotAI* botAI) { return new PullTargetValue(botAI); } + static UntypedValue* attacker_count(PlayerbotAI* botAI) { return new AttackerCountValue(botAI); } + static UntypedValue* my_attacker_count(PlayerbotAI* botAI) { return new MyAttackerCountValue(botAI); } + static UntypedValue* has_aggro(PlayerbotAI* botAI) { return new HasAggroValue(botAI); } + static UntypedValue* mounted(PlayerbotAI* botAI) { return new IsMountedValue(botAI); } + static UntypedValue* health(PlayerbotAI* botAI) { return new HealthValue(botAI); } + static UntypedValue* rage(PlayerbotAI* botAI) { return new RageValue(botAI); } + static UntypedValue* energy(PlayerbotAI* botAI) { return new EnergyValue(botAI); } + static UntypedValue* mana(PlayerbotAI* botAI) { return new ManaValue(botAI); } + static UntypedValue* combo(PlayerbotAI* botAI) { return new ComboPointsValue(botAI); } + static UntypedValue* dead(PlayerbotAI* botAI) { return new IsDeadValue(botAI); } + static UntypedValue* pet_happy(PlayerbotAI* botAI) { return new PetIsHappyValue(botAI); } + static UntypedValue* pet_dead(PlayerbotAI* botAI) { return new PetIsDeadValue(botAI); } + static UntypedValue* has_mana(PlayerbotAI* botAI) { return new HasManaValue(botAI); } + static UntypedValue* nearest_game_objects(PlayerbotAI* botAI) { return new NearestGameObjects(botAI); } + static UntypedValue* nearest_game_objects_no_los(PlayerbotAI* botAI) + { + return new NearestGameObjects(botAI, sPlayerbotAIConfig->sightDistance, true); + } + static UntypedValue* closest_game_objects(PlayerbotAI* botAI) + { + return new NearestGameObjects(botAI, INTERACTION_DISTANCE); + } + static UntypedValue* log_level(PlayerbotAI* botAI) { return new LogLevelValue(botAI); } + static UntypedValue* nearest_npcs(PlayerbotAI* botAI) { return new NearestNpcsValue(botAI); } + static UntypedValue* nearest_totems(PlayerbotAI* botAI) { return new NearestTotemsValue(botAI); } + static UntypedValue* nearest_vehicles(PlayerbotAI* botAI) { return new NearestVehiclesValue(botAI); } + static UntypedValue* nearest_friendly_players(PlayerbotAI* botAI) { return new NearestFriendlyPlayersValue(botAI); } + static UntypedValue* closest_friendly_players(PlayerbotAI* botAI) + { + return new NearestFriendlyPlayersValue(botAI, INTERACTION_DISTANCE); + } + static UntypedValue* nearest_enemy_players(PlayerbotAI* botAI) { return new NearestEnemyPlayersValue(botAI); } + static UntypedValue* nearest_corpses(PlayerbotAI* botAI) { return new NearestCorpsesValue(botAI); } + static UntypedValue* possible_rpg_targets(PlayerbotAI* botAI) { return new PossibleRpgTargetsValue(botAI); } + static UntypedValue* possible_targets(PlayerbotAI* botAI) { return new PossibleTargetsValue(botAI); } + static UntypedValue* possible_triggers(PlayerbotAI* botAI) { return new PossibleTriggersValue(botAI); } + static UntypedValue* possible_targets_no_los(PlayerbotAI* botAI) + { + return new PossibleTargetsValue(botAI, "possible targets", sPlayerbotAIConfig->sightDistance, true); + } + static UntypedValue* possible_adds(PlayerbotAI* botAI) { return new PossibleAddsValue(botAI); } + static UntypedValue* prioritized_targets(PlayerbotAI* botAI) { return new PrioritizedTargetsValue(botAI); } + static UntypedValue* all_targets(PlayerbotAI* botAI) { return new AllTargetsValue(botAI); } + static UntypedValue* nearest_adds(PlayerbotAI* botAI) { return new NearestAddsValue(botAI); } + static UntypedValue* party_member_without_aura(PlayerbotAI* botAI) + { + return new PartyMemberWithoutAuraValue(botAI); + } + static UntypedValue* attacker_without_aura(PlayerbotAI* botAI) { return new AttackerWithoutAuraTargetValue(botAI); } + static UntypedValue* melee_attacker_without_aura(PlayerbotAI* botAI) + { + return new MeleeAttackerWithoutAuraTargetValue(botAI); + } + static UntypedValue* party_member_to_heal(PlayerbotAI* botAI) { return new PartyMemberToHeal(botAI); } + static UntypedValue* party_member_to_resurrect(PlayerbotAI* botAI) { return new PartyMemberToResurrect(botAI); } + static UntypedValue* party_member_to_dispel(PlayerbotAI* botAI) { return new PartyMemberToDispel(botAI); } + static UntypedValue* party_member_to_protect(PlayerbotAI* botAI) { return new PartyMemberToProtect(botAI); } + static UntypedValue* current_target(PlayerbotAI* botAI) { return new CurrentTargetValue(botAI); } + static UntypedValue* old_target(PlayerbotAI* botAI) { return new CurrentTargetValue(botAI); } + static UntypedValue* self_target(PlayerbotAI* botAI) { return new SelfTargetValue(botAI); } + static UntypedValue* master(PlayerbotAI* botAI) { return new MasterTargetValue(botAI); } + static UntypedValue* line_target(PlayerbotAI* botAI) { return new LineTargetValue(botAI); } + static UntypedValue* tank_target(PlayerbotAI* botAI) { return new TankTargetValue(botAI); } + static UntypedValue* dps_target(PlayerbotAI* botAI) { return new DpsTargetValue(botAI); } + static UntypedValue* dps_aoe_target(PlayerbotAI* botAI) { return new DpsAoeTargetValue(botAI); } + static UntypedValue* least_hp_target(PlayerbotAI* botAI) { return new LeastHpTargetValue(botAI); } + static UntypedValue* enemy_player_target(PlayerbotAI* botAI) { return new EnemyPlayerValue(botAI); } + static UntypedValue* cc_target(PlayerbotAI* botAI) { return new CcTargetValue(botAI); } + static UntypedValue* current_cc_target(PlayerbotAI* botAI) { return new CurrentCcTargetValue(botAI); } + static UntypedValue* pet_target(PlayerbotAI* botAI) { return new PetTargetValue(botAI); } + static UntypedValue* grind_target(PlayerbotAI* botAI) { return new GrindTargetValue(botAI); } + static UntypedValue* rti_target(PlayerbotAI* botAI) { return new RtiTargetValue(botAI); } + static UntypedValue* rti_cc_target(PlayerbotAI* botAI) { return new RtiCcTargetValue(botAI); } + static UntypedValue* duel_target(PlayerbotAI* botAI) { return new DuelTargetValue(botAI); } + static UntypedValue* has_totem(PlayerbotAI* botAI) { return new HasTotemValue(botAI); } + static UntypedValue* threat(PlayerbotAI* botAI) { return new ThreatValue(botAI); } + static UntypedValue* combat(PlayerbotAI* botAI) { return new IsInCombatValue(botAI); } + static UntypedValue* lfg_proposal(PlayerbotAI* botAI) { return new LfgProposalValue(botAI); } + static UntypedValue* bag_space(PlayerbotAI* botAI) { return new BagSpaceValue(botAI); } + static UntypedValue* durability(PlayerbotAI* botAI) { return new DurabilityValue(botAI); } + static UntypedValue* max_repair_cost(PlayerbotAI* botAI) { return new MaxGearRepairCostValue(botAI); } + static UntypedValue* repair_cost(PlayerbotAI* botAI) { return new RepairCostValue(botAI); } + static UntypedValue* train_cost(PlayerbotAI* botAI) { return new TrainCostValue(botAI); } + static UntypedValue* enemy_healer_target(PlayerbotAI* botAI) { return new EnemyHealerTargetValue(botAI); } + static UntypedValue* snare_target(PlayerbotAI* botAI) { return new SnareTargetValue(botAI); } + static UntypedValue* speed(PlayerbotAI* botAI) { return new SpeedValue(botAI); } + static UntypedValue* last_said(PlayerbotAI* botAI) { return new LastSaidValue(botAI); } + static UntypedValue* last_emote(PlayerbotAI* botAI) { return new LastEmoteValue(botAI); } + static UntypedValue* aoe_count(PlayerbotAI* botAI) { return new AoeCountValue(botAI); } + static UntypedValue* aoe_position(PlayerbotAI* botAI) { return new AoePositionValue(botAI); } + static UntypedValue* outfit_list_value(PlayerbotAI* botAI) { return new OutfitListValue(botAI); } + static UntypedValue* random_bot_update_value(PlayerbotAI* botAI) { return new RandomBotUpdateValue(botAI); } + static UntypedValue* nearest_non_bot_players(PlayerbotAI* botAI) { return new NearestNonBotPlayersValue(botAI); } + static UntypedValue* skip_spells_list_value(PlayerbotAI* botAI) { return new SkipSpellsListValue(botAI); } + static UntypedValue* rpg_target(PlayerbotAI* botAI) { return new RpgTargetValue(botAI); } + static UntypedValue* ignore_rpg_target(PlayerbotAI* botAI) { return new IgnoreRpgTargetValue(botAI); } + static UntypedValue* talk_target(PlayerbotAI* botAI) { return new TalkTargetValue(botAI); } + static UntypedValue* next_rpg_action(PlayerbotAI* botAI) { return new NextRpgActionValue(botAI); } + static UntypedValue* travel_target(PlayerbotAI* botAI) { return new TravelTargetValue(botAI); } + static UntypedValue* pull_target(PlayerbotAI* botAI) { return new PullTargetValue(botAI); } - static UntypedValue* bg_master(PlayerbotAI* botAI) { return new BgMasterValue(botAI); } - static UntypedValue* bg_role(PlayerbotAI* botAI) { return new BgRoleValue(botAI); } - static UntypedValue* arena_type(PlayerbotAI* botAI) { return new ArenaTypeValue(botAI); } - static UntypedValue* bg_type(PlayerbotAI* botAI) { return new BgTypeValue(botAI); } - static UntypedValue* rpg_bg_type(PlayerbotAI* botAI) { return new RpgBgTypeValue(botAI); } - static UntypedValue* team_fc(PlayerbotAI* botAI) { return new FlagCarrierValue(botAI, true, true); } - static UntypedValue* enemy_fc(PlayerbotAI* botAI) { return new FlagCarrierValue(botAI, false, true); } + static UntypedValue* bg_master(PlayerbotAI* botAI) { return new BgMasterValue(botAI); } + static UntypedValue* bg_role(PlayerbotAI* botAI) { return new BgRoleValue(botAI); } + static UntypedValue* arena_type(PlayerbotAI* botAI) { return new ArenaTypeValue(botAI); } + static UntypedValue* bg_type(PlayerbotAI* botAI) { return new BgTypeValue(botAI); } + static UntypedValue* rpg_bg_type(PlayerbotAI* botAI) { return new RpgBgTypeValue(botAI); } + static UntypedValue* team_fc(PlayerbotAI* botAI) { return new FlagCarrierValue(botAI, true, true); } + static UntypedValue* enemy_fc(PlayerbotAI* botAI) { return new FlagCarrierValue(botAI, false, true); } - static UntypedValue* last_long_move(PlayerbotAI* botAI) { return new LastLongMoveValue(botAI); } - static UntypedValue* home_bind(PlayerbotAI* botAI) { return new HomeBindValue(botAI); } + static UntypedValue* last_long_move(PlayerbotAI* botAI) { return new LastLongMoveValue(botAI); } + static UntypedValue* home_bind(PlayerbotAI* botAI) { return new HomeBindValue(botAI); } - static UntypedValue* free_quest_log_slots(PlayerbotAI* botAI) { return new FreeQuestLogSlotValue(botAI); } - static UntypedValue* dialog_status(PlayerbotAI* botAI) { return new DialogStatusValue(botAI); } - static UntypedValue* dialog_status_quest(PlayerbotAI* botAI) { return new DialogStatusQuestValue(botAI); } - static UntypedValue* can_accept_quest_npc(PlayerbotAI* botAI) { return new CanAcceptQuestValue(botAI); } - static UntypedValue* can_accept_quest_low_level_npc(PlayerbotAI* botAI) { return new CanAcceptQuestLowLevelValue(botAI); } - static UntypedValue* can_turn_in_quest_npc(PlayerbotAI* botAI) { return new CanTurnInQuestValue(botAI); } + static UntypedValue* free_quest_log_slots(PlayerbotAI* botAI) { return new FreeQuestLogSlotValue(botAI); } + static UntypedValue* dialog_status(PlayerbotAI* botAI) { return new DialogStatusValue(botAI); } + static UntypedValue* dialog_status_quest(PlayerbotAI* botAI) { return new DialogStatusQuestValue(botAI); } + static UntypedValue* can_accept_quest_npc(PlayerbotAI* botAI) { return new CanAcceptQuestValue(botAI); } + static UntypedValue* can_accept_quest_low_level_npc(PlayerbotAI* botAI) + { + return new CanAcceptQuestLowLevelValue(botAI); + } + static UntypedValue* can_turn_in_quest_npc(PlayerbotAI* botAI) { return new CanTurnInQuestValue(botAI); } - static UntypedValue* money_needed_for(PlayerbotAI* botAI) { return new MoneyNeededForValue(botAI); } - static UntypedValue* total_money_needed_for(PlayerbotAI* botAI) { return new TotalMoneyNeededForValue(botAI); } - static UntypedValue* free_money_for(PlayerbotAI* botAI) { return new FreeMoneyForValue(botAI); } - static UntypedValue* should_get_money(PlayerbotAI* botAI) { return new ShouldGetMoneyValue(botAI); } + static UntypedValue* money_needed_for(PlayerbotAI* botAI) { return new MoneyNeededForValue(botAI); } + static UntypedValue* total_money_needed_for(PlayerbotAI* botAI) { return new TotalMoneyNeededForValue(botAI); } + static UntypedValue* free_money_for(PlayerbotAI* botAI) { return new FreeMoneyForValue(botAI); } + static UntypedValue* should_get_money(PlayerbotAI* botAI) { return new ShouldGetMoneyValue(botAI); } - static UntypedValue* can_move_around(PlayerbotAI* botAI) { return new CanMoveAroundValue(botAI); } - static UntypedValue* should_home_bind(PlayerbotAI* botAI) { return new ShouldHomeBindValue(botAI); } - static UntypedValue* should_repair(PlayerbotAI* botAI) { return new ShouldRepairValue(botAI); } - static UntypedValue* can_repair(PlayerbotAI* botAI) { return new CanRepairValue(botAI); } - static UntypedValue* should_sell(PlayerbotAI* botAI) { return new ShouldSellValue(botAI); } - static UntypedValue* can_sell(PlayerbotAI* botAI) { return new CanSellValue(botAI); } - static UntypedValue* can_fight_equal(PlayerbotAI* botAI) { return new CanFightEqualValue(botAI); } - static UntypedValue* can_fight_elite(PlayerbotAI* botAI) { return new CanFightEliteValue(botAI); } - static UntypedValue* can_fight_boss(PlayerbotAI* botAI) { return new CanFightBossValue(botAI); } + static UntypedValue* can_move_around(PlayerbotAI* botAI) { return new CanMoveAroundValue(botAI); } + static UntypedValue* should_home_bind(PlayerbotAI* botAI) { return new ShouldHomeBindValue(botAI); } + static UntypedValue* should_repair(PlayerbotAI* botAI) { return new ShouldRepairValue(botAI); } + static UntypedValue* can_repair(PlayerbotAI* botAI) { return new CanRepairValue(botAI); } + static UntypedValue* should_sell(PlayerbotAI* botAI) { return new ShouldSellValue(botAI); } + static UntypedValue* can_sell(PlayerbotAI* botAI) { return new CanSellValue(botAI); } + static UntypedValue* can_fight_equal(PlayerbotAI* botAI) { return new CanFightEqualValue(botAI); } + static UntypedValue* can_fight_elite(PlayerbotAI* botAI) { return new CanFightEliteValue(botAI); } + static UntypedValue* can_fight_boss(PlayerbotAI* botAI) { return new CanFightBossValue(botAI); } - static UntypedValue* death_count(PlayerbotAI* botAI) { return new DeathCountValue(botAI); } + static UntypedValue* death_count(PlayerbotAI* botAI) { return new DeathCountValue(botAI); } - static UntypedValue* group_members(PlayerbotAI* botAI) { return new GroupMembersValue(botAI); } - static UntypedValue* following_party(PlayerbotAI* botAI) { return new IsFollowingPartyValue(botAI); } - static UntypedValue* near_leader(PlayerbotAI* botAI) { return new IsNearLeaderValue(botAI); } - static UntypedValue* and_value(PlayerbotAI* botAI) { return new BoolANDValue(botAI); } - static UntypedValue* group_count(PlayerbotAI* botAI) { return new GroupBoolCountValue(botAI); } - static UntypedValue* group_and(PlayerbotAI* botAI) { return new GroupBoolANDValue(botAI); } - static UntypedValue* group_or(PlayerbotAI* botAI) { return new GroupBoolORValue(botAI); } - static UntypedValue* group_ready(PlayerbotAI* botAI) { return new GroupReadyValue(botAI); } + static UntypedValue* group_members(PlayerbotAI* botAI) { return new GroupMembersValue(botAI); } + static UntypedValue* following_party(PlayerbotAI* botAI) { return new IsFollowingPartyValue(botAI); } + static UntypedValue* near_leader(PlayerbotAI* botAI) { return new IsNearLeaderValue(botAI); } + static UntypedValue* and_value(PlayerbotAI* botAI) { return new BoolANDValue(botAI); } + static UntypedValue* group_count(PlayerbotAI* botAI) { return new GroupBoolCountValue(botAI); } + static UntypedValue* group_and(PlayerbotAI* botAI) { return new GroupBoolANDValue(botAI); } + static UntypedValue* group_or(PlayerbotAI* botAI) { return new GroupBoolORValue(botAI); } + static UntypedValue* group_ready(PlayerbotAI* botAI) { return new GroupReadyValue(botAI); } - static UntypedValue* petition_signs(PlayerbotAI* botAI) { return new PetitionSignsValue(botAI); } + static UntypedValue* petition_signs(PlayerbotAI* botAI) { return new PetitionSignsValue(botAI); } - static UntypedValue* experience(PlayerbotAI* botAI) { return new ExperienceValue(botAI); } + static UntypedValue* experience(PlayerbotAI* botAI) { return new ExperienceValue(botAI); } - static UntypedValue* entry_loot_usage(PlayerbotAI* botAI) { return new EntryLootUsageValue(botAI); } - static UntypedValue* has_upgrade(PlayerbotAI* botAI) { return new HasUpgradeValue(botAI); } - static UntypedValue* items_useful_to_give(PlayerbotAI* botAI) { return new ItemsUsefulToGiveValue(botAI); } + static UntypedValue* entry_loot_usage(PlayerbotAI* botAI) { return new EntryLootUsageValue(botAI); } + static UntypedValue* has_upgrade(PlayerbotAI* botAI) { return new HasUpgradeValue(botAI); } + static UntypedValue* items_useful_to_give(PlayerbotAI* botAI) { return new ItemsUsefulToGiveValue(botAI); } - static UntypedValue* see_spell_location(PlayerbotAI* botAI) { return new SeeSpellLocationValue(botAI); } - static UntypedValue* RTSC_selected(PlayerbotAI* botAI) { return new RTSCSelectedValue(botAI); } - static UntypedValue* RTSC_next_spell_action(PlayerbotAI* botAI) { return new RTSCNextSpellActionValue(botAI); } - static UntypedValue* RTSC_saved_location(PlayerbotAI* botAI) { return new RTSCSavedLocationValue(botAI); } + static UntypedValue* see_spell_location(PlayerbotAI* botAI) { return new SeeSpellLocationValue(botAI); } + static UntypedValue* RTSC_selected(PlayerbotAI* botAI) { return new RTSCSelectedValue(botAI); } + static UntypedValue* RTSC_next_spell_action(PlayerbotAI* botAI) { return new RTSCNextSpellActionValue(botAI); } + static UntypedValue* RTSC_saved_location(PlayerbotAI* botAI) { return new RTSCSavedLocationValue(botAI); } - static UntypedValue* has_area_debuff(PlayerbotAI* botAI) { return new HasAreaDebuffValue(botAI); } + static UntypedValue* has_area_debuff(PlayerbotAI* botAI) { return new HasAreaDebuffValue(botAI); } - static UntypedValue* main_tank(PlayerbotAI* ai) { return new PartyMemberMainTankValue(ai); } - static UntypedValue* find_target(PlayerbotAI* ai) { return new FindTargetValue(ai); } - static UntypedValue* boss_target(PlayerbotAI* ai) { return new BossTargetValue(ai); } - static UntypedValue* nearest_triggers(PlayerbotAI* ai) { return new NearestTriggersValue(ai); } - static UntypedValue* neglect_threat(PlayerbotAI* ai) { return new NeglectThreatResetValue(ai); } - static UntypedValue* expected_lifetime(PlayerbotAI* ai) { return new ExpectedLifetimeValue(ai); } - static UntypedValue* expected_group_dps(PlayerbotAI* ai) { return new ExpectedGroupDpsValue(ai); } - static UntypedValue* area_debuff(PlayerbotAI* ai) { return new AreaDebuffValue(ai); } - static UntypedValue* nearest_trap_with_damange(PlayerbotAI* ai) { return new NearestTrapWithDamageValue(ai); } - static UntypedValue* disperse_distance(PlayerbotAI* ai) { return new DisperseDistanceValue(ai); } - static UntypedValue* last_flee_angle(PlayerbotAI* ai) { return new LastFleeAngleValue(ai); } - static UntypedValue* last_flee_timestamp(PlayerbotAI* ai) { return new LastFleeTimestampValue(ai); } - static UntypedValue* recently_flee_info(PlayerbotAI* ai) { return new RecentlyFleeInfo(ai); } + static UntypedValue* main_tank(PlayerbotAI* ai) { return new PartyMemberMainTankValue(ai); } + static UntypedValue* find_target(PlayerbotAI* ai) { return new FindTargetValue(ai); } + static UntypedValue* boss_target(PlayerbotAI* ai) { return new BossTargetValue(ai); } + static UntypedValue* nearest_triggers(PlayerbotAI* ai) { return new NearestTriggersValue(ai); } + static UntypedValue* neglect_threat(PlayerbotAI* ai) { return new NeglectThreatResetValue(ai); } + static UntypedValue* expected_lifetime(PlayerbotAI* ai) { return new ExpectedLifetimeValue(ai); } + static UntypedValue* expected_group_dps(PlayerbotAI* ai) { return new ExpectedGroupDpsValue(ai); } + static UntypedValue* area_debuff(PlayerbotAI* ai) { return new AreaDebuffValue(ai); } + static UntypedValue* nearest_trap_with_damange(PlayerbotAI* ai) { return new NearestTrapWithDamageValue(ai); } + static UntypedValue* disperse_distance(PlayerbotAI* ai) { return new DisperseDistanceValue(ai); } + static UntypedValue* last_flee_angle(PlayerbotAI* ai) { return new LastFleeAngleValue(ai); } + static UntypedValue* last_flee_timestamp(PlayerbotAI* ai) { return new LastFleeTimestampValue(ai); } + static UntypedValue* recently_flee_info(PlayerbotAI* ai) { return new RecentlyFleeInfo(ai); } }; #endif diff --git a/src/strategy/warlock/DpsWarlockStrategy.cpp b/src/strategy/warlock/DpsWarlockStrategy.cpp index 3e79dfa8..e9b7fea5 100644 --- a/src/strategy/warlock/DpsWarlockStrategy.cpp +++ b/src/strategy/warlock/DpsWarlockStrategy.cpp @@ -1,42 +1,44 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "DpsWarlockStrategy.h" + #include "Playerbots.h" class DpsWarlockStrategyActionNodeFactory : public NamedObjectFactory { - public: - DpsWarlockStrategyActionNodeFactory() - { - creators["shadow bolt"] = &shadow_bolt; - creators["unstable affliction"] = &unstable_affliction; - creators["unstable affliction on attacker"] = &unstable_affliction_on_attacker; - } +public: + DpsWarlockStrategyActionNodeFactory() + { + creators["shadow bolt"] = &shadow_bolt; + creators["unstable affliction"] = &unstable_affliction; + creators["unstable affliction on attacker"] = &unstable_affliction_on_attacker; + } - private: - static ActionNode* shadow_bolt([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("shadow bolt", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), - /*C*/ nullptr); - } - static ActionNode* unstable_affliction(PlayerbotAI* ai) - { - return new ActionNode ("unstable affliction", - /*P*/ NULL, - /*A*/ NextAction::array(0, new NextAction("immolate"), NULL), - /*C*/ NULL); - } - static ActionNode* unstable_affliction_on_attacker(PlayerbotAI* ai) - { - return new ActionNode ("unstable affliction on attacker", - /*P*/ NULL, - /*A*/ NextAction::array(0, new NextAction("immolate on attacker"), NULL), - /*C*/ NULL); - } +private: + static ActionNode* shadow_bolt([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("shadow bolt", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("shoot"), nullptr), + /*C*/ nullptr); + } + static ActionNode* unstable_affliction(PlayerbotAI* ai) + { + return new ActionNode("unstable affliction", + /*P*/ NULL, + /*A*/ NextAction::array(0, new NextAction("immolate"), NULL), + /*C*/ NULL); + } + static ActionNode* unstable_affliction_on_attacker(PlayerbotAI* ai) + { + return new ActionNode("unstable affliction on attacker", + /*P*/ NULL, + /*A*/ NextAction::array(0, new NextAction("immolate on attacker"), NULL), + /*C*/ NULL); + } }; DpsWarlockStrategy::DpsWarlockStrategy(PlayerbotAI* botAI) : GenericWarlockStrategy(botAI) @@ -46,59 +48,55 @@ DpsWarlockStrategy::DpsWarlockStrategy(PlayerbotAI* botAI) : GenericWarlockStrat NextAction** DpsWarlockStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("haunt", ACTION_DEFAULT + 0.3f), - new NextAction("demonic empowerment", ACTION_DEFAULT + 0.2f), - new NextAction("shadow bolt", ACTION_DEFAULT + 0.1f), - new NextAction("shoot", ACTION_DEFAULT), - nullptr); + return NextAction::array( + 0, new NextAction("haunt", ACTION_DEFAULT + 0.3f), new NextAction("demonic empowerment", ACTION_DEFAULT + 0.2f), + new NextAction("shadow bolt", ACTION_DEFAULT + 0.1f), new NextAction("shoot", ACTION_DEFAULT), nullptr); } void DpsWarlockStrategy::InitTriggers(std::vector& triggers) { GenericWarlockStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("backlash", NextAction::array(0, new NextAction("shadow bolt", 20.0f), nullptr))); + triggers.push_back( + new TriggerNode("backlash", NextAction::array(0, new NextAction("shadow bolt", 20.0f), nullptr))); - triggers.push_back(new TriggerNode( - "haunt", - NextAction::array(0, new NextAction("haunt", 26.0f), NULL))); + triggers.push_back(new TriggerNode("haunt", NextAction::array(0, new NextAction("haunt", 26.0f), NULL))); - triggers.push_back(new TriggerNode( - "shadow trance", - NextAction::array(0, new NextAction("shadow bolt", 15.0f), NULL))); + triggers.push_back( + new TriggerNode("shadow trance", NextAction::array(0, new NextAction("shadow bolt", 15.0f), NULL))); - triggers.push_back(new TriggerNode( - "backlash", - NextAction::array(0, new NextAction("shadow bolt", 15.0f), NULL))); + triggers.push_back(new TriggerNode("backlash", NextAction::array(0, new NextAction("shadow bolt", 15.0f), NULL))); - triggers.push_back(new TriggerNode( - "molten core", - NextAction::array(0, new NextAction("incinerate", 15.0f), NULL))); + triggers.push_back(new TriggerNode("molten core", NextAction::array(0, new NextAction("incinerate", 15.0f), NULL))); - triggers.push_back(new TriggerNode( - "decimation", - NextAction::array(0, new NextAction("soul fire", 16.0f), NULL))); - - triggers.push_back(new TriggerNode( - "metamorphosis", - NextAction::array(0, new NextAction("metamorphosis", 20.0f), NULL))); + triggers.push_back(new TriggerNode("decimation", NextAction::array(0, new NextAction("soul fire", 16.0f), NULL))); + + triggers.push_back( + new TriggerNode("metamorphosis", NextAction::array(0, new NextAction("metamorphosis", 20.0f), NULL))); } void DpsAoeWarlockStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, - new NextAction("seed of corruption", 39.0f), - new NextAction("seed of corruption on attacker", 38.0f), - new NextAction("rain of fire", 37.0f), nullptr))); - triggers.push_back(new TriggerNode("corruption on attacker", NextAction::array(0, new NextAction("corruption on attacker", 27.0f), nullptr))); - triggers.push_back(new TriggerNode("unstable affliction on attacker", NextAction::array(0, new NextAction("unstable affliction on attacker", 26.0f), NULL))); - triggers.push_back(new TriggerNode("curse of agony on attacker", NextAction::array(0, new NextAction("curse of agony on attacker", 25.0f), nullptr))); + triggers.push_back( + new TriggerNode("medium aoe", NextAction::array(0, new NextAction("seed of corruption", 39.0f), + new NextAction("seed of corruption on attacker", 38.0f), + new NextAction("rain of fire", 37.0f), nullptr))); + triggers.push_back(new TriggerNode("corruption on attacker", + NextAction::array(0, new NextAction("corruption on attacker", 27.0f), nullptr))); + triggers.push_back( + new TriggerNode("unstable affliction on attacker", + NextAction::array(0, new NextAction("unstable affliction on attacker", 26.0f), NULL))); + triggers.push_back( + new TriggerNode("curse of agony on attacker", + NextAction::array(0, new NextAction("curse of agony on attacker", 25.0f), nullptr))); } void DpsWarlockDebuffStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("corruption", NextAction::array(0, new NextAction("corruption", 22.0f), nullptr))); - triggers.push_back(new TriggerNode("unstable affliction", NextAction::array(0, new NextAction("unstable affliction", 21.0f), NULL))); - triggers.push_back(new TriggerNode("curse of agony", NextAction::array(0, new NextAction("curse of agony", 20.0f), nullptr))); + triggers.push_back( + new TriggerNode("corruption", NextAction::array(0, new NextAction("corruption", 22.0f), nullptr))); + triggers.push_back(new TriggerNode("unstable affliction", + NextAction::array(0, new NextAction("unstable affliction", 21.0f), NULL))); + triggers.push_back( + new TriggerNode("curse of agony", NextAction::array(0, new NextAction("curse of agony", 20.0f), nullptr))); } diff --git a/src/strategy/warlock/DpsWarlockStrategy.h b/src/strategy/warlock/DpsWarlockStrategy.h index 6a7145c9..b6be2eee 100644 --- a/src/strategy/warlock/DpsWarlockStrategy.h +++ b/src/strategy/warlock/DpsWarlockStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_DPSWARLOCKSTRATEGY_H @@ -12,31 +13,31 @@ class PlayerbotAI; class DpsWarlockStrategy : public GenericWarlockStrategy { - public: - DpsWarlockStrategy(PlayerbotAI* botAI); +public: + DpsWarlockStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "dps"; } - void InitTriggers(std::vector& triggers) override; - NextAction** getDefaultActions() override; - uint32 GetType() const override { return GenericWarlockStrategy::GetType() | STRATEGY_TYPE_DPS; } + std::string const getName() override { return "dps"; } + void InitTriggers(std::vector& triggers) override; + NextAction** getDefaultActions() override; + uint32 GetType() const override { return GenericWarlockStrategy::GetType() | STRATEGY_TYPE_DPS; } }; class DpsAoeWarlockStrategy : public CombatStrategy { - public: - DpsAoeWarlockStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + DpsAoeWarlockStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "aoe"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "aoe"; } }; class DpsWarlockDebuffStrategy : public CombatStrategy { - public: - DpsWarlockDebuffStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) { } +public: + DpsWarlockDebuffStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) {} - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "dps debuff"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "dps debuff"; } }; #endif diff --git a/src/strategy/warlock/GenericWarlockNonCombatStrategy.cpp b/src/strategy/warlock/GenericWarlockNonCombatStrategy.cpp index 808f8e6e..7ed900cf 100644 --- a/src/strategy/warlock/GenericWarlockNonCombatStrategy.cpp +++ b/src/strategy/warlock/GenericWarlockNonCombatStrategy.cpp @@ -1,68 +1,70 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericWarlockNonCombatStrategy.h" + #include "Playerbots.h" class GenericWarlockNonCombatStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericWarlockNonCombatStrategyActionNodeFactory() - { - creators["fel armor"] = &fel_armor; - creators["demon armor"] = &demon_armor; - creators["summon voidwalker"] = &summon_voidwalker; - creators["summon felguard"] = &summon_felguard; - creators["summon succubus"] = &summon_succubus; - creators["summon felhunter"] = &summon_felhunter; - } +public: + GenericWarlockNonCombatStrategyActionNodeFactory() + { + creators["fel armor"] = &fel_armor; + creators["demon armor"] = &demon_armor; + creators["summon voidwalker"] = &summon_voidwalker; + creators["summon felguard"] = &summon_felguard; + creators["summon succubus"] = &summon_succubus; + creators["summon felhunter"] = &summon_felhunter; + } - private: - static ActionNode* fel_armor([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("fel armor", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("demon armor"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* fel_armor([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("fel armor", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("demon armor"), nullptr), + /*C*/ nullptr); + } - static ActionNode* demon_armor([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("demon armor", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("demon skin"), nullptr), - /*C*/ nullptr); - } + static ActionNode* demon_armor([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("demon armor", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("demon skin"), nullptr), + /*C*/ nullptr); + } - static ActionNode* summon_voidwalker([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("summon voidwalker", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("summon imp"), nullptr), - /*C*/ nullptr); - } - static ActionNode* summon_succubus(PlayerbotAI* botAI) - { - return new ActionNode("summon succubus", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("summon imp"), nullptr), - /*C*/ nullptr); - } - static ActionNode* summon_felhunter([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("summon felhunter", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("summon voidwalker"), nullptr), - /*C*/ nullptr); - } - static ActionNode* summon_felguard([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("summon felguard", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("summon succubus"), nullptr), - /*C*/ nullptr); - } + static ActionNode* summon_voidwalker([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("summon voidwalker", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("summon imp"), nullptr), + /*C*/ nullptr); + } + static ActionNode* summon_succubus(PlayerbotAI* botAI) + { + return new ActionNode("summon succubus", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("summon imp"), nullptr), + /*C*/ nullptr); + } + static ActionNode* summon_felhunter([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("summon felhunter", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("summon voidwalker"), nullptr), + /*C*/ nullptr); + } + static ActionNode* summon_felguard([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("summon felguard", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("summon succubus"), nullptr), + /*C*/ nullptr); + } }; GenericWarlockNonCombatStrategy::GenericWarlockNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) @@ -74,43 +76,44 @@ void GenericWarlockNonCombatStrategy::InitTriggers(std::vector& tr { NonCombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("demon armor", NextAction::array(0, new NextAction("fel armor", 21.0f), nullptr))); + triggers.push_back( + new TriggerNode("demon armor", NextAction::array(0, new NextAction("fel armor", 21.0f), nullptr))); // triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("apply oil", 1.0f), nullptr))); - triggers.push_back(new TriggerNode("has pet", NextAction::array(0, new NextAction("toggle pet spell", 60.0f), nullptr))); - triggers.push_back(new TriggerNode("no healthstone", NextAction::array(0, new NextAction("create healthstone", 15.0f), nullptr))); - triggers.push_back(new TriggerNode("no spellstone", NextAction::array(0, new NextAction("create spellstone", 13.0f), nullptr))); - triggers.push_back(new TriggerNode("spellstone", NextAction::array(0, new NextAction("spellstone", 13.0f), nullptr))); + triggers.push_back( + new TriggerNode("has pet", NextAction::array(0, new NextAction("toggle pet spell", 60.0f), nullptr))); + triggers.push_back( + new TriggerNode("no healthstone", NextAction::array(0, new NextAction("create healthstone", 15.0f), nullptr))); + triggers.push_back( + new TriggerNode("no spellstone", NextAction::array(0, new NextAction("create spellstone", 13.0f), nullptr))); + triggers.push_back( + new TriggerNode("spellstone", NextAction::array(0, new NextAction("spellstone", 13.0f), nullptr))); } void WarlockPetStrategy::InitTriggers(std::vector& triggers) { - // triggers.push_back(new TriggerNode("no pet", NextAction::array(0, new NextAction("summon felguard", 60.0f), nullptr))); + // triggers.push_back(new TriggerNode("no pet", NextAction::array(0, new NextAction("summon felguard", 60.0f), + // nullptr))); // TODO Warlock pets } -SummonImpStrategy::SummonImpStrategy(PlayerbotAI* ai): NonCombatStrategy(ai) {} +SummonImpStrategy::SummonImpStrategy(PlayerbotAI* ai) : NonCombatStrategy(ai) {} void SummonImpStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode( - "no pet", - NextAction::array(0, new NextAction("summon imp", 11.0f), NULL))); + triggers.push_back(new TriggerNode("no pet", NextAction::array(0, new NextAction("summon imp", 11.0f), NULL))); } -SummonFelguardStrategy::SummonFelguardStrategy(PlayerbotAI* ai): NonCombatStrategy(ai) {} +SummonFelguardStrategy::SummonFelguardStrategy(PlayerbotAI* ai) : NonCombatStrategy(ai) {} void SummonFelguardStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode( - "no pet", - NextAction::array(0, new NextAction("summon felguard", 11.0f), NULL))); + triggers.push_back(new TriggerNode("no pet", NextAction::array(0, new NextAction("summon felguard", 11.0f), NULL))); } -SummonFelhunterStrategy::SummonFelhunterStrategy(PlayerbotAI* ai): NonCombatStrategy(ai) {} +SummonFelhunterStrategy::SummonFelhunterStrategy(PlayerbotAI* ai) : NonCombatStrategy(ai) {} void SummonFelhunterStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode( - "no pet", - NextAction::array(0, new NextAction("summon felhunter", 11.0f), NULL))); + triggers.push_back( + new TriggerNode("no pet", NextAction::array(0, new NextAction("summon felhunter", 11.0f), NULL))); } \ No newline at end of file diff --git a/src/strategy/warlock/GenericWarlockNonCombatStrategy.h b/src/strategy/warlock/GenericWarlockNonCombatStrategy.h index e20c36b1..18fdcc3e 100644 --- a/src/strategy/warlock/GenericWarlockNonCombatStrategy.h +++ b/src/strategy/warlock/GenericWarlockNonCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICWARLOCKNONCOMBATSTRATEGY_H @@ -11,47 +12,50 @@ class PlayerbotAI; class GenericWarlockNonCombatStrategy : public NonCombatStrategy { - public: - GenericWarlockNonCombatStrategy(PlayerbotAI* botAI); +public: + GenericWarlockNonCombatStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "nc"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "nc"; } + void InitTriggers(std::vector& triggers) override; }; class WarlockPetStrategy : public Strategy { - public: - WarlockPetStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } +public: + WarlockPetStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} - std::string const getName() override { return "pet"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "pet"; } + void InitTriggers(std::vector& triggers) override; }; class SummonImpStrategy : public NonCombatStrategy { - public: - SummonImpStrategy(PlayerbotAI* ai); - virtual std::string const getName() override { return "bhealth"; } - public: - void InitTriggers(std::vector& triggers) override; +public: + SummonImpStrategy(PlayerbotAI* ai); + virtual std::string const getName() override { return "bhealth"; } + +public: + void InitTriggers(std::vector& triggers) override; }; class SummonFelguardStrategy : public NonCombatStrategy { - public: - SummonFelguardStrategy(PlayerbotAI* ai); - virtual std::string const getName() override { return "bdps"; } - public: - void InitTriggers(std::vector& triggers) override; +public: + SummonFelguardStrategy(PlayerbotAI* ai); + virtual std::string const getName() override { return "bdps"; } + +public: + void InitTriggers(std::vector& triggers) override; }; class SummonFelhunterStrategy : public NonCombatStrategy { - public: - SummonFelhunterStrategy(PlayerbotAI* ai); - virtual std::string const getName() override { return "bmana"; } - public: - void InitTriggers(std::vector& triggers) override; +public: + SummonFelhunterStrategy(PlayerbotAI* ai); + virtual std::string const getName() override { return "bmana"; } + +public: + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/warlock/GenericWarlockStrategy.cpp b/src/strategy/warlock/GenericWarlockStrategy.cpp index 729d0d57..8ed081b7 100644 --- a/src/strategy/warlock/GenericWarlockStrategy.cpp +++ b/src/strategy/warlock/GenericWarlockStrategy.cpp @@ -1,34 +1,36 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericWarlockStrategy.h" + #include "Playerbots.h" class GenericWarlockStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericWarlockStrategyActionNodeFactory() - { - //creators["summon voidwalker"] = &summon_voidwalker; - creators["banish"] = &banish; - } +public: + GenericWarlockStrategyActionNodeFactory() + { + // creators["summon voidwalker"] = &summon_voidwalker; + creators["banish"] = &banish; + } - private: - //static ActionNode* summon_voidwalker([[maybe_unused]] PlayerbotAI* botAI) - //{ - //return new ActionNode ("summon voidwalker", - /*P*/ //nullptr, - /*A*/ //NextAction::array(0, new NextAction("drain soul"), nullptr), - /*C*/ //nullptr); - //} - static ActionNode* banish([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("banish", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("fear"), nullptr), - /*C*/ nullptr); - } +private: + // static ActionNode* summon_voidwalker([[maybe_unused]] PlayerbotAI* botAI) + //{ + // return new ActionNode ("summon voidwalker", + /*P*/ // nullptr, + /*A*/ // NextAction::array(0, new NextAction("drain soul"), nullptr), + /*C*/ // nullptr); + //} + static ActionNode* banish([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("banish", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("fear"), nullptr), + /*C*/ nullptr); + } }; GenericWarlockStrategy::GenericWarlockStrategy(PlayerbotAI* botAI) : RangedCombatStrategy(botAI) @@ -36,26 +38,28 @@ GenericWarlockStrategy::GenericWarlockStrategy(PlayerbotAI* botAI) : RangedComba actionNodeFactories.Add(new GenericWarlockStrategyActionNodeFactory()); } -NextAction** GenericWarlockStrategy::getDefaultActions() -{ - return NextAction::array(0, nullptr); -} +NextAction** GenericWarlockStrategy::getDefaultActions() { return NextAction::array(0, nullptr); } void GenericWarlockStrategy::InitTriggers(std::vector& triggers) { RangedCombatStrategy::InitTriggers(triggers); - // triggers.push_back(new TriggerNode("shadow trance", NextAction::array(0, new NextAction("shadow bolt", 20.0f), nullptr))); - // triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("drain life", 40.0f), nullptr))); - triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("life tap", ACTION_EMERGENCY + 5), nullptr))); - triggers.push_back(new TriggerNode("target critical health", NextAction::array(0, new NextAction("drain soul", 30.0f), nullptr))); - // triggers.push_back(new TriggerNode("immolate", NextAction::array(0, new NextAction("immolate", 13.0f), new NextAction("conflagrate", 13.0f), nullptr))); - // triggers.push_back(new TriggerNode("enemy too close for spell", NextAction::array(0, new NextAction("flee", 49.0f), NULL))); + // triggers.push_back(new TriggerNode("shadow trance", NextAction::array(0, new NextAction("shadow bolt", 20.0f), + // nullptr))); triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("drain + // life", 40.0f), nullptr))); + triggers.push_back( + new TriggerNode("low mana", NextAction::array(0, new NextAction("life tap", ACTION_EMERGENCY + 5), nullptr))); + triggers.push_back( + new TriggerNode("target critical health", NextAction::array(0, new NextAction("drain soul", 30.0f), nullptr))); + // triggers.push_back(new TriggerNode("immolate", NextAction::array(0, new NextAction("immolate", 13.0f), new + // NextAction("conflagrate", 13.0f), nullptr))); triggers.push_back(new TriggerNode("enemy too close for spell", + // NextAction::array(0, new NextAction("flee", 49.0f), NULL))); } void WarlockBoostStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("amplify curse", NextAction::array(0, new NextAction("amplify curse", 41.0f), nullptr))); + triggers.push_back( + new TriggerNode("amplify curse", NextAction::array(0, new NextAction("amplify curse", 41.0f), nullptr))); } void WarlockCcStrategy::InitTriggers(std::vector& triggers) diff --git a/src/strategy/warlock/GenericWarlockStrategy.h b/src/strategy/warlock/GenericWarlockStrategy.h index aeffabfb..5cf98510 100644 --- a/src/strategy/warlock/GenericWarlockStrategy.h +++ b/src/strategy/warlock/GenericWarlockStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICWARLOCKSTRATEGY_H @@ -12,30 +13,30 @@ class PlayerbotAI; class GenericWarlockStrategy : public RangedCombatStrategy { - public: - GenericWarlockStrategy(PlayerbotAI* botAI); +public: + GenericWarlockStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "warlock"; } - void InitTriggers(std::vector& triggers) override; - NextAction** getDefaultActions() override; + std::string const getName() override { return "warlock"; } + void InitTriggers(std::vector& triggers) override; + NextAction** getDefaultActions() override; }; class WarlockBoostStrategy : public Strategy { - public: - WarlockBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + WarlockBoostStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - std::string const getName() override { return "boost"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "boost"; } + void InitTriggers(std::vector& triggers) override; }; class WarlockCcStrategy : public Strategy { - public: - WarlockCcStrategy(PlayerbotAI* botAI) : Strategy(botAI) { }; +public: + WarlockCcStrategy(PlayerbotAI* botAI) : Strategy(botAI){}; - std::string const getName() override { return "cc"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "cc"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/warlock/TankWarlockStrategy.cpp b/src/strategy/warlock/TankWarlockStrategy.cpp index a828fdec..551a6e0e 100644 --- a/src/strategy/warlock/TankWarlockStrategy.cpp +++ b/src/strategy/warlock/TankWarlockStrategy.cpp @@ -1,53 +1,55 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TankWarlockStrategy.h" + #include "Playerbots.h" class GenericWarlockStrategyActionNodeFactory : public NamedObjectFactory { - public: - GenericWarlockStrategyActionNodeFactory() - { - creators["summon voidwalker"] = &summon_voidwalker; - creators["summon felguard"] = &summon_felguard; - creators["summon succubus"] = &summon_succubus; - creators["summon felhunter"] = &summon_felhunter; - } +public: + GenericWarlockStrategyActionNodeFactory() + { + creators["summon voidwalker"] = &summon_voidwalker; + creators["summon felguard"] = &summon_felguard; + creators["summon succubus"] = &summon_succubus; + creators["summon felhunter"] = &summon_felhunter; + } - private: - static ActionNode* summon_voidwalker([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("summon voidwalker", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("summon imp"), nullptr), - /*C*/ nullptr); - } +private: + static ActionNode* summon_voidwalker([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("summon voidwalker", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("summon imp"), nullptr), + /*C*/ nullptr); + } - static ActionNode* summon_felguard([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode ("summon felguard", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("summon succubus"), nullptr), - /*C*/ nullptr); - } + static ActionNode* summon_felguard([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("summon felguard", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("summon succubus"), nullptr), + /*C*/ nullptr); + } - static ActionNode* summon_succubus([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("summon succubus", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("summon voidwalker"), nullptr), - /*C*/ nullptr); - } + static ActionNode* summon_succubus([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("summon succubus", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("summon voidwalker"), nullptr), + /*C*/ nullptr); + } - static ActionNode* summon_felhunter([[maybe_unused]] PlayerbotAI* botAI) - { - return new ActionNode("summon felhunter", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("summon imp"), nullptr), - /*C*/ nullptr); - } + static ActionNode* summon_felhunter([[maybe_unused]] PlayerbotAI* botAI) + { + return new ActionNode("summon felhunter", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("summon imp"), nullptr), + /*C*/ nullptr); + } }; TankWarlockStrategy::TankWarlockStrategy(PlayerbotAI* botAI) : GenericWarlockStrategy(botAI) diff --git a/src/strategy/warlock/TankWarlockStrategy.h b/src/strategy/warlock/TankWarlockStrategy.h index 12fb90ad..30bdbf7f 100644 --- a/src/strategy/warlock/TankWarlockStrategy.h +++ b/src/strategy/warlock/TankWarlockStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TANKWARLOCKSTRATEGY_H @@ -11,12 +12,12 @@ class PlayerbotAI; class TankWarlockStrategy : public GenericWarlockStrategy { - public: - TankWarlockStrategy(PlayerbotAI* botAI); +public: + TankWarlockStrategy(PlayerbotAI* botAI); - std::string const getName() override { return "tank"; } - void InitTriggers(std::vector& triggers) override; - NextAction** getDefaultActions() override; + std::string const getName() override { return "tank"; } + void InitTriggers(std::vector& triggers) override; + NextAction** getDefaultActions() override; }; #endif diff --git a/src/strategy/warlock/WarlockActions.cpp b/src/strategy/warlock/WarlockActions.cpp index 9a18e54a..005e268e 100644 --- a/src/strategy/warlock/WarlockActions.cpp +++ b/src/strategy/warlock/WarlockActions.cpp @@ -1,47 +1,25 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "WarlockActions.h" + #include "Event.h" #include "Playerbots.h" -bool CastDrainSoulAction::isUseful() -{ - return AI_VALUE2(uint32, "item count", "soul shard") < 10; -} +bool CastDrainSoulAction::isUseful() { return AI_VALUE2(uint32, "item count", "soul shard") < 10; } -Value* CastBanishAction::GetTargetValue() -{ - return context->GetValue("cc target", "banish"); -} +Value* CastBanishAction::GetTargetValue() { return context->GetValue("cc target", "banish"); } -bool CastBanishAction::Execute(Event event) -{ - return botAI->CastSpell("banish", GetTarget()); -} +bool CastBanishAction::Execute(Event event) { return botAI->CastSpell("banish", GetTarget()); } -Value* CastFearOnCcAction::GetTargetValue() -{ - return context->GetValue("cc target", "fear"); -} +Value* CastFearOnCcAction::GetTargetValue() { return context->GetValue("cc target", "fear"); } -bool CastFearOnCcAction::Execute(Event event) -{ - return botAI->CastSpell("fear", GetTarget()); -} +bool CastFearOnCcAction::Execute(Event event) { return botAI->CastSpell("fear", GetTarget()); } -bool CastFearOnCcAction::isPossible() -{ - return botAI->CanCastSpell("fear", GetTarget()); -} +bool CastFearOnCcAction::isPossible() { return botAI->CanCastSpell("fear", GetTarget()); } -bool CastFearOnCcAction::isUseful() -{ - return true; -} +bool CastFearOnCcAction::isUseful() { return true; } -bool CastLifeTapAction::isUseful() -{ - return AI_VALUE2(uint8, "health", "self target") > sPlayerbotAIConfig->lowHealth; -} +bool CastLifeTapAction::isUseful() { return AI_VALUE2(uint8, "health", "self target") > sPlayerbotAIConfig->lowHealth; } diff --git a/src/strategy/warlock/WarlockActions.h b/src/strategy/warlock/WarlockActions.h index 28f689d3..8f41d0b1 100644 --- a/src/strategy/warlock/WarlockActions.h +++ b/src/strategy/warlock/WarlockActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WARLOCKACTIONS_H @@ -12,20 +13,20 @@ class Unit; class CastDemonSkinAction : public CastBuffSpellAction { - public: - CastDemonSkinAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "demon skin") { } +public: + CastDemonSkinAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "demon skin") {} }; class CastDemonArmorAction : public CastBuffSpellAction { - public: - CastDemonArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "demon armor") { } +public: + CastDemonArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "demon armor") {} }; class CastFelArmorAction : public CastBuffSpellAction { - public: - CastFelArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "fel armor") { } +public: + CastFelArmorAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "fel armor") {} }; BEGIN_RANGED_SPELL_ACTION(CastShadowBoltAction, "shadow bolt") @@ -33,258 +34,272 @@ END_SPELL_ACTION() class CastDrainSoulAction : public CastSpellAction { - public: - CastDrainSoulAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "drain soul") { } +public: + CastDrainSoulAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "drain soul") {} - bool isUseful() override; + bool isUseful() override; }; class CastDrainManaAction : public CastSpellAction { - public: - CastDrainManaAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "drain mana") { } +public: + CastDrainManaAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "drain mana") {} }; class CastDrainLifeAction : public CastSpellAction { - public: - CastDrainLifeAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "drain life") { } +public: + CastDrainLifeAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "drain life") {} }; class CastCurseOfAgonyAction : public CastDebuffSpellAction { - public: - CastCurseOfAgonyAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "curse of agony", true) { } +public: + CastCurseOfAgonyAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "curse of agony", true) {} }; class CastCurseOfWeaknessAction : public CastDebuffSpellAction { - public: - CastCurseOfWeaknessAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "curse of weakness") { } +public: + CastCurseOfWeaknessAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "curse of weakness") {} }; class CastCorruptionAction : public CastDebuffSpellAction { - public: - CastCorruptionAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "corruption", true) { } - bool isUseful() override { - return CastDebuffSpellAction::isUseful() && !botAI->HasAura("seed of corruption", GetTarget(), false, true) ; - } +public: + CastCorruptionAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "corruption", true) {} + bool isUseful() override + { + return CastDebuffSpellAction::isUseful() && !botAI->HasAura("seed of corruption", GetTarget(), false, true); + } }; class CastCorruptionOnAttackerAction : public CastDebuffSpellOnAttackerAction { - public: - CastCorruptionOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "corruption", true) { } - bool isUseful() override { - return CastDebuffSpellOnAttackerAction::isUseful() && !botAI->HasAura("seed of corruption", GetTarget(), false, true) ; - } +public: + CastCorruptionOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "corruption", true) {} + bool isUseful() override + { + return CastDebuffSpellOnAttackerAction::isUseful() && + !botAI->HasAura("seed of corruption", GetTarget(), false, true); + } }; class CastCurseOfAgonyOnAttackerAction : public CastDebuffSpellOnAttackerAction { - public: - CastCurseOfAgonyOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "curse of agony", true) { } +public: + CastCurseOfAgonyOnAttackerAction(PlayerbotAI* botAI) + : CastDebuffSpellOnAttackerAction(botAI, "curse of agony", true) + { + } }; class CastSummonVoidwalkerAction : public CastBuffSpellAction { - public: - CastSummonVoidwalkerAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "summon voidwalker") { } +public: + CastSummonVoidwalkerAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "summon voidwalker") {} }; class CastSummonFelguardAction : public CastBuffSpellAction { - public: - CastSummonFelguardAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "summon felguard") { } +public: + CastSummonFelguardAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "summon felguard") {} }; class CastSummonFelhunterAction : public CastBuffSpellAction { - public: - CastSummonFelhunterAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "summon felhunter") { } +public: + CastSummonFelhunterAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "summon felhunter") {} }; class CastSummonImpAction : public CastBuffSpellAction { - public: - CastSummonImpAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "summon imp") { } +public: + CastSummonImpAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "summon imp") {} }; class CastSummonSuccubusAction : public CastBuffSpellAction { - public: - CastSummonSuccubusAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "summon succubus") { } +public: + CastSummonSuccubusAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "summon succubus") {} }; class CastCreateHealthstoneAction : public CastBuffSpellAction { - public: - CastCreateHealthstoneAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "create healthstone") { } +public: + CastCreateHealthstoneAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "create healthstone") {} }; class CastCreateFirestoneAction : public CastBuffSpellAction { - public: - CastCreateFirestoneAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "create firestone") { } +public: + CastCreateFirestoneAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "create firestone") {} }; class CastCreateSpellstoneAction : public CastBuffSpellAction { - public: - CastCreateSpellstoneAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "create spellstone") { } +public: + CastCreateSpellstoneAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "create spellstone") {} }; class CastBanishAction : public CastBuffSpellAction { - public: - CastBanishAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "banish on cc") { } +public: + CastBanishAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "banish on cc") {} - Value* GetTargetValue() override; - bool Execute(Event event) override; + Value* GetTargetValue() override; + bool Execute(Event event) override; }; class CastSeedOfCorruptionAction : public CastDebuffSpellAction { - public: - CastSeedOfCorruptionAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "seed of corruption", true, 0) { } - bool isUseful() override { - return CastDebuffSpellAction::isUseful() && !botAI->HasAura("corruption", GetTarget(), false, true) ; - } - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } +public: + CastSeedOfCorruptionAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "seed of corruption", true, 0) {} + bool isUseful() override + { + return CastDebuffSpellAction::isUseful() && !botAI->HasAura("corruption", GetTarget(), false, true); + } + ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } }; class CastSeedOfCorruptionOnAttackerAction : public CastDebuffSpellOnAttackerAction { - public: - CastSeedOfCorruptionOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "seed of corruption", true, 0) { } - bool isUseful() override { - return CastDebuffSpellOnAttackerAction::isUseful() && !botAI->HasAura("corruption", GetTarget(), false, true) ; - } - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } +public: + CastSeedOfCorruptionOnAttackerAction(PlayerbotAI* botAI) + : CastDebuffSpellOnAttackerAction(botAI, "seed of corruption", true, 0) + { + } + bool isUseful() override + { + return CastDebuffSpellOnAttackerAction::isUseful() && !botAI->HasAura("corruption", GetTarget(), false, true); + } + ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } }; class CastRainOfFireAction : public CastSpellAction { - public: - CastRainOfFireAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "rain of fire") { } - ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } +public: + CastRainOfFireAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "rain of fire") {} + ActionThreatType getThreatType() override { return ActionThreatType::Aoe; } }; class CastShadowfuryAction : public CastSpellAction { - public: - CastShadowfuryAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "shadowfury") { } +public: + CastShadowfuryAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "shadowfury") {} }; class CastImmolateAction : public CastDebuffSpellAction { - public: - CastImmolateAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "immolate", true) { } +public: + CastImmolateAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "immolate", true) {} }; class CastImmolateOnAttackerAction : public CastDebuffSpellOnAttackerAction { - public: - CastImmolateOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "immolate", true) { } +public: + CastImmolateOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "immolate", true) {} }; class CastConflagrateAction : public CastSpellAction { - public: - CastConflagrateAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "conflagrate") { } +public: + CastConflagrateAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "conflagrate") {} }; class CastIncinirateAction : public CastSpellAction { - public: - CastIncinirateAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "incinirate") { } +public: + CastIncinirateAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "incinirate") {} }; class CastFearAction : public CastDebuffSpellAction { - public: - CastFearAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "fear") { } +public: + CastFearAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "fear") {} }; class CastFearOnCcAction : public CastBuffSpellAction { - public: - CastFearOnCcAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "fear on cc") { } +public: + CastFearOnCcAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "fear on cc") {} - Value* GetTargetValue() override; - bool Execute(Event event) override; - bool isPossible() override; - bool isUseful() override; + Value* GetTargetValue() override; + bool Execute(Event event) override; + bool isPossible() override; + bool isUseful() override; }; -class CastLifeTapAction: public CastSpellAction +class CastLifeTapAction : public CastSpellAction { - public: - CastLifeTapAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "life tap") { } +public: + CastLifeTapAction(PlayerbotAI* botAI) : CastSpellAction(botAI, "life tap") {} - std::string const GetTargetName() override { return "self target"; } - bool isUseful() override; + std::string const GetTargetName() override { return "self target"; } + bool isUseful() override; }; class CastAmplifyCurseAction : public CastBuffSpellAction { - public: - CastAmplifyCurseAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "amplify curse") { } +public: + CastAmplifyCurseAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "amplify curse") {} }; class CastSiphonLifeAction : public CastDebuffSpellAction { - public: - CastSiphonLifeAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "siphon life", true) { } +public: + CastSiphonLifeAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "siphon life", true) {} }; class CastSiphonLifeOnAttackerAction : public CastDebuffSpellOnAttackerAction { - public: - CastSiphonLifeOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "siphon life") { } +public: + CastSiphonLifeOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "siphon life") {} }; -class CastUnstableAfflictionAction: public CastDebuffSpellAction +class CastUnstableAfflictionAction : public CastDebuffSpellAction { - public: - CastUnstableAfflictionAction(PlayerbotAI* ai) : CastDebuffSpellAction(ai, "unstable affliction", true) {} +public: + CastUnstableAfflictionAction(PlayerbotAI* ai) : CastDebuffSpellAction(ai, "unstable affliction", true) {} }; -class CastHauntAction: public CastSpellAction +class CastHauntAction : public CastSpellAction { - public: - CastHauntAction(PlayerbotAI* ai) : CastSpellAction(ai, "haunt") {} +public: + CastHauntAction(PlayerbotAI* ai) : CastSpellAction(ai, "haunt") {} }; class CastDemonicEmpowermentAction : public CastBuffSpellAction { - public: - CastDemonicEmpowermentAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, "demonic empowerment") {} - std::string const GetTargetName() override { return "pet target"; } +public: + CastDemonicEmpowermentAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, "demonic empowerment") {} + std::string const GetTargetName() override { return "pet target"; } }; class CastMetamorphosisAction : public CastBuffSpellAction { - public: - CastMetamorphosisAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, "metamorphosis") {} +public: + CastMetamorphosisAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, "metamorphosis") {} }; class CastUnstableAfflictionOnAttackerAction : public CastDebuffSpellOnAttackerAction { - public: - CastUnstableAfflictionOnAttackerAction(PlayerbotAI* ai) : CastDebuffSpellOnAttackerAction(ai, "unstable affliction", true) {} +public: + CastUnstableAfflictionOnAttackerAction(PlayerbotAI* ai) + : CastDebuffSpellOnAttackerAction(ai, "unstable affliction", true) + { + } }; class CastSoulFireAction : public CastSpellAction { - public: - CastSoulFireAction(PlayerbotAI* ai) : CastSpellAction(ai, "soul fire") {} +public: + CastSoulFireAction(PlayerbotAI* ai) : CastSpellAction(ai, "soul fire") {} }; class CastIncinerateAction : public CastSpellAction { - public: - CastIncinerateAction(PlayerbotAI* ai) : CastSpellAction(ai, "incinerate") {} +public: + CastIncinerateAction(PlayerbotAI* ai) : CastSpellAction(ai, "incinerate") {} }; #endif diff --git a/src/strategy/warlock/WarlockAiObjectContext.cpp b/src/strategy/warlock/WarlockAiObjectContext.cpp index 486c2cc2..81f888f3 100644 --- a/src/strategy/warlock/WarlockAiObjectContext.cpp +++ b/src/strategy/warlock/WarlockAiObjectContext.cpp @@ -1,55 +1,57 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "WarlockAiObjectContext.h" + #include "DpsWarlockStrategy.h" #include "GenericWarlockNonCombatStrategy.h" +#include "NamedObjectContext.h" +#include "Playerbots.h" +#include "PullStrategy.h" #include "Strategy.h" #include "TankWarlockStrategy.h" +#include "UseItemAction.h" #include "WarlockActions.h" #include "WarlockTriggers.h" -#include "NamedObjectContext.h" -#include "UseItemAction.h" -#include "PullStrategy.h" -#include "Playerbots.h" class WarlockStrategyFactoryInternal : public NamedObjectContext { - public: - WarlockStrategyFactoryInternal() - { - creators["nc"] = &WarlockStrategyFactoryInternal::nc; - creators["pull"] = &WarlockStrategyFactoryInternal::pull; - creators["aoe"] = &WarlockStrategyFactoryInternal::aoe; - creators["dps debuff"] = &WarlockStrategyFactoryInternal::dps_debuff; - creators["boost"] = &WarlockStrategyFactoryInternal::boost; - creators["cc"] = &WarlockStrategyFactoryInternal::cc; - creators["pet"] = &WarlockStrategyFactoryInternal::pet; - } +public: + WarlockStrategyFactoryInternal() + { + creators["nc"] = &WarlockStrategyFactoryInternal::nc; + creators["pull"] = &WarlockStrategyFactoryInternal::pull; + creators["aoe"] = &WarlockStrategyFactoryInternal::aoe; + creators["dps debuff"] = &WarlockStrategyFactoryInternal::dps_debuff; + creators["boost"] = &WarlockStrategyFactoryInternal::boost; + creators["cc"] = &WarlockStrategyFactoryInternal::cc; + creators["pet"] = &WarlockStrategyFactoryInternal::pet; + } - private: - static Strategy* pet(PlayerbotAI* botAI) { return new WarlockPetStrategy(botAI); } - static Strategy* nc(PlayerbotAI* botAI) { return new GenericWarlockNonCombatStrategy(botAI); } - static Strategy* aoe(PlayerbotAI* botAI) { return new DpsAoeWarlockStrategy(botAI); } - static Strategy* dps_debuff(PlayerbotAI* botAI) { return new DpsWarlockDebuffStrategy(botAI); } - static Strategy* pull(PlayerbotAI* botAI) { return new PullStrategy(botAI, "shoot"); } - static Strategy* boost(PlayerbotAI* botAI) { return new WarlockBoostStrategy(botAI); } - static Strategy* cc(PlayerbotAI* botAI) { return new WarlockCcStrategy(botAI); } +private: + static Strategy* pet(PlayerbotAI* botAI) { return new WarlockPetStrategy(botAI); } + static Strategy* nc(PlayerbotAI* botAI) { return new GenericWarlockNonCombatStrategy(botAI); } + static Strategy* aoe(PlayerbotAI* botAI) { return new DpsAoeWarlockStrategy(botAI); } + static Strategy* dps_debuff(PlayerbotAI* botAI) { return new DpsWarlockDebuffStrategy(botAI); } + static Strategy* pull(PlayerbotAI* botAI) { return new PullStrategy(botAI, "shoot"); } + static Strategy* boost(PlayerbotAI* botAI) { return new WarlockBoostStrategy(botAI); } + static Strategy* cc(PlayerbotAI* botAI) { return new WarlockCcStrategy(botAI); } }; class WarlockCombatStrategyFactoryInternal : public NamedObjectContext { - public: - WarlockCombatStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["dps"] = &WarlockCombatStrategyFactoryInternal::dps; - creators["tank"] = &WarlockCombatStrategyFactoryInternal::tank; - } +public: + WarlockCombatStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["dps"] = &WarlockCombatStrategyFactoryInternal::dps; + creators["tank"] = &WarlockCombatStrategyFactoryInternal::tank; + } - private: - static Strategy* tank(PlayerbotAI* botAI) { return new TankWarlockStrategy(botAI); } - static Strategy* dps(PlayerbotAI* botAI) { return new DpsWarlockStrategy(botAI); } +private: + static Strategy* tank(PlayerbotAI* botAI) { return new TankWarlockStrategy(botAI); } + static Strategy* dps(PlayerbotAI* botAI) { return new DpsWarlockStrategy(botAI); } }; class NonCombatBuffStrategyFactoryInternal : public NamedObjectContext @@ -61,167 +63,182 @@ public: creators["bmana"] = &NonCombatBuffStrategyFactoryInternal::felhunter; creators["bhealth"] = &NonCombatBuffStrategyFactoryInternal::imp; } + private: static Strategy* imp(PlayerbotAI* ai) { return new SummonImpStrategy(ai); } static Strategy* felhunter(PlayerbotAI* ai) { return new SummonFelhunterStrategy(ai); } static Strategy* felguard(PlayerbotAI* ai) { return new SummonFelguardStrategy(ai); } -}; +}; class WarlockTriggerFactoryInternal : public NamedObjectContext { - public: - WarlockTriggerFactoryInternal() - { - creators["shadow trance"] = &WarlockTriggerFactoryInternal::shadow_trance; - creators["demon armor"] = &WarlockTriggerFactoryInternal::demon_armor; - creators["no healthstone"] = &WarlockTriggerFactoryInternal::HasHealthstone; - creators["no firestone"] = &WarlockTriggerFactoryInternal::HasFirestone; - creators["no spellstone"] = &WarlockTriggerFactoryInternal::HasSpellstone; - creators["corruption"] = &WarlockTriggerFactoryInternal::corruption; - creators["corruption on attacker"] = &WarlockTriggerFactoryInternal::corruption_on_attacker; - creators["curse of agony"] = &WarlockTriggerFactoryInternal::curse_of_agony; - creators["curse of agony on attacker"] = &WarlockTriggerFactoryInternal::curse_of_agony_on_attacker; - creators["banish"] = &WarlockTriggerFactoryInternal::banish; - creators["spellstone"] = &WarlockTriggerFactoryInternal::spellstone; - creators["backlash"] = &WarlockTriggerFactoryInternal::backlash; - creators["fear"] = &WarlockTriggerFactoryInternal::fear; - creators["immolate"] = &WarlockTriggerFactoryInternal::immolate; - creators["amplify curse"] = &WarlockTriggerFactoryInternal::amplify_curse; - creators["siphon life"] = &WarlockTriggerFactoryInternal::siphon_life; - creators["siphon life on attacker"] = &WarlockTriggerFactoryInternal::siphon_life_on_attacker; +public: + WarlockTriggerFactoryInternal() + { + creators["shadow trance"] = &WarlockTriggerFactoryInternal::shadow_trance; + creators["demon armor"] = &WarlockTriggerFactoryInternal::demon_armor; + creators["no healthstone"] = &WarlockTriggerFactoryInternal::HasHealthstone; + creators["no firestone"] = &WarlockTriggerFactoryInternal::HasFirestone; + creators["no spellstone"] = &WarlockTriggerFactoryInternal::HasSpellstone; + creators["corruption"] = &WarlockTriggerFactoryInternal::corruption; + creators["corruption on attacker"] = &WarlockTriggerFactoryInternal::corruption_on_attacker; + creators["curse of agony"] = &WarlockTriggerFactoryInternal::curse_of_agony; + creators["curse of agony on attacker"] = &WarlockTriggerFactoryInternal::curse_of_agony_on_attacker; + creators["banish"] = &WarlockTriggerFactoryInternal::banish; + creators["spellstone"] = &WarlockTriggerFactoryInternal::spellstone; + creators["backlash"] = &WarlockTriggerFactoryInternal::backlash; + creators["fear"] = &WarlockTriggerFactoryInternal::fear; + creators["immolate"] = &WarlockTriggerFactoryInternal::immolate; + creators["amplify curse"] = &WarlockTriggerFactoryInternal::amplify_curse; + creators["siphon life"] = &WarlockTriggerFactoryInternal::siphon_life; + creators["siphon life on attacker"] = &WarlockTriggerFactoryInternal::siphon_life_on_attacker; - creators["immolate on attacker"] = &WarlockTriggerFactoryInternal::immolate_on_attacker; - creators["unstable affliction"] = &WarlockTriggerFactoryInternal::unstable_affliction; - creators["unstable affliction on attacker"] = &WarlockTriggerFactoryInternal::unstable_affliction_on_attacker; - creators["haunt"] = &WarlockTriggerFactoryInternal::haunt; - creators["decimation"] = &WarlockTriggerFactoryInternal::decimation; - creators["molten core"] = &WarlockTriggerFactoryInternal::molten_core; - creators["metamorphosis"] = &WarlockTriggerFactoryInternal::metamorphosis; - - } + creators["immolate on attacker"] = &WarlockTriggerFactoryInternal::immolate_on_attacker; + creators["unstable affliction"] = &WarlockTriggerFactoryInternal::unstable_affliction; + creators["unstable affliction on attacker"] = &WarlockTriggerFactoryInternal::unstable_affliction_on_attacker; + creators["haunt"] = &WarlockTriggerFactoryInternal::haunt; + creators["decimation"] = &WarlockTriggerFactoryInternal::decimation; + creators["molten core"] = &WarlockTriggerFactoryInternal::molten_core; + creators["metamorphosis"] = &WarlockTriggerFactoryInternal::metamorphosis; + } - private: - static Trigger* amplify_curse(PlayerbotAI* botAI) { return new AmplifyCurseTrigger(botAI); } - static Trigger* shadow_trance(PlayerbotAI* botAI) { return new ShadowTranceTrigger(botAI); } - static Trigger* demon_armor(PlayerbotAI* botAI) { return new DemonArmorTrigger(botAI); } - static Trigger* HasHealthstone(PlayerbotAI* botAI) { return new HasHealthstoneTrigger(botAI); } - static Trigger* HasFirestone(PlayerbotAI* botAI) { return new HasFirestoneTrigger(botAI); } - static Trigger* HasSpellstone(PlayerbotAI* botAI) { return new HasSpellstoneTrigger(botAI); } - static Trigger* corruption(PlayerbotAI* botAI) { return new CorruptionTrigger(botAI); } - static Trigger* corruption_on_attacker(PlayerbotAI* botAI) { return new CorruptionOnAttackerTrigger(botAI); } - static Trigger* siphon_life(PlayerbotAI* botAI) { return new SiphonLifeTrigger(botAI); } - static Trigger* siphon_life_on_attacker(PlayerbotAI* botAI) { return new SiphonLifeOnAttackerTrigger(botAI); } - static Trigger* curse_of_agony(PlayerbotAI* botAI) { return new CurseOfAgonyTrigger(botAI); } - static Trigger* curse_of_agony_on_attacker(PlayerbotAI* botAI) { return new CastCurseOfAgonyOnAttackerTrigger(botAI); } - static Trigger* banish(PlayerbotAI* botAI) { return new BanishTrigger(botAI); } - static Trigger* spellstone(PlayerbotAI* botAI) { return new SpellstoneTrigger(botAI); } - static Trigger* backlash(PlayerbotAI* botAI) { return new BacklashTrigger(botAI); } - static Trigger* fear(PlayerbotAI* botAI) { return new FearTrigger(botAI); } - static Trigger* immolate(PlayerbotAI* botAI) { return new ImmolateTrigger(botAI); } - static Trigger* immolate_on_attacker(PlayerbotAI* ai) { return new ImmolateOnAttackerTrigger(ai); } - static Trigger* unstable_affliction(PlayerbotAI* ai) { return new UnstableAfflictionTrigger(ai); } - static Trigger* unstable_affliction_on_attacker(PlayerbotAI* ai) { return new UnstableAfflictionOnAttackerTrigger(ai); } - static Trigger* haunt(PlayerbotAI* ai) { return new HauntTrigger(ai); } - static Trigger* decimation(PlayerbotAI* ai) { return new DecimationTrigger(ai); } - static Trigger* molten_core(PlayerbotAI* ai) { return new MoltenCoreTrigger(ai); } - static Trigger* metamorphosis(PlayerbotAI* ai) { return new MetamorphosisTrigger(ai); } +private: + static Trigger* amplify_curse(PlayerbotAI* botAI) { return new AmplifyCurseTrigger(botAI); } + static Trigger* shadow_trance(PlayerbotAI* botAI) { return new ShadowTranceTrigger(botAI); } + static Trigger* demon_armor(PlayerbotAI* botAI) { return new DemonArmorTrigger(botAI); } + static Trigger* HasHealthstone(PlayerbotAI* botAI) { return new HasHealthstoneTrigger(botAI); } + static Trigger* HasFirestone(PlayerbotAI* botAI) { return new HasFirestoneTrigger(botAI); } + static Trigger* HasSpellstone(PlayerbotAI* botAI) { return new HasSpellstoneTrigger(botAI); } + static Trigger* corruption(PlayerbotAI* botAI) { return new CorruptionTrigger(botAI); } + static Trigger* corruption_on_attacker(PlayerbotAI* botAI) { return new CorruptionOnAttackerTrigger(botAI); } + static Trigger* siphon_life(PlayerbotAI* botAI) { return new SiphonLifeTrigger(botAI); } + static Trigger* siphon_life_on_attacker(PlayerbotAI* botAI) { return new SiphonLifeOnAttackerTrigger(botAI); } + static Trigger* curse_of_agony(PlayerbotAI* botAI) { return new CurseOfAgonyTrigger(botAI); } + static Trigger* curse_of_agony_on_attacker(PlayerbotAI* botAI) + { + return new CastCurseOfAgonyOnAttackerTrigger(botAI); + } + static Trigger* banish(PlayerbotAI* botAI) { return new BanishTrigger(botAI); } + static Trigger* spellstone(PlayerbotAI* botAI) { return new SpellstoneTrigger(botAI); } + static Trigger* backlash(PlayerbotAI* botAI) { return new BacklashTrigger(botAI); } + static Trigger* fear(PlayerbotAI* botAI) { return new FearTrigger(botAI); } + static Trigger* immolate(PlayerbotAI* botAI) { return new ImmolateTrigger(botAI); } + static Trigger* immolate_on_attacker(PlayerbotAI* ai) { return new ImmolateOnAttackerTrigger(ai); } + static Trigger* unstable_affliction(PlayerbotAI* ai) { return new UnstableAfflictionTrigger(ai); } + static Trigger* unstable_affliction_on_attacker(PlayerbotAI* ai) + { + return new UnstableAfflictionOnAttackerTrigger(ai); + } + static Trigger* haunt(PlayerbotAI* ai) { return new HauntTrigger(ai); } + static Trigger* decimation(PlayerbotAI* ai) { return new DecimationTrigger(ai); } + static Trigger* molten_core(PlayerbotAI* ai) { return new MoltenCoreTrigger(ai); } + static Trigger* metamorphosis(PlayerbotAI* ai) { return new MetamorphosisTrigger(ai); } }; class WarlockAiObjectContextInternal : public NamedObjectContext { - public: - WarlockAiObjectContextInternal() - { - creators["fel armor"] = &WarlockAiObjectContextInternal::fel_armor; - creators["demon armor"] = &WarlockAiObjectContextInternal::demon_armor; - creators["demon skin"] = &WarlockAiObjectContextInternal::demon_skin; - creators["create healthstone"] = &WarlockAiObjectContextInternal::create_healthstone; - creators["create firestone"] = &WarlockAiObjectContextInternal::create_firestone; - creators["create spellstone"] = &WarlockAiObjectContextInternal::create_spellstone; - creators["spellstone"] = &WarlockAiObjectContextInternal::spellstone; - creators["summon voidwalker"] = &WarlockAiObjectContextInternal::summon_voidwalker; - creators["summon felguard"] = &WarlockAiObjectContextInternal::summon_felguard; - creators["summon felhunter"] = &WarlockAiObjectContextInternal::summon_felhunter; - creators["summon succubus"] = &WarlockAiObjectContextInternal::summon_succubus; - creators["summon imp"] = &WarlockAiObjectContextInternal::summon_imp; - creators["immolate"] = &WarlockAiObjectContextInternal::immolate; - creators["corruption"] = &WarlockAiObjectContextInternal::corruption; - creators["corruption on attacker"] = &WarlockAiObjectContextInternal::corruption_on_attacker; - creators["siphon life"] = &WarlockAiObjectContextInternal::siphon_life; - creators["siphon life on attacker"] = &WarlockAiObjectContextInternal::siphon_life_on_attacker; - creators["curse of agony"] = &WarlockAiObjectContextInternal::curse_of_agony; - creators["curse of agony on attacker"] = &WarlockAiObjectContextInternal::curse_of_agony_on_attacker; - creators["shadow bolt"] = &WarlockAiObjectContextInternal::shadow_bolt; - creators["drain soul"] = &WarlockAiObjectContextInternal::drain_soul; - creators["drain mana"] = &WarlockAiObjectContextInternal::drain_mana; - creators["drain life"] = &WarlockAiObjectContextInternal::drain_life; - creators["banish"] = &WarlockAiObjectContextInternal::banish; - creators["banish on cc"] = &WarlockAiObjectContextInternal::banish_on_cc; - creators["seed of corruption"] = &WarlockAiObjectContextInternal::seed_of_corruption; - creators["seed of corruption on attacker"] = &WarlockAiObjectContextInternal::seed_of_corruption_on_attacker; - creators["rain of fire"] = &WarlockAiObjectContextInternal::rain_of_fire; - creators["shadowfury"] = &WarlockAiObjectContextInternal::shadowfury; - creators["life tap"] = &WarlockAiObjectContextInternal::life_tap; - creators["fear"] = &WarlockAiObjectContextInternal::fear; - creators["fear on cc"] = &WarlockAiObjectContextInternal::fear_on_cc; - creators["incinirate"] = &WarlockAiObjectContextInternal::incinirate; - creators["conflagrate"] = &WarlockAiObjectContextInternal::conflagrate; - creators["amplify curse"] = &WarlockAiObjectContextInternal::amplify_curse; +public: + WarlockAiObjectContextInternal() + { + creators["fel armor"] = &WarlockAiObjectContextInternal::fel_armor; + creators["demon armor"] = &WarlockAiObjectContextInternal::demon_armor; + creators["demon skin"] = &WarlockAiObjectContextInternal::demon_skin; + creators["create healthstone"] = &WarlockAiObjectContextInternal::create_healthstone; + creators["create firestone"] = &WarlockAiObjectContextInternal::create_firestone; + creators["create spellstone"] = &WarlockAiObjectContextInternal::create_spellstone; + creators["spellstone"] = &WarlockAiObjectContextInternal::spellstone; + creators["summon voidwalker"] = &WarlockAiObjectContextInternal::summon_voidwalker; + creators["summon felguard"] = &WarlockAiObjectContextInternal::summon_felguard; + creators["summon felhunter"] = &WarlockAiObjectContextInternal::summon_felhunter; + creators["summon succubus"] = &WarlockAiObjectContextInternal::summon_succubus; + creators["summon imp"] = &WarlockAiObjectContextInternal::summon_imp; + creators["immolate"] = &WarlockAiObjectContextInternal::immolate; + creators["corruption"] = &WarlockAiObjectContextInternal::corruption; + creators["corruption on attacker"] = &WarlockAiObjectContextInternal::corruption_on_attacker; + creators["siphon life"] = &WarlockAiObjectContextInternal::siphon_life; + creators["siphon life on attacker"] = &WarlockAiObjectContextInternal::siphon_life_on_attacker; + creators["curse of agony"] = &WarlockAiObjectContextInternal::curse_of_agony; + creators["curse of agony on attacker"] = &WarlockAiObjectContextInternal::curse_of_agony_on_attacker; + creators["shadow bolt"] = &WarlockAiObjectContextInternal::shadow_bolt; + creators["drain soul"] = &WarlockAiObjectContextInternal::drain_soul; + creators["drain mana"] = &WarlockAiObjectContextInternal::drain_mana; + creators["drain life"] = &WarlockAiObjectContextInternal::drain_life; + creators["banish"] = &WarlockAiObjectContextInternal::banish; + creators["banish on cc"] = &WarlockAiObjectContextInternal::banish_on_cc; + creators["seed of corruption"] = &WarlockAiObjectContextInternal::seed_of_corruption; + creators["seed of corruption on attacker"] = &WarlockAiObjectContextInternal::seed_of_corruption_on_attacker; + creators["rain of fire"] = &WarlockAiObjectContextInternal::rain_of_fire; + creators["shadowfury"] = &WarlockAiObjectContextInternal::shadowfury; + creators["life tap"] = &WarlockAiObjectContextInternal::life_tap; + creators["fear"] = &WarlockAiObjectContextInternal::fear; + creators["fear on cc"] = &WarlockAiObjectContextInternal::fear_on_cc; + creators["incinirate"] = &WarlockAiObjectContextInternal::incinirate; + creators["conflagrate"] = &WarlockAiObjectContextInternal::conflagrate; + creators["amplify curse"] = &WarlockAiObjectContextInternal::amplify_curse; - creators["immolate on attacker"] = &WarlockAiObjectContextInternal::immolate_on_attacker; - creators["unstable affliction"] = &WarlockAiObjectContextInternal::unstable_affliction; - creators["unstable affliction on attacker"] = &WarlockAiObjectContextInternal::unstable_affliction_on_attacker; - creators["haunt"] = &WarlockAiObjectContextInternal::haunt; - creators["demonic empowerment"] = &WarlockAiObjectContextInternal::demonic_empowerment; - creators["metamorphosis"] = &WarlockAiObjectContextInternal::metamorphosis; - creators["soul fire"] = &WarlockAiObjectContextInternal::soul_fire; - creators["incinerate"] = &WarlockAiObjectContextInternal::incinerate; - } + creators["immolate on attacker"] = &WarlockAiObjectContextInternal::immolate_on_attacker; + creators["unstable affliction"] = &WarlockAiObjectContextInternal::unstable_affliction; + creators["unstable affliction on attacker"] = &WarlockAiObjectContextInternal::unstable_affliction_on_attacker; + creators["haunt"] = &WarlockAiObjectContextInternal::haunt; + creators["demonic empowerment"] = &WarlockAiObjectContextInternal::demonic_empowerment; + creators["metamorphosis"] = &WarlockAiObjectContextInternal::metamorphosis; + creators["soul fire"] = &WarlockAiObjectContextInternal::soul_fire; + creators["incinerate"] = &WarlockAiObjectContextInternal::incinerate; + } - private: - static Action* amplify_curse(PlayerbotAI* botAI) { return new CastAmplifyCurseAction(botAI); } - static Action* conflagrate(PlayerbotAI* botAI) { return new CastConflagrateAction(botAI); } - static Action* incinirate(PlayerbotAI* botAI) { return new CastIncinirateAction(botAI); } - static Action* fear_on_cc(PlayerbotAI* botAI) { return new CastFearOnCcAction(botAI); } - static Action* fear(PlayerbotAI* botAI) { return new CastFearAction(botAI); } - static Action* immolate(PlayerbotAI* botAI) { return new CastImmolateAction(botAI); } - static Action* summon_imp(PlayerbotAI* botAI) { return new CastSummonImpAction(botAI); } - static Action* summon_succubus(PlayerbotAI* botAI) { return new CastSummonSuccubusAction(botAI); } - static Action* fel_armor(PlayerbotAI* botAI) { return new CastFelArmorAction(botAI); } - static Action* demon_armor(PlayerbotAI* botAI) { return new CastDemonArmorAction(botAI); } - static Action* demon_skin(PlayerbotAI* botAI) { return new CastDemonSkinAction(botAI); } - static Action* create_healthstone(PlayerbotAI* botAI) { return new CastCreateHealthstoneAction(botAI); } - static Action* create_firestone(PlayerbotAI* botAI) { return new CastCreateFirestoneAction(botAI); } - static Action* create_spellstone(PlayerbotAI* botAI) { return new CastCreateSpellstoneAction(botAI); } - static Action* spellstone(PlayerbotAI* botAI) { return new UseSpellItemAction(botAI, "spellstone", true); } - static Action* summon_voidwalker(PlayerbotAI* botAI) { return new CastSummonVoidwalkerAction(botAI); } - static Action* summon_felguard(PlayerbotAI* botAI) { return new CastSummonFelguardAction(botAI); } - static Action* summon_felhunter(PlayerbotAI* botAI) { return new CastSummonFelhunterAction(botAI); } - static Action* corruption(PlayerbotAI* botAI) { return new CastCorruptionAction(botAI); } - static Action* corruption_on_attacker(PlayerbotAI* botAI) { return new CastCorruptionOnAttackerAction(botAI); } - static Action* siphon_life(PlayerbotAI* botAI) { return new CastSiphonLifeAction(botAI); } - static Action* siphon_life_on_attacker(PlayerbotAI* botAI) { return new CastSiphonLifeOnAttackerAction(botAI); } - static Action* curse_of_agony(PlayerbotAI* botAI) { return new CastCurseOfAgonyAction(botAI); } - static Action* curse_of_agony_on_attacker(PlayerbotAI* botAI) { return new CastCurseOfAgonyOnAttackerAction(botAI); } - static Action* shadow_bolt(PlayerbotAI* botAI) { return new CastShadowBoltAction(botAI); } - static Action* drain_soul(PlayerbotAI* botAI) { return new CastDrainSoulAction(botAI); } - static Action* drain_mana(PlayerbotAI* botAI) { return new CastDrainManaAction(botAI); } - static Action* drain_life(PlayerbotAI* botAI) { return new CastDrainLifeAction(botAI); } - static Action* banish(PlayerbotAI* botAI) { return new CastBanishAction(botAI); } - static Action* banish_on_cc(PlayerbotAI* botAI) { return new CastBanishAction(botAI); } - static Action* seed_of_corruption(PlayerbotAI* botAI) { return new CastSeedOfCorruptionAction(botAI); } - static Action* seed_of_corruption_on_attacker(PlayerbotAI* botAI) { return new CastSeedOfCorruptionOnAttackerAction(botAI); } - static Action* rain_of_fire(PlayerbotAI* botAI) { return new CastRainOfFireAction(botAI); } - static Action* shadowfury(PlayerbotAI* botAI) { return new CastShadowfuryAction(botAI); } - static Action* life_tap(PlayerbotAI* botAI) { return new CastLifeTapAction(botAI); } - static Action* immolate_on_attacker(PlayerbotAI* ai) { return new CastImmolateOnAttackerAction(ai); } - static Action* unstable_affliction(PlayerbotAI* ai) { return new CastUnstableAfflictionAction(ai); } - static Action* unstable_affliction_on_attacker(PlayerbotAI* ai) { return new CastUnstableAfflictionOnAttackerAction(ai); } - static Action* haunt(PlayerbotAI* ai) { return new CastHauntAction(ai); } - static Action* demonic_empowerment(PlayerbotAI* ai) { return new CastDemonicEmpowermentAction(ai); } - static Action* metamorphosis(PlayerbotAI* ai) { return new CastMetamorphosisAction(ai); } - static Action* soul_fire(PlayerbotAI* ai) { return new CastSoulFireAction(ai); } - static Action* incinerate(PlayerbotAI* ai) { return new CastIncinerateAction(ai); } +private: + static Action* amplify_curse(PlayerbotAI* botAI) { return new CastAmplifyCurseAction(botAI); } + static Action* conflagrate(PlayerbotAI* botAI) { return new CastConflagrateAction(botAI); } + static Action* incinirate(PlayerbotAI* botAI) { return new CastIncinirateAction(botAI); } + static Action* fear_on_cc(PlayerbotAI* botAI) { return new CastFearOnCcAction(botAI); } + static Action* fear(PlayerbotAI* botAI) { return new CastFearAction(botAI); } + static Action* immolate(PlayerbotAI* botAI) { return new CastImmolateAction(botAI); } + static Action* summon_imp(PlayerbotAI* botAI) { return new CastSummonImpAction(botAI); } + static Action* summon_succubus(PlayerbotAI* botAI) { return new CastSummonSuccubusAction(botAI); } + static Action* fel_armor(PlayerbotAI* botAI) { return new CastFelArmorAction(botAI); } + static Action* demon_armor(PlayerbotAI* botAI) { return new CastDemonArmorAction(botAI); } + static Action* demon_skin(PlayerbotAI* botAI) { return new CastDemonSkinAction(botAI); } + static Action* create_healthstone(PlayerbotAI* botAI) { return new CastCreateHealthstoneAction(botAI); } + static Action* create_firestone(PlayerbotAI* botAI) { return new CastCreateFirestoneAction(botAI); } + static Action* create_spellstone(PlayerbotAI* botAI) { return new CastCreateSpellstoneAction(botAI); } + static Action* spellstone(PlayerbotAI* botAI) { return new UseSpellItemAction(botAI, "spellstone", true); } + static Action* summon_voidwalker(PlayerbotAI* botAI) { return new CastSummonVoidwalkerAction(botAI); } + static Action* summon_felguard(PlayerbotAI* botAI) { return new CastSummonFelguardAction(botAI); } + static Action* summon_felhunter(PlayerbotAI* botAI) { return new CastSummonFelhunterAction(botAI); } + static Action* corruption(PlayerbotAI* botAI) { return new CastCorruptionAction(botAI); } + static Action* corruption_on_attacker(PlayerbotAI* botAI) { return new CastCorruptionOnAttackerAction(botAI); } + static Action* siphon_life(PlayerbotAI* botAI) { return new CastSiphonLifeAction(botAI); } + static Action* siphon_life_on_attacker(PlayerbotAI* botAI) { return new CastSiphonLifeOnAttackerAction(botAI); } + static Action* curse_of_agony(PlayerbotAI* botAI) { return new CastCurseOfAgonyAction(botAI); } + static Action* curse_of_agony_on_attacker(PlayerbotAI* botAI) + { + return new CastCurseOfAgonyOnAttackerAction(botAI); + } + static Action* shadow_bolt(PlayerbotAI* botAI) { return new CastShadowBoltAction(botAI); } + static Action* drain_soul(PlayerbotAI* botAI) { return new CastDrainSoulAction(botAI); } + static Action* drain_mana(PlayerbotAI* botAI) { return new CastDrainManaAction(botAI); } + static Action* drain_life(PlayerbotAI* botAI) { return new CastDrainLifeAction(botAI); } + static Action* banish(PlayerbotAI* botAI) { return new CastBanishAction(botAI); } + static Action* banish_on_cc(PlayerbotAI* botAI) { return new CastBanishAction(botAI); } + static Action* seed_of_corruption(PlayerbotAI* botAI) { return new CastSeedOfCorruptionAction(botAI); } + static Action* seed_of_corruption_on_attacker(PlayerbotAI* botAI) + { + return new CastSeedOfCorruptionOnAttackerAction(botAI); + } + static Action* rain_of_fire(PlayerbotAI* botAI) { return new CastRainOfFireAction(botAI); } + static Action* shadowfury(PlayerbotAI* botAI) { return new CastShadowfuryAction(botAI); } + static Action* life_tap(PlayerbotAI* botAI) { return new CastLifeTapAction(botAI); } + static Action* immolate_on_attacker(PlayerbotAI* ai) { return new CastImmolateOnAttackerAction(ai); } + static Action* unstable_affliction(PlayerbotAI* ai) { return new CastUnstableAfflictionAction(ai); } + static Action* unstable_affliction_on_attacker(PlayerbotAI* ai) + { + return new CastUnstableAfflictionOnAttackerAction(ai); + } + static Action* haunt(PlayerbotAI* ai) { return new CastHauntAction(ai); } + static Action* demonic_empowerment(PlayerbotAI* ai) { return new CastDemonicEmpowermentAction(ai); } + static Action* metamorphosis(PlayerbotAI* ai) { return new CastMetamorphosisAction(ai); } + static Action* soul_fire(PlayerbotAI* ai) { return new CastSoulFireAction(ai); } + static Action* incinerate(PlayerbotAI* ai) { return new CastIncinerateAction(ai); } }; WarlockAiObjectContext::WarlockAiObjectContext(PlayerbotAI* botAI) : AiObjectContext(botAI) diff --git a/src/strategy/warlock/WarlockAiObjectContext.h b/src/strategy/warlock/WarlockAiObjectContext.h index c6aaaeec..c1feb912 100644 --- a/src/strategy/warlock/WarlockAiObjectContext.h +++ b/src/strategy/warlock/WarlockAiObjectContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WARLOCKAIOBJECTCONTEXT_H @@ -11,8 +12,8 @@ class PlayerbotAI; class WarlockAiObjectContext : public AiObjectContext { - public: - WarlockAiObjectContext(PlayerbotAI* botAI); +public: + WarlockAiObjectContext(PlayerbotAI* botAI); }; #endif diff --git a/src/strategy/warlock/WarlockTriggers.cpp b/src/strategy/warlock/WarlockTriggers.cpp index 733e7502..6192dfc7 100644 --- a/src/strategy/warlock/WarlockTriggers.cpp +++ b/src/strategy/warlock/WarlockTriggers.cpp @@ -1,20 +1,20 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "WarlockTriggers.h" + #include "Playerbots.h" bool DemonArmorTrigger::IsActive() { - Unit* target = GetTarget(); - return !botAI->HasAura("demon skin", target) && !botAI->HasAura("demon armor", target) && !botAI->HasAura("fel armor", target); + Unit* target = GetTarget(); + return !botAI->HasAura("demon skin", target) && !botAI->HasAura("demon armor", target) && + !botAI->HasAura("fel armor", target); } -bool SpellstoneTrigger::IsActive() -{ - return BuffTrigger::IsActive() && AI_VALUE2(uint32, "item count", getName()) > 0; -} +bool SpellstoneTrigger::IsActive() { return BuffTrigger::IsActive() && AI_VALUE2(uint32, "item count", getName()) > 0; } bool WarlockConjuredItemTrigger::IsActive() { @@ -23,27 +23,25 @@ bool WarlockConjuredItemTrigger::IsActive() bool ImmolateOnAttackerTrigger::IsActive() { - return DebuffOnAttackerTrigger::IsActive() && - // !botAI->HasAura("immolate", GetTarget(), false, true) && - !botAI->HasAura("unstable affliction", GetTarget(), false, true); + return DebuffOnAttackerTrigger::IsActive() && + // !botAI->HasAura("immolate", GetTarget(), false, true) && + !botAI->HasAura("unstable affliction", GetTarget(), false, true); } bool UnstableAfflictionTrigger::IsActive() { - return DebuffTrigger::IsActive() && - !botAI->HasAura("immolate", GetTarget(), false, true); - // !botAI->HasAura("unstable affliction", GetTarget(), false, true); + return DebuffTrigger::IsActive() && !botAI->HasAura("immolate", GetTarget(), false, true); + // !botAI->HasAura("unstable affliction", GetTarget(), false, true); } bool UnstableAfflictionOnAttackerTrigger::IsActive() { - return DebuffOnAttackerTrigger::IsActive() && - !botAI->HasAura("immolate", GetTarget(), false, true); - // !botAI->HasAura("unstable affliction", GetTarget(), false, true); + return DebuffOnAttackerTrigger::IsActive() && !botAI->HasAura("immolate", GetTarget(), false, true); + // !botAI->HasAura("unstable affliction", GetTarget(), false, true); } bool DecimationTrigger::IsActive() { - Aura *aura = botAI->GetAura(getName(), GetTarget(), false, true); + Aura* aura = botAI->GetAura(getName(), GetTarget(), false, true); return aura && aura->GetDuration() > 3000; } \ No newline at end of file diff --git a/src/strategy/warlock/WarlockTriggers.h b/src/strategy/warlock/WarlockTriggers.h index 42c773f7..38514d04 100644 --- a/src/strategy/warlock/WarlockTriggers.h +++ b/src/strategy/warlock/WarlockTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WARLOCKTRIGGERS_H @@ -12,57 +13,62 @@ class PlayerbotAI; class DemonArmorTrigger : public BuffTrigger { - public: - DemonArmorTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "demon armor") { } +public: + DemonArmorTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "demon armor") {} - bool IsActive() override; + bool IsActive() override; }; class SpellstoneTrigger : public BuffTrigger { - public: - SpellstoneTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "spellstone") { } +public: + SpellstoneTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "spellstone") {} - bool IsActive() override; + bool IsActive() override; }; // DEBUFF_CHECKISOWNER_TRIGGER(CurseOfAgonyTrigger, "curse of agony"); class CurseOfAgonyTrigger : public DebuffTrigger { - public: - CurseOfAgonyTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "curse of agony", 1, true, 20.0f) { } +public: + CurseOfAgonyTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "curse of agony", 1, true, 20.0f) {} }; class CorruptionTrigger : public DebuffTrigger { - public: - CorruptionTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "corruption", 1, true) { } \ - bool IsActive() override { - return DebuffTrigger::IsActive() && !botAI->HasAura("seed of corruption", GetTarget(), false, true) ; - } +public: + CorruptionTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "corruption", 1, true) {} + bool IsActive() override + { + return DebuffTrigger::IsActive() && !botAI->HasAura("seed of corruption", GetTarget(), false, true); + } }; DEBUFF_CHECKISOWNER_TRIGGER(SiphonLifeTrigger, "siphon life"); class CorruptionOnAttackerTrigger : public DebuffOnAttackerTrigger { - public: - CorruptionOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "corruption", true) { } - bool IsActive() override { - return DebuffOnAttackerTrigger::IsActive() && !botAI->HasAura("seed of corruption", GetTarget(), false, true) ; - } +public: + CorruptionOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "corruption", true) {} + bool IsActive() override + { + return DebuffOnAttackerTrigger::IsActive() && !botAI->HasAura("seed of corruption", GetTarget(), false, true); + } }; class CastCurseOfAgonyOnAttackerTrigger : public DebuffOnAttackerTrigger { - public: - CastCurseOfAgonyOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "curse of agony", true, 20.0f) { } +public: + CastCurseOfAgonyOnAttackerTrigger(PlayerbotAI* botAI) + : DebuffOnAttackerTrigger(botAI, "curse of agony", true, 20.0f) + { + } }; class SiphonLifeOnAttackerTrigger : public DebuffOnAttackerTrigger { - public: - SiphonLifeOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "siphon life") { } +public: + SiphonLifeOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "siphon life") {} }; DEBUFF_CHECKISOWNER_TRIGGER(ImmolateTrigger, "immolate"); @@ -76,96 +82,96 @@ public: class ShadowTranceTrigger : public HasAuraTrigger { - public: - ShadowTranceTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "shadow trance") { } +public: + ShadowTranceTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "shadow trance") {} }; class BacklashTrigger : public HasAuraTrigger { - public: - BacklashTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "backlash") { } +public: + BacklashTrigger(PlayerbotAI* botAI) : HasAuraTrigger(botAI, "backlash") {} }; class BanishTrigger : public HasCcTargetTrigger { - public: - BanishTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "banish") { } +public: + BanishTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "banish") {} }; class WarlockConjuredItemTrigger : public ItemCountTrigger { - public: - WarlockConjuredItemTrigger(PlayerbotAI* botAI, std::string const item) : ItemCountTrigger(botAI, item, 1) { } +public: + WarlockConjuredItemTrigger(PlayerbotAI* botAI, std::string const item) : ItemCountTrigger(botAI, item, 1) {} - bool IsActive() override; + bool IsActive() override; }; class HasSpellstoneTrigger : public WarlockConjuredItemTrigger { - public: - HasSpellstoneTrigger(PlayerbotAI* botAI) : WarlockConjuredItemTrigger(botAI, "spellstone") { } +public: + HasSpellstoneTrigger(PlayerbotAI* botAI) : WarlockConjuredItemTrigger(botAI, "spellstone") {} }; class HasFirestoneTrigger : public WarlockConjuredItemTrigger { - public: - HasFirestoneTrigger(PlayerbotAI* botAI) : WarlockConjuredItemTrigger(botAI, "firestone") { } +public: + HasFirestoneTrigger(PlayerbotAI* botAI) : WarlockConjuredItemTrigger(botAI, "firestone") {} }; class HasHealthstoneTrigger : public WarlockConjuredItemTrigger { - public: - HasHealthstoneTrigger(PlayerbotAI* botAI) : WarlockConjuredItemTrigger(botAI, "healthstone") { } +public: + HasHealthstoneTrigger(PlayerbotAI* botAI) : WarlockConjuredItemTrigger(botAI, "healthstone") {} }; class FearTrigger : public HasCcTargetTrigger { - public: - FearTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "fear") { } +public: + FearTrigger(PlayerbotAI* botAI) : HasCcTargetTrigger(botAI, "fear") {} }; class AmplifyCurseTrigger : public BuffTrigger { - public: - AmplifyCurseTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "amplify curse") { } +public: + AmplifyCurseTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "amplify curse") {} }; -class UnstableAfflictionTrigger : public DebuffTrigger // SpellTrigger +class UnstableAfflictionTrigger : public DebuffTrigger // SpellTrigger { - public: - UnstableAfflictionTrigger(PlayerbotAI* ai) : DebuffTrigger(ai, "unstable affliction", 1, true) {} - bool IsActive() override; +public: + UnstableAfflictionTrigger(PlayerbotAI* ai) : DebuffTrigger(ai, "unstable affliction", 1, true) {} + bool IsActive() override; }; class UnstableAfflictionOnAttackerTrigger : public DebuffOnAttackerTrigger { - public: - UnstableAfflictionOnAttackerTrigger(PlayerbotAI* ai) : DebuffOnAttackerTrigger(ai, "unstable affliction", true) {} - bool IsActive() override; +public: + UnstableAfflictionOnAttackerTrigger(PlayerbotAI* ai) : DebuffOnAttackerTrigger(ai, "unstable affliction", true) {} + bool IsActive() override; }; class HauntTrigger : public DebuffTrigger { - public: - HauntTrigger(PlayerbotAI* ai) : DebuffTrigger(ai, "haunt", 1, true, 0) {} +public: + HauntTrigger(PlayerbotAI* ai) : DebuffTrigger(ai, "haunt", 1, true, 0) {} }; class DecimationTrigger : public HasAuraTrigger { - public: - DecimationTrigger(PlayerbotAI* ai) : HasAuraTrigger(ai, "decimation") {} - bool IsActive() override; +public: + DecimationTrigger(PlayerbotAI* ai) : HasAuraTrigger(ai, "decimation") {} + bool IsActive() override; }; class MoltenCoreTrigger : public HasAuraTrigger { - public: - MoltenCoreTrigger(PlayerbotAI* ai) : HasAuraTrigger(ai, "molten core") {} +public: + MoltenCoreTrigger(PlayerbotAI* ai) : HasAuraTrigger(ai, "molten core") {} }; class MetamorphosisTrigger : public BoostTrigger { - public: - MetamorphosisTrigger(PlayerbotAI* ai) : BoostTrigger(ai, "metamorphosis") {} +public: + MetamorphosisTrigger(PlayerbotAI* ai) : BoostTrigger(ai, "metamorphosis") {} }; #endif diff --git a/src/strategy/warrior/ArmsWarriorStrategy.cpp b/src/strategy/warrior/ArmsWarriorStrategy.cpp index ef27b800..bf56e891 100644 --- a/src/strategy/warrior/ArmsWarriorStrategy.cpp +++ b/src/strategy/warrior/ArmsWarriorStrategy.cpp @@ -1,28 +1,30 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "ArmsWarriorStrategy.h" + #include "Playerbots.h" class ArmsWarriorStrategyActionNodeFactory : public NamedObjectFactory { - public: - ArmsWarriorStrategyActionNodeFactory() - { - creators["charge"] = &charge; - creators["death wish"] = &death_wish; - creators["piercing howl"] = &piercing_howl; - creators["mocking blow"] = &mocking_blow; - creators["heroic strike"] = &heroic_strike; - } +public: + ArmsWarriorStrategyActionNodeFactory() + { + creators["charge"] = &charge; + creators["death wish"] = &death_wish; + creators["piercing howl"] = &piercing_howl; + creators["mocking blow"] = &mocking_blow; + creators["heroic strike"] = &heroic_strike; + } - private: - ACTION_NODE_A(charge, "charge", "reach melee"); - ACTION_NODE_A(death_wish, "death wish", "bloodrage"); - ACTION_NODE_A(piercing_howl, "piercing howl", "mocking blow"); - ACTION_NODE_A(mocking_blow, "mocking blow", "hamstring"); - ACTION_NODE_A(heroic_strike, "heroic strike", "melee"); +private: + ACTION_NODE_A(charge, "charge", "reach melee"); + ACTION_NODE_A(death_wish, "death wish", "bloodrage"); + ACTION_NODE_A(piercing_howl, "piercing howl", "mocking blow"); + ACTION_NODE_A(mocking_blow, "mocking blow", "hamstring"); + ACTION_NODE_A(heroic_strike, "heroic strike", "melee"); }; ArmsWarriorStrategy::ArmsWarriorStrategy(PlayerbotAI* botAI) : GenericWarriorStrategy(botAI) @@ -32,31 +34,47 @@ ArmsWarriorStrategy::ArmsWarriorStrategy(PlayerbotAI* botAI) : GenericWarriorStr NextAction** ArmsWarriorStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("bladestorm", ACTION_DEFAULT + 0.1f), - new NextAction("melee", ACTION_DEFAULT), nullptr); + return NextAction::array(0, new NextAction("bladestorm", ACTION_DEFAULT + 0.1f), + new NextAction("melee", ACTION_DEFAULT), nullptr); } void ArmsWarriorStrategy::InitTriggers(std::vector& triggers) { GenericWarriorStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("charge", ACTION_MOVE + 9), nullptr))); - triggers.push_back(new TriggerNode("battle stance", NextAction::array(0, new NextAction("battle stance", ACTION_HIGH + 9), nullptr))); - triggers.push_back(new TriggerNode("battle shout", NextAction::array(0, new NextAction("battle shout", ACTION_HIGH + 8), nullptr))); - triggers.push_back(new TriggerNode("mortal strike", NextAction::array(0, new NextAction("mortal strike", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("target critical health", NextAction::array(0, new NextAction("execute", ACTION_HIGH + 4), nullptr))); - triggers.push_back(new TriggerNode("sudden death", NextAction::array(0, new NextAction("execute", ACTION_HIGH + 4), nullptr))); - triggers.push_back(new TriggerNode("hamstring", NextAction::array(0, new NextAction("piercing howl", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("overpower", NextAction::array(0, new NextAction("overpower", ACTION_HIGH + 3), nullptr))); - triggers.push_back(new TriggerNode("taste for blood", NextAction::array(0, new NextAction("overpower", ACTION_HIGH + 3), nullptr))); - triggers.push_back(new TriggerNode("victory rush", NextAction::array(0, new NextAction("victory rush", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("medium rage available", NextAction::array(0, new NextAction("heroic strike", ACTION_HIGH + 10), nullptr))); - /*triggers.push_back(new TriggerNode("high rage available", NextAction::array(0, new NextAction("slam", ACTION_HIGH + 1), nullptr)));*/ - triggers.push_back(new TriggerNode("bloodrage", NextAction::array(0, new NextAction("bloodrage", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode("death wish", NextAction::array(0, new NextAction("death wish", ACTION_HIGH + 2), nullptr))); + triggers.push_back(new TriggerNode("enemy out of melee", + NextAction::array(0, new NextAction("charge", ACTION_MOVE + 9), nullptr))); + triggers.push_back(new TriggerNode( + "battle stance", NextAction::array(0, new NextAction("battle stance", ACTION_HIGH + 9), nullptr))); + triggers.push_back(new TriggerNode("battle shout", + NextAction::array(0, new NextAction("battle shout", ACTION_HIGH + 8), nullptr))); + triggers.push_back(new TriggerNode( + "mortal strike", NextAction::array(0, new NextAction("mortal strike", ACTION_HIGH + 1), nullptr))); + triggers.push_back(new TriggerNode("target critical health", + NextAction::array(0, new NextAction("execute", ACTION_HIGH + 4), nullptr))); + triggers.push_back( + new TriggerNode("sudden death", NextAction::array(0, new NextAction("execute", ACTION_HIGH + 4), nullptr))); + triggers.push_back( + new TriggerNode("hamstring", NextAction::array(0, new NextAction("piercing howl", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("overpower", NextAction::array(0, new NextAction("overpower", ACTION_HIGH + 3), nullptr))); + triggers.push_back(new TriggerNode("taste for blood", + NextAction::array(0, new NextAction("overpower", ACTION_HIGH + 3), nullptr))); + triggers.push_back(new TriggerNode( + "victory rush", NextAction::array(0, new NextAction("victory rush", ACTION_INTERRUPT), nullptr))); + triggers.push_back(new TriggerNode( + "medium rage available", NextAction::array(0, new NextAction("heroic strike", ACTION_HIGH + 10), nullptr))); + /*triggers.push_back(new TriggerNode("high rage available", NextAction::array(0, new NextAction("slam", ACTION_HIGH + * + 1), nullptr)));*/ + triggers.push_back( + new TriggerNode("bloodrage", NextAction::array(0, new NextAction("bloodrage", ACTION_HIGH + 2), nullptr))); + triggers.push_back( + new TriggerNode("death wish", NextAction::array(0, new NextAction("death wish", ACTION_HIGH + 2), nullptr))); triggers.push_back(new TriggerNode("rend", NextAction::array(0, new NextAction("rend", ACTION_HIGH + 5), nullptr))); - triggers.push_back(new TriggerNode("rend on attacker", NextAction::array(0, new NextAction("rend on attacker", ACTION_HIGH + 5), nullptr))); - triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("intimidating shout", ACTION_EMERGENCY), nullptr))); - triggers.push_back(new TriggerNode("medium rage available", NextAction::array(0, new NextAction("thunder clap", ACTION_HIGH + 1), nullptr))); + triggers.push_back(new TriggerNode( + "rend on attacker", NextAction::array(0, new NextAction("rend on attacker", ACTION_HIGH + 5), nullptr))); + triggers.push_back(new TriggerNode( + "critical health", NextAction::array(0, new NextAction("intimidating shout", ACTION_EMERGENCY), nullptr))); + triggers.push_back(new TriggerNode("medium rage available", + NextAction::array(0, new NextAction("thunder clap", ACTION_HIGH + 1), nullptr))); } diff --git a/src/strategy/warrior/ArmsWarriorStrategy.h b/src/strategy/warrior/ArmsWarriorStrategy.h index 74cebf58..fd99550c 100644 --- a/src/strategy/warrior/ArmsWarriorStrategy.h +++ b/src/strategy/warrior/ArmsWarriorStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_ARMSWARRIORSTRATEGY_H @@ -11,14 +12,14 @@ class PlayerbotAI; class ArmsWarriorStrategy : public GenericWarriorStrategy { - public: - ArmsWarriorStrategy(PlayerbotAI* botAI); +public: + ArmsWarriorStrategy(PlayerbotAI* botAI); - public: - void InitTriggers(std::vector &triggers) override; - std::string const getName() override { return "arms"; } - NextAction** getDefaultActions() override; - uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_MELEE; } +public: + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "arms"; } + NextAction** getDefaultActions() override; + uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_MELEE; } }; #endif diff --git a/src/strategy/warrior/FuryWarriorStrategy.cpp b/src/strategy/warrior/FuryWarriorStrategy.cpp index 57cf118e..56e12b7b 100644 --- a/src/strategy/warrior/FuryWarriorStrategy.cpp +++ b/src/strategy/warrior/FuryWarriorStrategy.cpp @@ -1,30 +1,32 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "FuryWarriorStrategy.h" + #include "Playerbots.h" class FuryWarriorStrategyActionNodeFactory : public NamedObjectFactory { - public: - FuryWarriorStrategyActionNodeFactory() - { - creators["charge"] = &charge; - creators["intercept"] = &intercept; - // creators["death wish"] = &death_wish; - creators["piercing howl"] = &piercing_howl; - // creators["bloodthirst"] = &bloodthirst; - creators["pummel"] = &pummel; - } +public: + FuryWarriorStrategyActionNodeFactory() + { + creators["charge"] = &charge; + creators["intercept"] = &intercept; + // creators["death wish"] = &death_wish; + creators["piercing howl"] = &piercing_howl; + // creators["bloodthirst"] = &bloodthirst; + creators["pummel"] = &pummel; + } - private: - ACTION_NODE_A(charge, "charge", "intercept"); - ACTION_NODE_A(intercept, "intercept", "reach melee"); - ACTION_NODE_A(piercing_howl, "piercing howl", "hamstring"); - // ACTION_NODE_A(death_wish, "death wish", "berserker rage"); - // ACTION_NODE_A(bloodthirst, "bloodthirst", "melee"); - ACTION_NODE_A(pummel, "pummel", "intercept"); +private: + ACTION_NODE_A(charge, "charge", "intercept"); + ACTION_NODE_A(intercept, "intercept", "reach melee"); + ACTION_NODE_A(piercing_howl, "piercing howl", "hamstring"); + // ACTION_NODE_A(death_wish, "death wish", "berserker rage"); + // ACTION_NODE_A(bloodthirst, "bloodthirst", "melee"); + ACTION_NODE_A(pummel, "pummel", "intercept"); }; FuryWarriorStrategy::FuryWarriorStrategy(PlayerbotAI* botAI) : GenericWarriorStrategy(botAI) @@ -34,39 +36,51 @@ FuryWarriorStrategy::FuryWarriorStrategy(PlayerbotAI* botAI) : GenericWarriorStr NextAction** FuryWarriorStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("bloodthirst", ACTION_DEFAULT + 0.5f), - new NextAction("whirlwind", ACTION_DEFAULT + 0.4f), - new NextAction("sunder armor", ACTION_DEFAULT + 0.3f), - new NextAction("execute", ACTION_DEFAULT + 0.2f), - // new NextAction("overpower", ACTION_DEFAULT + 0.1f), - new NextAction("melee", ACTION_DEFAULT), - NULL); + return NextAction::array( + 0, new NextAction("bloodthirst", ACTION_DEFAULT + 0.5f), new NextAction("whirlwind", ACTION_DEFAULT + 0.4f), + new NextAction("sunder armor", ACTION_DEFAULT + 0.3f), new NextAction("execute", ACTION_DEFAULT + 0.2f), + // new NextAction("overpower", ACTION_DEFAULT + 0.1f), + new NextAction("melee", ACTION_DEFAULT), NULL); } -void FuryWarriorStrategy::InitTriggers(std::vector &triggers) +void FuryWarriorStrategy::InitTriggers(std::vector& triggers) { GenericWarriorStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("charge", ACTION_MOVE + 9), nullptr))); - triggers.push_back(new TriggerNode("berserker stance", NextAction::array(0, new NextAction("berserker stance", ACTION_HIGH + 9), nullptr))); - triggers.push_back(new TriggerNode("battle shout", NextAction::array(0, new NextAction("battle shout", ACTION_HIGH + 8), nullptr))); - // triggers.push_back(new TriggerNode("target critical health", NextAction::array(0, new NextAction("execute", ACTION_HIGH + 4), nullptr))); - // triggers.push_back(new TriggerNode("sudden death", NextAction::array(0, new NextAction("execute", ACTION_HIGH + 4), nullptr))); - // triggers.push_back(new TriggerNode("hamstring", NextAction::array(0, new NextAction("piercing howl", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("pummel on enemy healer", NextAction::array(0, new NextAction("pummel on enemy healer", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("pummel", NextAction::array(0, new NextAction("pummel", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("victory rush", NextAction::array(0, new NextAction("victory rush", ACTION_INTERRUPT), nullptr))); - // triggers.push_back(new TriggerNode("intercept on snare target", NextAction::array(0, new NextAction("intercept on snare target", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("bloodthirst", NextAction::array(0, new NextAction("bloodthirst", ACTION_HIGH + 7), nullptr))); - triggers.push_back(new TriggerNode("instant slam", NextAction::array(0, new NextAction("slam", ACTION_HIGH + 5), nullptr))); - triggers.push_back(new TriggerNode("bloodrage", NextAction::array(0, new NextAction("bloodrage", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode("medium rage available", NextAction::array(0, new NextAction("heroic strike", ACTION_HIGH + 1), NULL))); - // triggers.push_back(new TriggerNode("berserker rage", NextAction::array(0, new NextAction("berserker rage", ACTION_HIGH + 2), nullptr))); - // triggers.push_back(new TriggerNode("light aoe", NextAction::array(0, + triggers.push_back(new TriggerNode("enemy out of melee", + NextAction::array(0, new NextAction("charge", ACTION_MOVE + 9), nullptr))); + triggers.push_back(new TriggerNode( + "berserker stance", NextAction::array(0, new NextAction("berserker stance", ACTION_HIGH + 9), nullptr))); + triggers.push_back(new TriggerNode("battle shout", + NextAction::array(0, new NextAction("battle shout", ACTION_HIGH + 8), nullptr))); + // triggers.push_back(new TriggerNode("target critical health", NextAction::array(0, new NextAction("execute", + // ACTION_HIGH + 4), nullptr))); triggers.push_back(new TriggerNode("sudden death", NextAction::array(0, new + // NextAction("execute", ACTION_HIGH + 4), nullptr))); triggers.push_back(new TriggerNode("hamstring", + // NextAction::array(0, new NextAction("piercing howl", ACTION_HIGH + 1), nullptr))); + triggers.push_back( + new TriggerNode("pummel on enemy healer", + NextAction::array(0, new NextAction("pummel on enemy healer", ACTION_INTERRUPT), nullptr))); + triggers.push_back( + new TriggerNode("pummel", NextAction::array(0, new NextAction("pummel", ACTION_INTERRUPT), nullptr))); + triggers.push_back(new TriggerNode( + "victory rush", NextAction::array(0, new NextAction("victory rush", ACTION_INTERRUPT), nullptr))); + // triggers.push_back(new TriggerNode("intercept on snare target", NextAction::array(0, new NextAction("intercept on + // snare target", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("bloodthirst", NextAction::array(0, new NextAction("bloodthirst", ACTION_HIGH + 7), nullptr))); + triggers.push_back( + new TriggerNode("instant slam", NextAction::array(0, new NextAction("slam", ACTION_HIGH + 5), nullptr))); + triggers.push_back( + new TriggerNode("bloodrage", NextAction::array(0, new NextAction("bloodrage", ACTION_HIGH + 2), nullptr))); + triggers.push_back(new TriggerNode("medium rage available", + NextAction::array(0, new NextAction("heroic strike", ACTION_HIGH + 1), NULL))); + // triggers.push_back(new TriggerNode("berserker rage", NextAction::array(0, new NextAction("berserker rage", + // ACTION_HIGH + 2), nullptr))); triggers.push_back(new TriggerNode("light aoe", NextAction::array(0, // new NextAction("whirlwind", ACTION_HIGH + 2), // nullptr))); - - triggers.push_back(new TriggerNode("death wish", NextAction::array(0, new NextAction("death wish", ACTION_HIGH), nullptr))); - triggers.push_back(new TriggerNode("recklessness", NextAction::array(0, new NextAction("recklessness", ACTION_HIGH), nullptr))); + + triggers.push_back( + new TriggerNode("death wish", NextAction::array(0, new NextAction("death wish", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("recklessness", NextAction::array(0, new NextAction("recklessness", ACTION_HIGH), nullptr))); } diff --git a/src/strategy/warrior/FuryWarriorStrategy.h b/src/strategy/warrior/FuryWarriorStrategy.h index 5862e6cf..22ddf19c 100644 --- a/src/strategy/warrior/FuryWarriorStrategy.h +++ b/src/strategy/warrior/FuryWarriorStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_FURYWARRIORSTRATEGY_H @@ -11,13 +12,13 @@ class PlayerbotAI; class FuryWarriorStrategy : public GenericWarriorStrategy { - public: - FuryWarriorStrategy(PlayerbotAI* botAI); +public: + FuryWarriorStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector &triggers) override; - std::string const getName() override { return "fury"; } - NextAction** getDefaultActions() override; - uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_MELEE; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "fury"; } + NextAction** getDefaultActions() override; + uint32 GetType() const override { return STRATEGY_TYPE_COMBAT | STRATEGY_TYPE_DPS | STRATEGY_TYPE_MELEE; } }; #endif diff --git a/src/strategy/warrior/GenericWarriorNonCombatStrategy.cpp b/src/strategy/warrior/GenericWarriorNonCombatStrategy.cpp index e494f4a2..a2c17af9 100644 --- a/src/strategy/warrior/GenericWarriorNonCombatStrategy.cpp +++ b/src/strategy/warrior/GenericWarriorNonCombatStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericWarriorNonCombatStrategy.h" + #include "Playerbots.h" void GenericWarriorNonCombatStrategy::InitTriggers(std::vector& triggers) @@ -10,6 +12,6 @@ void GenericWarriorNonCombatStrategy::InitTriggers(std::vector& tr NonCombatStrategy::InitTriggers(triggers); triggers.push_back(new TriggerNode("often", NextAction::array(0, new NextAction("apply stone", 1.0f), nullptr))); - // triggers.push_back(new TriggerNode("battle stance", NextAction::array(0, new NextAction("battle stance", 1.0f), nullptr))); + // triggers.push_back(new TriggerNode("battle stance", NextAction::array(0, new NextAction("battle stance", 1.0f), + // nullptr))); } - diff --git a/src/strategy/warrior/GenericWarriorNonCombatStrategy.h b/src/strategy/warrior/GenericWarriorNonCombatStrategy.h index 839db0f6..b685d922 100644 --- a/src/strategy/warrior/GenericWarriorNonCombatStrategy.h +++ b/src/strategy/warrior/GenericWarriorNonCombatStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICWARRIORNONCOBATSTRATEGY_H @@ -11,11 +12,11 @@ class PlayerbotAI; class GenericWarriorNonCombatStrategy : public NonCombatStrategy { - public: - GenericWarriorNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } +public: + GenericWarriorNonCombatStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) {} - std::string const getName() override { return "nc"; } - void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "nc"; } + void InitTriggers(std::vector& triggers) override; }; #endif diff --git a/src/strategy/warrior/GenericWarriorStrategy.cpp b/src/strategy/warrior/GenericWarriorStrategy.cpp index bb0399e8..99b107fc 100644 --- a/src/strategy/warrior/GenericWarriorStrategy.cpp +++ b/src/strategy/warrior/GenericWarriorStrategy.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "GenericWarriorStrategy.h" + #include "Playerbots.h" GenericWarriorStrategy::GenericWarriorStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) @@ -13,23 +15,26 @@ GenericWarriorStrategy::GenericWarriorStrategy(PlayerbotAI* botAI) : CombatStrat void GenericWarriorStrategy::InitTriggers(std::vector& triggers) { CombatStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("reach melee", ACTION_NORMAL + 8), nullptr))); - /*triggers.push_back(new TriggerNode("bloodrage", NextAction::array(0, new NextAction("bloodrage", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("shield bash", NextAction::array(0, new NextAction("shield bash", ACTION_INTERRUPT + 4), nullptr))); - triggers.push_back(new TriggerNode("shield bash on enemy healer", NextAction::array(0, new NextAction("shield bash on enemy healer", ACTION_INTERRUPT + 3), nullptr))); - triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("intimidating shout", ACTION_EMERGENCY), nullptr)));*/ + triggers.push_back(new TriggerNode( + "enemy out of melee", NextAction::array(0, new NextAction("reach melee", ACTION_NORMAL + 8), nullptr))); + /*triggers.push_back(new TriggerNode("bloodrage", NextAction::array(0, new NextAction("bloodrage", ACTION_HIGH + 1), + nullptr))); triggers.push_back(new TriggerNode("shield bash", NextAction::array(0, new NextAction("shield bash", + ACTION_INTERRUPT + 4), nullptr))); triggers.push_back(new TriggerNode("shield bash on enemy healer", + NextAction::array(0, new NextAction("shield bash on enemy healer", ACTION_INTERRUPT + 3), nullptr))); + triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("intimidating shout", + ACTION_EMERGENCY), nullptr)));*/ } class WarrirorAoeStrategyActionNodeFactory : public NamedObjectFactory { - public: - WarrirorAoeStrategyActionNodeFactory() - { - // creators["whirlwind"] = &whirlwind; - } +public: + WarrirorAoeStrategyActionNodeFactory() + { + // creators["whirlwind"] = &whirlwind; + } - private: - // ACTION_NODE_A(whirlwind, "whirlwind", "cleave"); +private: + // ACTION_NODE_A(whirlwind, "whirlwind", "cleave"); }; WarrirorAoeStrategy::WarrirorAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(botAI) @@ -39,17 +44,20 @@ WarrirorAoeStrategy::WarrirorAoeStrategy(PlayerbotAI* botAI) : CombatStrategy(bo void WarrirorAoeStrategy::InitTriggers(std::vector& triggers) { - // triggers.push_back(new TriggerNode("thunder clap on snare target", NextAction::array(0, new NextAction("thunder clap on snare target", ACTION_HIGH + 3), nullptr))); - // triggers.push_back(new TriggerNode("thunder clap", NextAction::array(0, new NextAction("thunder clap", ACTION_HIGH + 10), nullptr))); - triggers.push_back(new TriggerNode("light aoe", NextAction::array(0, - new NextAction("thunder clap", ACTION_HIGH + 5), - new NextAction("shockwave", ACTION_HIGH + 4), - new NextAction("sweeping strikes", ACTION_HIGH + 3), - new NextAction("bladestorm", ACTION_HIGH + 3), - // new NextAction("whirlwind", ACTION_HIGH + 2), - new NextAction("demoralizing shout without life time check", ACTION_HIGH + 1), - new NextAction("cleave", ACTION_HIGH), - nullptr))); - triggers.push_back(new TriggerNode("shockwave on snare target", NextAction::array(0, new NextAction("shockwave on snare target", ACTION_HIGH + 5), nullptr))); - // triggers.push_back(new TriggerNode("high rage available", NextAction::array(0, new NextAction("whirlwind", ACTION_HIGH + 10), nullptr))); + // triggers.push_back(new TriggerNode("thunder clap on snare target", NextAction::array(0, new NextAction("thunder + // clap on snare target", ACTION_HIGH + 3), nullptr))); triggers.push_back(new TriggerNode("thunder clap", + // NextAction::array(0, new NextAction("thunder clap", ACTION_HIGH + 10), nullptr))); + triggers.push_back(new TriggerNode( + "light aoe", NextAction::array(0, new NextAction("thunder clap", ACTION_HIGH + 5), + new NextAction("shockwave", ACTION_HIGH + 4), + new NextAction("sweeping strikes", ACTION_HIGH + 3), + new NextAction("bladestorm", ACTION_HIGH + 3), + // new NextAction("whirlwind", ACTION_HIGH + 2), + new NextAction("demoralizing shout without life time check", ACTION_HIGH + 1), + new NextAction("cleave", ACTION_HIGH), nullptr))); + triggers.push_back( + new TriggerNode("shockwave on snare target", + NextAction::array(0, new NextAction("shockwave on snare target", ACTION_HIGH + 5), nullptr))); + // triggers.push_back(new TriggerNode("high rage available", NextAction::array(0, new NextAction("whirlwind", + // ACTION_HIGH + 10), nullptr))); } diff --git a/src/strategy/warrior/GenericWarriorStrategy.h b/src/strategy/warrior/GenericWarriorStrategy.h index bf1bd1b1..dbfe339c 100644 --- a/src/strategy/warrior/GenericWarriorStrategy.h +++ b/src/strategy/warrior/GenericWarriorStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_GENERICWARRIORSTRATEGY_H @@ -12,68 +13,68 @@ class PlayerbotAI; // Stance requirements class WarriorStanceRequirementActionNodeFactory : public NamedObjectFactory { - public: - WarriorStanceRequirementActionNodeFactory() - { - // battle only - creators["charge"] = &charge; - creators["mocking blow"] = &mocking_blow; - creators["overpower"] = &overpower; +public: + WarriorStanceRequirementActionNodeFactory() + { + // battle only + creators["charge"] = &charge; + creators["mocking blow"] = &mocking_blow; + creators["overpower"] = &overpower; - // temp - creators["mortal strike"] = &mortal_strike; + // temp + creators["mortal strike"] = &mortal_strike; - // berserker only - creators["berserker rage"] = &berserker_rage; - creators["recklessness"] = &recklessness; - creators["whirlwind"] = &whirlwind; - creators["pummel"] = &pummel; - creators["intercept"] = &intercept; + // berserker only + creators["berserker rage"] = &berserker_rage; + creators["recklessness"] = &recklessness; + creators["whirlwind"] = &whirlwind; + creators["pummel"] = &pummel; + creators["intercept"] = &intercept; - // defensive only - creators["taunt"] = &taunt; - creators["revenge"] = &revenge; - creators["shield block"] = &shield_block; - creators["disarm"] = &disarm; - creators["shield wall"] = &shield_wall; - creators["intervene"] = &intervene; - } + // defensive only + creators["taunt"] = &taunt; + creators["revenge"] = &revenge; + creators["shield block"] = &shield_block; + creators["disarm"] = &disarm; + creators["shield wall"] = &shield_wall; + creators["intervene"] = &intervene; + } - private: - ACTION_NODE_P(charge, "charge", "battle stance"); - ACTION_NODE_P(mocking_blow, "mocking blow", "battle stance"); - ACTION_NODE_P(overpower, "overpower", "battle stance"); - ACTION_NODE_P(berserker_rage, "berserker rage", "berserker stance"); - ACTION_NODE_P(recklessness, "recklessness", "berserker stance"); - ACTION_NODE_P(whirlwind, "whirlwind", "berserker stance"); - ACTION_NODE_P(pummel, "pummel", "berserker stance"); - ACTION_NODE_P(intercept, "intercept", "berserker stance"); - ACTION_NODE_P(taunt, "taunt", "defensive stance"); - ACTION_NODE_P(revenge, "revenge", "defensive stance"); - ACTION_NODE_P(shield_block, "shield block", "defensive stance"); - ACTION_NODE_P(disarm, "disarm", "defensive stance"); - ACTION_NODE_P(shield_wall, "shield wall", "defensive stance"); - ACTION_NODE_P(intervene, "intervene", "defensive stance"); - //temp - ACTION_NODE_P(mortal_strike, "mortal strike", "battle stance"); +private: + ACTION_NODE_P(charge, "charge", "battle stance"); + ACTION_NODE_P(mocking_blow, "mocking blow", "battle stance"); + ACTION_NODE_P(overpower, "overpower", "battle stance"); + ACTION_NODE_P(berserker_rage, "berserker rage", "berserker stance"); + ACTION_NODE_P(recklessness, "recklessness", "berserker stance"); + ACTION_NODE_P(whirlwind, "whirlwind", "berserker stance"); + ACTION_NODE_P(pummel, "pummel", "berserker stance"); + ACTION_NODE_P(intercept, "intercept", "berserker stance"); + ACTION_NODE_P(taunt, "taunt", "defensive stance"); + ACTION_NODE_P(revenge, "revenge", "defensive stance"); + ACTION_NODE_P(shield_block, "shield block", "defensive stance"); + ACTION_NODE_P(disarm, "disarm", "defensive stance"); + ACTION_NODE_P(shield_wall, "shield wall", "defensive stance"); + ACTION_NODE_P(intervene, "intervene", "defensive stance"); + // temp + ACTION_NODE_P(mortal_strike, "mortal strike", "battle stance"); }; class GenericWarriorStrategy : public CombatStrategy { - public: - GenericWarriorStrategy(PlayerbotAI* botAI); +public: + GenericWarriorStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "warrior"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "warrior"; } }; class WarrirorAoeStrategy : public CombatStrategy { - public: - WarrirorAoeStrategy(PlayerbotAI* botAI); +public: + WarrirorAoeStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "aoe"; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "aoe"; } }; #endif diff --git a/src/strategy/warrior/TankWarriorStrategy.cpp b/src/strategy/warrior/TankWarriorStrategy.cpp index bbdfb740..d7e47f6b 100644 --- a/src/strategy/warrior/TankWarriorStrategy.cpp +++ b/src/strategy/warrior/TankWarriorStrategy.cpp @@ -1,44 +1,46 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "TankWarriorStrategy.h" + #include "Playerbots.h" class TankWarriorStrategyActionNodeFactory : public NamedObjectFactory { - public: - TankWarriorStrategyActionNodeFactory() - { - creators["charge"] = &charge; - creators["sunder armor"] = &sunder_armor; - creators["commanding shout"] = &commanding_shout; - // creators["shield slam"] = &shield_slam; - creators["devastate"] = &devastate; - creators["last stand"] = &last_stand; - creators["heroic throw on snare target"] = &heroic_throw_on_snare_target; - creators["heroic throw taunt"] = &heroic_throw_taunt; - creators["taunt"] = &taunt; - creators["taunt spell"] = &taunt; - } +public: + TankWarriorStrategyActionNodeFactory() + { + creators["charge"] = &charge; + creators["sunder armor"] = &sunder_armor; + creators["commanding shout"] = &commanding_shout; + // creators["shield slam"] = &shield_slam; + creators["devastate"] = &devastate; + creators["last stand"] = &last_stand; + creators["heroic throw on snare target"] = &heroic_throw_on_snare_target; + creators["heroic throw taunt"] = &heroic_throw_taunt; + creators["taunt"] = &taunt; + creators["taunt spell"] = &taunt; + } - private: - //ACTION_NODE_A(charge, "charge", "intercept with stance"); - ACTION_NODE_A(charge, "charge", "reach melee"); - ACTION_NODE_A(sunder_armor, "sunder armor", "melee"); - ACTION_NODE_A(commanding_shout, "commanding shout", "battle shout"); - // ACTION_NODE_A(shield_slam, "shield slam", "heroic strike"); - ACTION_NODE_A(devastate, "devastate", "sunder armor"); - ACTION_NODE_A(last_stand, "last stand", "intimidating shout"); - ACTION_NODE_A(heroic_throw_on_snare_target, "heroic throw on snare target", "taunt on snare target"); - ACTION_NODE_A(heroic_throw_taunt, "heroic throw", "shield slam"); - static ActionNode* taunt(PlayerbotAI* botAI) - { - return new ActionNode("taunt", - /*P*/ nullptr, - /*A*/ NextAction::array(0, new NextAction("heroic throw taunt"), nullptr), - /*C*/ nullptr); - } +private: + // ACTION_NODE_A(charge, "charge", "intercept with stance"); + ACTION_NODE_A(charge, "charge", "reach melee"); + ACTION_NODE_A(sunder_armor, "sunder armor", "melee"); + ACTION_NODE_A(commanding_shout, "commanding shout", "battle shout"); + // ACTION_NODE_A(shield_slam, "shield slam", "heroic strike"); + ACTION_NODE_A(devastate, "devastate", "sunder armor"); + ACTION_NODE_A(last_stand, "last stand", "intimidating shout"); + ACTION_NODE_A(heroic_throw_on_snare_target, "heroic throw on snare target", "taunt on snare target"); + ACTION_NODE_A(heroic_throw_taunt, "heroic throw", "shield slam"); + static ActionNode* taunt(PlayerbotAI* botAI) + { + return new ActionNode("taunt", + /*P*/ nullptr, + /*A*/ NextAction::array(0, new NextAction("heroic throw taunt"), nullptr), + /*C*/ nullptr); + } }; TankWarriorStrategy::TankWarriorStrategy(PlayerbotAI* botAI) : GenericWarriorStrategy(botAI) @@ -48,46 +50,74 @@ TankWarriorStrategy::TankWarriorStrategy(PlayerbotAI* botAI) : GenericWarriorStr NextAction** TankWarriorStrategy::getDefaultActions() { - return NextAction::array(0, - new NextAction("devastate", ACTION_DEFAULT + 0.3f), - new NextAction("revenge", ACTION_DEFAULT + 0.2f), - new NextAction("demoralizing shout", ACTION_DEFAULT + 0.1f), - new NextAction("melee", ACTION_DEFAULT), - NULL); + return NextAction::array( + 0, new NextAction("devastate", ACTION_DEFAULT + 0.3f), new NextAction("revenge", ACTION_DEFAULT + 0.2f), + new NextAction("demoralizing shout", ACTION_DEFAULT + 0.1f), new NextAction("melee", ACTION_DEFAULT), NULL); } void TankWarriorStrategy::InitTriggers(std::vector& triggers) { GenericWarriorStrategy::InitTriggers(triggers); - triggers.push_back(new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("heroic throw", ACTION_MOVE + 11), new NextAction("charge", ACTION_MOVE + 10), nullptr))); - // triggers.push_back(new TriggerNode("intercept and rage", NextAction::array(0, new NextAction("berserker stance", ACTION_MOVE + 14), nullptr))); - // triggers.push_back(new TriggerNode("intercept and rage", NextAction::array(0, new NextAction("intercept", ACTION_MOVE + 13), nullptr))); - // triggers.push_back(new TriggerNode("thunder clap and rage", NextAction::array(0, new NextAction("battle stance", ACTION_MOVE + 12), nullptr))); - triggers.push_back(new TriggerNode("thunder clap and rage", NextAction::array(0, new NextAction("thunder clap", ACTION_MOVE + 11), nullptr))); - triggers.push_back(new TriggerNode("defensive stance", NextAction::array(0, new NextAction("defensive stance", ACTION_HIGH + 9), nullptr))); - triggers.push_back(new TriggerNode("commanding shout", NextAction::array(0, new NextAction("commanding shout", ACTION_HIGH + 8), nullptr))); - triggers.push_back(new TriggerNode("bloodrage", NextAction::array(0, new NextAction("bloodrage", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode("sunder armor", NextAction::array(0, new NextAction("devastate", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode("medium rage available", NextAction::array(0, new NextAction("shield slam", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("shield block", NextAction::array(0, new NextAction("shield block", ACTION_INTERRUPT + 1), nullptr))); - triggers.push_back(new TriggerNode("revenge", NextAction::array(0, new NextAction("revenge", ACTION_HIGH + 2), nullptr))); - triggers.push_back(new TriggerNode("disarm", NextAction::array(0, new NextAction("disarm", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("lose aggro", NextAction::array(0, new NextAction("taunt", ACTION_INTERRUPT + 1), nullptr))); - triggers.push_back(new TriggerNode("taunt on snare target", NextAction::array(0, new NextAction("heroic throw on snare target", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("low health", NextAction::array(0, new NextAction("shield wall", ACTION_MEDIUM_HEAL), nullptr))); - triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("last stand", ACTION_EMERGENCY + 3), nullptr))); - // triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("battle shout taunt", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("high aoe", NextAction::array(0, new NextAction("challenging shout", ACTION_HIGH + 3), nullptr))); - triggers.push_back(new TriggerNode("concussion blow", NextAction::array(0, new NextAction("concussion blow", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("shield bash", NextAction::array(0, new NextAction("shield bash", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("shield bash on enemy healer", NextAction::array(0, new NextAction("shield bash on enemy healer", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("spell reflection", NextAction::array(0, new NextAction("spell reflection", ACTION_INTERRUPT + 1), nullptr))); - triggers.push_back(new TriggerNode("victory rush", NextAction::array(0, new NextAction("victory rush", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("sword and board", NextAction::array(0, new NextAction("shield slam", ACTION_INTERRUPT), nullptr))); - triggers.push_back(new TriggerNode("rend", NextAction::array(0, new NextAction("rend", ACTION_NORMAL + 1), nullptr))); - triggers.push_back(new TriggerNode("rend on attacker", NextAction::array(0, new NextAction("rend on attacker", ACTION_NORMAL + 1), nullptr))); - triggers.push_back(new TriggerNode("protect party member", NextAction::array(0, new NextAction("intervene", ACTION_EMERGENCY), nullptr))); - triggers.push_back(new TriggerNode("high rage available", NextAction::array(0, new NextAction("heroic strike", ACTION_HIGH + 1), nullptr))); - triggers.push_back(new TriggerNode("medium rage available", NextAction::array(0, new NextAction("thunder clap", ACTION_HIGH + 1), nullptr))); + triggers.push_back( + new TriggerNode("enemy out of melee", NextAction::array(0, new NextAction("heroic throw", ACTION_MOVE + 11), + new NextAction("charge", ACTION_MOVE + 10), nullptr))); + // triggers.push_back(new TriggerNode("intercept and rage", NextAction::array(0, new NextAction("berserker stance", + // ACTION_MOVE + 14), nullptr))); triggers.push_back(new TriggerNode("intercept and rage", NextAction::array(0, new + // NextAction("intercept", ACTION_MOVE + 13), nullptr))); triggers.push_back(new TriggerNode("thunder clap and + // rage", NextAction::array(0, new NextAction("battle stance", ACTION_MOVE + 12), nullptr))); + triggers.push_back(new TriggerNode( + "thunder clap and rage", NextAction::array(0, new NextAction("thunder clap", ACTION_MOVE + 11), nullptr))); + triggers.push_back(new TriggerNode( + "defensive stance", NextAction::array(0, new NextAction("defensive stance", ACTION_HIGH + 9), nullptr))); + triggers.push_back(new TriggerNode( + "commanding shout", NextAction::array(0, new NextAction("commanding shout", ACTION_HIGH + 8), nullptr))); + triggers.push_back( + new TriggerNode("bloodrage", NextAction::array(0, new NextAction("bloodrage", ACTION_HIGH + 2), nullptr))); + triggers.push_back( + new TriggerNode("sunder armor", NextAction::array(0, new NextAction("devastate", ACTION_HIGH + 2), nullptr))); + triggers.push_back(new TriggerNode("medium rage available", + NextAction::array(0, new NextAction("shield slam", ACTION_HIGH + 1), nullptr))); + triggers.push_back(new TriggerNode( + "shield block", NextAction::array(0, new NextAction("shield block", ACTION_INTERRUPT + 1), nullptr))); + triggers.push_back( + new TriggerNode("revenge", NextAction::array(0, new NextAction("revenge", ACTION_HIGH + 2), nullptr))); + triggers.push_back( + new TriggerNode("disarm", NextAction::array(0, new NextAction("disarm", ACTION_HIGH + 1), nullptr))); + triggers.push_back( + new TriggerNode("lose aggro", NextAction::array(0, new NextAction("taunt", ACTION_INTERRUPT + 1), nullptr))); + triggers.push_back(new TriggerNode( + "taunt on snare target", + NextAction::array(0, new NextAction("heroic throw on snare target", ACTION_INTERRUPT), nullptr))); + triggers.push_back(new TriggerNode( + "low health", NextAction::array(0, new NextAction("shield wall", ACTION_MEDIUM_HEAL), nullptr))); + triggers.push_back(new TriggerNode( + "critical health", NextAction::array(0, new NextAction("last stand", ACTION_EMERGENCY + 3), nullptr))); + // triggers.push_back(new TriggerNode("medium aoe", NextAction::array(0, new NextAction("battle shout taunt", + // ACTION_HIGH + 1), nullptr))); + triggers.push_back(new TriggerNode( + "high aoe", NextAction::array(0, new NextAction("challenging shout", ACTION_HIGH + 3), nullptr))); + triggers.push_back(new TriggerNode( + "concussion blow", NextAction::array(0, new NextAction("concussion blow", ACTION_INTERRUPT), nullptr))); + triggers.push_back( + new TriggerNode("shield bash", NextAction::array(0, new NextAction("shield bash", ACTION_INTERRUPT), nullptr))); + triggers.push_back(new TriggerNode( + "shield bash on enemy healer", + NextAction::array(0, new NextAction("shield bash on enemy healer", ACTION_INTERRUPT), nullptr))); + triggers.push_back(new TriggerNode( + "spell reflection", NextAction::array(0, new NextAction("spell reflection", ACTION_INTERRUPT + 1), nullptr))); + triggers.push_back(new TriggerNode( + "victory rush", NextAction::array(0, new NextAction("victory rush", ACTION_INTERRUPT), nullptr))); + triggers.push_back(new TriggerNode("sword and board", + NextAction::array(0, new NextAction("shield slam", ACTION_INTERRUPT), nullptr))); + triggers.push_back( + new TriggerNode("rend", NextAction::array(0, new NextAction("rend", ACTION_NORMAL + 1), nullptr))); + triggers.push_back(new TriggerNode( + "rend on attacker", NextAction::array(0, new NextAction("rend on attacker", ACTION_NORMAL + 1), nullptr))); + triggers.push_back(new TriggerNode("protect party member", + NextAction::array(0, new NextAction("intervene", ACTION_EMERGENCY), nullptr))); + triggers.push_back(new TriggerNode( + "high rage available", NextAction::array(0, new NextAction("heroic strike", ACTION_HIGH + 1), nullptr))); + triggers.push_back(new TriggerNode("medium rage available", + NextAction::array(0, new NextAction("thunder clap", ACTION_HIGH + 1), nullptr))); } diff --git a/src/strategy/warrior/TankWarriorStrategy.h b/src/strategy/warrior/TankWarriorStrategy.h index dcc18ae8..2e388729 100644 --- a/src/strategy/warrior/TankWarriorStrategy.h +++ b/src/strategy/warrior/TankWarriorStrategy.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_TANKWARRIORSTRATEGY_H @@ -12,13 +13,13 @@ class PlayerbotAI; class TankWarriorStrategy : public GenericWarriorStrategy { - public: - TankWarriorStrategy(PlayerbotAI* botAI); +public: + TankWarriorStrategy(PlayerbotAI* botAI); - void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "tank"; } - NextAction** getDefaultActions() override; - uint32 GetType() const override { return STRATEGY_TYPE_TANK | STRATEGY_TYPE_MELEE; } + void InitTriggers(std::vector& triggers) override; + std::string const getName() override { return "tank"; } + NextAction** getDefaultActions() override; + uint32 GetType() const override { return STRATEGY_TYPE_TANK | STRATEGY_TYPE_MELEE; } }; #endif diff --git a/src/strategy/warrior/WarriorActions.cpp b/src/strategy/warrior/WarriorActions.cpp index de38b8ff..eaf8f9a5 100644 --- a/src/strategy/warrior/WarriorActions.cpp +++ b/src/strategy/warrior/WarriorActions.cpp @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "WarriorActions.h" + #include "Playerbots.h" bool CastSunderArmorAction::isUseful() { - Aura *aura = botAI->GetAura("sunder armor", GetTarget(), false, true); + Aura* aura = botAI->GetAura("sunder armor", GetTarget(), false, true); return !aura || aura->GetStackAmount() < 5 || aura->GetDuration() <= 6000; } diff --git a/src/strategy/warrior/WarriorActions.h b/src/strategy/warrior/WarriorActions.h index a9bad59b..d571b67e 100644 --- a/src/strategy/warrior/WarriorActions.h +++ b/src/strategy/warrior/WarriorActions.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WARRIORACTIONS_H @@ -18,15 +19,16 @@ BUFF_ACTION(CastBerserkerStanceAction, "berserker stance"); // shouts BUFF_ACTION(CastBattleShoutAction, "battle shout"); -MELEE_ACTION_U(CastBattleShoutTauntAction, "battle shout", CastSpellAction::isUseful()); // useful to rebuff -DEBUFF_ACTION_R(CastDemoralizingShoutAction, "demoralizing shout", 8.0f); // low range debuff +MELEE_ACTION_U(CastBattleShoutTauntAction, "battle shout", CastSpellAction::isUseful()); // useful to rebuff +DEBUFF_ACTION_R(CastDemoralizingShoutAction, "demoralizing shout", 8.0f); // low range debuff class CastDemoralizingShoutWithoutLifeTimeCheckAction : public CastDebuffSpellAction { - public: - CastDemoralizingShoutWithoutLifeTimeCheckAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "demoralizing shout", false, 0.0f) \ - { - range = 8.0f; - } +public: + CastDemoralizingShoutWithoutLifeTimeCheckAction(PlayerbotAI* botAI) + : CastDebuffSpellAction(botAI, "demoralizing shout", false, 0.0f) + { + range = 8.0f; + } }; MELEE_ACTION(CastChallengingShoutAction, "challenging shout"); @@ -42,8 +44,8 @@ DEBUFF_CHECKISOWNER_ACTION(CastRendAction, "rend"); class CastRendOnAttackerAction : public CastDebuffSpellOnMeleeAttackerAction { - public: - CastRendOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnMeleeAttackerAction(botAI, "rend") {} +public: + CastRendOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnMeleeAttackerAction(botAI, "rend") {} }; MELEE_ACTION(CastThunderClapAction, "thunder clap"); @@ -96,7 +98,9 @@ MELEE_ACTION(CastShieldBashAction, "shield bash"); ENEMY_HEALER_ACTION(CastShieldBashOnEnemyHealerAction, "shield bash"); MELEE_ACTION(CastRevengeAction, "revenge"); BUFF_ACTION(CastShieldBlockAction, "shield block"); -DEBUFF_ACTION_U(CastDisarmAction, "disarm", GetTarget() && GetTarget()->IsPlayer() ? !botAI->IsRanged((Player*)GetTarget()) : CastDebuffSpellAction::isUseful()); +DEBUFF_ACTION_U(CastDisarmAction, "disarm", + GetTarget() && GetTarget()->IsPlayer() ? !botAI->IsRanged((Player*)GetTarget()) + : CastDebuffSpellAction::isUseful()); DEBUFF_ENEMY_ACTION(CastDisarmOnAttackerAction, "disarm"); BUFF_ACTION(CastShieldWallAction, "shield wall"); // protection 2.4.3 @@ -115,13 +119,13 @@ SNARE_ACTION(CastShockwaveSnareAction, "shockwave"); class CastSunderArmorAction : public CastDebuffSpellAction { - public: - CastSunderArmorAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "sunder armor") - { - range = ATTACK_DISTANCE; - } +public: + CastSunderArmorAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "sunder armor") + { + range = ATTACK_DISTANCE; + } - bool isUseful() override; + bool isUseful() override; }; #endif diff --git a/src/strategy/warrior/WarriorAiObjectContext.cpp b/src/strategy/warrior/WarriorAiObjectContext.cpp index 1cabf441..71be13bf 100644 --- a/src/strategy/warrior/WarriorAiObjectContext.cpp +++ b/src/strategy/warrior/WarriorAiObjectContext.cpp @@ -1,283 +1,309 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "WarriorAiObjectContext.h" + #include "ArmsWarriorStrategy.h" #include "FuryWarriorStrategy.h" #include "GenericWarriorNonCombatStrategy.h" +#include "NamedObjectContext.h" +#include "Playerbots.h" +#include "PullStrategy.h" #include "TankWarriorStrategy.h" #include "WarriorActions.h" #include "WarriorTriggers.h" -#include "NamedObjectContext.h" -#include "PullStrategy.h" -#include "Playerbots.h" class WarriorStrategyFactoryInternal : public NamedObjectContext { - public: - WarriorStrategyFactoryInternal() - { - creators["nc"] = &WarriorStrategyFactoryInternal::nc; - creators["pull"] = &WarriorStrategyFactoryInternal::pull; - creators["aoe"] = &WarriorStrategyFactoryInternal::warrior_aoe; - } +public: + WarriorStrategyFactoryInternal() + { + creators["nc"] = &WarriorStrategyFactoryInternal::nc; + creators["pull"] = &WarriorStrategyFactoryInternal::pull; + creators["aoe"] = &WarriorStrategyFactoryInternal::warrior_aoe; + } - private: - static Strategy* nc(PlayerbotAI* botAI) { return new GenericWarriorNonCombatStrategy(botAI); } - static Strategy* warrior_aoe(PlayerbotAI* botAI) { return new WarrirorAoeStrategy(botAI); } - static Strategy* pull(PlayerbotAI* botAI) { return new PullStrategy(botAI, "shoot"); } +private: + static Strategy* nc(PlayerbotAI* botAI) { return new GenericWarriorNonCombatStrategy(botAI); } + static Strategy* warrior_aoe(PlayerbotAI* botAI) { return new WarrirorAoeStrategy(botAI); } + static Strategy* pull(PlayerbotAI* botAI) { return new PullStrategy(botAI, "shoot"); } }; class WarriorCombatStrategyFactoryInternal : public NamedObjectContext { - public: - WarriorCombatStrategyFactoryInternal() : NamedObjectContext(false, true) - { - creators["tank"] = &WarriorCombatStrategyFactoryInternal::tank; - creators["arms"] = &WarriorCombatStrategyFactoryInternal::arms; - creators["fury"] = &WarriorCombatStrategyFactoryInternal::fury; - } +public: + WarriorCombatStrategyFactoryInternal() : NamedObjectContext(false, true) + { + creators["tank"] = &WarriorCombatStrategyFactoryInternal::tank; + creators["arms"] = &WarriorCombatStrategyFactoryInternal::arms; + creators["fury"] = &WarriorCombatStrategyFactoryInternal::fury; + } - private: - static Strategy* tank(PlayerbotAI* botAI) { return new TankWarriorStrategy(botAI); } - static Strategy* arms(PlayerbotAI* botAI) { return new ArmsWarriorStrategy(botAI); } - static Strategy* fury(PlayerbotAI* botAI) { return new FuryWarriorStrategy(botAI); } +private: + static Strategy* tank(PlayerbotAI* botAI) { return new TankWarriorStrategy(botAI); } + static Strategy* arms(PlayerbotAI* botAI) { return new ArmsWarriorStrategy(botAI); } + static Strategy* fury(PlayerbotAI* botAI) { return new FuryWarriorStrategy(botAI); } }; class WarriorTriggerFactoryInternal : public NamedObjectContext { - public: - WarriorTriggerFactoryInternal() - { - creators["hamstring"] = &WarriorTriggerFactoryInternal::hamstring; - creators["victory rush"] = &WarriorTriggerFactoryInternal::victory_rush; - creators["death wish"] = &WarriorTriggerFactoryInternal::death_wish; - creators["recklessness"] = &WarriorTriggerFactoryInternal::recklessness; - creators["battle shout"] = &WarriorTriggerFactoryInternal::battle_shout; - creators["rend"] = &WarriorTriggerFactoryInternal::rend; - creators["rend on attacker"] = &WarriorTriggerFactoryInternal::rend_on_attacker; - creators["bloodrage"] = &WarriorTriggerFactoryInternal::bloodrage; - creators["shield bash"] = &WarriorTriggerFactoryInternal::shield_bash; - creators["disarm"] = &WarriorTriggerFactoryInternal::disarm; - creators["concussion blow"] = &WarriorTriggerFactoryInternal::concussion_blow; - creators["sword and board"] = &WarriorTriggerFactoryInternal::SwordAndBoard; - creators["shield bash on enemy healer"] = &WarriorTriggerFactoryInternal::shield_bash_on_enemy_healer; - creators["battle stance"] = &WarriorTriggerFactoryInternal::battle_stance; - creators["defensive stance"] = &WarriorTriggerFactoryInternal::defensive_stance; - creators["berserker stance"] = &WarriorTriggerFactoryInternal::berserker_stance; - creators["shield block"] = &WarriorTriggerFactoryInternal::shield_block; - creators["sunder armor"] = &WarriorTriggerFactoryInternal::sunder_armor; - creators["revenge"] = &WarriorTriggerFactoryInternal::revenge; - creators["overpower"] = &WarriorTriggerFactoryInternal::overpower; - creators["mocking blow"] = &WarriorTriggerFactoryInternal::mocking_blow; - creators["rampage"] = &WarriorTriggerFactoryInternal::rampage; - creators["mortal strike"] = &WarriorTriggerFactoryInternal::mortal_strike; - creators["thunder clap on snare target"] = &WarriorTriggerFactoryInternal::thunder_clap_on_snare_target; - creators["thunder clap"] = &WarriorTriggerFactoryInternal::thunder_clap; - creators["bloodthirst"] = &WarriorTriggerFactoryInternal::bloodthirst; - creators["berserker rage"] = &WarriorTriggerFactoryInternal::berserker_rage; - creators["pummel on enemy healer"] = &WarriorTriggerFactoryInternal::pummel_on_enemy_healer; - creators["pummel"] = &WarriorTriggerFactoryInternal::pummel; - creators["intercept on enemy healer"] = &WarriorTriggerFactoryInternal::intercept_on_enemy_healer; - creators["intercept"] = &WarriorTriggerFactoryInternal::intercept; - creators["taunt on snare target"] = &WarriorTriggerFactoryInternal::taunt_on_snare_target; - creators["commanding shout"] = &WarriorTriggerFactoryInternal::commanding_shout; - creators["intercept on snare target"] = &WarriorTriggerFactoryInternal::intercept_on_snare_target; - creators["spell reflection"] = &WarriorTriggerFactoryInternal::spell_reflection; - creators["sudden death"] = &WarriorTriggerFactoryInternal::sudden_death; - creators["instant slam"] = &WarriorTriggerFactoryInternal::instant_slam; - creators["shockwave"] = &WarriorTriggerFactoryInternal::shockwave; - creators["shockwave on snare target"] = &WarriorTriggerFactoryInternal::shockwave_on_snare_target; - creators["taste for blood"] = &WarriorTriggerFactoryInternal::taste_for_blood; +public: + WarriorTriggerFactoryInternal() + { + creators["hamstring"] = &WarriorTriggerFactoryInternal::hamstring; + creators["victory rush"] = &WarriorTriggerFactoryInternal::victory_rush; + creators["death wish"] = &WarriorTriggerFactoryInternal::death_wish; + creators["recklessness"] = &WarriorTriggerFactoryInternal::recklessness; + creators["battle shout"] = &WarriorTriggerFactoryInternal::battle_shout; + creators["rend"] = &WarriorTriggerFactoryInternal::rend; + creators["rend on attacker"] = &WarriorTriggerFactoryInternal::rend_on_attacker; + creators["bloodrage"] = &WarriorTriggerFactoryInternal::bloodrage; + creators["shield bash"] = &WarriorTriggerFactoryInternal::shield_bash; + creators["disarm"] = &WarriorTriggerFactoryInternal::disarm; + creators["concussion blow"] = &WarriorTriggerFactoryInternal::concussion_blow; + creators["sword and board"] = &WarriorTriggerFactoryInternal::SwordAndBoard; + creators["shield bash on enemy healer"] = &WarriorTriggerFactoryInternal::shield_bash_on_enemy_healer; + creators["battle stance"] = &WarriorTriggerFactoryInternal::battle_stance; + creators["defensive stance"] = &WarriorTriggerFactoryInternal::defensive_stance; + creators["berserker stance"] = &WarriorTriggerFactoryInternal::berserker_stance; + creators["shield block"] = &WarriorTriggerFactoryInternal::shield_block; + creators["sunder armor"] = &WarriorTriggerFactoryInternal::sunder_armor; + creators["revenge"] = &WarriorTriggerFactoryInternal::revenge; + creators["overpower"] = &WarriorTriggerFactoryInternal::overpower; + creators["mocking blow"] = &WarriorTriggerFactoryInternal::mocking_blow; + creators["rampage"] = &WarriorTriggerFactoryInternal::rampage; + creators["mortal strike"] = &WarriorTriggerFactoryInternal::mortal_strike; + creators["thunder clap on snare target"] = &WarriorTriggerFactoryInternal::thunder_clap_on_snare_target; + creators["thunder clap"] = &WarriorTriggerFactoryInternal::thunder_clap; + creators["bloodthirst"] = &WarriorTriggerFactoryInternal::bloodthirst; + creators["berserker rage"] = &WarriorTriggerFactoryInternal::berserker_rage; + creators["pummel on enemy healer"] = &WarriorTriggerFactoryInternal::pummel_on_enemy_healer; + creators["pummel"] = &WarriorTriggerFactoryInternal::pummel; + creators["intercept on enemy healer"] = &WarriorTriggerFactoryInternal::intercept_on_enemy_healer; + creators["intercept"] = &WarriorTriggerFactoryInternal::intercept; + creators["taunt on snare target"] = &WarriorTriggerFactoryInternal::taunt_on_snare_target; + creators["commanding shout"] = &WarriorTriggerFactoryInternal::commanding_shout; + creators["intercept on snare target"] = &WarriorTriggerFactoryInternal::intercept_on_snare_target; + creators["spell reflection"] = &WarriorTriggerFactoryInternal::spell_reflection; + creators["sudden death"] = &WarriorTriggerFactoryInternal::sudden_death; + creators["instant slam"] = &WarriorTriggerFactoryInternal::instant_slam; + creators["shockwave"] = &WarriorTriggerFactoryInternal::shockwave; + creators["shockwave on snare target"] = &WarriorTriggerFactoryInternal::shockwave_on_snare_target; + creators["taste for blood"] = &WarriorTriggerFactoryInternal::taste_for_blood; - creators["thunder clap and rage"] = &WarriorTriggerFactoryInternal::thunderclap_and_rage; - creators["intercept can cast"] = &WarriorTriggerFactoryInternal::intercept_can_cast; - creators["intercept and far enemy"] = &WarriorTriggerFactoryInternal::intercept_and_far_enemy; - creators["intercept and rage"] = &WarriorTriggerFactoryInternal::intercept_and_rage; - // creators["slam"] = &WarriorTriggerFactoryInternal::slam; - } + creators["thunder clap and rage"] = &WarriorTriggerFactoryInternal::thunderclap_and_rage; + creators["intercept can cast"] = &WarriorTriggerFactoryInternal::intercept_can_cast; + creators["intercept and far enemy"] = &WarriorTriggerFactoryInternal::intercept_and_far_enemy; + creators["intercept and rage"] = &WarriorTriggerFactoryInternal::intercept_and_rage; + // creators["slam"] = &WarriorTriggerFactoryInternal::slam; + } - private: - static Trigger* shield_block(PlayerbotAI* botAI) { return new ShieldBlockTrigger(botAI); } - static Trigger* defensive_stance(PlayerbotAI* botAI) { return new DefensiveStanceTrigger(botAI); } - static Trigger* berserker_stance(PlayerbotAI* botAI) { return new BerserkerStanceTrigger(botAI); } - static Trigger* battle_stance(PlayerbotAI* botAI) { return new BattleStanceTrigger(botAI); } - static Trigger* hamstring(PlayerbotAI* botAI) { return new HamstringTrigger(botAI); } - static Trigger* victory_rush(PlayerbotAI* botAI) { return new VictoryRushTrigger(botAI); } - static Trigger* death_wish(PlayerbotAI* botAI) { return new DeathWishTrigger(botAI); } - static Trigger* recklessness(PlayerbotAI* botAI) { return new RecklessnessTrigger(botAI); } - static Trigger* battle_shout(PlayerbotAI* botAI) { return new BattleShoutTrigger(botAI); } - static Trigger* rend(PlayerbotAI* botAI) { return new RendDebuffTrigger(botAI); } - static Trigger* rend_on_attacker(PlayerbotAI* botAI) { return new RendDebuffOnAttackerTrigger(botAI); } - static Trigger* bloodrage(PlayerbotAI* botAI) { return new BloodrageBuffTrigger(botAI); } - static Trigger* shield_bash(PlayerbotAI* botAI) { return new ShieldBashInterruptSpellTrigger(botAI); } - static Trigger* disarm(PlayerbotAI* botAI) { return new DisarmDebuffTrigger(botAI); } - static Trigger* concussion_blow(PlayerbotAI* botAI) { return new ConcussionBlowTrigger(botAI); } - static Trigger* SwordAndBoard(PlayerbotAI* botAI) { return new SwordAndBoardTrigger(botAI); } - static Trigger* shield_bash_on_enemy_healer(PlayerbotAI* botAI) { return new ShieldBashInterruptEnemyHealerSpellTrigger(botAI); } +private: + static Trigger* shield_block(PlayerbotAI* botAI) { return new ShieldBlockTrigger(botAI); } + static Trigger* defensive_stance(PlayerbotAI* botAI) { return new DefensiveStanceTrigger(botAI); } + static Trigger* berserker_stance(PlayerbotAI* botAI) { return new BerserkerStanceTrigger(botAI); } + static Trigger* battle_stance(PlayerbotAI* botAI) { return new BattleStanceTrigger(botAI); } + static Trigger* hamstring(PlayerbotAI* botAI) { return new HamstringTrigger(botAI); } + static Trigger* victory_rush(PlayerbotAI* botAI) { return new VictoryRushTrigger(botAI); } + static Trigger* death_wish(PlayerbotAI* botAI) { return new DeathWishTrigger(botAI); } + static Trigger* recklessness(PlayerbotAI* botAI) { return new RecklessnessTrigger(botAI); } + static Trigger* battle_shout(PlayerbotAI* botAI) { return new BattleShoutTrigger(botAI); } + static Trigger* rend(PlayerbotAI* botAI) { return new RendDebuffTrigger(botAI); } + static Trigger* rend_on_attacker(PlayerbotAI* botAI) { return new RendDebuffOnAttackerTrigger(botAI); } + static Trigger* bloodrage(PlayerbotAI* botAI) { return new BloodrageBuffTrigger(botAI); } + static Trigger* shield_bash(PlayerbotAI* botAI) { return new ShieldBashInterruptSpellTrigger(botAI); } + static Trigger* disarm(PlayerbotAI* botAI) { return new DisarmDebuffTrigger(botAI); } + static Trigger* concussion_blow(PlayerbotAI* botAI) { return new ConcussionBlowTrigger(botAI); } + static Trigger* SwordAndBoard(PlayerbotAI* botAI) { return new SwordAndBoardTrigger(botAI); } + static Trigger* shield_bash_on_enemy_healer(PlayerbotAI* botAI) + { + return new ShieldBashInterruptEnemyHealerSpellTrigger(botAI); + } - static Trigger* thunderclap_and_rage(PlayerbotAI* botAI) { return new TwoTriggers(botAI, "thunder clap", "light rage available"); } - static Trigger* intercept_can_cast(PlayerbotAI* botAI) { return new InterceptCanCastTrigger(botAI); } - static Trigger* intercept_and_far_enemy(PlayerbotAI* botAI) { return new TwoTriggers(botAI, "enemy is out of melee", "intercept can cast"); } - static Trigger* intercept_and_rage(PlayerbotAI* botAI) { return new TwoTriggers(botAI, "intercept and far enemy", "light rage available"); } + static Trigger* thunderclap_and_rage(PlayerbotAI* botAI) + { + return new TwoTriggers(botAI, "thunder clap", "light rage available"); + } + static Trigger* intercept_can_cast(PlayerbotAI* botAI) { return new InterceptCanCastTrigger(botAI); } + static Trigger* intercept_and_far_enemy(PlayerbotAI* botAI) + { + return new TwoTriggers(botAI, "enemy is out of melee", "intercept can cast"); + } + static Trigger* intercept_and_rage(PlayerbotAI* botAI) + { + return new TwoTriggers(botAI, "intercept and far enemy", "light rage available"); + } - static Trigger* intercept_on_snare_target(PlayerbotAI* botAI) { return new InterceptSnareTrigger(botAI); } - static Trigger* spell_reflection(PlayerbotAI* botAI) { return new SpellReflectionTrigger(botAI); } - static Trigger* taste_for_blood(PlayerbotAI* botAI) { return new TasteForBloodTrigger(botAI); } - static Trigger* shockwave_on_snare_target(PlayerbotAI* botAI) { return new ShockwaveSnareTrigger(botAI); } - static Trigger* shockwave(PlayerbotAI* botAI) { return new ShockwaveTrigger(botAI); } - static Trigger* instant_slam(PlayerbotAI* botAI) { return new SlamInstantTrigger(botAI); } - static Trigger* sudden_death(PlayerbotAI* botAI) { return new SuddenDeathTrigger(botAI); } - static Trigger* commanding_shout(PlayerbotAI* botAI) { return new CommandingShoutTrigger(botAI); } - static Trigger* taunt_on_snare_target(PlayerbotAI* botAI) { return new TauntSnareTrigger(botAI); } - static Trigger* intercept(PlayerbotAI* botAI) { return new InterceptInterruptSpellTrigger(botAI); } - static Trigger* intercept_on_enemy_healer(PlayerbotAI* botAI) { return new InterceptInterruptEnemyHealerSpellTrigger(botAI); } - static Trigger* pummel(PlayerbotAI* botAI) { return new PummelInterruptSpellTrigger(botAI); } - static Trigger* pummel_on_enemy_healer(PlayerbotAI* botAI) { return new PummelInterruptEnemyHealerSpellTrigger(botAI); } - static Trigger* berserker_rage(PlayerbotAI* botAI) { return new BerserkerRageBuffTrigger(botAI); } - static Trigger* bloodthirst(PlayerbotAI* botAI) { return new BloodthirstBuffTrigger(botAI); } - static Trigger* thunder_clap_on_snare_target(PlayerbotAI* botAI) { return new ThunderClapSnareTrigger(botAI); } - static Trigger* thunder_clap(PlayerbotAI* botAI) { return new ThunderClapTrigger(botAI); } - static Trigger* mortal_strike(PlayerbotAI* botAI) { return new MortalStrikeDebuffTrigger(botAI); } - static Trigger* rampage(PlayerbotAI* botAI) { return new RampageAvailableTrigger(botAI); } - static Trigger* mocking_blow(PlayerbotAI* botAI) { return new MockingBlowTrigger(botAI); } - static Trigger* overpower(PlayerbotAI* botAI) { return new OverpowerAvailableTrigger(botAI); } - static Trigger* revenge(PlayerbotAI* botAI) { return new RevengeAvailableTrigger(botAI); } - static Trigger* sunder_armor(PlayerbotAI* botAI) { return new SunderArmorDebuffTrigger(botAI); } - // static Trigger* slam(PlayerbotAI* ai) { return new SlamTrigger(ai); } + static Trigger* intercept_on_snare_target(PlayerbotAI* botAI) { return new InterceptSnareTrigger(botAI); } + static Trigger* spell_reflection(PlayerbotAI* botAI) { return new SpellReflectionTrigger(botAI); } + static Trigger* taste_for_blood(PlayerbotAI* botAI) { return new TasteForBloodTrigger(botAI); } + static Trigger* shockwave_on_snare_target(PlayerbotAI* botAI) { return new ShockwaveSnareTrigger(botAI); } + static Trigger* shockwave(PlayerbotAI* botAI) { return new ShockwaveTrigger(botAI); } + static Trigger* instant_slam(PlayerbotAI* botAI) { return new SlamInstantTrigger(botAI); } + static Trigger* sudden_death(PlayerbotAI* botAI) { return new SuddenDeathTrigger(botAI); } + static Trigger* commanding_shout(PlayerbotAI* botAI) { return new CommandingShoutTrigger(botAI); } + static Trigger* taunt_on_snare_target(PlayerbotAI* botAI) { return new TauntSnareTrigger(botAI); } + static Trigger* intercept(PlayerbotAI* botAI) { return new InterceptInterruptSpellTrigger(botAI); } + static Trigger* intercept_on_enemy_healer(PlayerbotAI* botAI) + { + return new InterceptInterruptEnemyHealerSpellTrigger(botAI); + } + static Trigger* pummel(PlayerbotAI* botAI) { return new PummelInterruptSpellTrigger(botAI); } + static Trigger* pummel_on_enemy_healer(PlayerbotAI* botAI) + { + return new PummelInterruptEnemyHealerSpellTrigger(botAI); + } + static Trigger* berserker_rage(PlayerbotAI* botAI) { return new BerserkerRageBuffTrigger(botAI); } + static Trigger* bloodthirst(PlayerbotAI* botAI) { return new BloodthirstBuffTrigger(botAI); } + static Trigger* thunder_clap_on_snare_target(PlayerbotAI* botAI) { return new ThunderClapSnareTrigger(botAI); } + static Trigger* thunder_clap(PlayerbotAI* botAI) { return new ThunderClapTrigger(botAI); } + static Trigger* mortal_strike(PlayerbotAI* botAI) { return new MortalStrikeDebuffTrigger(botAI); } + static Trigger* rampage(PlayerbotAI* botAI) { return new RampageAvailableTrigger(botAI); } + static Trigger* mocking_blow(PlayerbotAI* botAI) { return new MockingBlowTrigger(botAI); } + static Trigger* overpower(PlayerbotAI* botAI) { return new OverpowerAvailableTrigger(botAI); } + static Trigger* revenge(PlayerbotAI* botAI) { return new RevengeAvailableTrigger(botAI); } + static Trigger* sunder_armor(PlayerbotAI* botAI) { return new SunderArmorDebuffTrigger(botAI); } + // static Trigger* slam(PlayerbotAI* ai) { return new SlamTrigger(ai); } }; - class WarriorAiObjectContextInternal : public NamedObjectContext { - public: - WarriorAiObjectContextInternal() - { - creators["devastate"] = &WarriorAiObjectContextInternal::devastate; - creators["overpower"] = &WarriorAiObjectContextInternal::overpower; - creators["charge"] = &WarriorAiObjectContextInternal::charge; - creators["bloodthirst"] = &WarriorAiObjectContextInternal::bloodthirst; - creators["rend"] = &WarriorAiObjectContextInternal::rend; - creators["rend on attacker"] = &WarriorAiObjectContextInternal::rend_on_attacker; - creators["mocking blow"] = &WarriorAiObjectContextInternal::mocking_blow; - creators["death wish"] = &WarriorAiObjectContextInternal::death_wish; - creators["recklessness"] = &WarriorAiObjectContextInternal::recklessness; - creators["berserker rage"] = &WarriorAiObjectContextInternal::berserker_rage; - creators["victory rush"] = &WarriorAiObjectContextInternal::victory_rush; - creators["execute"] = &WarriorAiObjectContextInternal::execute; - creators["defensive stance"] = &WarriorAiObjectContextInternal::defensive_stance; - creators["hamstring"] = &WarriorAiObjectContextInternal::hamstring; - creators["shield bash"] = &WarriorAiObjectContextInternal::shield_bash; - creators["shield block"] = &WarriorAiObjectContextInternal::shield_block; - creators["bloodrage"] = &WarriorAiObjectContextInternal::bloodrage; - creators["battle stance"] = &WarriorAiObjectContextInternal::battle_stance; - creators["heroic strike"] = &WarriorAiObjectContextInternal::heroic_strike; - creators["intimidating shout"] = &WarriorAiObjectContextInternal::intimidating_shout; - creators["demoralizing shout"] = &WarriorAiObjectContextInternal::demoralizing_shout; - creators["demoralizing shout without life time check"] = &WarriorAiObjectContextInternal::demoralizing_shout_without_life_time_check; - creators["challenging shout"] = &WarriorAiObjectContextInternal::challenging_shout; - creators["shield wall"] = &WarriorAiObjectContextInternal::shield_wall; - creators["battle shout"] = &WarriorAiObjectContextInternal::battle_shout; - creators["battle shout taunt"] = &WarriorAiObjectContextInternal::battle_shout_taunt; - creators["thunder clap"] = &WarriorAiObjectContextInternal::thunder_clap; - creators["taunt"] = &WarriorAiObjectContextInternal::taunt; - creators["revenge"] = &WarriorAiObjectContextInternal::revenge; - creators["slam"] = &WarriorAiObjectContextInternal::slam; - creators["shield slam"] = &WarriorAiObjectContextInternal::shield_slam; - creators["disarm"] = &WarriorAiObjectContextInternal::disarm; - creators["sunder armor"] = &WarriorAiObjectContextInternal::sunder_armor; - creators["last stand"] = &WarriorAiObjectContextInternal::last_stand; - creators["shockwave on snare target"] = &WarriorAiObjectContextInternal::shockwave_on_snare_target; - creators["shockwave"] = &WarriorAiObjectContextInternal::shockwave; - creators["cleave"] = &WarriorAiObjectContextInternal::cleave; - creators["concussion blow"] = &WarriorAiObjectContextInternal::concussion_blow; - creators["shield bash on enemy healer"] = &WarriorAiObjectContextInternal::shield_bash_on_enemy_healer; - creators["berserker stance"] = &WarriorAiObjectContextInternal::berserker_stance; - creators["commanding shout"] = &WarriorAiObjectContextInternal::commanding_shout; - creators["retaliation"] = &WarriorAiObjectContextInternal::retaliation; - creators["mortal strike"] = &WarriorAiObjectContextInternal::mortal_strike; - creators["sweeping strikes"] = &WarriorAiObjectContextInternal::sweeping_strikes; - creators["intercept"] = &WarriorAiObjectContextInternal::intercept; - creators["whirlwind"] = &WarriorAiObjectContextInternal::whirlwind; - creators["pummel"] = &WarriorAiObjectContextInternal::pummel; - creators["pummel on enemy healer"] = &WarriorAiObjectContextInternal::pummel_on_enemy_healer; - creators["recklessness"] = &WarriorAiObjectContextInternal::recklessness; - creators["piercing howl"] = &WarriorAiObjectContextInternal::piercing_howl; - creators["rampage"] = &WarriorAiObjectContextInternal::rampage; - creators["intervene"] = &WarriorAiObjectContextInternal::intervene; - creators["spell reflection"] = &WarriorAiObjectContextInternal::spell_reflection; - creators["thunder clap on snare target"] = &WarriorAiObjectContextInternal::thunder_clap_on_snare_target; - creators["taunt on snare target"] = &WarriorAiObjectContextInternal::taunt_on_snare_target; - creators["intercept on enemy healer"] = &WarriorAiObjectContextInternal::intercept_on_enemy_healer; - creators["intercept on snare target"] = &WarriorAiObjectContextInternal::intercept_on_snare_target; - creators["bladestorm"] = &WarriorAiObjectContextInternal::bladestorm; - creators["heroic throw"] = &WarriorAiObjectContextInternal::heroic_throw; - creators["heroic throw on snare target"] = &WarriorAiObjectContextInternal::heroic_throw_on_snare_target; - creators["shattering throw"] = &WarriorAiObjectContextInternal::shattering_throw; - } +public: + WarriorAiObjectContextInternal() + { + creators["devastate"] = &WarriorAiObjectContextInternal::devastate; + creators["overpower"] = &WarriorAiObjectContextInternal::overpower; + creators["charge"] = &WarriorAiObjectContextInternal::charge; + creators["bloodthirst"] = &WarriorAiObjectContextInternal::bloodthirst; + creators["rend"] = &WarriorAiObjectContextInternal::rend; + creators["rend on attacker"] = &WarriorAiObjectContextInternal::rend_on_attacker; + creators["mocking blow"] = &WarriorAiObjectContextInternal::mocking_blow; + creators["death wish"] = &WarriorAiObjectContextInternal::death_wish; + creators["recklessness"] = &WarriorAiObjectContextInternal::recklessness; + creators["berserker rage"] = &WarriorAiObjectContextInternal::berserker_rage; + creators["victory rush"] = &WarriorAiObjectContextInternal::victory_rush; + creators["execute"] = &WarriorAiObjectContextInternal::execute; + creators["defensive stance"] = &WarriorAiObjectContextInternal::defensive_stance; + creators["hamstring"] = &WarriorAiObjectContextInternal::hamstring; + creators["shield bash"] = &WarriorAiObjectContextInternal::shield_bash; + creators["shield block"] = &WarriorAiObjectContextInternal::shield_block; + creators["bloodrage"] = &WarriorAiObjectContextInternal::bloodrage; + creators["battle stance"] = &WarriorAiObjectContextInternal::battle_stance; + creators["heroic strike"] = &WarriorAiObjectContextInternal::heroic_strike; + creators["intimidating shout"] = &WarriorAiObjectContextInternal::intimidating_shout; + creators["demoralizing shout"] = &WarriorAiObjectContextInternal::demoralizing_shout; + creators["demoralizing shout without life time check"] = + &WarriorAiObjectContextInternal::demoralizing_shout_without_life_time_check; + creators["challenging shout"] = &WarriorAiObjectContextInternal::challenging_shout; + creators["shield wall"] = &WarriorAiObjectContextInternal::shield_wall; + creators["battle shout"] = &WarriorAiObjectContextInternal::battle_shout; + creators["battle shout taunt"] = &WarriorAiObjectContextInternal::battle_shout_taunt; + creators["thunder clap"] = &WarriorAiObjectContextInternal::thunder_clap; + creators["taunt"] = &WarriorAiObjectContextInternal::taunt; + creators["revenge"] = &WarriorAiObjectContextInternal::revenge; + creators["slam"] = &WarriorAiObjectContextInternal::slam; + creators["shield slam"] = &WarriorAiObjectContextInternal::shield_slam; + creators["disarm"] = &WarriorAiObjectContextInternal::disarm; + creators["sunder armor"] = &WarriorAiObjectContextInternal::sunder_armor; + creators["last stand"] = &WarriorAiObjectContextInternal::last_stand; + creators["shockwave on snare target"] = &WarriorAiObjectContextInternal::shockwave_on_snare_target; + creators["shockwave"] = &WarriorAiObjectContextInternal::shockwave; + creators["cleave"] = &WarriorAiObjectContextInternal::cleave; + creators["concussion blow"] = &WarriorAiObjectContextInternal::concussion_blow; + creators["shield bash on enemy healer"] = &WarriorAiObjectContextInternal::shield_bash_on_enemy_healer; + creators["berserker stance"] = &WarriorAiObjectContextInternal::berserker_stance; + creators["commanding shout"] = &WarriorAiObjectContextInternal::commanding_shout; + creators["retaliation"] = &WarriorAiObjectContextInternal::retaliation; + creators["mortal strike"] = &WarriorAiObjectContextInternal::mortal_strike; + creators["sweeping strikes"] = &WarriorAiObjectContextInternal::sweeping_strikes; + creators["intercept"] = &WarriorAiObjectContextInternal::intercept; + creators["whirlwind"] = &WarriorAiObjectContextInternal::whirlwind; + creators["pummel"] = &WarriorAiObjectContextInternal::pummel; + creators["pummel on enemy healer"] = &WarriorAiObjectContextInternal::pummel_on_enemy_healer; + creators["recklessness"] = &WarriorAiObjectContextInternal::recklessness; + creators["piercing howl"] = &WarriorAiObjectContextInternal::piercing_howl; + creators["rampage"] = &WarriorAiObjectContextInternal::rampage; + creators["intervene"] = &WarriorAiObjectContextInternal::intervene; + creators["spell reflection"] = &WarriorAiObjectContextInternal::spell_reflection; + creators["thunder clap on snare target"] = &WarriorAiObjectContextInternal::thunder_clap_on_snare_target; + creators["taunt on snare target"] = &WarriorAiObjectContextInternal::taunt_on_snare_target; + creators["intercept on enemy healer"] = &WarriorAiObjectContextInternal::intercept_on_enemy_healer; + creators["intercept on snare target"] = &WarriorAiObjectContextInternal::intercept_on_snare_target; + creators["bladestorm"] = &WarriorAiObjectContextInternal::bladestorm; + creators["heroic throw"] = &WarriorAiObjectContextInternal::heroic_throw; + creators["heroic throw on snare target"] = &WarriorAiObjectContextInternal::heroic_throw_on_snare_target; + creators["shattering throw"] = &WarriorAiObjectContextInternal::shattering_throw; + } - private: - static Action* devastate(PlayerbotAI* botAI) { return new CastDevastateAction(botAI); } - static Action* last_stand(PlayerbotAI* botAI) { return new CastLastStandAction(botAI); } - static Action* shockwave(PlayerbotAI* botAI) { return new CastShockwaveAction(botAI); } - static Action* shockwave_on_snare_target(PlayerbotAI* botAI) { return new CastShockwaveSnareAction(botAI); } - static Action* cleave(PlayerbotAI* botAI) { return new CastCleaveAction(botAI); } - static Action* concussion_blow(PlayerbotAI* botAI) { return new CastConcussionBlowAction(botAI); } - static Action* taunt(PlayerbotAI* botAI) { return new CastTauntAction(botAI); } - static Action* revenge(PlayerbotAI* botAI) { return new CastRevengeAction(botAI); } - static Action* slam(PlayerbotAI* botAI) { return new CastSlamAction(botAI); } - static Action* shield_slam(PlayerbotAI* botAI) { return new CastShieldSlamAction(botAI); } - static Action* disarm(PlayerbotAI* botAI) { return new CastDisarmAction(botAI); } - static Action* sunder_armor(PlayerbotAI* botAI) { return new CastSunderArmorAction(botAI); } - static Action* overpower(PlayerbotAI* botAI) { return new CastOverpowerAction(botAI); } - static Action* charge(PlayerbotAI* botAI) { return new CastChargeAction(botAI); } - static Action* bloodthirst(PlayerbotAI* botAI) { return new CastBloodthirstAction(botAI); } - static Action* rend(PlayerbotAI* botAI) { return new CastRendAction(botAI); } - static Action* rend_on_attacker(PlayerbotAI* botAI) { return new CastRendOnAttackerAction(botAI); } - static Action* mocking_blow(PlayerbotAI* botAI) { return new CastMockingBlowAction(botAI); } - static Action* death_wish(PlayerbotAI* botAI) { return new CastDeathWishAction(botAI); } - static Action* recklessness(PlayerbotAI* botAI) { return new CastRecklessnessAction(botAI); } - static Action* berserker_rage(PlayerbotAI* botAI) { return new CastBerserkerRageAction(botAI); } - static Action* victory_rush(PlayerbotAI* botAI) { return new CastVictoryRushAction(botAI); } - static Action* execute(PlayerbotAI* botAI) { return new CastExecuteAction(botAI); } - static Action* defensive_stance(PlayerbotAI* botAI) { return new CastDefensiveStanceAction(botAI); } - static Action* hamstring(PlayerbotAI* botAI) { return new CastHamstringAction(botAI); } - static Action* shield_bash(PlayerbotAI* botAI) { return new CastShieldBashAction(botAI); } - static Action* shield_block(PlayerbotAI* botAI) { return new CastShieldBlockAction(botAI); } - static Action* bloodrage(PlayerbotAI* botAI) { return new CastBloodrageAction(botAI); } - static Action* battle_stance(PlayerbotAI* botAI) { return new CastBattleStanceAction(botAI); } - static Action* heroic_strike(PlayerbotAI* botAI) { return new CastHeroicStrikeAction(botAI); } - static Action* intimidating_shout(PlayerbotAI* botAI) { return new CastIntimidatingShoutAction(botAI); } - static Action* demoralizing_shout(PlayerbotAI* botAI) { return new CastDemoralizingShoutAction(botAI); } - static Action* demoralizing_shout_without_life_time_check(PlayerbotAI* botAI) { return new CastDemoralizingShoutWithoutLifeTimeCheckAction(botAI); } - static Action* challenging_shout(PlayerbotAI* botAI) { return new CastChallengingShoutAction(botAI); } - static Action* shield_wall(PlayerbotAI* botAI) { return new CastShieldWallAction(botAI); } - static Action* battle_shout(PlayerbotAI* botAI) { return new CastBattleShoutAction(botAI); } - static Action* battle_shout_taunt(PlayerbotAI* botAI) { return new CastBattleShoutTauntAction(botAI); } - static Action* thunder_clap(PlayerbotAI* botAI) { return new CastThunderClapAction(botAI); } - static Action* shield_bash_on_enemy_healer(PlayerbotAI* botAI) { return new CastShieldBashOnEnemyHealerAction(botAI); } - static Action* intercept_on_snare_target(PlayerbotAI* botAI) { return new CastInterceptOnSnareTargetAction(botAI); } - static Action* intercept_on_enemy_healer(PlayerbotAI* botAI) { return new CastInterceptOnEnemyHealerAction(botAI); } - static Action* taunt_on_snare_target(PlayerbotAI* botAI) { return new CastTauntOnSnareTargetAction(botAI); } - static Action* thunder_clap_on_snare_target(PlayerbotAI* botAI) { return new CastThunderClapSnareAction(botAI); } - static Action* berserker_stance(PlayerbotAI* botAI) { return new CastBerserkerStanceAction(botAI); } - static Action* commanding_shout(PlayerbotAI* botAI) { return new CastCommandingShoutAction(botAI); } - static Action* retaliation(PlayerbotAI* botAI) { return new CastRetaliationAction(botAI); } - static Action* mortal_strike(PlayerbotAI* botAI) { return new CastMortalStrikeAction(botAI); } - static Action* sweeping_strikes(PlayerbotAI* botAI) { return new CastSweepingStrikesAction(botAI); } - static Action* intercept(PlayerbotAI* botAI) { return new CastInterceptAction(botAI); } - static Action* whirlwind(PlayerbotAI* botAI) { return new CastWhirlwindAction(botAI); } - static Action* pummel(PlayerbotAI* botAI) { return new CastPummelAction (botAI); } - static Action* pummel_on_enemy_healer(PlayerbotAI* botAI) { return new CastPummelOnEnemyHealerAction(botAI); } - static Action* piercing_howl(PlayerbotAI* botAI) { return new CastPiercingHowlAction(botAI); } - static Action* rampage(PlayerbotAI* botAI) { return new CastRampageAction(botAI); } - static Action* intervene(PlayerbotAI* botAI) { return new CastInterveneAction(botAI); } - static Action* spell_reflection(PlayerbotAI* botAI) { return new CastSpellReflectionAction(botAI); } - static Action* shattering_throw(PlayerbotAI* botAI) { return new CastShatteringThrowAction(botAI); } - static Action* heroic_throw_on_snare_target(PlayerbotAI* botAI) { return new CastHeroicThrowSnareAction(botAI); } - static Action* heroic_throw(PlayerbotAI* botAI) { return new CastHeroicThrowAction(botAI); } - static Action* bladestorm(PlayerbotAI* botAI) { return new CastBladestormAction(botAI); } +private: + static Action* devastate(PlayerbotAI* botAI) { return new CastDevastateAction(botAI); } + static Action* last_stand(PlayerbotAI* botAI) { return new CastLastStandAction(botAI); } + static Action* shockwave(PlayerbotAI* botAI) { return new CastShockwaveAction(botAI); } + static Action* shockwave_on_snare_target(PlayerbotAI* botAI) { return new CastShockwaveSnareAction(botAI); } + static Action* cleave(PlayerbotAI* botAI) { return new CastCleaveAction(botAI); } + static Action* concussion_blow(PlayerbotAI* botAI) { return new CastConcussionBlowAction(botAI); } + static Action* taunt(PlayerbotAI* botAI) { return new CastTauntAction(botAI); } + static Action* revenge(PlayerbotAI* botAI) { return new CastRevengeAction(botAI); } + static Action* slam(PlayerbotAI* botAI) { return new CastSlamAction(botAI); } + static Action* shield_slam(PlayerbotAI* botAI) { return new CastShieldSlamAction(botAI); } + static Action* disarm(PlayerbotAI* botAI) { return new CastDisarmAction(botAI); } + static Action* sunder_armor(PlayerbotAI* botAI) { return new CastSunderArmorAction(botAI); } + static Action* overpower(PlayerbotAI* botAI) { return new CastOverpowerAction(botAI); } + static Action* charge(PlayerbotAI* botAI) { return new CastChargeAction(botAI); } + static Action* bloodthirst(PlayerbotAI* botAI) { return new CastBloodthirstAction(botAI); } + static Action* rend(PlayerbotAI* botAI) { return new CastRendAction(botAI); } + static Action* rend_on_attacker(PlayerbotAI* botAI) { return new CastRendOnAttackerAction(botAI); } + static Action* mocking_blow(PlayerbotAI* botAI) { return new CastMockingBlowAction(botAI); } + static Action* death_wish(PlayerbotAI* botAI) { return new CastDeathWishAction(botAI); } + static Action* recklessness(PlayerbotAI* botAI) { return new CastRecklessnessAction(botAI); } + static Action* berserker_rage(PlayerbotAI* botAI) { return new CastBerserkerRageAction(botAI); } + static Action* victory_rush(PlayerbotAI* botAI) { return new CastVictoryRushAction(botAI); } + static Action* execute(PlayerbotAI* botAI) { return new CastExecuteAction(botAI); } + static Action* defensive_stance(PlayerbotAI* botAI) { return new CastDefensiveStanceAction(botAI); } + static Action* hamstring(PlayerbotAI* botAI) { return new CastHamstringAction(botAI); } + static Action* shield_bash(PlayerbotAI* botAI) { return new CastShieldBashAction(botAI); } + static Action* shield_block(PlayerbotAI* botAI) { return new CastShieldBlockAction(botAI); } + static Action* bloodrage(PlayerbotAI* botAI) { return new CastBloodrageAction(botAI); } + static Action* battle_stance(PlayerbotAI* botAI) { return new CastBattleStanceAction(botAI); } + static Action* heroic_strike(PlayerbotAI* botAI) { return new CastHeroicStrikeAction(botAI); } + static Action* intimidating_shout(PlayerbotAI* botAI) { return new CastIntimidatingShoutAction(botAI); } + static Action* demoralizing_shout(PlayerbotAI* botAI) { return new CastDemoralizingShoutAction(botAI); } + static Action* demoralizing_shout_without_life_time_check(PlayerbotAI* botAI) + { + return new CastDemoralizingShoutWithoutLifeTimeCheckAction(botAI); + } + static Action* challenging_shout(PlayerbotAI* botAI) { return new CastChallengingShoutAction(botAI); } + static Action* shield_wall(PlayerbotAI* botAI) { return new CastShieldWallAction(botAI); } + static Action* battle_shout(PlayerbotAI* botAI) { return new CastBattleShoutAction(botAI); } + static Action* battle_shout_taunt(PlayerbotAI* botAI) { return new CastBattleShoutTauntAction(botAI); } + static Action* thunder_clap(PlayerbotAI* botAI) { return new CastThunderClapAction(botAI); } + static Action* shield_bash_on_enemy_healer(PlayerbotAI* botAI) + { + return new CastShieldBashOnEnemyHealerAction(botAI); + } + static Action* intercept_on_snare_target(PlayerbotAI* botAI) { return new CastInterceptOnSnareTargetAction(botAI); } + static Action* intercept_on_enemy_healer(PlayerbotAI* botAI) { return new CastInterceptOnEnemyHealerAction(botAI); } + static Action* taunt_on_snare_target(PlayerbotAI* botAI) { return new CastTauntOnSnareTargetAction(botAI); } + static Action* thunder_clap_on_snare_target(PlayerbotAI* botAI) { return new CastThunderClapSnareAction(botAI); } + static Action* berserker_stance(PlayerbotAI* botAI) { return new CastBerserkerStanceAction(botAI); } + static Action* commanding_shout(PlayerbotAI* botAI) { return new CastCommandingShoutAction(botAI); } + static Action* retaliation(PlayerbotAI* botAI) { return new CastRetaliationAction(botAI); } + static Action* mortal_strike(PlayerbotAI* botAI) { return new CastMortalStrikeAction(botAI); } + static Action* sweeping_strikes(PlayerbotAI* botAI) { return new CastSweepingStrikesAction(botAI); } + static Action* intercept(PlayerbotAI* botAI) { return new CastInterceptAction(botAI); } + static Action* whirlwind(PlayerbotAI* botAI) { return new CastWhirlwindAction(botAI); } + static Action* pummel(PlayerbotAI* botAI) { return new CastPummelAction(botAI); } + static Action* pummel_on_enemy_healer(PlayerbotAI* botAI) { return new CastPummelOnEnemyHealerAction(botAI); } + static Action* piercing_howl(PlayerbotAI* botAI) { return new CastPiercingHowlAction(botAI); } + static Action* rampage(PlayerbotAI* botAI) { return new CastRampageAction(botAI); } + static Action* intervene(PlayerbotAI* botAI) { return new CastInterveneAction(botAI); } + static Action* spell_reflection(PlayerbotAI* botAI) { return new CastSpellReflectionAction(botAI); } + static Action* shattering_throw(PlayerbotAI* botAI) { return new CastShatteringThrowAction(botAI); } + static Action* heroic_throw_on_snare_target(PlayerbotAI* botAI) { return new CastHeroicThrowSnareAction(botAI); } + static Action* heroic_throw(PlayerbotAI* botAI) { return new CastHeroicThrowAction(botAI); } + static Action* bladestorm(PlayerbotAI* botAI) { return new CastBladestormAction(botAI); } }; WarriorAiObjectContext::WarriorAiObjectContext(PlayerbotAI* botAI) : AiObjectContext(botAI) diff --git a/src/strategy/warrior/WarriorAiObjectContext.h b/src/strategy/warrior/WarriorAiObjectContext.h index df20036a..ab522922 100644 --- a/src/strategy/warrior/WarriorAiObjectContext.h +++ b/src/strategy/warrior/WarriorAiObjectContext.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WARRIORAIOBJECTCONTEXT_H @@ -11,8 +12,8 @@ class PlayerbotAI; class WarriorAiObjectContext : public AiObjectContext { - public: - WarriorAiObjectContext(PlayerbotAI* botAI); +public: + WarriorAiObjectContext(PlayerbotAI* botAI); }; #endif diff --git a/src/strategy/warrior/WarriorTriggers.cpp b/src/strategy/warrior/WarriorTriggers.cpp index 86c029fa..f2ea13da 100644 --- a/src/strategy/warrior/WarriorTriggers.cpp +++ b/src/strategy/warrior/WarriorTriggers.cpp @@ -1,11 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #include "WarriorTriggers.h" + #include "Playerbots.h" bool BloodrageBuffTrigger::IsActive() { - return AI_VALUE2(uint8, "health", "self target") >= sPlayerbotAIConfig->mediumHealth && AI_VALUE2(uint8, "rage", "self target") < 20; + return AI_VALUE2(uint8, "health", "self target") >= sPlayerbotAIConfig->mediumHealth && + AI_VALUE2(uint8, "rage", "self target") < 20; } diff --git a/src/strategy/warrior/WarriorTriggers.h b/src/strategy/warrior/WarriorTriggers.h index 44885a36..223e0049 100644 --- a/src/strategy/warrior/WarriorTriggers.h +++ b/src/strategy/warrior/WarriorTriggers.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it + * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_WARRIORTRIGGERS_H @@ -19,10 +20,10 @@ DEBUFF_TRIGGER(SunderArmorDebuffTrigger, "sunder armor"); DEBUFF_TRIGGER(MortalStrikeDebuffTrigger, "mortal strike"); // DEBUFF_ENEMY_TRIGGER(RendDebuffOnAttackerTrigger, "rend"); -class RendDebuffOnAttackerTrigger : public DebuffOnMeleeAttackerTrigger +class RendDebuffOnAttackerTrigger : public DebuffOnMeleeAttackerTrigger { - public: - RendDebuffOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnMeleeAttackerTrigger(botAI, "rend") {} +public: + RendDebuffOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnMeleeAttackerTrigger(botAI, "rend") {} }; CAN_CAST_TRIGGER(RevengeAvailableTrigger, "revenge"); @@ -58,8 +59,8 @@ HAS_AURA_TRIGGER(TasteForBloodTrigger, "taste for blood"); class RendDebuffTrigger : public DebuffTrigger { - public: - RendDebuffTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "rend", 1, true) { } +public: + RendDebuffTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "rend", 1, true) {} }; // class SlamTrigger : public HasAuraTrigger