From f03e12cb38f8cafceb85161a061ce37b4f0a6d54 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Wed, 27 Mar 2024 10:26:14 +0800 Subject: [PATCH] Enchant paladin divine sacrifice --- conf/playerbots.conf.dist | 2 +- .../GenericPaladinStrategyActionNodeFactory.h | 36 +++++++++++-------- src/strategy/paladin/HealPaladinStrategy.cpp | 20 +++++++---- src/strategy/paladin/PaladinActions.cpp | 16 +++++++++ src/strategy/paladin/PaladinActions.h | 27 ++++++++++++-- .../paladin/PaladinAiObjectContext.cpp | 6 ++++ src/strategy/paladin/TankPaladinStrategy.cpp | 3 ++ src/strategy/shaman/HealShamanStrategy.cpp | 8 ++--- 8 files changed, 89 insertions(+), 29 deletions(-) diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index 8abae51e..27d6764b 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -305,7 +305,6 @@ AiPlayerbot.AlmostFullHealth = 85 AiPlayerbot.LowMana = 15 AiPlayerbot.MediumMana = 40 -# Random bot default strategies (applied after defaults) # Enable healer bot save mana # Default: 1 (enable) @@ -316,6 +315,7 @@ AiPlayerbot.AutoSaveMana = 1 AiPlayerbot.SaveManaThreshold = 60 +# Random bot default strategies (applied after defaults) AiPlayerbot.RandomBotCombatStrategies = "+dps,+dps assist,-threat" # AiPlayerbot.RandomBotNonCombatStrategies = "+grind,+loot,+rpg,+custom::say" AiPlayerbot.RandomBotNonCombatStrategies = "" diff --git a/src/strategy/paladin/GenericPaladinStrategyActionNodeFactory.h b/src/strategy/paladin/GenericPaladinStrategyActionNodeFactory.h index 5ed43bd7..e2e00f2f 100644 --- a/src/strategy/paladin/GenericPaladinStrategyActionNodeFactory.h +++ b/src/strategy/paladin/GenericPaladinStrategyActionNodeFactory.h @@ -43,6 +43,7 @@ class GenericPaladinStrategyActionNodeFactory : public NamedObjectFactory& triggers) // triggers.push_back(new TriggerNode("concentration aura", NextAction::array(0, new NextAction("concentration aura", ACTION_NORMAL), nullptr))); triggers.push_back(new TriggerNode("seal", NextAction::array(0, new NextAction("seal of wisdom", ACTION_HIGH), nullptr))); + triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new NextAction("divine illumination", ACTION_HIGH + 2), nullptr))); triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("divine favor", ACTION_HIGH + 1), nullptr))); // triggers.push_back(new TriggerNode("blessing", NextAction::array(0, new NextAction("blessing of sanctuary", ACTION_HIGH + 9), nullptr))); triggers.push_back(new TriggerNode("party member to heal out of spell range", NextAction::array(0, new NextAction("reach party member to heal", ACTION_EMERGENCY + 3), nullptr))); + triggers.push_back(new TriggerNode( + "medium group heal occasion", + NextAction::array(0, new NextAction("divine sacrifice", ACTION_CRITICAL_HEAL + 5), nullptr))); + triggers.push_back(new TriggerNode( "party member critical health", NextAction::array(0, - new NextAction("holy shock on party", ACTION_CRITICAL_HEAL + 5), + new NextAction("holy shock on party", ACTION_CRITICAL_HEAL + 6), + new NextAction("divine sacrifice", ACTION_CRITICAL_HEAL + 5), new NextAction("holy light on party", ACTION_CRITICAL_HEAL + 4), - NULL))); + nullptr))); triggers.push_back(new TriggerNode( "party member low health", NextAction::array(0, new NextAction("holy light on party", ACTION_MEDIUM_HEAL + 5), - NULL))); + nullptr))); triggers.push_back(new TriggerNode( "party member medium health", NextAction::array(0, new NextAction("holy light on party", ACTION_LIGHT_HEAL + 9), new NextAction("flash of light on party", ACTION_LIGHT_HEAL + 8), - NULL))); + nullptr))); triggers.push_back(new TriggerNode( "party member almost full health", NextAction::array(0, new NextAction("flash of light on party", ACTION_LIGHT_HEAL + 3), - NULL))); + nullptr))); triggers.push_back(new TriggerNode( "beacon of light on main tank", - NextAction::array(0, new NextAction("beacon of light on main tank", ACTION_CRITICAL_HEAL + 7), NULL))); + NextAction::array(0, new NextAction("beacon of light on main tank", ACTION_CRITICAL_HEAL + 7), nullptr))); triggers.push_back(new TriggerNode( "sacred shield on main tank", - NextAction::array(0, new NextAction("sacred shield on main tank", ACTION_CRITICAL_HEAL + 6), NULL))); + NextAction::array(0, new NextAction("sacred shield on main tank", ACTION_CRITICAL_HEAL + 6), nullptr))); } diff --git a/src/strategy/paladin/PaladinActions.cpp b/src/strategy/paladin/PaladinActions.cpp index e53ea67c..82fe4ec4 100644 --- a/src/strategy/paladin/PaladinActions.cpp +++ b/src/strategy/paladin/PaladinActions.cpp @@ -154,4 +154,20 @@ bool CastMeleeConsecrationAction::isUseful() Unit* target = GetTarget(); // float dis = distance + CONTACT_DISTANCE; return target && bot->IsWithinCombatRange(target, sPlayerbotAIConfig->meleeDistance); // sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", GetTargetName()), distance); +} + +bool CastDivineSacrificeAction::isUseful() +{ + return GetTarget() && (GetTarget() != nullptr) && CastSpellAction::isUseful() && !botAI->HasAura("divine guardian", GetTarget(), false, false, -1, true); +} + +bool CastCancelDivineSacrificeAction::Execute(Event event) +{ + botAI->RemoveAura("divine sacrifice"); + return true; +} + +bool CastCancelDivineSacrificeAction::isUseful() +{ + return botAI->HasAura("divine sacrifice", GetTarget(), false, true, -1, true); } \ No newline at end of file diff --git a/src/strategy/paladin/PaladinActions.h b/src/strategy/paladin/PaladinActions.h index 0afc9c71..24a3874a 100644 --- a/src/strategy/paladin/PaladinActions.h +++ b/src/strategy/paladin/PaladinActions.h @@ -170,13 +170,13 @@ class CastHolyLightAction : public CastHealingSpellAction class CastHolyShockOnPartyAction : public HealPartyMemberAction { public: - CastHolyShockOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "holy shock", 25.0f, HealingManaEfficiency::MEDIUM) { } + CastHolyShockOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "holy shock", 25.0f, HealingManaEfficiency::LOW) { } }; class CastHolyLightOnPartyAction : public HealPartyMemberAction { public: - CastHolyLightOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "holy light", 50.0f, HealingManaEfficiency::HIGH) { } + CastHolyLightOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "holy light", 50.0f, HealingManaEfficiency::MEDIUM) { } }; class CastFlashOfLightAction : public CastHealingSpellAction @@ -188,7 +188,7 @@ class CastFlashOfLightAction : public CastHealingSpellAction class CastFlashOfLightOnPartyAction : public HealPartyMemberAction { public: - CastFlashOfLightOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "flash of light", 15.0f, HealingManaEfficiency::LOW) { } + CastFlashOfLightOnPartyAction(PlayerbotAI* botAI) : HealPartyMemberAction(botAI, "flash of light", 15.0f, HealingManaEfficiency::HIGH) { } }; class CastLayOnHandsAction : public CastHealingSpellAction @@ -393,4 +393,25 @@ class CastAvengingWrathAction : public CastBuffSpellAction public: CastAvengingWrathAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "avenging wrath") {} }; + +class CastDivineIlluminationAction : public CastBuffSpellAction +{ + public: + CastDivineIlluminationAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "divine illumination") {} +}; + +class CastDivineSacrificeAction : public CastBuffSpellAction +{ + public: + CastDivineSacrificeAction(PlayerbotAI* botAI) : CastBuffSpellAction(botAI, "divine sacrifice") {} + bool isUseful() override; +}; + +class CastCancelDivineSacrificeAction : public Action +{ + public: + CastCancelDivineSacrificeAction(PlayerbotAI* botAI) : Action(botAI, "cancel divine sacrifice") {} + bool Execute(Event event) override; + bool isUseful() override; +}; #endif diff --git a/src/strategy/paladin/PaladinAiObjectContext.cpp b/src/strategy/paladin/PaladinAiObjectContext.cpp index c22bdbe3..68766229 100644 --- a/src/strategy/paladin/PaladinAiObjectContext.cpp +++ b/src/strategy/paladin/PaladinAiObjectContext.cpp @@ -263,6 +263,9 @@ class PaladinAiObjectContextInternal : public NamedObjectContext creators["beacon of light on main tank"] = &PaladinAiObjectContextInternal::beacon_of_light_on_main_tank; creators["sacred shield on main tank"] = &PaladinAiObjectContextInternal::sacred_shield_on_main_tank; creators["avenging wrath"] = &PaladinAiObjectContextInternal::avenging_wrath; + creators["divine illumination"] = &PaladinAiObjectContextInternal::divine_illumination; + creators["divine sacrifice"] = &PaladinAiObjectContextInternal::divine_sacrifice; + creators["cancel divine sacrifice"] = &PaladinAiObjectContextInternal::cancel_divine_sacrifice; } private: @@ -341,6 +344,9 @@ class PaladinAiObjectContextInternal : public NamedObjectContext static Action* beacon_of_light_on_main_tank(PlayerbotAI* ai) { return new CastBeaconOfLightOnMainTankAction(ai); } static Action* sacred_shield_on_main_tank(PlayerbotAI* ai) { return new CastSacredShieldOnMainTankAction(ai); } static Action* avenging_wrath(PlayerbotAI* ai) { return new CastAvengingWrathAction(ai); } + static Action* divine_illumination(PlayerbotAI* ai) { return new CastDivineIlluminationAction(ai); } + static Action* divine_sacrifice(PlayerbotAI* ai) { return new CastDivineSacrificeAction(ai); } + static Action* cancel_divine_sacrifice(PlayerbotAI* ai) { return new CastCancelDivineSacrificeAction(ai); } }; PaladinAiObjectContext::PaladinAiObjectContext(PlayerbotAI* botAI) : AiObjectContext(botAI) diff --git a/src/strategy/paladin/TankPaladinStrategy.cpp b/src/strategy/paladin/TankPaladinStrategy.cpp index f69f53f9..bbbeac00 100644 --- a/src/strategy/paladin/TankPaladinStrategy.cpp +++ b/src/strategy/paladin/TankPaladinStrategy.cpp @@ -91,6 +91,9 @@ void TankPaladinStrategy::InitTriggers(std::vector& triggers) triggers.push_back(new TriggerNode( "righteous fury", NextAction::array(0, new NextAction("righteous fury", ACTION_HIGH + 8), nullptr))); + triggers.push_back(new TriggerNode( + "medium group heal occasion", + NextAction::array(0, new NextAction("divine sacrifice", ACTION_HIGH + 5), nullptr))); triggers.push_back(new TriggerNode( "not facing target", NextAction::array(0, new NextAction("set facing", ACTION_NORMAL + 7), nullptr))); diff --git a/src/strategy/shaman/HealShamanStrategy.cpp b/src/strategy/shaman/HealShamanStrategy.cpp index 1a9bd811..97edd46b 100644 --- a/src/strategy/shaman/HealShamanStrategy.cpp +++ b/src/strategy/shaman/HealShamanStrategy.cpp @@ -49,19 +49,19 @@ void HealShamanStrategy::InitTriggers(std::vector& triggers) triggers.push_back(new TriggerNode( "party member critical health", - NextAction::array(0, new NextAction("riptide on party", 24.0f), new NextAction("lesser healing wave on party", 23.0f), nullptr))); + NextAction::array(0, new NextAction("riptide on party", 25.0f), new NextAction("healing wave on party", 24.0f), new NextAction("lesser healing wave on party", 23.0f), nullptr))); triggers.push_back(new TriggerNode( "party member low health", - NextAction::array(0, new NextAction("riptide on party", 18.0f), new NextAction("lesser healing wave on party", 17.0f), nullptr))); + NextAction::array(0, new NextAction("riptide on party", 19.0f), new NextAction("healing wave on party", 18.0f), new NextAction("lesser healing wave on party", 17.0f), nullptr))); triggers.push_back(new TriggerNode( "party member medium health", - NextAction::array(0, new NextAction("riptide on party", 15.0f), new NextAction("lesser healing wave on party", 14.0f), nullptr))); + NextAction::array(0, new NextAction("riptide on party", 16.0f), new NextAction("healing wave on party", 15.0f), new NextAction("lesser healing wave on party", 14.0f), nullptr))); triggers.push_back(new TriggerNode( "party member almost full health", - NextAction::array(0, new NextAction("riptide on party", 12.0f), nullptr))); + NextAction::array(0, new NextAction("riptide on party", 12.0f), new NextAction("lesser healing wave on party", 11.0f), nullptr))); triggers.push_back(new TriggerNode( "party member cleanse spirit poison",