From 305f769a846f78cd2d08c14e204345d67112e6c7 Mon Sep 17 00:00:00 2001 From: kadeshar Date: Fri, 4 Jul 2025 17:14:07 +0200 Subject: [PATCH] - Added chat command to wipe group (#1408) --- src/strategy/actions/ChatActionContext.h | 3 +++ src/strategy/actions/WipeAction.cpp | 18 ++++++++++++++ src/strategy/actions/WipeAction.h | 24 +++++++++++++++++++ .../generic/ChatCommandHandlerStrategy.cpp | 2 ++ src/strategy/triggers/ChatTriggerContext.h | 2 ++ 5 files changed, 49 insertions(+) create mode 100644 src/strategy/actions/WipeAction.cpp create mode 100644 src/strategy/actions/WipeAction.h diff --git a/src/strategy/actions/ChatActionContext.h b/src/strategy/actions/ChatActionContext.h index 4d2fe064..6b5c6c44 100644 --- a/src/strategy/actions/ChatActionContext.h +++ b/src/strategy/actions/ChatActionContext.h @@ -73,6 +73,7 @@ #include "UseItemAction.h" #include "UseMeetingStoneAction.h" #include "WhoAction.h" +#include "WipeAction.h" #include "WtsAction.h" #include "OpenItemAction.h" #include "UnlockItemAction.h" @@ -185,6 +186,7 @@ public: creators["join"] = &ChatActionContext::join; creators["lfg"] = &ChatActionContext::lfg; creators["calc"] = &ChatActionContext::calc; + creators["wipe"] = &ChatActionContext::wipe; } private: @@ -290,6 +292,7 @@ private: static Action* tell_estimated_dps(PlayerbotAI* ai) { return new TellEstimatedDpsAction(ai); } static Action* join(PlayerbotAI* ai) { return new JoinGroupAction(ai); } static Action* calc(PlayerbotAI* ai) { return new TellCalculateItemAction(ai); } + static Action* wipe(PlayerbotAI* ai) { return new WipeAction(ai); } }; #endif diff --git a/src/strategy/actions/WipeAction.cpp b/src/strategy/actions/WipeAction.cpp new file mode 100644 index 00000000..d00fdde0 --- /dev/null +++ b/src/strategy/actions/WipeAction.cpp @@ -0,0 +1,18 @@ +/* + * 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. + */ + +#include "PlayerbotAI.h" +#include "WipeAction.h" + +bool WipeAction::Execute(Event event) +{ + Player* master = event.getOwner(); + + if (botAI->GetMaster()->GetGUID() != event.getOwner()->GetGUID()) + return false; + + bot->Kill(bot, bot); + return true; +} diff --git a/src/strategy/actions/WipeAction.h b/src/strategy/actions/WipeAction.h new file mode 100644 index 00000000..e26770d4 --- /dev/null +++ b/src/strategy/actions/WipeAction.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_WIPEACTION_H +#define _PLAYERBOT_WIPEACTION_H + +#include "Action.h" + +class PlayerbotAI; + +class WipeAction : public Action +{ +public: + WipeAction(PlayerbotAI* botAI) : Action(botAI, "wipe") {} + + bool Execute(Event event) override; + +private: + std::string bossName; +}; + +#endif diff --git a/src/strategy/generic/ChatCommandHandlerStrategy.cpp b/src/strategy/generic/ChatCommandHandlerStrategy.cpp index bf766d67..b3367213 100644 --- a/src/strategy/generic/ChatCommandHandlerStrategy.cpp +++ b/src/strategy/generic/ChatCommandHandlerStrategy.cpp @@ -100,6 +100,8 @@ void ChatCommandHandlerStrategy::InitTriggers(std::vector& trigger new TriggerNode("unlock items", NextAction::array(0, new NextAction("unlock items", relevance), nullptr))); triggers.push_back( new TriggerNode("unlock traded item", NextAction::array(0, new NextAction("unlock traded item", relevance), nullptr))); + triggers.push_back( + new TriggerNode("wipe", NextAction::array(0, new NextAction("wipe", relevance), nullptr))); } ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : PassTroughStrategy(botAI) diff --git a/src/strategy/triggers/ChatTriggerContext.h b/src/strategy/triggers/ChatTriggerContext.h index e61ac6ad..9ea6770e 100644 --- a/src/strategy/triggers/ChatTriggerContext.h +++ b/src/strategy/triggers/ChatTriggerContext.h @@ -132,6 +132,7 @@ public: creators["disperse"] = &ChatTriggerContext::disperse; creators["calc"] = &ChatTriggerContext::calc; creators["qi"] = &ChatTriggerContext::qi; + creators["wipe"] = &ChatTriggerContext::wipe; } private: @@ -243,6 +244,7 @@ private: static Trigger* disperse(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "disperse"); } static Trigger* calc(PlayerbotAI* ai) { return new ChatCommandTrigger(ai, "calc"); } static Trigger* qi(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "qi"); } + static Trigger* wipe(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "wipe"); } }; #endif