From f8cc3810b6266b38917d4f29010e6e0a7b1906ec Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Mon, 24 Jul 2023 14:42:40 +0800 Subject: [PATCH] Discipline priest shield --- src/strategy/priest/HealPriestStrategy.cpp | 12 ++--- src/strategy/priest/PriestActions.cpp | 50 +++++++++++++++++++ src/strategy/priest/PriestActions.h | 7 +++ src/strategy/priest/PriestAiObjectContext.cpp | 2 + 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/src/strategy/priest/HealPriestStrategy.cpp b/src/strategy/priest/HealPriestStrategy.cpp index 223b8e26..876889b9 100644 --- a/src/strategy/priest/HealPriestStrategy.cpp +++ b/src/strategy/priest/HealPriestStrategy.cpp @@ -24,12 +24,12 @@ void HealPriestStrategy::InitTriggers(std::vector& triggers) "enemy out of spell", NextAction::array(0, new NextAction("reach spell", ACTION_NORMAL + 9), NULL))); - triggers.push_back(new TriggerNode( - "medium aoe heal", - NextAction::array(0, - new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 8), - // new NextAction("power word: shield on almost full health below", ACTION_MEDIUM_HEAL + 7), - NULL))); + // triggers.push_back(new TriggerNode( + // "medium aoe heal", + // NextAction::array(0, + // new NextAction("circle of healing", ACTION_MEDIUM_HEAL + 8), + // // new NextAction("power word: shield on almost full health below", ACTION_MEDIUM_HEAL + 7), + // NULL))); triggers.push_back(new TriggerNode( "group heal occasion", diff --git a/src/strategy/priest/PriestActions.cpp b/src/strategy/priest/PriestActions.cpp index 793d0800..9b49d2fe 100644 --- a/src/strategy/priest/PriestActions.cpp +++ b/src/strategy/priest/PriestActions.cpp @@ -21,3 +21,53 @@ bool CastRemoveShadowformAction::Execute(Event event) botAI->RemoveAura("shadowform"); return true; } + +Unit* CastPowerWordShieldOnAlmostFullHealthBelow::GetTarget() +{ + Group *group = bot->GetGroup(); + for (GroupReference *gref = group->GetFirstMember(); gref; gref = gref->next()) + { + Player* player = gref->GetSource(); + if (!player) + continue; + if (player->isDead()) { + continue; + } + if (player->GetHealthPct() > sPlayerbotAIConfig->almostFullHealth) { + continue; + } + if (player->GetDistance2d(bot) > sPlayerbotAIConfig->spellDistance) { + continue; + } + if (botAI->HasAnyAuraOf(player, "weakened soul", "power word: shield", NULL)) { + continue; + } + return player; + } + return NULL; +} + +bool CastPowerWordShieldOnAlmostFullHealthBelow::isUseful() +{ + Group *group = bot->GetGroup(); + for (GroupReference *gref = group->GetFirstMember(); gref; gref = gref->next()) + { + Player* player = gref->GetSource(); + if (!player) + continue; + if (player->isDead()) { + continue; + } + if (player->GetHealthPct() > sPlayerbotAIConfig->almostFullHealth) { + continue; + } + if (player->GetDistance2d(bot) > sPlayerbotAIConfig->spellDistance) { + continue; + } + if (botAI->HasAnyAuraOf(player, "weakened soul", "power word: shield", NULL)) { + continue; + } + return true; + } + return false; +} \ No newline at end of file diff --git a/src/strategy/priest/PriestActions.h b/src/strategy/priest/PriestActions.h index 09f6e502..74562c5c 100644 --- a/src/strategy/priest/PriestActions.h +++ b/src/strategy/priest/PriestActions.h @@ -149,4 +149,11 @@ public: CastShadowfiendAction(PlayerbotAI* ai) : CastSpellAction(ai, "shadowfiend") {} virtual std::string const GetTargetName() { return "current target"; } }; + +class CastPowerWordShieldOnAlmostFullHealthBelow : public HealPartyMemberAction { +public: + CastPowerWordShieldOnAlmostFullHealthBelow(PlayerbotAI* ai) : HealPartyMemberAction(ai, "power word: shield") {} + bool isUseful() override; + Unit* GetTarget() override; +}; #endif diff --git a/src/strategy/priest/PriestAiObjectContext.cpp b/src/strategy/priest/PriestAiObjectContext.cpp index 687a9c3e..b8b75d4a 100644 --- a/src/strategy/priest/PriestAiObjectContext.cpp +++ b/src/strategy/priest/PriestAiObjectContext.cpp @@ -158,6 +158,7 @@ class PriestAiObjectContextInternal : public NamedObjectContext creators["divine spirit on party"] = &PriestAiObjectContextInternal::divine_spirit_on_party; creators["power word: shield"] = &PriestAiObjectContextInternal::power_word_shield; creators["power word: shield on party"] = &PriestAiObjectContextInternal::power_word_shield_on_party; + creators["power word: shield on almost full health below"] = &PriestAiObjectContextInternal::power_word_shield_on_almost_full_health_below; creators["renew"] = &PriestAiObjectContextInternal::renew; creators["renew on party"] = &PriestAiObjectContextInternal::renew_on_party; creators["greater heal"] = &PriestAiObjectContextInternal::greater_heal; @@ -247,6 +248,7 @@ class PriestAiObjectContextInternal : public NamedObjectContext static Action* divine_spirit_on_party(PlayerbotAI* botAI) { return new CastDivineSpiritOnPartyAction(botAI); } static Action* power_word_shield(PlayerbotAI* botAI) { return new CastPowerWordShieldAction(botAI); } static Action* power_word_shield_on_party(PlayerbotAI* botAI) { return new CastPowerWordShieldOnPartyAction(botAI); } + static Action* power_word_shield_on_almost_full_health_below(PlayerbotAI* ai) { return new CastPowerWordShieldOnAlmostFullHealthBelow(ai); } static Action* renew(PlayerbotAI* botAI) { return new CastRenewAction(botAI); } static Action* renew_on_party(PlayerbotAI* botAI) { return new CastRenewOnPartyAction(botAI); } static Action* greater_heal(PlayerbotAI* botAI) { return new CastGreaterHealAction(botAI); }