From fb404b27a9ab0366897c594fdf5aaaab51309b17 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Wed, 26 Jun 2024 20:30:12 +0800 Subject: [PATCH] [Initialization] Glyphs remove and dual spec --- src/TravelMgr.cpp | 4 +++- src/strategy/actions/ChangeTalentsAction.cpp | 9 +++++++-- src/strategy/actions/ChatActionContext.h | 2 ++ src/strategy/actions/TrainerAction.cpp | 9 +++++++++ src/strategy/actions/TrainerAction.h | 7 +++++++ src/strategy/generic/ChatCommandHandlerStrategy.cpp | 1 + src/strategy/triggers/ChatTriggerContext.h | 2 ++ 7 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/TravelMgr.cpp b/src/TravelMgr.cpp index 755d1103..f010df99 100644 --- a/src/TravelMgr.cpp +++ b/src/TravelMgr.cpp @@ -1495,6 +1495,8 @@ void TravelTarget::setStatus(TravelStatus status) break; case TRAVEL_STATUS_COOLDOWN: statusTime = tDestination->getCooldownDelay(); + default: + break; } } @@ -3687,7 +3689,7 @@ void TravelMgr::LoadQuestTravelTable() } } else - "all"; + out << "all"; out << "\n"; } diff --git a/src/strategy/actions/ChangeTalentsAction.cpp b/src/strategy/actions/ChangeTalentsAction.cpp index e0f3b8db..69a6b19f 100644 --- a/src/strategy/actions/ChangeTalentsAction.cpp +++ b/src/strategy/actions/ChangeTalentsAction.cpp @@ -23,10 +23,15 @@ bool ChangeTalentsAction::Execute(Event event) if (param.find("help") != std::string::npos) { out << TalentsHelp(); } else if (param.find("switch") != std::string::npos) { - if (param.find("switch 1")) { + if (param.find("switch 1") != std::string::npos) { bot->ActivateSpec(0); out << "Active first talent"; - } else if (param.find("switch 2")) { + } else if (param.find("switch 2") != std::string::npos) { + if (bot->GetSpecsCount() == 1 && bot->GetLevel() >= sWorld->getIntConfig(CONFIG_MIN_DUALSPEC_LEVEL)) + { + bot->CastSpell(bot, 63680, true, nullptr, nullptr, bot->GetGUID()); + bot->CastSpell(bot, 63624, true, nullptr, nullptr, bot->GetGUID()); + } bot->ActivateSpec(1); out << "Active second talent"; } diff --git a/src/strategy/actions/ChatActionContext.h b/src/strategy/actions/ChatActionContext.h index 2930dae0..8fb48c64 100644 --- a/src/strategy/actions/ChatActionContext.h +++ b/src/strategy/actions/ChatActionContext.h @@ -115,6 +115,7 @@ class ChatActionContext : public NamedObjectContext creators["de"] = &ChatActionContext::dead; creators["trainer"] = &ChatActionContext::trainer; creators["maintenance"] = &ChatActionContext::maintenance; + creators["remove glyph"] = &ChatActionContext::remove_glyph; creators["autogear"] = &ChatActionContext::autogear; creators["equip upgrade"] = &ChatActionContext::equip_upgrade; creators["attack my target"] = &ChatActionContext::attack_my_target; @@ -215,6 +216,7 @@ class ChatActionContext : public NamedObjectContext static Action* attack_my_target(PlayerbotAI* botAI) { return new AttackMyTargetAction(botAI); } static Action* trainer(PlayerbotAI* botAI) { return new TrainerAction(botAI); } static Action* maintenance(PlayerbotAI* botAI) { return new MaintenanceAction(botAI); } + static Action* remove_glyph(PlayerbotAI* botAI) { return new RemoveGlyphAction(botAI); } static Action* autogear(PlayerbotAI* botAI) { return new AutoGearAction(botAI); } static Action* equip_upgrade(PlayerbotAI* botAI) { return new EquipUpgradeAction(botAI); } static Action* co(PlayerbotAI* botAI) { return new ChangeCombatStrategyAction(botAI); } diff --git a/src/strategy/actions/TrainerAction.cpp b/src/strategy/actions/TrainerAction.cpp index de3fea5d..2454e563 100644 --- a/src/strategy/actions/TrainerAction.cpp +++ b/src/strategy/actions/TrainerAction.cpp @@ -175,6 +175,15 @@ bool MaintenanceAction::Execute(Event event) return true; } +bool RemoveGlyphAction::Execute(Event event) +{ + for (uint32 slotIndex = 0; slotIndex < MAX_GLYPH_SLOT_INDEX; ++slotIndex) + { + bot->SetGlyph(slotIndex, 0, true); + } + return true; +} + bool AutoGearAction::Execute(Event event) { if (!sPlayerbotAIConfig->autoGearCommand) { diff --git a/src/strategy/actions/TrainerAction.h b/src/strategy/actions/TrainerAction.h index ea1f6e66..5ea6300c 100644 --- a/src/strategy/actions/TrainerAction.h +++ b/src/strategy/actions/TrainerAction.h @@ -35,6 +35,13 @@ class MaintenanceAction : public Action bool Execute(Event event) override; }; +class RemoveGlyphAction : public Action +{ + public: + RemoveGlyphAction(PlayerbotAI* botAI) : Action(botAI, "remove glyph") { } + bool Execute(Event event) override; +}; + class AutoGearAction : public Action { public: diff --git a/src/strategy/generic/ChatCommandHandlerStrategy.cpp b/src/strategy/generic/ChatCommandHandlerStrategy.cpp index bbb1c1a4..4da74e5b 100644 --- a/src/strategy/generic/ChatCommandHandlerStrategy.cpp +++ b/src/strategy/generic/ChatCommandHandlerStrategy.cpp @@ -89,6 +89,7 @@ ChatCommandHandlerStrategy::ChatCommandHandlerStrategy(PlayerbotAI* botAI) : Pas supported.push_back("de"); supported.push_back("trainer"); supported.push_back("maintenance"); + supported.push_back("remove glyph"); supported.push_back("autogear"); supported.push_back("equip upgrade"); supported.push_back("chat"); diff --git a/src/strategy/triggers/ChatTriggerContext.h b/src/strategy/triggers/ChatTriggerContext.h index c0721390..af52cd7e 100644 --- a/src/strategy/triggers/ChatTriggerContext.h +++ b/src/strategy/triggers/ChatTriggerContext.h @@ -55,6 +55,7 @@ class ChatTriggerContext : public NamedObjectContext creators["de"] = &ChatTriggerContext::dead; creators["trainer"] = &ChatTriggerContext::trainer; creators["maintenance"] = &ChatTriggerContext::maintenance; + creators["remove glyph"] = &ChatTriggerContext::remove_glyph; creators["autogear"] = &ChatTriggerContext::autogear; creators["equip upgrade"] = &ChatTriggerContext::equip_upgrade; creators["attack"] = &ChatTriggerContext::attack; @@ -168,6 +169,7 @@ class ChatTriggerContext : public NamedObjectContext static Trigger* attack(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "attack"); } static Trigger* trainer(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "trainer"); } static Trigger* maintenance(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "maintenance"); } + static Trigger* remove_glyph(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "remove glyph"); } static Trigger* autogear(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "autogear"); } static Trigger* equip_upgrade(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "equip upgrade"); } static Trigger* co(PlayerbotAI* botAI) { return new ChatCommandTrigger(botAI, "co"); }