diff --git a/src/strategy/AiObjectContext.cpp b/src/strategy/AiObjectContext.cpp index b2ede465..fc791244 100644 --- a/src/strategy/AiObjectContext.cpp +++ b/src/strategy/AiObjectContext.cpp @@ -62,6 +62,7 @@ AiObjectContext::AiObjectContext(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) actionContexts.Add(new WotlkDungeonOccActionContext()); actionContexts.Add(new WotlkDungeonUPActionContext()); actionContexts.Add(new WotlkDungeonCoSActionContext()); + actionContexts.Add(new WotlkDungeonFoSActionContext()); triggerContexts.Add(new TriggerContext()); triggerContexts.Add(new ChatTriggerContext()); @@ -84,6 +85,7 @@ AiObjectContext::AiObjectContext(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) triggerContexts.Add(new WotlkDungeonOccTriggerContext()); triggerContexts.Add(new WotlkDungeonUPTriggerContext()); triggerContexts.Add(new WotlkDungeonCoSTriggerContext()); + triggerContexts.Add(new WotlkDungeonFosTriggerContext()); valueContexts.Add(new ValueContext()); diff --git a/src/strategy/dungeons/DungeonStrategyContext.h b/src/strategy/dungeons/DungeonStrategyContext.h index 5b1914a2..aa266f66 100644 --- a/src/strategy/dungeons/DungeonStrategyContext.h +++ b/src/strategy/dungeons/DungeonStrategyContext.h @@ -14,6 +14,7 @@ #include "wotlk/oculus/OculusStrategy.h" #include "wotlk/utgardepinnacle/UtgardePinnacleStrategy.h" #include "wotlk/cullingofstratholme/CullingOfStratholmeStrategy.h" +#include "wotlk/forgeofsouls/ForgeOfSoulsStrategy.h" /* Full list/TODO: @@ -76,11 +77,12 @@ class DungeonStrategyContext : public NamedObjectContext static Strategy* wotlk_occ(PlayerbotAI* botAI) { return new WotlkDungeonOccStrategy(botAI); } static Strategy* wotlk_up(PlayerbotAI* botAI) { return new WotlkDungeonUPStrategy(botAI); } static Strategy* wotlk_cos(PlayerbotAI* botAI) { return new WotlkDungeonCoSStrategy(botAI); } + static Strategy* wotlk_fos(PlayerbotAI* botAI) { return new WotlkDungeonFoSStrategy(botAI); } // NYI from here down static Strategy* wotlk_toc(PlayerbotAI* botAI) { return new WotlkDungeonUKStrategy(botAI); } static Strategy* wotlk_hor(PlayerbotAI* botAI) { return new WotlkDungeonUKStrategy(botAI); } static Strategy* wotlk_pos(PlayerbotAI* botAI) { return new WotlkDungeonUKStrategy(botAI); } - static Strategy* wotlk_fos(PlayerbotAI* botAI) { return new WotlkDungeonUKStrategy(botAI); } + }; #endif diff --git a/src/strategy/dungeons/DungeonStrategyUtils.h b/src/strategy/dungeons/DungeonStrategyUtils.h index 2b738360..3f67f4b4 100644 --- a/src/strategy/dungeons/DungeonStrategyUtils.h +++ b/src/strategy/dungeons/DungeonStrategyUtils.h @@ -1,7 +1,6 @@ #ifndef _PLAYERBOT_DUNGEONUTILS_H #define _PLAYERBOT_DUNGEONUTILS_H - template inline const T& DUNGEON_MODE(Player* bot, const T& normal5, const T& heroic10) { diff --git a/src/strategy/dungeons/wotlk/WotlkDungeonActionContext.h b/src/strategy/dungeons/wotlk/WotlkDungeonActionContext.h index e6f2e00a..75769739 100644 --- a/src/strategy/dungeons/wotlk/WotlkDungeonActionContext.h +++ b/src/strategy/dungeons/wotlk/WotlkDungeonActionContext.h @@ -13,9 +13,9 @@ #include "oculus/OculusActionContext.h" #include "utgardepinnacle/UtgardePinnacleActionContext.h" #include "cullingofstratholme/CullingOfStratholmeActionContext.h" +#include "forgeofsouls/ForgeOfSoulsActionContext.h" // #include "trialofthechampion/TrialOfTheChampionActionContext.h" // #include "hallsofreflection/HallsOfReflectionActionContext.h" // #include "pitofsaron/PitOfSaronActionContext.h" -// #include "forgeofsouls/ForgeOfSoulsActionContext.h" #endif diff --git a/src/strategy/dungeons/wotlk/WotlkDungeonTriggerContext.h b/src/strategy/dungeons/wotlk/WotlkDungeonTriggerContext.h index 455239ab..8b4e979e 100644 --- a/src/strategy/dungeons/wotlk/WotlkDungeonTriggerContext.h +++ b/src/strategy/dungeons/wotlk/WotlkDungeonTriggerContext.h @@ -13,9 +13,9 @@ #include "oculus/OculusTriggerContext.h" #include "utgardepinnacle/UtgardePinnacleTriggerContext.h" #include "cullingofstratholme/CullingOfStratholmeTriggerContext.h" +#include "forgeofsouls/ForgeOfSoulsTriggerContext.h" // #include "trialofthechampion/TrialOfTheChampionTriggerContext.h" // #include "hallsofreflection/HallsOfReflectionTriggerContext.h" // #include "pitofsaron/PitOfSaronTriggerContext.h" -// #include "forgeofsouls/ForgeOfSoulsTriggerContext.h" #endif diff --git a/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsActionContext.h b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsActionContext.h new file mode 100644 index 00000000..0ba0b1d2 --- /dev/null +++ b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsActionContext.h @@ -0,0 +1,23 @@ +#ifndef _PLAYERBOT_WOTLKDUNGEONFOSACTIONCONTEXT_H +#define _PLAYERBOT_WOTLKDUNGEONFOSACTIONCONTEXT_H + +#include "Action.h" +#include "NamedObjectContext.h" +#include "ForgeOfSoulsActions.h" + +class WotlkDungeonFoSActionContext : public NamedObjectContext +{ + public: + WotlkDungeonFoSActionContext() + { + creators["move from bronjahm"] = &WotlkDungeonFoSActionContext::move_from_bronjahm; + creators["attack corrupted soul fragment"] = &WotlkDungeonFoSActionContext::attack_corrupted_soul_fragment; + creators["bronjahm group position"] = &WotlkDungeonFoSActionContext::bronjahm_group_position; + } + private: + static Action* move_from_bronjahm(PlayerbotAI* ai) { return new MoveFromBronjahmAction(ai); } + static Action* attack_corrupted_soul_fragment(PlayerbotAI* ai) { return new AttackCorruptedSoulFragmentAction(ai); } + static Action* bronjahm_group_position(PlayerbotAI* ai) { return new BronjahmGroupPositionAction(ai); } +}; + +#endif diff --git a/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsActions.cpp b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsActions.cpp new file mode 100644 index 00000000..0992bd3b --- /dev/null +++ b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsActions.cpp @@ -0,0 +1,87 @@ +#include "Playerbots.h" +#include "ForgeOfSoulsActions.h" +#include "ForgeOfSoulsStrategy.h" + +bool MoveFromBronjahmAction::Execute(Event event) +{ + Unit* boss = AI_VALUE2(Unit*, "find target", "bronjahm"); + if (!boss) + return false; + + + float distance = bot->GetExactDist2d(boss->GetPosition()); + float targetDis = 20.0f; + if (distance >= targetDis) + return false; + return MoveAway(boss, targetDis - distance); +} + + +bool AttackCorruptedSoulFragmentAction::Execute(Event event) +{ + Unit* fragment = nullptr; + + GuidVector targets = AI_VALUE(GuidVector, "possible targets no los"); + + for (auto &target : targets) + { + Unit* unit = botAI->GetUnit(target); + if (unit && unit->GetEntry() == NPC_CORRUPTED_SOUL_FRAGMENT) + { + fragment = unit; + break; + } + } + + if (fragment && AI_VALUE(Unit*, "current target") != fragment) + return Attack(fragment); + + return false; + +} + + +bool BronjahmGroupPositionAction::Execute(Event event) +{ + Unit* boss = AI_VALUE2(Unit*, "find target", "bronjahm"); + if (!boss) + return false; + + if (botAI->IsTank(bot)) + { + bot->SetTarget(boss->GetGUID()); + if (AI_VALUE2(bool, "has aggro", "current target")) + if (bot->GetExactDist2d(BRONJAHM_TANK_POSITION) > 5.0f) + return MoveTo(bot->GetMapId(), BRONJAHM_TANK_POSITION.GetPositionX(), + BRONJAHM_TANK_POSITION.GetPositionY(), BRONJAHM_TANK_POSITION.GetPositionZ(), false, + false, false, true, MovementPriority::MOVEMENT_NORMAL); + else + return Attack(boss); + else + { + return Attack(boss); + } + } + else + { + float maxMovement = 10.0f; + + if (bot->GetExactDist2d(boss) > maxMovement) + { + if (bot->getClass() == CLASS_HUNTER) + { + return Move(bot->GetAngle(boss), fmin(bot->GetExactDist2d(boss) - 6.5f, maxMovement)); + } + else + { + return Move(bot->GetAngle(boss), fmin(bot->GetExactDist2d(boss) - 2.0f, maxMovement)); + } + } + else + return false; + } +} + +bool BronjahmGroupPositionAction::isUseful() { return true; } + + diff --git a/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsActions.h b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsActions.h new file mode 100644 index 00000000..2388fe50 --- /dev/null +++ b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsActions.h @@ -0,0 +1,37 @@ +#ifndef _PLAYERBOT_WOTLKDUNGEONFOSACTIONS_H +#define _PLAYERBOT_WOTLKDUNGEONFOSACTIONS_H + +#include "Action.h" +#include "AttackAction.h" +#include "PlayerbotAI.h" +#include "Playerbots.h" +#include "ForgeOfSoulsTriggers.h" + +const Position BRONJAHM_TANK_POSITION = Position(5297.920f, 2506.698f, 686.068f); + +class MoveFromBronjahmAction : public MovementAction +{ +public: + MoveFromBronjahmAction(PlayerbotAI* ai) : MovementAction(ai, "move from bronjahm") {} + bool Execute(Event event) override; +}; + +class AttackCorruptedSoulFragmentAction : public AttackAction +{ +public: + AttackCorruptedSoulFragmentAction(PlayerbotAI* ai) : AttackAction(ai, "attack corrupted soul fragment") {} + bool Execute(Event event) override; +}; + +class BronjahmGroupPositionAction : public AttackAction +{ +public: + BronjahmGroupPositionAction(PlayerbotAI* ai) : AttackAction(ai, "bronjahm group position") {} + + bool Execute(Event event) override; + + bool isUseful() override; +}; + + +#endif diff --git a/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsMultipliers.cpp b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsMultipliers.cpp new file mode 100644 index 00000000..36f67fb0 --- /dev/null +++ b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsMultipliers.cpp @@ -0,0 +1,50 @@ +#include "ForgeOfSoulsMultipliers.h" +#include "ForgeOfSoulsActions.h" +#include "GenericSpellActions.h" +#include "ChooseTargetActions.h" +#include "MovementActions.h" +#include "ForgeOfSoulsTriggers.h" +#include "ForgeOfSoulsActions.h" + + +float BronjahmMultiplier::GetValue(Action* action) { + Unit* boss = AI_VALUE2(Unit *, "find target", "bronjahm"); + if (!boss) + return 1.0f; + + if (dynamic_cast(action)) + return 0.0f; + + if (boss->FindCurrentSpellBySpellId(SPELL_CORRUPT_SOUL) && + bot->HasAura(SPELL_CORRUPT_SOUL)) + { + if (dynamic_cast(action) && !dynamic_cast(action)) + { + return 0.0f; + } + } + return 1.0f; +} + +float AttackFragmentMultiplier::GetValue(Action* action) +{ + + Unit* fragment = nullptr; + + GuidVector targets = AI_VALUE(GuidVector, "possible targets no los"); + + for (auto& target : targets) + { + Unit* unit = botAI->GetUnit(target); + if (unit && unit->GetEntry() == NPC_CORRUPTED_SOUL_FRAGMENT) + { + fragment = unit; + break; + } + } + + if (fragment && botAI->IsDps(bot) && dynamic_cast(action)) + return 0.0f; + + return 1.0f; +} diff --git a/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsMultipliers.h b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsMultipliers.h new file mode 100644 index 00000000..99d7e47b --- /dev/null +++ b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsMultipliers.h @@ -0,0 +1,24 @@ +#ifndef _PLAYERBOT_WOTLKDUNGEONFOSMULTIPLIERS_H +#define _PLAYERBOT_WOTLKDUNGEONFOSMULTIPLIERS_H + +#include "Multiplier.h" + +class BronjahmMultiplier : public Multiplier +{ + public: + BronjahmMultiplier(PlayerbotAI* ai) : Multiplier(ai, "bronjahm") {} + + public: + virtual float GetValue(Action* action); +}; + +class AttackFragmentMultiplier : public Multiplier +{ +public: + AttackFragmentMultiplier(PlayerbotAI* ai) : Multiplier(ai, "attack fragment") { } + + float GetValue(Action* action) override; +}; + + +#endif diff --git a/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsStrategy.cpp b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsStrategy.cpp new file mode 100644 index 00000000..68b89157 --- /dev/null +++ b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsStrategy.cpp @@ -0,0 +1,18 @@ +#include "ForgeOfSoulsStrategy.h" +#include "ForgeOfSoulsMultipliers.h" + +void WotlkDungeonFoSStrategy::InitTriggers(std::vector& triggers) { + triggers.push_back( + new TriggerNode("move from bronjahm", + NextAction::array(0, new NextAction("move from bronjahm", ACTION_MOVE + 5), nullptr))); + triggers.push_back(new TriggerNode( + "switch to soul fragment", NextAction::array(0, new NextAction("attack corrupted soul fragment", ACTION_RAID + 1), nullptr))); + triggers.push_back(new TriggerNode("bronjahm position", + NextAction::array(0, new NextAction("bronjahm group position", ACTION_RAID + 1), nullptr))); +} + +void WotlkDungeonFoSStrategy::InitMultipliers(std::vector& multipliers) +{ + multipliers.push_back(new BronjahmMultiplier(botAI)); + multipliers.push_back(new AttackFragmentMultiplier(botAI)); +} diff --git a/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsStrategy.h b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsStrategy.h new file mode 100644 index 00000000..79d58334 --- /dev/null +++ b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsStrategy.h @@ -0,0 +1,16 @@ +#ifndef _PLAYERBOT_WOTLKDUNGEONFOSSTRATEGY_H +#define _PLAYERBOT_WOTLKDUNGEONFOSSTRATEGY_H +#include "Multiplier.h" +#include "Strategy.h" + +class WotlkDungeonFoSStrategy : public Strategy +{ +public: + WotlkDungeonFoSStrategy(PlayerbotAI* ai) : Strategy(ai) {} + std::string const getName() override { return "forge of souls"; } + void InitTriggers(std::vector &triggers) override; + void InitMultipliers(std::vector &multipliers) override; + +}; + +#endif // !_PLAYERBOT_WOTLKDUNGEONFOSSTRATEGY_H diff --git a/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsTriggerContext.h b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsTriggerContext.h new file mode 100644 index 00000000..9cef6373 --- /dev/null +++ b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsTriggerContext.h @@ -0,0 +1,24 @@ +#ifndef _PLAYERBOT_WOTLKDUNGEONFOSTRIGGERCONTEXT_H +#define _PLAYERBOT_WOTLKDUNGEONFOSTRIGGERCONTEXT_H + +#include "NamedObjectContext.h" +#include "AiObjectContext.h" +#include "ForgeOfSoulsTriggers.h" + +class WotlkDungeonFosTriggerContext : public NamedObjectContext +{ +public: + WotlkDungeonFosTriggerContext() + { + creators["bronjahm position"] = &WotlkDungeonFosTriggerContext::bronjahm_position; + creators["move from bronjahm"] = &WotlkDungeonFosTriggerContext::move_from_bronjahm; + creators["switch to soul fragment"] = &WotlkDungeonFosTriggerContext::switch_to_soul_fragment; + } + +private: + static Trigger* move_from_bronjahm(PlayerbotAI* ai) { return new MoveFromBronjahmTrigger(ai); } + static Trigger* switch_to_soul_fragment(PlayerbotAI* ai) { return new SwitchToSoulFragment(ai); } + static Trigger* bronjahm_position(PlayerbotAI* ai) { return new BronjahmPositionTrigger(ai); } +}; + +#endif // !_PLAYERBOT_WOTLKDUNGEONFOSTRIGGERCONTEXT_H diff --git a/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsTriggers.cpp b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsTriggers.cpp new file mode 100644 index 00000000..13256d70 --- /dev/null +++ b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsTriggers.cpp @@ -0,0 +1,39 @@ +#include "Playerbots.h" +#include "ForgeOfSoulsTriggers.h" +#include "AiObject.h" +#include "AiObjectContext.h" + +bool MoveFromBronjahmTrigger::IsActive() +{ + Unit* boss = AI_VALUE2(Unit*, "find target", "bronjahm"); + + if (boss->FindCurrentSpellBySpellId(SPELL_CORRUPT_SOUL) && bot->HasAura(SPELL_CORRUPT_SOUL)) + return true; + + return false; +} + +bool SwitchToSoulFragment::IsActive() +{ + Unit* fragment = nullptr; + GuidVector targets = AI_VALUE(GuidVector, "possible targets no los"); + + for (auto& target : targets) + { + Unit* unit = botAI->GetUnit(target); + if (unit && unit->GetEntry() == NPC_CORRUPTED_SOUL_FRAGMENT) + { + if (botAI->IsDps(bot)) + return true; + } + } + + return false; + +} + +bool BronjahmPositionTrigger::IsActive() +{ + + return bool(AI_VALUE2(Unit*, "find target", "bronjahm")); +} diff --git a/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsTriggers.h b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsTriggers.h new file mode 100644 index 00000000..3ddf8f66 --- /dev/null +++ b/src/strategy/dungeons/wotlk/forgeofsouls/ForgeOfSoulsTriggers.h @@ -0,0 +1,40 @@ +#ifndef _PLAYERBOT_WOTLKDUNGEONFOSTRIGGERS_H +#define _PLAYERBOT_WOTLKDUNGEONFOSTRIGGERS_H + +#include "Trigger.h" +#include "PlayerbotAIConfig.h" +#include "GenericTriggers.h" +#include "DungeonStrategyUtils.h" + +enum ForgeOfSoulsBronjahmIDs +{ + // Boss1 + NPC_CORRUPTED_SOUL_FRAGMENT = 36535, + + SPELL_CORRUPT_SOUL = 68839 +}; + +class MoveFromBronjahmTrigger : public Trigger +{ +public: + MoveFromBronjahmTrigger(PlayerbotAI* ai) : Trigger(ai, "move from bronjahm") {} + + bool IsActive() override; +}; + +class SwitchToSoulFragment : public Trigger +{ +public: + SwitchToSoulFragment(PlayerbotAI* ai) : Trigger(ai, "switch to soul fragment") {} + + bool IsActive() override; +}; + +class BronjahmPositionTrigger : public Trigger +{ +public: + BronjahmPositionTrigger(PlayerbotAI* ai) : Trigger(ai, "bronjahm position") {} + bool IsActive() override; +}; + +#endif diff --git a/src/strategy/dungeons/wotlk/forgeofsouls/TODO b/src/strategy/dungeons/wotlk/forgeofsouls/TODO deleted file mode 100644 index e69de29b..00000000