diff --git a/src/strategy/StrategyContext.h b/src/strategy/StrategyContext.h index e87982c6..53c3f699 100644 --- a/src/strategy/StrategyContext.h +++ b/src/strategy/StrategyContext.h @@ -72,6 +72,7 @@ class StrategyContext : public NamedObjectContext creators["potions"] = &StrategyContext::potions; creators["cast time"] = &StrategyContext::cast_time; creators["threat"] = &StrategyContext::threat; + creators["focus"] = &StrategyContext::focus; creators["tell target"] = &StrategyContext::tell_target; creators["pvp"] = &StrategyContext::pvp; creators["return"] = &StrategyContext::_return; @@ -120,6 +121,7 @@ class StrategyContext : public NamedObjectContext static Strategy* mark_rti(PlayerbotAI* botAI) { return new MarkRtiStrategy(botAI); } static Strategy* tell_target(PlayerbotAI* botAI) { return new TellTargetStrategy(botAI); } static Strategy* threat(PlayerbotAI* botAI) { return new ThreatStrategy(botAI); } + static Strategy* focus(PlayerbotAI* botAI) { return new FocusStrategy(botAI); } static Strategy* cast_time(PlayerbotAI* botAI) { return new CastTimeStrategy(botAI); } static Strategy* potions(PlayerbotAI* botAI) { return new UsePotionsStrategy(botAI); } static Strategy* kite(PlayerbotAI* botAI) { return new KiteStrategy(botAI); } diff --git a/src/strategy/generic/ThreatStrategy.cpp b/src/strategy/generic/ThreatStrategy.cpp index 4b2d39ed..ba1cbf4c 100644 --- a/src/strategy/generic/ThreatStrategy.cpp +++ b/src/strategy/generic/ThreatStrategy.cpp @@ -4,6 +4,7 @@ #include "ThreatStrategy.h" #include "GenericSpellActions.h" +#include "Map.h" #include "Playerbots.h" float ThreatMultiplier::GetValue(Action* action) @@ -36,3 +37,22 @@ void ThreatStrategy::InitMultipliers(std::vector& multipliers) { multipliers.push_back(new ThreatMultiplier(botAI)); } + +float FocusMultiplier::GetValue(Action* action) +{ + if (!action) { + return 1.0f; + } + if (action->getThreatType() == Action::ActionThreatType::Aoe && !dynamic_cast(action)) { + return 0.0f; + } + if (dynamic_cast(action)) { + return 0.0f; + } + return 1.0f; +} + +void FocusStrategy::InitMultipliers(std::vector& multipliers) +{ + multipliers.push_back(new FocusMultiplier(botAI)); +} diff --git a/src/strategy/generic/ThreatStrategy.h b/src/strategy/generic/ThreatStrategy.h index 5c917f4e..521233c9 100644 --- a/src/strategy/generic/ThreatStrategy.h +++ b/src/strategy/generic/ThreatStrategy.h @@ -26,4 +26,21 @@ class ThreatStrategy : public Strategy std::string const getName() override { return "threat"; } }; +class FocusMultiplier : public Multiplier +{ + public: + FocusMultiplier(PlayerbotAI* botAI) : Multiplier(botAI, "focus") { } + + float GetValue(Action* action) override; +}; + +class FocusStrategy : public Strategy +{ + public: + FocusStrategy(PlayerbotAI* botAI) : Strategy(botAI) { } + + void InitMultipliers(std::vector& multipliers) override; + std::string const getName() override { return "focus"; } +}; + #endif