diff --git a/src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.cpp b/src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.cpp index 958554b4a..9e05600e3 100644 --- a/src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.cpp +++ b/src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.cpp @@ -41,6 +41,58 @@ bool CastAuraSpellAction::isUseful() return CastSpellAction::isUseful() && !ai->HasAura(spell, GetTarget()); } +bool CastDebuffSpellAction::isUseful() +{ + if (!CastAuraSpellAction::isUseful()) + { + return false; + } + + Unit* target = GetTarget(); + if (!target) + { + return true; + } + + Player* bot = ai->GetBot(); + Group* group = bot->GetGroup(); + if (!group || group->GetTargetIcon(4) != target->GetObjectGuid()) + { + return true; + } + + Player* tank = ai->GetGroupTank(bot); + if (!tank) + { + return true; + } + + Unit* tankVictim = tank->getVictim(); + if (tankVictim && tankVictim->GetObjectGuid() == target->GetObjectGuid()) + { + return true; + } + + uint32 spellId = AI_VALUE2(uint32, "spell id", spell); + if (spellId) + { + const SpellEntry* spellInfo = sSpellStore.LookupEntry(spellId); + if (spellInfo) + { + for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + { + if (spellInfo->EffectAura[j] == SPELL_AURA_PERIODIC_DAMAGE || + spellInfo->EffectAura[j] == SPELL_AURA_PERIODIC_DAMAGE_PERCENT) + { + return false; + } + } + } + } + + return true; +} + bool CastEnchantItemAction::isUseful() { if (!CastSpellAction::isUseful()) diff --git a/src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.h b/src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.h index 0007c4961..a69c6be10 100644 --- a/src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.h +++ b/src/modules/Bots/playerbot/strategy/actions/GenericSpellActions.h @@ -116,6 +116,7 @@ namespace ai { public: CastDebuffSpellAction(PlayerbotAI* ai, string spell) : CastAuraSpellAction(ai, spell) {} + virtual bool isUseful(); }; class CastDebuffSpellOnAttackerAction : public CastAuraSpellAction