From 09db983a35e6bce13d5c59276d846364d68232bf Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 7 Jan 2024 00:47:20 +0800 Subject: [PATCH] Rogue eviscerate for almost dead enemy --- src/strategy/rogue/DpsRogueStrategy.cpp | 5 +++++ src/strategy/rogue/RogueAiObjectContext.cpp | 2 ++ src/strategy/rogue/RogueTriggers.cpp | 9 +++++++++ src/strategy/rogue/RogueTriggers.h | 9 +++++++++ 4 files changed, 25 insertions(+) diff --git a/src/strategy/rogue/DpsRogueStrategy.cpp b/src/strategy/rogue/DpsRogueStrategy.cpp index ed7f1e06..5c976136 100644 --- a/src/strategy/rogue/DpsRogueStrategy.cpp +++ b/src/strategy/rogue/DpsRogueStrategy.cpp @@ -101,6 +101,11 @@ void DpsRogueStrategy::InitTriggers(std::vector& triggers) NextAction::array(0, new NextAction("rupture", ACTION_HIGH + 1), NULL))); + triggers.push_back(new TriggerNode( + "target with combo points almost dead", + NextAction::array(0, + new NextAction("eviscerate", ACTION_HIGH + 1), NULL))); + triggers.push_back(new TriggerNode( "medium threat", NextAction::array(0, new NextAction("vanish", ACTION_HIGH), NULL))); diff --git a/src/strategy/rogue/RogueAiObjectContext.cpp b/src/strategy/rogue/RogueAiObjectContext.cpp index 5b5b2063..49f8a9d4 100644 --- a/src/strategy/rogue/RogueAiObjectContext.cpp +++ b/src/strategy/rogue/RogueAiObjectContext.cpp @@ -73,6 +73,7 @@ class RogueTriggerFactoryInternal : public NamedObjectContext creators["off hand weapon no enchant"] = &RogueTriggerFactoryInternal::off_hand_weapon_no_enchant; creators["tricks of the trade on main tank"] = &RogueTriggerFactoryInternal::tricks_of_the_trade_on_main_tank; creators["adrenaline rush"] = &RogueTriggerFactoryInternal::adrenaline_rush; + creators["target with combo points almost dead"] =&RogueTriggerFactoryInternal::target_with_combo_points_almost_dead; } private: @@ -91,6 +92,7 @@ class RogueTriggerFactoryInternal : public NamedObjectContext static Trigger* main_hand_weapon_no_enchant(PlayerbotAI* ai) { return new MainHandWeaponNoEnchantTrigger(ai); } static Trigger* off_hand_weapon_no_enchant(PlayerbotAI* ai) { return new OffHandWeaponNoEnchantTrigger(ai); } static Trigger* tricks_of_the_trade_on_main_tank(PlayerbotAI* ai) { return new TricksOfTheTradeOnMainTankTrigger(ai); } + static Trigger* target_with_combo_points_almost_dead(PlayerbotAI* ai) { return new TargetWithComboPointsLowerHealTrigger(ai, 3, 3.0f); } }; class RogueAiObjectContextInternal : public NamedObjectContext diff --git a/src/strategy/rogue/RogueTriggers.cpp b/src/strategy/rogue/RogueTriggers.cpp index 8355dc06..37613672 100644 --- a/src/strategy/rogue/RogueTriggers.cpp +++ b/src/strategy/rogue/RogueTriggers.cpp @@ -3,6 +3,7 @@ */ #include "RogueTriggers.h" +#include "GenericTriggers.h" #include "Playerbots.h" #include "ServerFacade.h" @@ -116,4 +117,12 @@ bool OffHandWeaponNoEnchantTrigger::IsActive() { if (!itemForSpell || itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) return false; return true; +} + +bool TargetWithComboPointsLowerHealTrigger::IsActive() { + Unit* target = AI_VALUE(Unit*, "current target"); + if (!target || !target->IsAlive() || !target->IsInWorld()) { + return false; + } + return ComboPointsAvailableTrigger::IsActive() && (target->GetHealth() / AI_VALUE(float, "expected group dps")) <= lifeTime; } \ No newline at end of file diff --git a/src/strategy/rogue/RogueTriggers.h b/src/strategy/rogue/RogueTriggers.h index 4d494868..c129d279 100644 --- a/src/strategy/rogue/RogueTriggers.h +++ b/src/strategy/rogue/RogueTriggers.h @@ -113,4 +113,13 @@ class TricksOfTheTradeOnMainTankTrigger : public BuffOnMainTankTrigger TricksOfTheTradeOnMainTankTrigger(PlayerbotAI* ai) : BuffOnMainTankTrigger(ai, "tricks of the trade", true) {} }; +class TargetWithComboPointsLowerHealTrigger : public ComboPointsAvailableTrigger +{ + public: + TargetWithComboPointsLowerHealTrigger(PlayerbotAI* ai, int32 combo_point = 5, float lifeTime = 8.0f) : ComboPointsAvailableTrigger(ai, combo_point), lifeTime(lifeTime) {} + bool IsActive() override; + private: + float lifeTime; +}; + #endif