From a44b310c0a603ae93858191b3e074dbdef271620 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Fri, 2 Jun 2023 19:57:08 +0800 Subject: [PATCH] debuff trigger and action, allow multiple spell --- src/PlayerbotAI.cpp | 19 ++++++++++-------- src/PlayerbotAI.h | 2 +- src/PlayerbotMgr.cpp | 2 +- src/strategy/AiObject.h | 14 +++++++++++++ src/strategy/Queue.cpp | 2 +- src/strategy/actions/GenericSpellActions.cpp | 4 ++-- src/strategy/actions/GenericSpellActions.h | 2 +- src/strategy/actions/MovementActions.cpp | 10 +++++----- src/strategy/deathknight/DKActions.h | 6 +++--- src/strategy/deathknight/DKTriggers.h | 12 +++++------ src/strategy/druid/DruidActions.h | 4 ++-- src/strategy/druid/DruidTriggers.h | 6 +++--- src/strategy/generic/CombatStrategy.cpp | 2 +- src/strategy/generic/FollowMasterStrategy.cpp | 2 +- src/strategy/hunter/HunterActions.cpp | 5 ----- src/strategy/hunter/HunterActions.h | 9 ++++----- src/strategy/hunter/HunterTriggers.cpp | 6 ++++-- src/strategy/hunter/HunterTriggers.h | 13 ++++++++---- src/strategy/mage/MageActions.h | 2 +- src/strategy/mage/MageTriggers.h | 6 +++--- src/strategy/priest/PriestActions.h | 8 ++++---- src/strategy/priest/PriestTriggers.h | 10 +++++----- src/strategy/rogue/RogueTriggers.h | 2 +- src/strategy/shaman/ShamanActions.h | 4 ++-- src/strategy/shaman/ShamanTriggers.cpp | 3 ++- src/strategy/shaman/ShamanTriggers.h | 2 +- src/strategy/triggers/GenericTriggers.h | 2 +- .../values/AttackerWithoutAuraTargetValue.cpp | 2 +- src/strategy/warlock/WarlockActions.h | 20 ++++++++++++------- src/strategy/warlock/WarlockTriggers.h | 8 ++++---- src/strategy/warrior/WarriorActions.h | 2 +- src/strategy/warrior/WarriorTriggers.h | 7 +++++-- 32 files changed, 113 insertions(+), 85 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 9fcd0349..6c607480 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -1599,7 +1599,7 @@ bool IsRealAura(Player* bot, AuraEffect const* aurEff, Unit const* unit) return false; } -bool PlayerbotAI::HasAura(std::string const name, Unit* unit, bool maxStack, bool checkIsOwner, int maxAuraAmount) +bool PlayerbotAI::HasAura(std::string const name, Unit* unit, bool maxStack, bool checkIsOwner, int maxAuraAmount, bool checkDuration) { if (!unit) return false; @@ -1628,26 +1628,29 @@ bool PlayerbotAI::HasAura(std::string const name, Unit* unit, bool maxStack, boo if (IsRealAura(bot, aurEff, unit)) { - if (checkIsOwner && aurEff) - { + if (checkIsOwner && aurEff) { if (aurEff->GetCasterGUID() != bot->GetGUID()) continue; } + + if (checkDuration && aurEff) { + if (aurEff->GetBase()->GetDuration() == -1) { + continue; + } + } uint32 maxStackAmount = spellInfo->StackAmount; uint32 maxProcCharges = spellInfo->ProcCharges; - if (maxStack) - { + if (maxStack) { if (maxStackAmount && aurEff->GetBase()->GetStackAmount() >= maxStackAmount) auraAmount++; if (maxProcCharges && aurEff->GetBase()->GetCharges() >= maxProcCharges) auraAmount++; + } else { + auraAmount++; } - - auraAmount++; - if (maxAuraAmount < 0) return auraAmount > 0; } diff --git a/src/PlayerbotAI.h b/src/PlayerbotAI.h index 0b5b000a..661dab7d 100644 --- a/src/PlayerbotAI.h +++ b/src/PlayerbotAI.h @@ -366,7 +366,7 @@ class PlayerbotAI : public PlayerbotAIBase virtual bool CanCastSpell(std::string const name, Unit* target, Item* itemTarget = nullptr); virtual bool CastSpell(std::string const name, Unit* target, Item* itemTarget = nullptr); - virtual bool HasAura(std::string const spellName, Unit* player, bool maxStack = false, bool checkIsOwner = false, int maxAmount = -1); + virtual bool HasAura(std::string const spellName, Unit* player, bool maxStack = false, bool checkIsOwner = false, int maxAmount = -1, bool checkDuration = false); virtual bool HasAnyAuraOf(Unit* player, ...); virtual bool IsInterruptableSpellCasting(Unit* player, std::string const spell); diff --git a/src/PlayerbotMgr.cpp b/src/PlayerbotMgr.cpp index 72774793..39b53188 100644 --- a/src/PlayerbotMgr.cpp +++ b/src/PlayerbotMgr.cpp @@ -430,7 +430,7 @@ void PlayerbotHolder::OnBotLogin(Player* const bot) uint32 accountId = bot->GetSession()->GetAccountId(); bool isRandomAccount = sPlayerbotAIConfig->IsInRandomAccountList(accountId); - if (master && isRandomAccount) { + if (master && isRandomAccount && master->GetLevel() < bot->GetLevel()) { PlayerbotFactory factory(bot, master->getLevel()); factory.Randomize(false); } diff --git a/src/strategy/AiObject.h b/src/strategy/AiObject.h index c066456b..ec78779e 100644 --- a/src/strategy/AiObject.h +++ b/src/strategy/AiObject.h @@ -91,6 +91,13 @@ class clazz : public DebuffTrigger \ clazz(PlayerbotAI* botAI) : DebuffTrigger(botAI, spell) { } \ } +#define DEBUFF_CHECKISOWNER_TRIGGER(clazz, spell) \ +class clazz : public DebuffTrigger \ +{ \ + public: \ + clazz(PlayerbotAI* botAI) : DebuffTrigger(botAI, spell, 1, true) { } \ +} + #define DEBUFF_TRIGGER_A(clazz, spell) \ class clazz : public DebuffTrigger \ { \ @@ -359,6 +366,13 @@ class clazz : public CastDebuffSpellAction \ clazz(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, spell) { } \ } +#define DEBUFF_CHECKISOWNER_ACTION(clazz, spell) \ +class clazz : public CastDebuffSpellAction \ +{ \ + public: \ + clazz(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, spell, true) { } \ +} + #define DEBUFF_ACTION_U(clazz, spell, useful) \ class clazz : public CastDebuffSpellAction \ { \ diff --git a/src/strategy/Queue.cpp b/src/strategy/Queue.cpp index 89a3618f..91c46895 100644 --- a/src/strategy/Queue.cpp +++ b/src/strategy/Queue.cpp @@ -97,7 +97,7 @@ void Queue::RemoveExpired() if (ActionNode* action = basket->getAction()) { - LOG_DEBUG("playerbots", "Action {} is expired", action->getName().c_str()); + // LOG_DEBUG("playerbots", "Action {} is expired", action->getName().c_str()); delete action; } diff --git a/src/strategy/actions/GenericSpellActions.cpp b/src/strategy/actions/GenericSpellActions.cpp index c33321f4..323d3b5c 100644 --- a/src/strategy/actions/GenericSpellActions.cpp +++ b/src/strategy/actions/GenericSpellActions.cpp @@ -118,7 +118,7 @@ CastMeleeSpellAction::CastMeleeSpellAction(PlayerbotAI* botAI, std::string const bool CastAuraSpellAction::isUseful() { - return GetTarget() && (GetTarget() != nullptr) && (GetTarget() != nullptr) && CastSpellAction::isUseful() && !botAI->HasAura(spell, GetTarget(), true); + return GetTarget() && (GetTarget() != nullptr) && (GetTarget() != nullptr) && CastSpellAction::isUseful() && !botAI->HasAura(spell, GetTarget(), true, isOwner); } CastEnchantItemAction::CastEnchantItemAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell) @@ -135,7 +135,7 @@ bool CastEnchantItemAction::isPossible() return spellId && AI_VALUE2(Item*, "item for spell", spellId); } -CastHealingSpellAction::CastHealingSpellAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount) : CastAuraSpellAction(botAI, spell), estAmount(estAmount) +CastHealingSpellAction::CastHealingSpellAction(PlayerbotAI* botAI, std::string const spell, uint8 estAmount) : CastAuraSpellAction(botAI, spell, true), estAmount(estAmount) { range = botAI->GetRange("spell"); } diff --git a/src/strategy/actions/GenericSpellActions.h b/src/strategy/actions/GenericSpellActions.h index 98e98ee3..db1f393c 100644 --- a/src/strategy/actions/GenericSpellActions.h +++ b/src/strategy/actions/GenericSpellActions.h @@ -56,7 +56,7 @@ class CastDebuffSpellAction : public CastAuraSpellAction class CastDebuffSpellOnAttackerAction : public CastAuraSpellAction { public: - CastDebuffSpellOnAttackerAction(PlayerbotAI* botAI, std::string const spell, bool isOwner = false) : CastAuraSpellAction(botAI, spell, isOwner) { } + CastDebuffSpellOnAttackerAction(PlayerbotAI* botAI, std::string const spell, bool isOwner = true) : CastAuraSpellAction(botAI, spell, isOwner) { } Value* GetTargetValue() override; std::string const getName() override { return spell + " on attacker"; } diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index 7274317d..0da2153b 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -129,7 +129,7 @@ bool MovementAction::MoveToLOS(WorldObject* target, bool ranged) bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, bool react) { UpdateMovementState(); - LOG_DEBUG("playerbots", "IsMovingAllowed {}", IsMovingAllowed()); + // LOG_DEBUG("playerbots", "IsMovingAllowed {}", IsMovingAllowed()); if (!IsMovingAllowed()) return false; @@ -478,7 +478,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, sPlayerbotAIConfig->log("bot_movement.csv", out.str().c_str()); } - LOG_DEBUG("playerbots", "({}, {}) -> ({}, {})", startPosition.getX(), startPosition.getY(), movePosition.getX(), movePosition.getY()); + // LOG_DEBUG("playerbots", "({}, {}) -> ({}, {})", startPosition.getX(), startPosition.getY(), movePosition.getX(), movePosition.getY()); if (!react) if (totalDistance > maxDist) WaitForReach(startPosition.distance(movePosition) - 10.0f); @@ -543,13 +543,13 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, bot->SetWalk(true); bot->SendMovementFlagUpdate(); - LOG_DEBUG("playerbots", "normal move? {} {} {}", !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !bot->HasAuraType(SPELL_AURA_FLY), - bot->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE), bot->getStandState()); + // LOG_DEBUG("playerbots", "normal move? {} {} {}", !bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !bot->HasAuraType(SPELL_AURA_FLY), + // bot->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE), bot->getStandState()); if (!bot->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !bot->HasAuraType(SPELL_AURA_FLY)) { bot->SetWalk(masterWalking); bot->GetMotionMaster()->MovePoint(movePosition.getMapId(), movePosition.getX(), movePosition.getY(), movePosition.getZ(), generatePath); - LOG_DEBUG("playerbots", "Movepoint to ({}, {})", movePosition.getX(), movePosition.getY()); + // LOG_DEBUG("playerbots", "Movepoint to ({}, {})", movePosition.getX(), movePosition.getY()); } else { diff --git a/src/strategy/deathknight/DKActions.h b/src/strategy/deathknight/DKActions.h index 6f28a9aa..5b73957f 100644 --- a/src/strategy/deathknight/DKActions.h +++ b/src/strategy/deathknight/DKActions.h @@ -94,7 +94,7 @@ END_SPELL_ACTION() class CastIcyTouchOnAttackerAction : public CastDebuffSpellOnAttackerAction { public: - CastIcyTouchOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "icy touch") { } + CastIcyTouchOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "icy touch", true) { } }; //debuff ps @@ -104,7 +104,7 @@ END_SPELL_ACTION() class CastPlagueStrikeOnAttackerAction : public CastDebuffSpellOnAttackerAction { public: - CastPlagueStrikeOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "plague strike") { } + CastPlagueStrikeOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "plague strike", true) { } }; //debuff @@ -114,7 +114,7 @@ END_SPELL_ACTION() class CastMarkOfBloodOnAttackerAction : public CastDebuffSpellOnAttackerAction { public: - CastMarkOfBloodOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "mark of blood") { } + CastMarkOfBloodOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "mark of blood", true) { } }; class CastUnholyBlightAction : public CastBuffSpellAction diff --git a/src/strategy/deathknight/DKTriggers.h b/src/strategy/deathknight/DKTriggers.h index 9a3a4a9a..c71f93a4 100644 --- a/src/strategy/deathknight/DKTriggers.h +++ b/src/strategy/deathknight/DKTriggers.h @@ -12,19 +12,19 @@ class PlayerbotAI; BUFF_TRIGGER(HornOfWinterTrigger, "horn of winter"); BUFF_TRIGGER(BoneShieldTrigger, "bone shield"); BUFF_TRIGGER(ImprovedIcyTalonsTrigger, "improved icy talons"); -DEBUFF_TRIGGER(PlagueStrikeDebuffTrigger, "plague strike"); -DEBUFF_TRIGGER(IcyTouchDebuffTrigger, "icy touch"); +DEBUFF_CHECKISOWNER_TRIGGER(PlagueStrikeDebuffTrigger, "plague strike"); +DEBUFF_CHECKISOWNER_TRIGGER(IcyTouchDebuffTrigger, "icy touch"); class PlagueStrikeDebuffOnAttackerTrigger : public DebuffOnAttackerTrigger { public: - PlagueStrikeDebuffOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "plague strike") { } + PlagueStrikeDebuffOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "plague strike", true) { } }; class IcyTouchDebuffOnAttackerTrigger : public DebuffOnAttackerTrigger { public: - IcyTouchDebuffOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "icy touch") { } + IcyTouchDebuffOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "icy touch", true) { } }; class DKPresenceTrigger : public BuffTrigger @@ -68,13 +68,13 @@ class PestilenceTrigger : public DebuffTrigger class BloodStrikeTrigger : public DebuffTrigger { public: - BloodStrikeTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "blood strike") { } + BloodStrikeTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "blood strike", 1, true) { } }; class HowlingBlastTrigger : public DebuffTrigger { public: - HowlingBlastTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "howling blast") { } + HowlingBlastTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "howling blast", 1, true) { } }; class MindFreezeInterruptSpellTrigger : public InterruptSpellTrigger diff --git a/src/strategy/druid/DruidActions.h b/src/strategy/druid/DruidActions.h index 372ebead..3aceea96 100644 --- a/src/strategy/druid/DruidActions.h +++ b/src/strategy/druid/DruidActions.h @@ -134,13 +134,13 @@ class CastHurricaneAction : public CastSpellAction class CastMoonfireAction : public CastDebuffSpellAction { public: - CastMoonfireAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "moonfire") { } + CastMoonfireAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "moonfire", true) { } }; class CastInsectSwarmAction : public CastDebuffSpellAction { public: - CastInsectSwarmAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "insect swarm") { } + CastInsectSwarmAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "insect swarm", true) { } }; class CastStarfireAction : public CastSpellAction diff --git a/src/strategy/druid/DruidTriggers.h b/src/strategy/druid/DruidTriggers.h index 6f0381ad..4d47db58 100644 --- a/src/strategy/druid/DruidTriggers.h +++ b/src/strategy/druid/DruidTriggers.h @@ -51,19 +51,19 @@ class OmenOfClarityTrigger : public BuffTrigger class RakeTrigger : public DebuffTrigger { public: - RakeTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "rake") { } + RakeTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "rake", 1, true) { } }; class InsectSwarmTrigger : public DebuffTrigger { public: - InsectSwarmTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "insect swarm") { } + InsectSwarmTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "insect swarm", 1, true) { } }; class MoonfireTrigger : public DebuffTrigger { public: - MoonfireTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "moonfire") { } + MoonfireTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "moonfire", 1, true) { } bool IsActive() override; }; diff --git a/src/strategy/generic/CombatStrategy.cpp b/src/strategy/generic/CombatStrategy.cpp index 39064765..96b65e59 100644 --- a/src/strategy/generic/CombatStrategy.cpp +++ b/src/strategy/generic/CombatStrategy.cpp @@ -10,7 +10,7 @@ void CombatStrategy::InitTriggers(std::vector &triggers) triggers.push_back(new TriggerNode("enemy out of spell", NextAction::array(0, new NextAction("reach spell", ACTION_MOVE + 11), nullptr))); triggers.push_back(new TriggerNode("invalid target", NextAction::array(0, new NextAction("drop target", 100), nullptr))); triggers.push_back(new TriggerNode("mounted", NextAction::array(0, new NextAction("check mount state", 54), nullptr))); - triggers.push_back(new TriggerNode("out of react range", NextAction::array(0, new NextAction("flee to master", 55), nullptr))); + // triggers.push_back(new TriggerNode("out of react range", NextAction::array(0, new NextAction("flee to master", 55), nullptr))); triggers.push_back(new TriggerNode("combat stuck", NextAction::array(0, new NextAction("reset", 1.0f), nullptr))); // triggers.push_back(new TriggerNode("combat long stuck", NextAction::array(0, new NextAction("hearthstone", 0.9f), new NextAction("repop", 0.8f), nullptr))); } diff --git a/src/strategy/generic/FollowMasterStrategy.cpp b/src/strategy/generic/FollowMasterStrategy.cpp index f57a4286..4b4651e1 100644 --- a/src/strategy/generic/FollowMasterStrategy.cpp +++ b/src/strategy/generic/FollowMasterStrategy.cpp @@ -12,5 +12,5 @@ NextAction** FollowMasterStrategy::getDefaultActions() void FollowMasterStrategy::InitTriggers(std::vector& triggers) { - triggers.push_back(new TriggerNode("out of react range", NextAction::array(0, new NextAction("flee to master", ACTION_HIGH), nullptr))); + // triggers.push_back(new TriggerNode("out of react range", NextAction::array(0, new NextAction("flee to master", ACTION_HIGH), nullptr))); } diff --git a/src/strategy/hunter/HunterActions.cpp b/src/strategy/hunter/HunterActions.cpp index 1c7a5554..1bbe3d3d 100644 --- a/src/strategy/hunter/HunterActions.cpp +++ b/src/strategy/hunter/HunterActions.cpp @@ -6,11 +6,6 @@ #include "Event.h" #include "Playerbots.h" -bool CastSerpentStingAction::isUseful() -{ - return AI_VALUE2(uint8, "health", "current target") > 50; -} - bool CastViperStingAction::isUseful() { return AI_VALUE2(uint8, "mana", "self target") < 50 && AI_VALUE2(uint8, "mana", "current target") >= 30; diff --git a/src/strategy/hunter/HunterActions.h b/src/strategy/hunter/HunterActions.h index 91e58798..5c82e5e6 100644 --- a/src/strategy/hunter/HunterActions.h +++ b/src/strategy/hunter/HunterActions.h @@ -5,6 +5,7 @@ #ifndef _PLAYERBOT_HUNTERACTIONS_H #define _PLAYERBOT_HUNTERACTIONS_H +#include "AiObject.h" #include "GenericSpellActions.h" class PlayerbotAI; @@ -48,9 +49,7 @@ END_SPELL_ACTION() BEGIN_RANGED_SPELL_ACTION(CastVolleyAction, "volley") END_SPELL_ACTION() -BEGIN_RANGED_SPELL_ACTION(CastSerpentStingAction, "serpent sting") -bool isUseful() override; -END_SPELL_ACTION() +DEBUFF_CHECKISOWNER_ACTION(CastSerpentStingAction, "serpent sting"); BEGIN_RANGED_SPELL_ACTION(CastWyvernStingAction, "wyvern sting") END_SPELL_ACTION() @@ -156,7 +155,7 @@ class CastReadinessAction : public CastBuffSpellAction class CastBlackArrow : public CastDebuffSpellAction { public: - CastBlackArrow(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "black arrow") { } + CastBlackArrow(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "black arrow", true) { } }; class CastFreezingTrap : public CastDebuffSpellAction @@ -187,7 +186,7 @@ class CastRaptorStrikeAction : public CastMeleeSpellAction class CastSerpentStingOnAttackerAction : public CastDebuffSpellOnAttackerAction { public: - CastSerpentStingOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "serpent sting") { } + CastSerpentStingOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "serpent sting", true) { } }; class FeedPetAction : public Action diff --git a/src/strategy/hunter/HunterTriggers.cpp b/src/strategy/hunter/HunterTriggers.cpp index 57259306..94b7589d 100644 --- a/src/strategy/hunter/HunterTriggers.cpp +++ b/src/strategy/hunter/HunterTriggers.cpp @@ -18,8 +18,10 @@ bool HunterAspectOfTheHawkTrigger::IsActive() bool HunterNoStingsActiveTrigger::IsActive() { Unit* target = AI_VALUE(Unit*, "current target"); - return target && AI_VALUE2(uint8, "health", "current target") > 40 && !botAI->HasAura("serpent sting", target) && - !botAI->HasAura("scorpid sting", target) && !botAI->HasAura("viper sting", target); + return target && AI_VALUE2(uint8, "health", "current target") > 15 && + !botAI->HasAura("serpent sting", target, false, true) && + !botAI->HasAura("scorpid sting", target, false, true) && + !botAI->HasAura("viper sting", target, false, true); } bool HuntersPetDeadTrigger::IsActive() diff --git a/src/strategy/hunter/HunterTriggers.h b/src/strategy/hunter/HunterTriggers.h index f02154d7..c022a05c 100644 --- a/src/strategy/hunter/HunterTriggers.h +++ b/src/strategy/hunter/HunterTriggers.h @@ -6,11 +6,16 @@ #define _PLAYERBOT_HUNTERTRIGGERS_H #include "GenericTriggers.h" +#include "Trigger.h" class PlayerbotAI; -BEGIN_TRIGGER(HunterNoStingsActiveTrigger, Trigger) -END_TRIGGER() +class HunterNoStingsActiveTrigger : public Trigger +{ + public: + HunterNoStingsActiveTrigger(PlayerbotAI* botAI): Trigger(botAI, "no stings") {} + bool IsActive() override; +}; class AutoShotTrigger : public Trigger { @@ -58,7 +63,7 @@ END_TRIGGER() class BlackArrowTrigger : public DebuffTrigger { public: - BlackArrowTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "black arrow") { } + BlackArrowTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "black arrow", 1, true) { } }; class HuntersMarkTrigger : public DebuffTrigger @@ -88,7 +93,7 @@ class TrueshotAuraTrigger : public BuffTrigger class SerpentStingOnAttackerTrigger : public DebuffOnAttackerTrigger { public: - SerpentStingOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "serpent sting") { } + SerpentStingOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "serpent sting", true) { } }; BEGIN_TRIGGER(HunterPetNotHappy, Trigger) diff --git a/src/strategy/mage/MageActions.h b/src/strategy/mage/MageActions.h index 71b96cc3..46d495ac 100644 --- a/src/strategy/mage/MageActions.h +++ b/src/strategy/mage/MageActions.h @@ -195,7 +195,7 @@ class CastSpellstealAction : public CastSpellAction class CastLivingBombAction : public CastDebuffSpellAction { public: - CastLivingBombAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "living bomb") { } + CastLivingBombAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "living bomb", true) { } }; class CastDragonsBreathAction : public CastSpellAction diff --git a/src/strategy/mage/MageTriggers.h b/src/strategy/mage/MageTriggers.h index eda23244..e1de795b 100644 --- a/src/strategy/mage/MageTriggers.h +++ b/src/strategy/mage/MageTriggers.h @@ -40,19 +40,19 @@ class MageArmorTrigger : public BuffTrigger class LivingBombTrigger : public DebuffTrigger { public: - LivingBombTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "living bomb") { } + LivingBombTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "living bomb", 1, true) { } }; class FireballTrigger : public DebuffTrigger { public: - FireballTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "fireball") { } + FireballTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "fireball", 1, true) { } }; class PyroblastTrigger : public DebuffTrigger { public: - PyroblastTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "pyroblast") { } + PyroblastTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "pyroblast", 1, true) { } }; class HotStreakTrigger : public HasAuraTrigger diff --git a/src/strategy/priest/PriestActions.h b/src/strategy/priest/PriestActions.h index 30a6ae77..3fe1d4b4 100644 --- a/src/strategy/priest/PriestActions.h +++ b/src/strategy/priest/PriestActions.h @@ -66,13 +66,13 @@ CURE_PARTY_ACTION(CastCureDiseaseOnPartyAction, "cure disease", DISPEL_DISEASE); CURE_ACTION(CastAbolishDiseaseAction, "abolish disease"); CURE_PARTY_ACTION(CastAbolishDiseaseOnPartyAction, "abolish disease", DISPEL_DISEASE); -DEBUFF_ACTION(CastHolyFireAction, "holy fire"); +DEBUFF_CHECKISOWNER_ACTION(CastHolyFireAction, "holy fire"); // shadow 2.4.3 BUFF_ACTION(CastShadowfiendAction, "shadowfiend"); SPELL_ACTION(CastShadowWordDeathAction, "shadow word: death"); // shadow -DEBUFF_ACTION(CastPowerWordPainAction, "shadow word: pain"); +DEBUFF_CHECKISOWNER_ACTION(CastPowerWordPainAction, "shadow word: pain"); DEBUFF_ENEMY_ACTION(CastPowerWordPainOnAttackerAction, "shadow word: pain"); SPELL_ACTION(CastMindBlastAction, "mind blast"); SPELL_ACTION(CastPsychicScreamAction, "psychic scream"); @@ -89,10 +89,10 @@ BUFF_ACTION(CastShadowformAction, "shadowform"); SPELL_ACTION(CastSilenceAction, "silence"); ENEMY_HEALER_ACTION(CastSilenceOnEnemyHealerAction, "silence"); // shadow talents 2.4.3 -DEBUFF_ACTION(CastVampiricTouchAction, "vampiric touch"); +DEBUFF_CHECKISOWNER_ACTION(CastVampiricTouchAction, "vampiric touch"); // racials -DEBUFF_ACTION(CastDevouringPlagueAction, "devouring plague"); +DEBUFF_CHECKISOWNER_ACTION(CastDevouringPlagueAction, "devouring plague"); BUFF_ACTION(CastTouchOfWeaknessAction, "touch of weakness"); DEBUFF_ACTION(CastHexOfWeaknessAction, "hex of weakness"); BUFF_ACTION(CastShadowguardAction, "shadowguard"); diff --git a/src/strategy/priest/PriestTriggers.h b/src/strategy/priest/PriestTriggers.h index 77b8f411..717c4d90 100644 --- a/src/strategy/priest/PriestTriggers.h +++ b/src/strategy/priest/PriestTriggers.h @@ -10,11 +10,11 @@ class PlayerbotAI; -DEBUFF_TRIGGER(HolyFireTrigger, "holy fire"); -DEBUFF_TRIGGER(PowerWordPainTrigger, "shadow word: pain"); +DEBUFF_CHECKISOWNER_TRIGGER(HolyFireTrigger, "holy fire"); +DEBUFF_CHECKISOWNER_TRIGGER(PowerWordPainTrigger, "shadow word: pain"); DEBUFF_ENEMY_TRIGGER(PowerWordPainOnAttackerTrigger, "shadow word: pain"); -DEBUFF_TRIGGER(VampiricTouchTrigger, "vampiric touch"); -DEBUFF_TRIGGER(VampiricEmbraceTrigger, "vampiric embrace"); +DEBUFF_CHECKISOWNER_TRIGGER(VampiricTouchTrigger, "vampiric touch"); +BUFF_TRIGGER(VampiricEmbraceTrigger, "vampiric embrace"); CURE_TRIGGER(DispelMagicTrigger, "dispel magic", DISPEL_MAGIC); CURE_PARTY_TRIGGER(DispelMagicPartyMemberTrigger, "dispel magic", DISPEL_MAGIC); CURE_TRIGGER(CureDiseaseTrigger, "cure disease", DISPEL_DISEASE); @@ -30,7 +30,7 @@ INTERRUPT_TRIGGER(SilenceTrigger, "silence"); INTERRUPT_HEALER_TRIGGER(SilenceEnemyHealerTrigger, "silence"); // racials -DEBUFF_TRIGGER(DevouringPlagueTrigger, "devouring plague"); +DEBUFF_CHECKISOWNER_TRIGGER(DevouringPlagueTrigger, "devouring plague"); BUFF_TRIGGER(TouchOfWeaknessTrigger, "touch of weakness"); DEBUFF_TRIGGER(HexOfWeaknessTrigger, "hex of weakness"); BUFF_TRIGGER(ShadowguardTrigger, "shadowguard"); diff --git a/src/strategy/rogue/RogueTriggers.h b/src/strategy/rogue/RogueTriggers.h index 671cb4ea..76115d08 100644 --- a/src/strategy/rogue/RogueTriggers.h +++ b/src/strategy/rogue/RogueTriggers.h @@ -32,7 +32,7 @@ class AdrenalineRushTrigger : public BuffTrigger class RuptureTrigger : public DebuffTrigger { public: - RuptureTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "rupture") { } + RuptureTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "rupture", 1, true) { } }; class ExposeArmorTrigger : public DebuffTrigger diff --git a/src/strategy/shaman/ShamanActions.h b/src/strategy/shaman/ShamanActions.h index 03a2cfd0..69f03999 100644 --- a/src/strategy/shaman/ShamanActions.h +++ b/src/strategy/shaman/ShamanActions.h @@ -291,13 +291,13 @@ class CastCleanseSpiritDiseaseOnPartyAction : public CurePartyMemberAction class CastFlameShockAction : public CastDebuffSpellAction { public: - CastFlameShockAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "flame shock") { } + CastFlameShockAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "flame shock", true) { } }; class CastEarthShockAction : public CastDebuffSpellAction { public: - CastEarthShockAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "earth shock") { } + CastEarthShockAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "earth shock", true) { } }; class CastFrostShockAction : public CastSnareSpellAction diff --git a/src/strategy/shaman/ShamanTriggers.cpp b/src/strategy/shaman/ShamanTriggers.cpp index ddc4b9b0..a7f9778b 100644 --- a/src/strategy/shaman/ShamanTriggers.cpp +++ b/src/strategy/shaman/ShamanTriggers.cpp @@ -33,7 +33,8 @@ bool ShamanWeaponTrigger::IsActive() bool ShockTrigger::IsActive() { - return SpellTrigger::IsActive() && !botAI->HasAnyAuraOf(GetTarget(), "frost shock", "earth shock", "flame shock", nullptr); + return SpellTrigger::IsActive() && !botAI->HasAura("flame shock", GetTarget(), false, true) && + !botAI->HasAura("frost shock", GetTarget(), false, true); } bool TotemTrigger::IsActive() diff --git a/src/strategy/shaman/ShamanTriggers.h b/src/strategy/shaman/ShamanTriggers.h index 47864f59..5b0f9eb9 100644 --- a/src/strategy/shaman/ShamanTriggers.h +++ b/src/strategy/shaman/ShamanTriggers.h @@ -171,7 +171,7 @@ class PartyMemberCleanseSpiritDiseaseTrigger : public PartyMemberNeedCureTrigger class ShockTrigger : public DebuffTrigger { public: - ShockTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "earth shock") { } + ShockTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "earth shock", 1, true) { } bool IsActive() override; }; diff --git a/src/strategy/triggers/GenericTriggers.h b/src/strategy/triggers/GenericTriggers.h index d2852e9a..e9a0bd8f 100644 --- a/src/strategy/triggers/GenericTriggers.h +++ b/src/strategy/triggers/GenericTriggers.h @@ -315,7 +315,7 @@ class DebuffTrigger : public BuffTrigger class DebuffOnAttackerTrigger : public DebuffTrigger { public: - DebuffOnAttackerTrigger(PlayerbotAI* botAI, std::string const spell) : DebuffTrigger(botAI, spell) { } + DebuffOnAttackerTrigger(PlayerbotAI* botAI, std::string const spell, bool checkIsOwner = true) : DebuffTrigger(botAI, spell, 1, checkIsOwner) { } Value* GetTargetValue() override; std::string const getName() override { return spell + " on attacker"; } diff --git a/src/strategy/values/AttackerWithoutAuraTargetValue.cpp b/src/strategy/values/AttackerWithoutAuraTargetValue.cpp index d831ac0b..481f3e0f 100644 --- a/src/strategy/values/AttackerWithoutAuraTargetValue.cpp +++ b/src/strategy/values/AttackerWithoutAuraTargetValue.cpp @@ -18,7 +18,7 @@ Unit* AttackerWithoutAuraTargetValue::Calculate() if (bot->GetDistance(unit) > botAI->GetRange("spell")) continue; - if (!botAI->HasAura(qualifier, unit)) + if (!botAI->HasAura(qualifier, unit, false, true)) return unit; } diff --git a/src/strategy/warlock/WarlockActions.h b/src/strategy/warlock/WarlockActions.h index da3648f8..71fd5faa 100644 --- a/src/strategy/warlock/WarlockActions.h +++ b/src/strategy/warlock/WarlockActions.h @@ -54,7 +54,7 @@ class CastDrainLifeAction : public CastSpellAction class CastCurseOfAgonyAction : public CastDebuffSpellAction { public: - CastCurseOfAgonyAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "curse of agony") { } + CastCurseOfAgonyAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "curse of agony", true) { } }; class CastCurseOfWeaknessAction : public CastDebuffSpellAction @@ -66,19 +66,19 @@ class CastCurseOfWeaknessAction : public CastDebuffSpellAction class CastCorruptionAction : public CastDebuffSpellAction { public: - CastCorruptionAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "corruption") { } + CastCorruptionAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "corruption", true) { } }; class CastCorruptionOnAttackerAction : public CastDebuffSpellOnAttackerAction { public: - CastCorruptionOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "corruption") { } + CastCorruptionOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "corruption", true) { } }; class CastCurseOfAgonyOnAttackerAction : public CastDebuffSpellOnAttackerAction { public: - CastCurseOfAgonyOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "curse of agony") { } + CastCurseOfAgonyOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "curse of agony", true) { } }; class CastSummonVoidwalkerAction : public CastBuffSpellAction @@ -135,7 +135,7 @@ class CastBanishAction : public CastBuffSpellAction class CastSeedOfCorruptionAction : public CastDebuffSpellAction { public: - CastSeedOfCorruptionAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "seed of corruption") { } + CastSeedOfCorruptionAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "seed of corruption", true) { } }; class CastRainOfFireAction : public CastSpellAction @@ -153,7 +153,13 @@ class CastShadowfuryAction : public CastSpellAction class CastImmolateAction : public CastDebuffSpellAction { public: - CastImmolateAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "immolate") { } + CastImmolateAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "immolate", true) { } +}; + +class CastImmolateOnAttackerAction : public CastDebuffSpellOnAttackerAction +{ + public: + CastImmolateOnAttackerAction(PlayerbotAI* botAI) : CastDebuffSpellOnAttackerAction(botAI, "immolate", true) { } }; class CastConflagrateAction : public CastSpellAction @@ -203,7 +209,7 @@ class CastAmplifyCurseAction : public CastBuffSpellAction class CastSiphonLifeAction : public CastDebuffSpellAction { public: - CastSiphonLifeAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "siphon life") { } + CastSiphonLifeAction(PlayerbotAI* botAI) : CastDebuffSpellAction(botAI, "siphon life", true) { } }; class CastSiphonLifeOnAttackerAction : public CastDebuffSpellOnAttackerAction diff --git a/src/strategy/warlock/WarlockTriggers.h b/src/strategy/warlock/WarlockTriggers.h index c71ba93a..f622eeac 100644 --- a/src/strategy/warlock/WarlockTriggers.h +++ b/src/strategy/warlock/WarlockTriggers.h @@ -25,9 +25,9 @@ class SpellstoneTrigger : public BuffTrigger bool IsActive() override; }; -DEBUFF_TRIGGER(CurseOfAgonyTrigger, "curse of agony"); -DEBUFF_TRIGGER(CorruptionTrigger, "corruption"); -DEBUFF_TRIGGER(SiphonLifeTrigger, "siphon life"); +DEBUFF_CHECKISOWNER_TRIGGER(CurseOfAgonyTrigger, "curse of agony"); +DEBUFF_CHECKISOWNER_TRIGGER(CorruptionTrigger, "corruption"); +DEBUFF_CHECKISOWNER_TRIGGER(SiphonLifeTrigger, "siphon life"); class CorruptionOnAttackerTrigger : public DebuffOnAttackerTrigger { @@ -47,7 +47,7 @@ class SiphonLifeOnAttackerTrigger : public DebuffOnAttackerTrigger SiphonLifeOnAttackerTrigger(PlayerbotAI* botAI) : DebuffOnAttackerTrigger(botAI, "siphon life") { } }; -DEBUFF_TRIGGER(ImmolateTrigger, "immolate"); +DEBUFF_CHECKISOWNER_TRIGGER(ImmolateTrigger, "immolate"); class ShadowTranceTrigger : public HasAuraTrigger { diff --git a/src/strategy/warrior/WarriorActions.h b/src/strategy/warrior/WarriorActions.h index c6d2972b..099e1ce3 100644 --- a/src/strategy/warrior/WarriorActions.h +++ b/src/strategy/warrior/WarriorActions.h @@ -27,7 +27,7 @@ BUFF_ACTION(CastCommandingShoutAction, "commanding shout"); // arms MELEE_ACTION(CastHeroicStrikeAction, "heroic strike"); REACH_ACTION(CastChargeAction, "charge", 8.0f); -DEBUFF_ACTION(CastRendAction, "rend"); +DEBUFF_CHECKISOWNER_ACTION(CastRendAction, "rend"); DEBUFF_ENEMY_ACTION(CastRendOnAttackerAction, "rend"); DEBUFF_ACTION_R(CastThunderClapAction, "thunder clap", 8.0f); SNARE_ACTION(CastThunderClapSnareAction, "thunder clap"); diff --git a/src/strategy/warrior/WarriorTriggers.h b/src/strategy/warrior/WarriorTriggers.h index 71654813..3aecd091 100644 --- a/src/strategy/warrior/WarriorTriggers.h +++ b/src/strategy/warrior/WarriorTriggers.h @@ -13,8 +13,6 @@ BUFF_TRIGGER(DefensiveStanceTrigger, "defensive stance"); BUFF_TRIGGER(BerserkerStanceTrigger, "berserker stance"); BUFF_TRIGGER(ShieldBlockTrigger, "shield block"); BUFF_TRIGGER(CommandingShoutTrigger, "commanding shout"); - -DEBUFF_TRIGGER(RendDebuffTrigger, "rend"); DEBUFF_TRIGGER(DisarmDebuffTrigger, "disarm"); DEBUFF_TRIGGER(SunderArmorDebuffTrigger, "sunder armor"); DEBUFF_TRIGGER(MortalStrikeDebuffTrigger, "mortal strike"); @@ -49,4 +47,9 @@ HAS_AURA_TRIGGER(SuddenDeathTrigger, "sudden death"); HAS_AURA_TRIGGER(SlamInstantTrigger, "slam!"); HAS_AURA_TRIGGER(TasteForBloodTrigger, "taste for blood"); +class RendDebuffTrigger : public DebuffTrigger +{ + public: + RendDebuffTrigger(PlayerbotAI* botAI) : DebuffTrigger(botAI, "rend", 1, true) { } +}; #endif