diff --git a/src/Ai/Class/Druid/Action/DruidActions.cpp b/src/Ai/Class/Druid/Action/DruidActions.cpp index 2eb809480..c01cc4342 100644 --- a/src/Ai/Class/Druid/Action/DruidActions.cpp +++ b/src/Ai/Class/Druid/Action/DruidActions.cpp @@ -11,6 +11,22 @@ #include "AoeValues.h" #include "TargetValue.h" +namespace +{ + bool PrepareThornsTarget(PlayerbotAI* botAI, Unit* target) + { + if (!target) + return false; + + Aura* existingThorns = botAI->GetAura("thorns", target, true); + if (!existingThorns) + return true; + + target->RemoveOwnedAura(existingThorns, AURA_REMOVE_BY_CANCEL); + return true; + } +} + std::vector CastAbolishPoisonAction::getAlternatives() { return NextAction::merge({ NextAction("cure poison") }, @@ -33,6 +49,21 @@ bool CastLifebloomOnMainTankAction::isUseful() return !lifebloom || lifebloom->GetStackAmount() < 3 || lifebloom->GetDuration() < 2000; } +bool CastThornsAction::Execute(Event event) +{ + return PrepareThornsTarget(botAI, GetTarget()) && CastBuffSpellAction::Execute(event); +} + +bool CastThornsOnPartyAction::Execute(Event event) +{ + return PrepareThornsTarget(botAI, GetTarget()) && BuffOnPartyAction::Execute(event); +} + +bool CastThornsOnMainTankAction::Execute(Event event) +{ + return PrepareThornsTarget(botAI, GetTarget()) && BuffOnMainTankAction::Execute(event); +} + Value* CastEntanglingRootsCcAction::GetTargetValue() { return context->GetValue("cc target", "entangling roots"); diff --git a/src/Ai/Class/Druid/Action/DruidActions.h b/src/Ai/Class/Druid/Action/DruidActions.h index 016c3dfc4..7e02a985f 100644 --- a/src/Ai/Class/Druid/Action/DruidActions.h +++ b/src/Ai/Class/Druid/Action/DruidActions.h @@ -114,18 +114,24 @@ class CastThornsAction : public CastBuffSpellAction { public: CastThornsAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "thorns") {} + + bool Execute(Event event) override; }; class CastThornsOnPartyAction : public BuffOnPartyAction { public: CastThornsOnPartyAction(PlayerbotAI* botAI) : BuffOnPartyAction(botAI, "thorns") {} + + bool Execute(Event event) override; }; class CastThornsOnMainTankAction : public BuffOnMainTankAction { public: CastThornsOnMainTankAction(PlayerbotAI* botAI) : BuffOnMainTankAction(botAI, "thorns", false) {} + + bool Execute(Event event) override; }; class CastLifebloomOnMainTankAction : public BuffOnMainTankAction