bwl strategy

This commit is contained in:
Yunfan Li
2023-08-28 21:21:58 +08:00
parent b97876dbc2
commit dba908be9e
18 changed files with 196 additions and 20 deletions

View File

@@ -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());

View File

@@ -47,7 +47,6 @@
#include "UseFoodStrategy.h"
#include "UsePotionsStrategy.h"
#include "WorldPacketHandlerStrategy.h"
#include "RaidNaxxStrategy.h"
class StrategyContext : public NamedObjectContext<Strategy>
{

View File

@@ -165,6 +165,8 @@ class ChatActionContext : public NamedObjectContext<Action>
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<Action>
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

View File

@@ -200,4 +200,17 @@ bool NaxxChatShortcutAction::Execute(Event event)
botAI->ChangeStrategy("+naxx", BOT_STATE_COMBAT);
bot->Say("Add Naxx Strategies!", LANG_UNIVERSAL);
return true;
}
}
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;
}

View File

@@ -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

View File

@@ -59,6 +59,7 @@ void ChatCommandHandlerStrategy::InitTriggers(std::vector<TriggerNode*>& 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)

View File

@@ -7,15 +7,20 @@
#include "Action.h"
#include "NamedObjectContext.h"
#include "raids/blackwinglair/RaidBwlActions.h"
class RaidActionContext : public NamedObjectContext<Action>
{
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

View File

@@ -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<Strategy>
{
@@ -10,9 +11,11 @@ class RaidStrategyContext : public NamedObjectContext<Strategy>
RaidStrategyContext() : NamedObjectContext<Strategy>(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

View File

@@ -0,0 +1,24 @@
// /*
// * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, 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<Trigger>
{
public:
RaidTriggerContext()
{
creators["bwl suppression device"] = &RaidTriggerContext::bwl_suppression_device;
}
private:
static Trigger* bwl_suppression_device(PlayerbotAI* ai) { return new BwlSuppressionDeviceTrigger(ai); }
};
#endif

View File

@@ -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;
}

View File

@@ -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

View File

@@ -0,0 +1,13 @@
#include "RaidBwlStrategy.h"
#include "Strategy.h"
void RaidBwlStrategy::InitTriggers(std::vector<TriggerNode*> &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)));
}

View File

@@ -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<TriggerNode*> &triggers) override;
// virtual void InitMultipliers(std::vector<Multiplier*> &multipliers) override;
};
#endif

View File

@@ -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;
}

View File

@@ -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

View File

@@ -5,11 +5,7 @@
#include "RaidNaxxStrategy.h"
#include "ScriptedCreature.h"
#include "SharedDefines.h"
#include "raids/naxxramas/RaidNaxxBossHelper.h"
#include <algorithm>
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<Unit*> targets;
std::vector<Unit*> 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<GuidVector >("attackers")->Get();
Unit* target = nullptr;
Unit *target_boss = nullptr;
vector<Unit*> target_guards;
std::vector<Unit*> target_guards;
for (ObjectGuid const guid : attackers)
{
Unit* unit = botAI->GetUnit(guid);

View File

@@ -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 T>
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 T>
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;
};

View File

@@ -113,6 +113,7 @@ class ChatTriggerContext : public NamedObjectContext<Trigger>
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<Trigger>
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