From dba908be9e7d583e81b46646793357cf7ba051c1 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Mon, 28 Aug 2023 21:21:58 +0800 Subject: [PATCH] bwl strategy --- src/strategy/AiObjectContext.cpp | 10 +++++-- src/strategy/StrategyContext.h | 1 - src/strategy/actions/ChatActionContext.h | 3 ++ src/strategy/actions/ChatShortcutActions.cpp | 15 +++++++++- src/strategy/actions/ChatShortcutActions.h | 7 +++++ .../generic/ChatCommandHandlerStrategy.cpp | 1 + src/strategy/raids/RaidActionContext.h | 5 ++++ src/strategy/raids/RaidStrategyContext.h | 5 +++- src/strategy/raids/RaidTriggerContext.h | 24 +++++++++++++++ .../raids/blackwinglair/RaidBwlActions.cpp | 30 +++++++++++++++++++ .../raids/blackwinglair/RaidBwlActions.h | 26 ++++++++++++++++ .../raids/blackwinglair/RaidBwlStrategy.cpp | 13 ++++++++ .../raids/blackwinglair/RaidBwlStrategy.h | 19 ++++++++++++ .../raids/blackwinglair/RaidBwlTriggers.cpp | 18 +++++++++++ .../raids/blackwinglair/RaidBwlTriggers.h | 15 ++++++++++ .../raids/naxxramas/RaidNaxxActions.cpp | 10 ++----- .../raids/naxxramas/RaidNaxxTriggers.h | 12 ++++---- src/strategy/triggers/ChatTriggerContext.h | 2 ++ 18 files changed, 196 insertions(+), 20 deletions(-) create mode 100644 src/strategy/raids/blackwinglair/RaidBwlActions.cpp create mode 100644 src/strategy/raids/blackwinglair/RaidBwlActions.h create mode 100644 src/strategy/raids/blackwinglair/RaidBwlStrategy.cpp create mode 100644 src/strategy/raids/blackwinglair/RaidBwlStrategy.h create mode 100644 src/strategy/raids/blackwinglair/RaidBwlTriggers.cpp create mode 100644 src/strategy/raids/blackwinglair/RaidBwlTriggers.h diff --git a/src/strategy/AiObjectContext.cpp b/src/strategy/AiObjectContext.cpp index 8c0e85b8..b65c5370 100644 --- a/src/strategy/AiObjectContext.cpp +++ b/src/strategy/AiObjectContext.cpp @@ -13,9 +13,11 @@ #include "WorldPacketTriggerContext.h" #include "ValueContext.h" #include "Playerbots.h" -#include "RaidStrategyContext.h" -#include "RaidNaxxActionContext.h" -#include "RaidNaxxTriggerContext.h" +#include "raids/RaidTriggerContext.h" +#include "raids/RaidActionContext.h" +#include "raids/RaidStrategyContext.h" +#include "raids/naxxramas/RaidNaxxActionContext.h" +#include "raids/naxxramas/RaidNaxxTriggerContext.h" AiObjectContext::AiObjectContext(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) { @@ -28,11 +30,13 @@ AiObjectContext::AiObjectContext(PlayerbotAI* botAI) : PlayerbotAIAware(botAI) actionContexts.Add(new ActionContext()); actionContexts.Add(new ChatActionContext()); actionContexts.Add(new WorldPacketActionContext()); + actionContexts.Add(new RaidActionContext()); actionContexts.Add(new RaidNaxxActionContext()); triggerContexts.Add(new TriggerContext()); triggerContexts.Add(new ChatTriggerContext()); triggerContexts.Add(new WorldPacketTriggerContext()); + triggerContexts.Add(new RaidTriggerContext()); triggerContexts.Add(new RaidNaxxTriggerContext()); valueContexts.Add(new ValueContext()); diff --git a/src/strategy/StrategyContext.h b/src/strategy/StrategyContext.h index 649ddca9..318e5387 100644 --- a/src/strategy/StrategyContext.h +++ b/src/strategy/StrategyContext.h @@ -47,7 +47,6 @@ #include "UseFoodStrategy.h" #include "UsePotionsStrategy.h" #include "WorldPacketHandlerStrategy.h" -#include "RaidNaxxStrategy.h" class StrategyContext : public NamedObjectContext { diff --git a/src/strategy/actions/ChatActionContext.h b/src/strategy/actions/ChatActionContext.h index e9d2c1ab..1775e066 100644 --- a/src/strategy/actions/ChatActionContext.h +++ b/src/strategy/actions/ChatActionContext.h @@ -165,6 +165,8 @@ class ChatActionContext : public NamedObjectContext creators["guild leave"] = &ChatActionContext::guild_leave; creators["rtsc"] = &ChatActionContext::rtsc; creators["naxx chat shortcut"] = &ChatActionContext::naxx_chat_shortcut; + creators["bwl chat shortcut"] = &ChatActionContext::bwl_chat_shortcut; + } private: @@ -255,6 +257,7 @@ class ChatActionContext : public NamedObjectContext static Action* guild_leave(PlayerbotAI* botAI) { return new GuildLeaveAction(botAI); } static Action* rtsc(PlayerbotAI* botAI) { return new RTSCAction(botAI); } static Action* naxx_chat_shortcut(PlayerbotAI* ai) { return new NaxxChatShortcutAction(ai); } + static Action* bwl_chat_shortcut(PlayerbotAI* ai) { return new BwlChatShortcutAction(ai); } }; #endif diff --git a/src/strategy/actions/ChatShortcutActions.cpp b/src/strategy/actions/ChatShortcutActions.cpp index af44b7c1..849b0a16 100644 --- a/src/strategy/actions/ChatShortcutActions.cpp +++ b/src/strategy/actions/ChatShortcutActions.cpp @@ -200,4 +200,17 @@ bool NaxxChatShortcutAction::Execute(Event event) botAI->ChangeStrategy("+naxx", BOT_STATE_COMBAT); bot->Say("Add Naxx Strategies!", LANG_UNIVERSAL); return true; -} \ No newline at end of file +} + +bool BwlChatShortcutAction::Execute(Event event) +{ + Player* master = GetMaster(); + if (!master) + return false; + + botAI->Reset(); + botAI->ChangeStrategy("+bwl", BOT_STATE_NON_COMBAT); + botAI->ChangeStrategy("+bwl", BOT_STATE_COMBAT); + bot->Say("Add Bwl Strategies!", LANG_UNIVERSAL); + return true; +} diff --git a/src/strategy/actions/ChatShortcutActions.h b/src/strategy/actions/ChatShortcutActions.h index e9491d2b..916ecc1e 100644 --- a/src/strategy/actions/ChatShortcutActions.h +++ b/src/strategy/actions/ChatShortcutActions.h @@ -80,4 +80,11 @@ class NaxxChatShortcutAction : public Action NaxxChatShortcutAction(PlayerbotAI* ai) : Action(ai, "naxx chat shortcut") {} virtual bool Execute(Event event); }; + +class BwlChatShortcutAction : public Action +{ + public: + BwlChatShortcutAction(PlayerbotAI* ai) : Action(ai, "bwl chat shortcut") {} + virtual bool Execute(Event event); +}; #endif diff --git a/src/strategy/generic/ChatCommandHandlerStrategy.cpp b/src/strategy/generic/ChatCommandHandlerStrategy.cpp index 878726b0..52842a91 100644 --- a/src/strategy/generic/ChatCommandHandlerStrategy.cpp +++ b/src/strategy/generic/ChatCommandHandlerStrategy.cpp @@ -59,6 +59,7 @@ void ChatCommandHandlerStrategy::InitTriggers(std::vector& trigger triggers.push_back(new TriggerNode("target", NextAction::array(0, new NextAction("tell target", relevance), nullptr))); triggers.push_back(new TriggerNode("ready", NextAction::array(0, new NextAction("ready check", relevance), nullptr))); triggers.push_back(new TriggerNode("naxx", NextAction::array(0, new NextAction("naxx chat shortcut", relevance), NULL))); + triggers.push_back(new TriggerNode("bwl", NextAction::array(0, new NextAction("bwl chat shortcut", relevance), NULL))); } ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) diff --git a/src/strategy/raids/RaidActionContext.h b/src/strategy/raids/RaidActionContext.h index c378f146..644aee0e 100644 --- a/src/strategy/raids/RaidActionContext.h +++ b/src/strategy/raids/RaidActionContext.h @@ -7,15 +7,20 @@ #include "Action.h" #include "NamedObjectContext.h" +#include "raids/blackwinglair/RaidBwlActions.h" class RaidActionContext : public NamedObjectContext { public: RaidActionContext() { + creators["bwl check onyxia scale cloak"] = &RaidActionContext::bwl_check_onyxia_scale_cloak; + creators["bwl turn off suppression device"] = &RaidActionContext::bwl_turn_off_suppression_device; } private: + static Action* bwl_check_onyxia_scale_cloak(PlayerbotAI* botAI) { return new BwlOnyxiaScaleCloakAuraCheckAction(botAI); } + static Action* bwl_turn_off_suppression_device(PlayerbotAI* botAI) { return new BwlTurnOffSuppressionDeviceAction(botAI); } }; #endif diff --git a/src/strategy/raids/RaidStrategyContext.h b/src/strategy/raids/RaidStrategyContext.h index 1abbe668..2d40d5f2 100644 --- a/src/strategy/raids/RaidStrategyContext.h +++ b/src/strategy/raids/RaidStrategyContext.h @@ -2,7 +2,8 @@ #define _PLAYERBOT_RAIDSTRATEGYCONTEXT_H_ #include "Strategy.h" -#include "RaidNaxxStrategy.h" +#include "raids/blackwinglair/RaidBwlStrategy.h" +#include "raids/naxxramas/RaidNaxxStrategy.h" class RaidStrategyContext : public NamedObjectContext { @@ -10,9 +11,11 @@ class RaidStrategyContext : public NamedObjectContext RaidStrategyContext() : NamedObjectContext(false, true) { creators["naxx"] = &RaidStrategyContext::naxx; + creators["bwl"] = &RaidStrategyContext::bwl; } private: static Strategy* naxx(PlayerbotAI* botAI) { return new RaidNaxxStrategy(botAI); } + static Strategy* bwl(PlayerbotAI* botAI) { return new RaidBwlStrategy(botAI); } }; #endif \ No newline at end of file diff --git a/src/strategy/raids/RaidTriggerContext.h b/src/strategy/raids/RaidTriggerContext.h index e69de29b..93803f48 100644 --- a/src/strategy/raids/RaidTriggerContext.h +++ b/src/strategy/raids/RaidTriggerContext.h @@ -0,0 +1,24 @@ +// /* +// * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. +// */ + +#ifndef _PLAYERBOT_RAIDTRIGGERCONTEXT_H +#define _PLAYERBOT_RAIDTRIGGERCONTEXT_H + +#include "NamedObjectContext.h" +#include "AiObjectContext.h" +#include "raids/naxxramas/RaidNaxxTriggers.h" +#include "raids/blackwinglair/RaidBwlTriggers.h" + +class RaidTriggerContext : public NamedObjectContext +{ + public: + RaidTriggerContext() + { + creators["bwl suppression device"] = &RaidTriggerContext::bwl_suppression_device; + } + private: + static Trigger* bwl_suppression_device(PlayerbotAI* ai) { return new BwlSuppressionDeviceTrigger(ai); } +}; + +#endif \ No newline at end of file diff --git a/src/strategy/raids/blackwinglair/RaidBwlActions.cpp b/src/strategy/raids/blackwinglair/RaidBwlActions.cpp new file mode 100644 index 00000000..ef9a13eb --- /dev/null +++ b/src/strategy/raids/blackwinglair/RaidBwlActions.cpp @@ -0,0 +1,30 @@ +#include "RaidBwlActions.h" +#include "Playerbots.h" + +bool BwlOnyxiaScaleCloakAuraCheckAction::Execute(Event event) +{ + bot->AddAura(22683, bot); + return true; +} + +bool BwlOnyxiaScaleCloakAuraCheckAction::isUseful() +{ + return !bot->HasAura(22683); +} + +bool BwlTurnOffSuppressionDeviceAction::Execute(Event event) +{ + GuidVector gos = AI_VALUE(GuidVector, "nearest game objects"); + for (GuidVector::iterator i = gos.begin(); i != gos.end(); i++) + { + GameObject* go = botAI->GetGameObject(*i); + if (!go) { + continue; + } + if (go->GetEntry() != 179784 || go->GetDistance(bot) >= 15.0f || go->GetGoState() != GO_STATE_READY) { + continue; + } + go->SetGoState(GO_STATE_ACTIVE); + } + return true; +} \ No newline at end of file diff --git a/src/strategy/raids/blackwinglair/RaidBwlActions.h b/src/strategy/raids/blackwinglair/RaidBwlActions.h new file mode 100644 index 00000000..56f94089 --- /dev/null +++ b/src/strategy/raids/blackwinglair/RaidBwlActions.h @@ -0,0 +1,26 @@ +#ifndef _PLAYERBOT_RAIDBWLACTIONS_H +#define _PLAYERBOT_RAIDBWLACTIONS_H + +#include "Action.h" +#include "MovementActions.h" +#include "AttackAction.h" +#include "GenericActions.h" +#include "PlayerbotAI.h" +#include "Playerbots.h" + +class BwlOnyxiaScaleCloakAuraCheckAction : public Action +{ + public: + BwlOnyxiaScaleCloakAuraCheckAction(PlayerbotAI* botAI) : Action(botAI, "bwl onyxia scale cloak aura check") {} + bool Execute(Event event) override; + bool isUseful() override; +}; + +class BwlTurnOffSuppressionDeviceAction : public Action +{ + public: + BwlTurnOffSuppressionDeviceAction(PlayerbotAI* botAI) : Action(botAI, "bwl turn off suppression device") {} + bool Execute(Event event) override; +}; + +#endif \ No newline at end of file diff --git a/src/strategy/raids/blackwinglair/RaidBwlStrategy.cpp b/src/strategy/raids/blackwinglair/RaidBwlStrategy.cpp new file mode 100644 index 00000000..f9e98e52 --- /dev/null +++ b/src/strategy/raids/blackwinglair/RaidBwlStrategy.cpp @@ -0,0 +1,13 @@ +#include "RaidBwlStrategy.h" +#include "Strategy.h" + +void RaidBwlStrategy::InitTriggers(std::vector &triggers) +{ + triggers.push_back(new TriggerNode( + "often", + NextAction::array(0, new NextAction("bwl check onyxia scale cloak", ACTION_RAID), NULL))); + + triggers.push_back(new TriggerNode( + "bwl suppression device", + NextAction::array(0, new NextAction("bwl turn off suppression device", ACTION_RAID), NULL))); +} \ No newline at end of file diff --git a/src/strategy/raids/blackwinglair/RaidBwlStrategy.h b/src/strategy/raids/blackwinglair/RaidBwlStrategy.h new file mode 100644 index 00000000..98c60c53 --- /dev/null +++ b/src/strategy/raids/blackwinglair/RaidBwlStrategy.h @@ -0,0 +1,19 @@ + +#ifndef _PLAYERBOT_RAIDBWLSTRATEGY_H +#define _PLAYERBOT_RAIDBWLSTRATEGY_H + +#include "Multiplier.h" +#include "AiObjectContext.h" +#include "Strategy.h" + +class RaidBwlStrategy : public Strategy +{ +public: + RaidBwlStrategy(PlayerbotAI* ai) : Strategy(ai) {} + virtual std::string const getName() override { return "bwl"; } + virtual void InitTriggers(std::vector &triggers) override; + // virtual void InitMultipliers(std::vector &multipliers) override; +}; + + +#endif \ No newline at end of file diff --git a/src/strategy/raids/blackwinglair/RaidBwlTriggers.cpp b/src/strategy/raids/blackwinglair/RaidBwlTriggers.cpp new file mode 100644 index 00000000..1b303bb7 --- /dev/null +++ b/src/strategy/raids/blackwinglair/RaidBwlTriggers.cpp @@ -0,0 +1,18 @@ +#include "RaidBwlTriggers.h" +#include "SharedDefines.h" + +bool BwlSuppressionDeviceTrigger::IsActive() { + GuidVector gos = AI_VALUE(GuidVector, "nearest game objects"); + for (GuidVector::iterator i = gos.begin(); i != gos.end(); i++) + { + GameObject* go = botAI->GetGameObject(*i); + if (!go) { + continue; + } + if (go->GetEntry() != 179784 || go->GetDistance(bot) >= 15.0f || go->GetGoState() != GO_STATE_READY) { + continue; + } + return true; + } + return false; +} \ No newline at end of file diff --git a/src/strategy/raids/blackwinglair/RaidBwlTriggers.h b/src/strategy/raids/blackwinglair/RaidBwlTriggers.h new file mode 100644 index 00000000..d1aedb6f --- /dev/null +++ b/src/strategy/raids/blackwinglair/RaidBwlTriggers.h @@ -0,0 +1,15 @@ +#ifndef _PLAYERBOT_RAIDBWLTRIGGERS_H +#define _PLAYERBOT_RAIDBWLTRIGGERS_H + +#include "Trigger.h" +#include "PlayerbotAI.h" +#include "Playerbots.h" + +class BwlSuppressionDeviceTrigger : public Trigger +{ + public: + BwlSuppressionDeviceTrigger(PlayerbotAI* botAI) : Trigger(botAI, "bwl suppression device") {} + bool IsActive() override; +}; + +#endif \ No newline at end of file diff --git a/src/strategy/raids/naxxramas/RaidNaxxActions.cpp b/src/strategy/raids/naxxramas/RaidNaxxActions.cpp index 7440817f..d5c86eb9 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxActions.cpp +++ b/src/strategy/raids/naxxramas/RaidNaxxActions.cpp @@ -5,11 +5,7 @@ #include "RaidNaxxStrategy.h" #include "ScriptedCreature.h" #include "SharedDefines.h" -#include "raids/naxxramas/RaidNaxxBossHelper.h" -#include - - -using namespace std; +#include "RaidNaxxBossHelper.h" // bool TryToGetBossAIAction::Execute(Event event) { // Unit* boss = AI_VALUE(Unit*, "boss target"); @@ -698,7 +694,7 @@ bool KelthuzadChooseTargetAction::Execute(Event event) target_kelthuzad = unit; } } - vector targets; + std::vector targets; if (botAI->IsRanged(bot)) { if (botAI->GetRangedDpsIndex(bot) <= 1) { targets = {target_soldier, target_weaver, target_abomination, target_kelthuzad}; @@ -788,7 +784,7 @@ bool AnubrekhanChooseTargetAction::Execute(Event event) GuidVector attackers = context->GetValue("attackers")->Get(); Unit* target = nullptr; Unit *target_boss = nullptr; - vector target_guards; + std::vector target_guards; for (ObjectGuid const guid : attackers) { Unit* unit = botAI->GetUnit(guid); diff --git a/src/strategy/raids/naxxramas/RaidNaxxTriggers.h b/src/strategy/raids/naxxramas/RaidNaxxTriggers.h index 581a6ab5..882d4ddf 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxTriggers.h +++ b/src/strategy/raids/naxxramas/RaidNaxxTriggers.h @@ -7,9 +7,7 @@ #include "PlayerbotAIConfig.h" #include "GenericTriggers.h" #include "RaidNaxxScripts.h" -#include "raids/naxxramas/RaidNaxxBossHelper.h" - -using namespace std; +#include "RaidNaxxBossHelper.h" class MutatingInjectionTrigger : public HasAuraTrigger { @@ -20,7 +18,7 @@ public: class AuraRemovedTrigger : public Trigger { public: - AuraRemovedTrigger(PlayerbotAI* botAI, string name): Trigger(botAI, name, 1) { + AuraRemovedTrigger(PlayerbotAI* botAI, std::string name): Trigger(botAI, name, 1) { this->prev_check = false; } virtual bool IsActive() override; @@ -39,7 +37,7 @@ template class BossEventTrigger : public Trigger { public: - BossEventTrigger(PlayerbotAI* ai, uint32 boss_entry, uint32 event_id, string name = "boss event"): Trigger(ai, name, 1) { + BossEventTrigger(PlayerbotAI* ai, uint32 boss_entry, uint32 event_id, std::string name = "boss event"): Trigger(ai, name, 1) { this->boss_entry = boss_entry; this->event_id = event_id; this->last_event_time = -1; @@ -53,13 +51,13 @@ template class BossPhaseTrigger : public Trigger { public: - BossPhaseTrigger(PlayerbotAI* ai, string boss_name, uint32 phase_mask, string name = "boss event"): Trigger(ai, name, 1) { + BossPhaseTrigger(PlayerbotAI* ai, std::string boss_name, uint32 phase_mask, std::string name = "boss event"): Trigger(ai, name, 1) { this->boss_name = boss_name; this->phase_mask = phase_mask; } virtual bool IsActive(); protected: - string boss_name; + std::string boss_name; uint32 phase_mask; }; diff --git a/src/strategy/triggers/ChatTriggerContext.h b/src/strategy/triggers/ChatTriggerContext.h index f421685c..6e9f2d6c 100644 --- a/src/strategy/triggers/ChatTriggerContext.h +++ b/src/strategy/triggers/ChatTriggerContext.h @@ -113,6 +113,7 @@ class ChatTriggerContext : public NamedObjectContext creators["rtsc"] = &ChatTriggerContext::rtsc; creators["drink"] = &ChatTriggerContext::drink; creators["naxx"] = &ChatTriggerContext::naxx; + creators["bwl"] = &ChatTriggerContext::bwl; } private: @@ -206,6 +207,7 @@ class ChatTriggerContext : public NamedObjectContext static Trigger* rtsc(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "rtsc"); } static Trigger* drink(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "drink"); } static Trigger* naxx(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "naxx"); } + static Trigger* bwl(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "bwl"); } }; #endif