From 37a2721ff52b4acaee2f9f2ceacd91d07bbd8110 Mon Sep 17 00:00:00 2001 From: Fuzz Date: Mon, 26 Aug 2024 22:43:13 +1000 Subject: [PATCH] added mc/moltencore strat (just for baron geddon's inferno and living-bomb) --- src/PlayerbotAI.cpp | 3 ++ src/strategy/AiObjectContext.cpp | 4 ++ src/strategy/raids/RaidStrategyContext.h | 6 +++ .../raids/moltencore/RaidMcActionContext.h | 22 ++++++++++ .../raids/moltencore/RaidMcActions.cpp | 43 +++++++++++++++++++ src/strategy/raids/moltencore/RaidMcActions.h | 24 +++++++++++ .../raids/moltencore/RaidMcStrategy.cpp | 13 ++++++ .../raids/moltencore/RaidMcStrategy.h | 17 ++++++++ .../raids/moltencore/RaidMcTriggerContext.h | 22 ++++++++++ .../raids/moltencore/RaidMcTriggers.cpp | 22 ++++++++++ .../raids/moltencore/RaidMcTriggers.h | 22 ++++++++++ 11 files changed, 198 insertions(+) create mode 100644 src/strategy/raids/moltencore/RaidMcActionContext.h create mode 100644 src/strategy/raids/moltencore/RaidMcActions.cpp create mode 100644 src/strategy/raids/moltencore/RaidMcActions.h create mode 100644 src/strategy/raids/moltencore/RaidMcStrategy.cpp create mode 100644 src/strategy/raids/moltencore/RaidMcStrategy.h create mode 100644 src/strategy/raids/moltencore/RaidMcTriggerContext.h create mode 100644 src/strategy/raids/moltencore/RaidMcTriggers.cpp create mode 100644 src/strategy/raids/moltencore/RaidMcTriggers.h diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 4fb38ed9..07b07293 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -1504,6 +1504,9 @@ void PlayerbotAI::ApplyInstanceStrategies(uint32 mapId, bool tellMaster) case 469: strategyName = "bwl"; break; + case 409: + strategyName = "mc"; + break; default: break; } diff --git a/src/strategy/AiObjectContext.cpp b/src/strategy/AiObjectContext.cpp index 5c4237d7..9052b61b 100644 --- a/src/strategy/AiObjectContext.cpp +++ b/src/strategy/AiObjectContext.cpp @@ -22,6 +22,8 @@ #include "raids/RaidTriggerContext.h" #include "raids/naxxramas/RaidNaxxActionContext.h" #include "raids/naxxramas/RaidNaxxTriggerContext.h" +#include "raids/moltencore/RaidMcActionContext.h" +#include "raids/moltencore/RaidMcTriggerContext.h" AiObjectContext::AiObjectContext(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) { @@ -37,6 +39,7 @@ AiObjectContext::AiObjectContext(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) actionContexts.Add(new RaidActionContext()); actionContexts.Add(new RaidNaxxActionContext()); actionContexts.Add(new RaidUlduarActionContext()); + actionContexts.Add(new RaidMcActionContext()); triggerContexts.Add(new TriggerContext()); triggerContexts.Add(new ChatTriggerContext()); @@ -44,6 +47,7 @@ AiObjectContext::AiObjectContext(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) triggerContexts.Add(new RaidTriggerContext()); triggerContexts.Add(new RaidNaxxTriggerContext()); triggerContexts.Add(new RaidUlduarTriggerContext()); + triggerContexts.Add(new RaidMcTriggerContext()); valueContexts.Add(new ValueContext()); diff --git a/src/strategy/raids/RaidStrategyContext.h b/src/strategy/raids/RaidStrategyContext.h index f0092302..29e997d2 100644 --- a/src/strategy/raids/RaidStrategyContext.h +++ b/src/strategy/raids/RaidStrategyContext.h @@ -5,21 +5,27 @@ #include "Strategy.h" #include "RaidBwlStrategy.h" #include "RaidNaxxStrategy.h" +#include "RaidMcStrategy.h" class RaidStrategyContext : public NamedObjectContext { public: RaidStrategyContext() : NamedObjectContext(false, true) { + // TODO should we give these prefixes (eg: "naxx" -> "raid naxx")? because if we don't it's going to end up + // very crowded (with possible conflicts) once we have strats for all raids and some dungeons + // (mc already very similiar to nc) creators["naxx"] = &RaidStrategyContext::naxx; creators["bwl"] = &RaidStrategyContext::bwl; creators["uld"] = &RaidStrategyContext::uld; + creators["mc"] = &RaidStrategyContext::mc; } private: static Strategy* naxx(PlayerbotAI* botAI) { return new RaidNaxxStrategy(botAI); } static Strategy* bwl(PlayerbotAI* botAI) { return new RaidBwlStrategy(botAI); } static Strategy* uld(PlayerbotAI* botAI) { return new RaidUlduarStrategy(botAI); } + static Strategy* mc(PlayerbotAI* botAI) { return new RaidMcStrategy(botAI); } }; #endif \ No newline at end of file diff --git a/src/strategy/raids/moltencore/RaidMcActionContext.h b/src/strategy/raids/moltencore/RaidMcActionContext.h new file mode 100644 index 00000000..45e6e056 --- /dev/null +++ b/src/strategy/raids/moltencore/RaidMcActionContext.h @@ -0,0 +1,22 @@ +#ifndef _PLAYERBOT_RAIDMCACTIONCONTEXT_H +#define _PLAYERBOT_RAIDMCACTIONCONTEXT_H + +#include "Action.h" +#include "NamedObjectContext.h" +#include "RaidMcActions.h" + +class RaidMcActionContext : public NamedObjectContext +{ +public: + RaidMcActionContext() + { + creators["mc check should move from group"] = &RaidMcActionContext::check_should_move_from_group; + creators["mc move from baron geddon"] = &RaidMcActionContext::move_from_baron_geddon; + } + +private: + static Action* check_should_move_from_group(PlayerbotAI* ai) { return new McCheckShouldMoveFromGroupAction(ai); } + static Action* move_from_baron_geddon(PlayerbotAI* ai) { return new McMoveFromBaronGeddonAction(ai); } +}; + +#endif diff --git a/src/strategy/raids/moltencore/RaidMcActions.cpp b/src/strategy/raids/moltencore/RaidMcActions.cpp new file mode 100644 index 00000000..f58f344d --- /dev/null +++ b/src/strategy/raids/moltencore/RaidMcActions.cpp @@ -0,0 +1,43 @@ +#include "RaidMcActions.h" + +#include "Playerbots.h" + +bool McCheckShouldMoveFromGroupAction::Execute(Event event) +{ + if (bot->HasAura(20475)) // barron geddon's living bomb + { + if (!botAI->HasStrategy("move from group", BotState::BOT_STATE_COMBAT)) + { + // add/remove from both for now as it will make it more obvious to + // player if this strat remains on after fight somehow + botAI->ChangeStrategy("+move from group", BOT_STATE_NON_COMBAT); + botAI->ChangeStrategy("+move from group", BOT_STATE_COMBAT); + return true; + } + } + else if (botAI->HasStrategy("move from group", BotState::BOT_STATE_COMBAT)) + { + // add/remove from both for now as it will make it more obvious to + // player if this strat remains on after fight somehow + botAI->ChangeStrategy("-move from group", BOT_STATE_NON_COMBAT); + botAI->ChangeStrategy("-move from group", BOT_STATE_COMBAT); + return true; + } + return false; +} + +bool McMoveFromBaronGeddonAction::Execute(Event event) +{ + const float radius = 25.0f; // more than should be needed but bots keep trying to run back in + if (Unit* boss = AI_VALUE2(Unit*, "find target", "baron geddon")) + { + long distToTravel = radius - bot->GetDistance(boss); + if (distToTravel > 0) + { + // float angle = bot->GetAngle(boss) + M_PI; + // return Move(angle, distToTravel); + return MoveAway(boss, distToTravel); + } + } + return false; +} diff --git a/src/strategy/raids/moltencore/RaidMcActions.h b/src/strategy/raids/moltencore/RaidMcActions.h new file mode 100644 index 00000000..6ff18513 --- /dev/null +++ b/src/strategy/raids/moltencore/RaidMcActions.h @@ -0,0 +1,24 @@ +#ifndef _PLAYERBOT_RAIDMCACTIONS_H +#define _PLAYERBOT_RAIDMCACTIONS_H + +#include "MovementActions.h" +#include "PlayerbotAI.h" +#include "Playerbots.h" + +class McCheckShouldMoveFromGroupAction : public Action +{ +public: + McCheckShouldMoveFromGroupAction(PlayerbotAI* botAI, std::string const name = "mc check should move from group") + : Action(botAI, name) {} + bool Execute(Event event) override; +}; + +class McMoveFromBaronGeddonAction : public MovementAction +{ +public: + McMoveFromBaronGeddonAction(PlayerbotAI* botAI, std::string const name = "mc move from baron geddon") + : MovementAction(botAI, name) {} + bool Execute(Event event) override; +}; + +#endif diff --git a/src/strategy/raids/moltencore/RaidMcStrategy.cpp b/src/strategy/raids/moltencore/RaidMcStrategy.cpp new file mode 100644 index 00000000..67793de9 --- /dev/null +++ b/src/strategy/raids/moltencore/RaidMcStrategy.cpp @@ -0,0 +1,13 @@ +#include "RaidMcStrategy.h" + +#include "Strategy.h" + +void RaidMcStrategy::InitTriggers(std::vector& triggers) +{ + triggers.push_back( + new TriggerNode("mc living bomb debuff", + NextAction::array(0, new NextAction("mc check should move from group", ACTION_RAID), nullptr))); + triggers.push_back( + new TriggerNode("mc baron geddon inferno", + NextAction::array(0, new NextAction("mc move from baron geddon", ACTION_RAID), nullptr))); +} diff --git a/src/strategy/raids/moltencore/RaidMcStrategy.h b/src/strategy/raids/moltencore/RaidMcStrategy.h new file mode 100644 index 00000000..82b7d8f2 --- /dev/null +++ b/src/strategy/raids/moltencore/RaidMcStrategy.h @@ -0,0 +1,17 @@ +#ifndef _PLAYERBOT_RAIDMCSTRATEGY_H +#define _PLAYERBOT_RAIDMCSTRATEGY_H + +#include "AiObjectContext.h" +#include "Multiplier.h" +#include "Strategy.h" + +class RaidMcStrategy : public Strategy +{ +public: + RaidMcStrategy(PlayerbotAI* ai) : Strategy(ai) {} + virtual std::string const getName() override { return "mc"; } + virtual void InitTriggers(std::vector& triggers) override; + // virtual void InitMultipliers(std::vector &multipliers) override; +}; + +#endif diff --git a/src/strategy/raids/moltencore/RaidMcTriggerContext.h b/src/strategy/raids/moltencore/RaidMcTriggerContext.h new file mode 100644 index 00000000..93fe6df0 --- /dev/null +++ b/src/strategy/raids/moltencore/RaidMcTriggerContext.h @@ -0,0 +1,22 @@ +#ifndef _PLAYERBOT_RAIDMCTRIGGERCONTEXT_H +#define _PLAYERBOT_RAIDMCTRIGGERCONTEXT_H + +#include "AiObjectContext.h" +#include "NamedObjectContext.h" +#include "RaidMcTriggers.h" + +class RaidMcTriggerContext : public NamedObjectContext +{ +public: + RaidMcTriggerContext() + { + creators["mc living bomb debuff"] = &RaidMcTriggerContext::living_bomb_debuff; + creators["mc baron geddon inferno"] = &RaidMcTriggerContext::baron_geddon_inferno; + } + +private: + static Trigger* living_bomb_debuff(PlayerbotAI* ai) { return new McLivingBombDebuffTrigger(ai); } + static Trigger* baron_geddon_inferno(PlayerbotAI* ai) { return new McBaronGeddonInfernoTrigger(ai); } +}; + +#endif diff --git a/src/strategy/raids/moltencore/RaidMcTriggers.cpp b/src/strategy/raids/moltencore/RaidMcTriggers.cpp new file mode 100644 index 00000000..f77b70f2 --- /dev/null +++ b/src/strategy/raids/moltencore/RaidMcTriggers.cpp @@ -0,0 +1,22 @@ +#include "RaidMcTriggers.h" + +#include "SharedDefines.h" + +bool McLivingBombDebuffTrigger::IsActive() +{ + // if bot has barron geddon's living bomb, we need to add strat, otherwise we need to remove + // only do when fighting baron geddon (to avoid modifying strat set by player outside this fight) + if (Unit* boss = AI_VALUE2(Unit*, "find target", "baron geddon")) + { + if (boss->IsInCombat()) + return bot->HasAura(20475) != botAI->HasStrategy("move from group", BotState::BOT_STATE_COMBAT); + } + return false; +} + +bool McBaronGeddonInfernoTrigger::IsActive() +{ + if (Unit* boss = AI_VALUE2(Unit*, "find target", "baron geddon")) + return boss->HasAura(19695); + return false; +} diff --git a/src/strategy/raids/moltencore/RaidMcTriggers.h b/src/strategy/raids/moltencore/RaidMcTriggers.h new file mode 100644 index 00000000..9d2fb985 --- /dev/null +++ b/src/strategy/raids/moltencore/RaidMcTriggers.h @@ -0,0 +1,22 @@ +#ifndef _PLAYERBOT_RAIDMCTRIGGERS_H +#define _PLAYERBOT_RAIDMCTRIGGERS_H + +#include "PlayerbotAI.h" +#include "Playerbots.h" +#include "Trigger.h" + +class McLivingBombDebuffTrigger : public Trigger +{ +public: + McLivingBombDebuffTrigger(PlayerbotAI* botAI) : Trigger(botAI, "mc living bomb debuff") {} + bool IsActive() override; +}; + +class McBaronGeddonInfernoTrigger : public Trigger +{ +public: + McBaronGeddonInfernoTrigger(PlayerbotAI* botAI) : Trigger(botAI, "mc baron geddon inferno") {} + bool IsActive() override; +}; + +#endif