Skip to content

Commit

Permalink
Merge pull request #11 from Vigerus/viger_add_qualifiers_rtsc_and_aura
Browse files Browse the repository at this point in the history
adding qualifiers to rtsc command and has aura trigger
  • Loading branch information
mostlikely4r authored Jun 11, 2024
2 parents f9546d5 + fe5ab37 commit 9863670
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 5 deletions.
5 changes: 5 additions & 0 deletions playerbot/strategy/actions/RtscAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions playerbot/strategy/actions/RtscAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
72 changes: 71 additions & 1 deletion playerbot/strategy/triggers/GenericTriggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "playerbot/strategy/values/PositionValue.h"
#include "playerbot/strategy/values/AoeValues.h"

#include <regex>

using namespace ai;

bool NoManaTrigger::IsActive()
Expand Down Expand Up @@ -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());
Expand Down
5 changes: 3 additions & 2 deletions playerbot/strategy/triggers/GenericTriggers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions playerbot/strategy/triggers/TriggerContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9863670

Please sign in to comment.