From 26faac914ebc7ec2e7deeba20e3b546d92d1f215 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Tue, 7 May 2024 22:21:38 +0800 Subject: [PATCH] [Class spell] Fix healing priests stop casting due to threat --- src/AiFactory.cpp | 12 ++-- src/strategy/priest/HolyPriestStrategy.cpp | 61 +++++++++++++++++++ src/strategy/priest/HolyPriestStrategy.h | 15 ++++- src/strategy/priest/PriestAiObjectContext.cpp | 6 +- 4 files changed, 85 insertions(+), 9 deletions(-) diff --git a/src/AiFactory.cpp b/src/AiFactory.cpp index bd903b5c..3a29ef79 100644 --- a/src/AiFactory.cpp +++ b/src/AiFactory.cpp @@ -277,12 +277,12 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa switch (player->getClass()) { case CLASS_PRIEST: - if (tab == 2) - { + if (tab == 2) { engine->addStrategies("dps", "shadow debuff", "shadow aoe", "threat", nullptr); - } - else { - engine->addStrategies("heal", "threat", nullptr); + } else if (tab == PRIEST_TAB_DISIPLINE) { + engine->addStrategies("heal", nullptr); + } else { + engine->addStrategies("holy heal", nullptr); } engine->addStrategies("dps assist", "cure", nullptr); @@ -375,7 +375,7 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa switch (player->getClass()) { case CLASS_PRIEST: { if (tab != PRIEST_TAB_SHADOW) { - engine->addStrategies("holy", "shadow debuff", "shadow aoe", nullptr); + engine->addStrategies("holy dps", "shadow debuff", "shadow aoe", nullptr); } break; } diff --git a/src/strategy/priest/HolyPriestStrategy.cpp b/src/strategy/priest/HolyPriestStrategy.cpp index ba24d730..a9e64204 100644 --- a/src/strategy/priest/HolyPriestStrategy.cpp +++ b/src/strategy/priest/HolyPriestStrategy.cpp @@ -42,3 +42,64 @@ void HolyPriestStrategy::InitTriggers(std::vector& triggers) triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new NextAction("shadowfiend", ACTION_HIGH), nullptr))); triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("mana burn", ACTION_HIGH), nullptr))); } + +HolyHealPriestStrategy::HolyHealPriestStrategy(PlayerbotAI* botAI) : GenericPriestStrategy(botAI) +{ + actionNodeFactories.Add(new GenericPriestStrategyActionNodeFactory()); +} + +NextAction** HolyHealPriestStrategy::getDefaultActions() +{ + return NextAction::array(0, new NextAction("shoot", ACTION_DEFAULT), nullptr); +} + +void HolyHealPriestStrategy::InitTriggers(std::vector& triggers) +{ + GenericPriestStrategy::InitTriggers(triggers); + + triggers.push_back(new TriggerNode( + "group heal occasion", + NextAction::array(0, + new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 8), + new NextAction("prayer of healing on party", ACTION_MEDIUM_HEAL + 6), + NULL))); + + triggers.push_back(new TriggerNode( + "medium group heal occasion", + NextAction::array(0, new NextAction("divine hymn", ACTION_CRITICAL_HEAL + 5), NULL))); + + triggers.push_back(new TriggerNode( + "party member critical health", + NextAction::array(0, + new NextAction("power word: shield on party", ACTION_CRITICAL_HEAL + 5), + new NextAction("flash heal on party", ACTION_CRITICAL_HEAL + 3), + new NextAction("prayer of mending on party", ACTION_CRITICAL_HEAL + 2), + NULL))); + + triggers.push_back(new TriggerNode( + "party member low health", + NextAction::array(0, + new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 4), + new NextAction("greater heal on party", ACTION_MEDIUM_HEAL + 3), + new NextAction("prayer of mending on party", ACTION_MEDIUM_HEAL + 2), + new NextAction("flash heal on party", ACTION_MEDIUM_HEAL + 1), + NULL))); + + triggers.push_back(new TriggerNode( + "party member medium health", + NextAction::array(0, + new NextAction("circle of healing", ACTION_LIGHT_HEAL + 7), + new NextAction("prayer of mending on party", ACTION_LIGHT_HEAL + 6), + new NextAction("flash heal on party", ACTION_LIGHT_HEAL + 5), + // new NextAction("renew on party", ACTION_LIGHT_HEAL + 8), + NULL))); + + triggers.push_back(new TriggerNode( + "party member almost full health", + NextAction::array(0, + new NextAction("renew on party", ACTION_LIGHT_HEAL + 2), + // new NextAction("flash heal on party", ACTION_LIGHT_HEAL + 1), + NULL))); + + triggers.push_back(new TriggerNode("party member to heal out of spell range", NextAction::array(0, new NextAction("reach party member to heal", ACTION_CRITICAL_HEAL + 10), nullptr))); +} diff --git a/src/strategy/priest/HolyPriestStrategy.h b/src/strategy/priest/HolyPriestStrategy.h index 39173069..108cdf68 100644 --- a/src/strategy/priest/HolyPriestStrategy.h +++ b/src/strategy/priest/HolyPriestStrategy.h @@ -6,6 +6,7 @@ #define _PLAYERBOT_HOLYPRIESTSTRATEGY_H #include "HealPriestStrategy.h" +#include "GenericPriestStrategyActionNodeFactory.h" class PlayerbotAI; @@ -16,8 +17,20 @@ class HolyPriestStrategy : public HealPriestStrategy NextAction** getDefaultActions() override; void InitTriggers(std::vector& triggers) override; - std::string const getName() override { return "holy"; } + std::string const getName() override { return "holy dps"; } uint32 GetType() const override { return STRATEGY_TYPE_DPS | STRATEGY_TYPE_RANGED; } }; +class HolyHealPriestStrategy : public GenericPriestStrategy +{ + public: + HolyHealPriestStrategy(PlayerbotAI* botAI); + + void InitTriggers(std::vector& triggers) override; + NextAction** getDefaultActions() override; + std::string const getName() override { return "holy heal"; } + uint32 GetType() const override { return STRATEGY_TYPE_HEAL | STRATEGY_TYPE_RANGED; } +}; + + #endif diff --git a/src/strategy/priest/PriestAiObjectContext.cpp b/src/strategy/priest/PriestAiObjectContext.cpp index d6810897..690539a5 100644 --- a/src/strategy/priest/PriestAiObjectContext.cpp +++ b/src/strategy/priest/PriestAiObjectContext.cpp @@ -50,13 +50,15 @@ class PriestCombatStrategyFactoryInternal : public NamedObjectContext creators["heal"] = &PriestCombatStrategyFactoryInternal::heal; creators["shadow"] = &PriestCombatStrategyFactoryInternal::dps; creators["dps"] = &PriestCombatStrategyFactoryInternal::dps; - creators["holy"] = &PriestCombatStrategyFactoryInternal::holy; + creators["holy dps"] = &PriestCombatStrategyFactoryInternal::holy_dps; + creators["holy heal"] = &PriestCombatStrategyFactoryInternal::holy_heal; } private: static Strategy* heal(PlayerbotAI* botAI) { return new HealPriestStrategy(botAI); } static Strategy* dps(PlayerbotAI* botAI) { return new ShadowPriestStrategy(botAI); } - static Strategy* holy(PlayerbotAI* botAI) { return new HolyPriestStrategy(botAI); } + static Strategy* holy_dps(PlayerbotAI* botAI) { return new HolyPriestStrategy(botAI); } + static Strategy* holy_heal(PlayerbotAI* botAI) { return new HolyHealPriestStrategy(botAI); } }; class PriestTriggerFactoryInternal : public NamedObjectContext