diff --git a/playerbot/strategy/actions/RtscAction.cpp b/playerbot/strategy/actions/RtscAction.cpp index 0351f8977..9ed4263dd 100644 --- a/playerbot/strategy/actions/RtscAction.cpp +++ b/playerbot/strategy/actions/RtscAction.cpp @@ -12,6 +12,11 @@ bool RTSCAction::Execute(Event& event) std::string command = event.getParam(); Player* requester = event.getOwner() ? event.getOwner() : GetMaster(); + if (command.empty() && !qualifier.empty()) + { + command = qualifier; + } + if (!requester) return false; diff --git a/playerbot/strategy/actions/RtscAction.h b/playerbot/strategy/actions/RtscAction.h index a3c2106e6..2dc2de54d 100644 --- a/playerbot/strategy/actions/RtscAction.h +++ b/playerbot/strategy/actions/RtscAction.h @@ -7,10 +7,10 @@ namespace ai { #define RTSC_MOVE_SPELL 30758 //Aedm (Awesome Energetic do move) - class RTSCAction : public SeeSpellAction + class RTSCAction : public SeeSpellAction, public Qualified { public: - RTSCAction(PlayerbotAI* ai) : SeeSpellAction(ai, "rtsc") {} + RTSCAction(PlayerbotAI* ai) : SeeSpellAction(ai, "rtsc"), Qualified() {} virtual bool Execute(Event& event); }; } diff --git a/playerbot/strategy/triggers/GenericTriggers.cpp b/playerbot/strategy/triggers/GenericTriggers.cpp index da0f90242..93ef1645d 100644 --- a/playerbot/strategy/triggers/GenericTriggers.cpp +++ b/playerbot/strategy/triggers/GenericTriggers.cpp @@ -6,6 +6,8 @@ #include "playerbot/strategy/values/PositionValue.h" #include "playerbot/strategy/values/AoeValues.h" +#include + using namespace ai; bool NoManaTrigger::IsActive() @@ -481,9 +483,77 @@ bool DeflectSpellTrigger::IsActive() bool HasAuraTrigger::IsActive() { - return ai->HasAura(getName(), GetTarget(), false, false, -1, false, 0, auraTypeId); + if (!name.empty()) + { + return ai->HasAura(name, GetTarget(), false, false, -1, false, 0, auraTypeId); + } + + std::string str = getQualifier(); + std::regex pattern(R"(spellid::(\d+)::([^:]*)::(\d+))"); + std::smatch match; + + if (std::regex_search(str, match, pattern) && match.size() == 4) + { + uint32 spell_id = atoi(match[1].str().c_str()); + + if (Aura* aura = ai->GetAura(spell_id, GetTarget())) + { + uint32 count = atoi(match[3].str().c_str()); + uint32 stack_size = aura->GetStackAmount(); + std::string comp_symb = match[2].str(); + + if (comp_symb == "equal") + { + return stack_size == count; + } + else if (comp_symb == "greater or equal") + { + return stack_size >= count; + } + else if (comp_symb == "lesser or equal") + { + return stack_size <= count; + } + else if (comp_symb == "greater") + { + return stack_size > count; + } + else if (comp_symb == "lesser") + { + return stack_size < count; + } + else + { + return false; + } + } + }; + + pattern = R"(spellid::(\d+))"; + + if (std::regex_search(str, match, pattern) && match.size() == 2) + { + + uint32 spell_id = atoi(match[1].str().c_str()); + return ai->HasAura(spell_id, GetTarget()); + } + + return false; } +std::string HasAuraTrigger::getName() +{ + if (!name.empty()) + { + return name; + } + + std::ostringstream ss; + ss << "has aura with " << getQualifier(); + return ss.str(); +} + + bool HasNoAuraTrigger::IsActive() { return !ai->HasAura(getName(), GetTarget()); diff --git a/playerbot/strategy/triggers/GenericTriggers.h b/playerbot/strategy/triggers/GenericTriggers.h index 1cbb4a3ab..580dd7cf3 100644 --- a/playerbot/strategy/triggers/GenericTriggers.h +++ b/playerbot/strategy/triggers/GenericTriggers.h @@ -654,12 +654,13 @@ namespace ai AmmoCountTrigger(PlayerbotAI* ai, std::string item, uint32 count = 1, int interval = 30) : ItemCountTrigger(ai, item, count, interval) {} }; - class HasAuraTrigger : public Trigger + class HasAuraTrigger : public Trigger, public Qualified { public: - HasAuraTrigger(PlayerbotAI* ai, std::string spell, int interval = 1, int auraTypeId = TOTAL_AURAS) : Trigger(ai, spell, interval), auraTypeId(auraTypeId) {} + HasAuraTrigger(PlayerbotAI* ai, std::string spell = "", int interval = 1, int auraTypeId = TOTAL_AURAS) : Trigger(ai, spell, interval), Qualified(), auraTypeId(auraTypeId) {} virtual std::string GetTargetName() override { return "self target"; } virtual bool IsActive() override; + virtual std::string getName() override; protected: int auraTypeId; diff --git a/playerbot/strategy/triggers/TriggerContext.h b/playerbot/strategy/triggers/TriggerContext.h index 02ce2769c..fb7c2c840 100644 --- a/playerbot/strategy/triggers/TriggerContext.h +++ b/playerbot/strategy/triggers/TriggerContext.h @@ -98,6 +98,7 @@ namespace ai creators["melee very high aoe"] = &TriggerContext::melee_very_high_aoe; creators["has area debuff"] = &TriggerContext::HasAreaDebuff; + creators["has aura"] = [](PlayerbotAI* ai) { return new HasAuraTrigger(ai); }; creators["enemy out of melee"] = &TriggerContext::EnemyOutOfMelee; creators["enemy out of spell"] = &TriggerContext::EnemyOutOfSpell;