From d1cac8d0273f763d2a576293920cc71231b0b408 Mon Sep 17 00:00:00 2001 From: Keleborn <22352763+Celandriel@users.noreply.github.com> Date: Sun, 15 Feb 2026 16:29:20 -0800 Subject: [PATCH] Bug fix. Equip Action triggered action (#2142) # Pull Request Brighton caught a mistake I made changeing the action registry, so the correct action was no longer triggering. I cleaned that up, and renamed the action. ## How to Test the Changes - This was tested by adding logging to both equip actions. But to test this without that, the best way to verify the fix is to stop alts from auto upgrading via config. Then they should correctly follow the configured behavior. ## Complexity & Impact Does this change add new decision branches? - - [x ] No - - [ ] Yes (**explain below**) Does this change increase per-bot or per-tick processing? - - [x] No - - [ ] Yes (**describe and justify impact**) Could this logic scale poorly under load? - - [x] No - - [ ] Yes (**explain why**) --- ## Defaults & Configuration Does this change modify default bot behavior? - - [x] No - - [ ] Yes (**explain why**) If this introduces more advanced or AI-heavy logic: - - [x] Lightweight mode remains the default - - [ ] More complex behavior is optional and thereby configurable --- ## AI Assistance Was AI assistance (e.g. ChatGPT or similar tools) used while working on this change? - - [x] No - - [ ] Yes (**explain below**) If yes, please specify: - AI tool or model used (e.g. ChatGPT, GPT-4, Claude, etc.) - Purpose of usage (e.g. brainstorming, refactoring, documentation, code generation) - Which parts of the change were influenced or generated - Whether the result was manually reviewed and adapted AI assistance is allowed, but all submitted code must be fully understood, reviewed, and owned by the contributor. Any AI-influenced changes must be verified against existing CORE and PB logic. We expect contributors to be honest about what they do and do not understand. --- ## Final Checklist - - [x] Stability is not compromised - - [x] Performance impact is understood, tested, and acceptable - - [x] Added logic complexity is justified and explained - - [x] Documentation updated if needed --- ## Notes for Reviewers Anything that significantly improves realism at the cost of stability or performance should be carefully discussed before merging. --- src/Ai/Base/Actions/BuyAction.cpp | 4 ++-- src/Ai/Base/Actions/EquipAction.cpp | 8 ++++---- src/Ai/Base/Actions/EquipAction.h | 4 ++-- src/Ai/Base/ChatActionContext.h | 1 - src/Ai/Base/Strategy/NonCombatStrategy.cpp | 2 +- src/Ai/Base/Strategy/WorldPacketHandlerStrategy.cpp | 6 +++--- src/Ai/Base/WorldPacketActionContext.h | 2 ++ .../Hunter/Strategy/GenericHunterNonCombatStrategy.cpp | 2 +- src/Ai/Class/Hunter/Strategy/GenericHunterStrategy.cpp | 2 +- 9 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/Ai/Base/Actions/BuyAction.cpp b/src/Ai/Base/Actions/BuyAction.cpp index 1e8ec7e5c..f0729f251 100644 --- a/src/Ai/Base/Actions/BuyAction.cpp +++ b/src/Ai/Base/Actions/BuyAction.cpp @@ -175,7 +175,7 @@ bool BuyAction::Execute(Event event) if (needMoneyFor == NeedMoneyFor::gear) { - botAI->DoSpecificAction("equip upgrades"); + botAI->DoSpecificAction("equip upgrades packet action"); } } } @@ -206,7 +206,7 @@ bool BuyAction::Execute(Event event) if (usage == ITEM_USAGE_REPLACE || usage == ITEM_USAGE_EQUIP || usage == ITEM_USAGE_BAD_EQUIP || usage == ITEM_USAGE_BROKEN_EQUIP) { - botAI->DoSpecificAction("equip upgrades"); + botAI->DoSpecificAction("equip upgrades packet action"); break; } } diff --git a/src/Ai/Base/Actions/EquipAction.cpp b/src/Ai/Base/Actions/EquipAction.cpp index 5c91c13c8..d6900391f 100644 --- a/src/Ai/Base/Actions/EquipAction.cpp +++ b/src/Ai/Base/Actions/EquipAction.cpp @@ -364,12 +364,12 @@ ItemIds EquipAction::SelectInventoryItemsToEquip() return items; } -bool EquipUpgradesTriggeredAction::Execute(Event event) +bool EquipUpgradesPacketAction::Execute(Event event) { if (!sPlayerbotAIConfig.autoEquipUpgradeLoot && !sRandomPlayerbotMgr.IsRandomBot(bot)) return false; - - if (event.GetSource() == "trade status") + std::string const source = event.GetSource(); + if (source == "trade status") { WorldPacket p(event.getPacket()); p.rpos(0); @@ -380,7 +380,7 @@ bool EquipUpgradesTriggeredAction::Execute(Event event) return false; } - if (event.GetSource() == "item push result") + else if (source == "item push result") { WorldPacket p(event.getPacket()); p.rpos(0); diff --git a/src/Ai/Base/Actions/EquipAction.h b/src/Ai/Base/Actions/EquipAction.h index 4f84f942b..bf609d861 100644 --- a/src/Ai/Base/Actions/EquipAction.h +++ b/src/Ai/Base/Actions/EquipAction.h @@ -29,10 +29,10 @@ private: void EquipItem(Item* item); }; -class EquipUpgradesTriggeredAction : public EquipAction +class EquipUpgradesPacketAction : public EquipAction { public: - explicit EquipUpgradesTriggeredAction(PlayerbotAI* botAI, std::string const name = "equip upgrades") : EquipAction(botAI, name) {} + explicit EquipUpgradesPacketAction(PlayerbotAI* botAI, std::string const name = "equip upgrades packet action") : EquipAction(botAI, name) {} bool Execute(Event event) override; }; diff --git a/src/Ai/Base/ChatActionContext.h b/src/Ai/Base/ChatActionContext.h index 8e4ed9ccf..4bfdcb043 100644 --- a/src/Ai/Base/ChatActionContext.h +++ b/src/Ai/Base/ChatActionContext.h @@ -120,7 +120,6 @@ public: creators["use"] = &ChatActionContext::use; creators["item count"] = &ChatActionContext::item_count; creators["equip"] = &ChatActionContext::equip; - creators["equip upgrades"] = &ChatActionContext::equip_upgrade; creators["unequip"] = &ChatActionContext::unequip; creators["sell"] = &ChatActionContext::sell; creators["buy"] = &ChatActionContext::buy; diff --git a/src/Ai/Base/Strategy/NonCombatStrategy.cpp b/src/Ai/Base/Strategy/NonCombatStrategy.cpp index 136dcc53e..cb32233f4 100644 --- a/src/Ai/Base/Strategy/NonCombatStrategy.cpp +++ b/src/Ai/Base/Strategy/NonCombatStrategy.cpp @@ -56,7 +56,7 @@ void MasterFishingStrategy::InitTriggers(std::vector& triggers) "random", { NextAction("end master fishing", 12.0f), - NextAction("equip upgrades", 6.0f) + NextAction("equip upgrades packet action", 6.0f) } ) ); diff --git a/src/Ai/Base/Strategy/WorldPacketHandlerStrategy.cpp b/src/Ai/Base/Strategy/WorldPacketHandlerStrategy.cpp index 2debc44cb..ad31c2c39 100644 --- a/src/Ai/Base/Strategy/WorldPacketHandlerStrategy.cpp +++ b/src/Ai/Base/Strategy/WorldPacketHandlerStrategy.cpp @@ -32,7 +32,7 @@ void WorldPacketHandlerStrategy::InitTriggers(std::vector& trigger triggers.push_back(new TriggerNode("activate taxi", { NextAction("remember taxi", relevance), NextAction("taxi", relevance) })); triggers.push_back(new TriggerNode("taxi done", { NextAction("taxi", relevance) })); - triggers.push_back(new TriggerNode("trade status", { NextAction("accept trade", relevance), NextAction("equip upgrades", relevance) })); + triggers.push_back(new TriggerNode("trade status", { NextAction("accept trade", relevance), NextAction("equip upgrades packet action", relevance) })); triggers.push_back(new TriggerNode("trade status extended", { NextAction("trade status extended", relevance) })); triggers.push_back(new TriggerNode("area trigger", { NextAction("reach area trigger", relevance) })); triggers.push_back(new TriggerNode("within area trigger", { NextAction("area trigger", relevance) })); @@ -40,9 +40,9 @@ void WorldPacketHandlerStrategy::InitTriggers(std::vector& trigger triggers.push_back(new TriggerNode("item push result", { NextAction("unlock items", relevance), NextAction("open items", relevance), NextAction("query item usage", relevance), - NextAction("equip upgrades", relevance) })); + NextAction("equip upgrades packet action", relevance) })); triggers.push_back(new TriggerNode("item push result", { NextAction("quest item push result", relevance) })); - triggers.push_back(new TriggerNode("loot roll won", { NextAction("equip upgrades", relevance) })); + triggers.push_back(new TriggerNode("loot roll won", { NextAction("equip upgrades packet action", relevance) })); triggers.push_back(new TriggerNode("ready check finished", { NextAction("finish ready check", relevance) })); // triggers.push_back(new TriggerNode("often", { NextAction("security check", relevance), NextAction("check mail", relevance) })); triggers.push_back(new TriggerNode("guild invite", { NextAction("guild accept", relevance) })); diff --git a/src/Ai/Base/WorldPacketActionContext.h b/src/Ai/Base/WorldPacketActionContext.h index 59c055036..839a88655 100644 --- a/src/Ai/Base/WorldPacketActionContext.h +++ b/src/Ai/Base/WorldPacketActionContext.h @@ -72,6 +72,7 @@ public: creators["store loot"] = &WorldPacketActionContext::store_loot; creators["self resurrect"] = &WorldPacketActionContext::self_resurrect; creators["pet"] = &WorldPacketActionContext::pet; + creators["equip upgrades packet action"] = &WorldPacketActionContext::equip_upgrades_packet_action; // quest creators["talk to quest giver"] = &WorldPacketActionContext::turn_in_quest; @@ -142,6 +143,7 @@ private: static Action* tell_cannot_equip(PlayerbotAI* botAI) { return new InventoryChangeFailureAction(botAI); } static Action* self_resurrect(PlayerbotAI* botAI) { return new SelfResurrectAction(botAI); } static Action* pet(PlayerbotAI* botAI) { return new PetsAction(botAI); } + static Action* equip_upgrades_packet_action(PlayerbotAI* botAI) { return new EquipUpgradesPacketAction(botAI); } // quest static Action* quest_update_add_kill(PlayerbotAI* ai) { return new QuestUpdateAddKillAction(ai); } diff --git a/src/Ai/Class/Hunter/Strategy/GenericHunterNonCombatStrategy.cpp b/src/Ai/Class/Hunter/Strategy/GenericHunterNonCombatStrategy.cpp index 151feadf1..00c35dc2a 100644 --- a/src/Ai/Class/Hunter/Strategy/GenericHunterNonCombatStrategy.cpp +++ b/src/Ai/Class/Hunter/Strategy/GenericHunterNonCombatStrategy.cpp @@ -51,7 +51,7 @@ void GenericHunterNonCombatStrategy::InitTriggers(std::vector& tri })); triggers.push_back(new TriggerNode("low ammo", { NextAction("say::low ammo", ACTION_NORMAL)})); triggers.push_back(new TriggerNode("no track", { NextAction("track humanoids", ACTION_NORMAL)})); - triggers.push_back(new TriggerNode("no ammo", { NextAction("equip upgrades", ACTION_HIGH + 1)})); + triggers.push_back(new TriggerNode("no ammo", { NextAction("equip upgrades packet action", ACTION_HIGH + 1)})); } void HunterPetStrategy::InitTriggers(std::vector& triggers) diff --git a/src/Ai/Class/Hunter/Strategy/GenericHunterStrategy.cpp b/src/Ai/Class/Hunter/Strategy/GenericHunterStrategy.cpp index 16a22eaeb..0a9e88a54 100644 --- a/src/Ai/Class/Hunter/Strategy/GenericHunterStrategy.cpp +++ b/src/Ai/Class/Hunter/Strategy/GenericHunterStrategy.cpp @@ -98,7 +98,7 @@ void GenericHunterStrategy::InitTriggers(std::vector& triggers) CombatStrategy::InitTriggers(triggers); // Mark/Ammo/Mana Triggers - triggers.push_back(new TriggerNode("no ammo", { NextAction("equip upgrades", 30.0f) })); + triggers.push_back(new TriggerNode("no ammo", { NextAction("equip upgrades packet action", 30.0f) })); triggers.push_back(new TriggerNode("hunter's mark", { NextAction("hunter's mark", 29.5f) })); triggers.push_back(new TriggerNode("rapid fire", { NextAction("rapid fire", 29.0f) })); triggers.push_back(new TriggerNode("aspect of the viper", { NextAction("aspect of the viper", 28.0f) }));