[Strategy] Focus strategy

This commit is contained in:
Yunfan Li
2024-06-04 22:15:39 +08:00
parent 46e585f854
commit 5f40c39e5e
3 changed files with 39 additions and 0 deletions

View File

@@ -72,6 +72,7 @@ class StrategyContext : public NamedObjectContext<Strategy>
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<Strategy>
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); }

View File

@@ -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<Multiplier*>& 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<CastHealingSpellAction*>(action)) {
return 0.0f;
}
if (dynamic_cast<CastDebuffSpellOnAttackerAction*>(action)) {
return 0.0f;
}
return 1.0f;
}
void FocusStrategy::InitMultipliers(std::vector<Multiplier*>& multipliers)
{
multipliers.push_back(new FocusMultiplier(botAI));
}

View File

@@ -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<Multiplier*>& multipliers) override;
std::string const getName() override { return "focus"; }
};
#endif