diff --git a/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.lua b/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.lua index 87f22a5d80..81e99f4239 100644 --- a/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.lua +++ b/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.lua @@ -259,8 +259,6 @@ local function ServerCommand(text) end Cmd.Say(text) end --- a dot command from a click, for the other files (ForeverBots_Trade.lua): see Cmd.Say -Cmd.ns.Say = function(text) ServerCommand(text) end -- Stance button of the panel, three steps (Karrz 2026-11-03: "passive, defensive and aggressive"). ForeverBotsDB.stance is -- "nofight" - Passive: the bots attack nothing at all, not even to defend; heals and buffs go on (taming a beast, a sheep that diff --git a/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.toc b/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.toc index 2327b6624c..0ebc0efade 100644 --- a/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.toc +++ b/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots.toc @@ -2,7 +2,7 @@ ## Title: WoW Forever Bots ## Notes: One-click PlayerbotV2 companions: add a bot of any class and role, call, dismiss and command your bots. ## Author: Karrz -## Version: 0.6.22 +## Version: 0.6.21 ## IconTexture: Interface\AddOns\ForeverBots\Textures\mono_fb64.tga ## SavedVariables: ForeverBotsDB diff --git a/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots_Trade.lua b/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots_Trade.lua deleted file mode 100644 index 0eacb2deb8..0000000000 --- a/src/modules/PlayerbotV2/Addon/ForeverBots/ForeverBots_Trade.lua +++ /dev/null @@ -1,78 +0,0 @@ ---[[ -ForeverBots_Trade: one click on Trade accepts a trade with a bot. - -The stock Trade button sends the offer state the client last heard of. A bot answers an offer in the same moment (puts its side -in, changes it, accepts), so the click often carries an older state and the server answers "the trade has changed", click after -click. Right after the stock click this file sends what the window shows (both sides' money, the item and count in each of the -six traded slots) as `.bot trade `. When the window still holds exactly that, the server accepts for you -with the bot's current state; when it does not, nothing is accepted and you are told to look again. A trade with a player is -left to the stock click alone (the server answers "none"). - -The command goes the way every click command of the add-on goes (ns.Say): alone as a whisper to yourself, which the server runs -as a dot command before any whisper is made; in a group as an add-on message on the group channel. The answer is a hidden -system line (TRADE_RESP, AddonControl.cpp), which reaches a solo client. Nothing here runs from a timer or an event. -]] - -local _, ns = ... -local net = ns.Net -if not net then return end -net.ANSWERS.TRADE_RESP = true -local L = ns.L or setmetatable({}, { __index = function(_, k) return (k:gsub("^short:", "")) end }) - -local SLOTS = 6 -- traded slots; slot 7 ("will not be traded") does not change hands - -local function ItemId(link) - return type(link) == "string" and tonumber(link:match("item:(%d+)")) or 0 -end - --- One side as the server writes it (TradeSideText): money, then entry:count per traded slot, 0:0 for an empty one. -local function Side(linkOf, infoOf, money) - local out = { tostring(math.floor(tonumber(money) or 0)) } - for i = 1, SLOTS do - local id = ItemId(linkOf and linkOf(i)) - local count = 0 - if id > 0 then - local _, _, n = infoOf(i) - count = tonumber(n) or 1 - end - out[#out + 1] = tostring(id) - out[#out + 1] = tostring(count) - end - return table.concat(out, ":") -end - -local function Seen() - if not (GetTradeTargetItemLink and GetTradePlayerItemLink and GetTargetTradeMoney and GetPlayerTradeMoney) then return nil end - return Side(GetTradeTargetItemLink, GetTradeTargetItemInfo, GetTargetTradeMoney()) .. ":" .. - Side(GetTradePlayerItemLink, GetTradePlayerItemInfo, GetPlayerTradeMoney()) -end - -local function Answered(fields) - if fields and fields[1] == "changed" and UIErrorsFrame then - UIErrorsFrame:AddMessage(L["The bot changed its offer: look at it again, then click Trade."], 1, 0.6, 0) - end -end - --- after the stock click, from the click itself -local function AfterTradeClick() - if not (ns.Say and TradeFrame and TradeFrame:IsShown()) then return end - local seen = Seen() - if not seen then return end - net.seq = (net.seq % 0x7ffffffe) + 1 - local seq = net.seq - net.pending[seq] = { cb = Answered, mtype = "TRADE_RESP", at = GetTime() } - ns.Say(string.format(".bot trade %x %s", seq, seen)) -end - -local hooked = false -local function Hook() - local button = TradeFrameTradeButton or (TradeFrame and TradeFrame.TradeButton) - if hooked or not button or not button.HookScript then return end - button:HookScript("OnClick", AfterTradeClick) - hooked = true -end - -local f = CreateFrame("Frame") -f:RegisterEvent("TRADE_SHOW") -f:RegisterEvent("PLAYER_LOGIN") -f:SetScript("OnEvent", Hook) diff --git a/src/modules/PlayerbotV2/Addon/ForeverBots/Locale_ruRU.lua b/src/modules/PlayerbotV2/Addon/ForeverBots/Locale_ruRU.lua index 4924a28c21..ad32a96ed9 100644 --- a/src/modules/PlayerbotV2/Addon/ForeverBots/Locale_ruRU.lua +++ b/src/modules/PlayerbotV2/Addon/ForeverBots/Locale_ruRU.lua @@ -585,7 +585,6 @@ ForeverBotsLocale = { ["Set with the mouse"] = "Поставить мышью", ["short:G%d"] = "Г%d", ["Tick every bot in this raid group. Click again when they are all ticked to untick them."] = "Отметить всех ботов этой группы рейда. Нажмите еще раз, когда отмечены все, чтобы снять отметку.", - ["The bot changed its offer: look at it again, then click Trade."] = "Бот изменил свое предложение: посмотрите еще раз и нажмите «Обмен».", -- check -- Tank leads (Orders tab) ["short:Ignore"] = "Не трогать", -- check ["short:Tank leads"] = "Танк ведет", -- check diff --git a/src/modules/PlayerbotV2/Bot/BotSnapshot.h b/src/modules/PlayerbotV2/Bot/BotSnapshot.h index d07342a37e..278c341686 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshot.h +++ b/src/modules/PlayerbotV2/Bot/BotSnapshot.h @@ -1735,7 +1735,6 @@ struct StablePet uint8 level = 0; uint8 slot_kind = 0; // 0=active, 1=stabled, 2=unslotted uint8 slot_index = 0; - bool dead = false; // saved with 0 health: died, and its body is gone (only Revive Pet brings it back) }; struct PetState { diff --git a/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp b/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp index 995ad61339..48e458b3bf 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp +++ b/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp @@ -10827,7 +10827,6 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b sp.level = info.Level; sp.slot_kind = 0; // active sp.slot_index = i; - sp.dead = info.Health == 0; snap->pet.stable_pets.push_back(std::move(sp)); } for (uint8 i = 0; i < stable->StabledPets.size(); ++i) diff --git a/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp b/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp index 5ddc440a0c..803c6b37b5 100644 --- a/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp +++ b/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp @@ -359,17 +359,9 @@ bool MaintainPet(BotSnapshotView const& s, BotAI& ai, BotIntentEmitter& emit, constexpr uint32 CALL_PET_4 = 83244; constexpr uint32 CALL_PET_5 = 83245; constexpr uint32 REVIVE_PET = 982; - // The pet died: its body still lies there (a guid but no living pet), or the body is gone and the pet is saved dead in an - // active slot (no guid any more). Only Revive Pet brings it back; the core refuses Call Pet for every active pet while one is - // saved dead, so never fall through to the Call Pet loop below (it was cast again and again, Discord 2026-11-14). - bool active_pet_dead = false; - for (auto const& sp : s.raw().pet.stable_pets) - if (sp.slot_kind == 0 && sp.creature_id != 0 && sp.dead) - { active_pet_dead = true; break; } - if (!s.pet_guid().IsEmpty() || active_pet_dead) + // Pet entry exists but is dead → revive + if (!s.pet_guid().IsEmpty() && s.knows_spell(REVIVE_PET) && s.is_ready(REVIVE_PET)) { - if (!s.knows_spell(REVIVE_PET) || !s.is_ready(REVIVE_PET)) - return false; emit.cast(REVIVE_PET); ai.note_pet_summon_attempt(pet_now_ms); return true; diff --git a/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Hunter.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Hunter.cpp index b83cfaf43d..7f65a4a20b 100644 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Hunter.cpp +++ b/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Hunter.cpp @@ -143,22 +143,9 @@ bool ShouldTrueshotAura(ApPredicateContext const& ctx) } void DoTrueshotAura(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(TRUESHOT_AURA); } -// A pet in an active slot that died and whose body is gone: saved with 0 health. While one is, the core refuses Call Pet for every -// active pet ("your pet is dead", Spell::CheckCast) and only Revive Pet works, with no pet in the world to target. -bool ActivePetDead(ApPredicateContext const& ctx) -{ - for (auto const& sp : ctx.bot.stable_pets()) - if (sp.slot_kind == 0 && sp.creature_id != 0 && sp.dead) - return true; - return false; -} - bool ShouldCallPet(ApPredicateContext const& ctx) { if (ctx.bot.in_combat() || !ctx.bot.pet_guid().IsEmpty() || ctx.bot.owner_pet_off() || Classic::LoneWolfKeepsPetAway(ctx.bot)) return false; - // A dead pet whose body despawned left the guid empty, so the bot cast Call Pet again and again and the core refused each one - // (Discord, 2026-11-14); Revive Pet below brings it back instead. - if (ActivePetDead(ctx)) return false; if (!Ready(ctx, CALL_PET)) return false; for (auto const& sp : ctx.bot.stable_pets()) if (sp.slot_kind == 0 && sp.creature_id != 0) @@ -169,11 +156,9 @@ void DoCallPet(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CALL_PET bool ShouldRevivePet(ApPredicateContext const& ctx) { - // Only when a pet existed and died: its body still lies there (a guid but no living pet), or the body is gone and the pet is - // saved dead in an active slot (no guid any more). Not while the owner keeps the pet away ("pet off"). - if (ctx.bot.owner_pet_off() || Classic::LoneWolfKeepsPetAway(ctx.bot) || ctx.bot.has_pet()) return false; - if (ctx.bot.pet_guid().IsEmpty() && !ActivePetDead(ctx)) return false; - return Ready(ctx, REVIVE_PET); + // Only when a pet existed and died; an empty guid means never tamed. Not while the owner keeps the pet away ("pet off"). + return !ctx.bot.owner_pet_off() && !Classic::LoneWolfKeepsPetAway(ctx.bot) && !ctx.bot.pet_guid().IsEmpty() && !ctx.bot.has_pet() + && Ready(ctx, REVIVE_PET); } void DoRevivePet(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(REVIVE_PET); } diff --git a/src/modules/PlayerbotV2/Commands/cs_playerbot_v2.cpp b/src/modules/PlayerbotV2/Commands/cs_playerbot_v2.cpp index 3a4e639397..7ee7913955 100644 --- a/src/modules/PlayerbotV2/Commands/cs_playerbot_v2.cpp +++ b/src/modules/PlayerbotV2/Commands/cs_playerbot_v2.cpp @@ -815,22 +815,6 @@ public: return true; } - // `.bot trade `: right after the stock Trade click, the ForeverBots trade window sends what it - // shows, and a trade with a bot is accepted when that is still exactly the offer (AddonControl::BotTradeRequest). Alone the - // add-on sends it as a whisper to the player's own name from the click: a dot command runs before any whisper is made, so - // nothing is sent to anyone. The answer is a hidden TRADE_RESP frame, never plain text. - static bool HandleBotTrade(ChatHandler* handler, std::string seqHex, std::string seen) - { - WorldSession* sess = handler->GetSession(); - Player* me = sess ? sess->GetPlayer() : nullptr; - if (!me || seqHex.empty() || seqHex.size() > 8 || seqHex.find_first_not_of("0123456789abcdefABCDEF") != std::string::npos) - return true; // quiet: only the add-on sends this - if (seen.empty() || seen.size() > 230 || seen.find_first_not_of("0123456789:") != std::string::npos) - return true; - Playerbot::V2::AddonControl::BotTradeRequest(me, uint32(std::strtoul(seqHex.c_str(), nullptr, 16)), seen); - return true; - } - // ---- .bot: one-step companions ------------------------------------------------------------------------------ static Playerbot::Role ParseRoleWord(std::string const& token, bool& ok) diff --git a/src/modules/PlayerbotV2/Session/AddonControl.cpp b/src/modules/PlayerbotV2/Session/AddonControl.cpp index 69f2d75e19..f50896cecf 100644 --- a/src/modules/PlayerbotV2/Session/AddonControl.cpp +++ b/src/modules/PlayerbotV2/Session/AddonControl.cpp @@ -37,8 +37,6 @@ #include "Player.h" #include "QuestDef.h" #include "RBAC.h" -#include "TradeData.h" -#include "TradePackets.h" #include "World.h" #include "WorldSession.h" @@ -1690,89 +1688,6 @@ void DispatchAssembled(WorldSession* sess, uint32 seq, // ============================================================================ // Public entry — called from the PlayerScript::OnChat hook. // ============================================================================ -// ============================================================================ -// Trading with a bot (ForeverBots_Trade.lua, `.bot trade `). -// The stock Trade button sends the offer state the client last heard of. A bot -// answers an offer in the same moment (puts its side in, changes it, accepts), -// so the click often carries an older state and the server answers "the trade -// has changed", click after click. Right after the stock click the add-on sends -// what the window shows: both sides' money and the item and count in each of the -// six traded slots. When that is exactly what the window holds now, the player's -// accept runs with the bot's current state; when it is not, nothing is accepted -// (the player has not seen the new offer) and the add-on says to look again. -// TRADE_RESP|done accepted for the player (the normal accept ran) -// TRADE_RESP|already the stock click was accepted already -// TRADE_RESP|changed the window is not what the player saw -// TRADE_RESP|none no window with a bot (a trade with a player keeps the stock click only) -// Answers always go as hidden system lines: alone, the client gets no add-on -// whisper through (Net.lua), and this request usually comes from a solo player. -// ============================================================================ -namespace { - -void SendTradeAnswer(WorldSession* sess, uint32 seq, std::string_view what) -{ - char head[24]; - std::snprintf(head, sizeof(head), "%s|%08x|1|1|", kProtoVersion, seq); - std::string body = std::string(kSysMarker) + head + "TRADE_RESP|" + std::string(what); - WorldPackets::Chat::Chat sys; - sys.Initialize(CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, body); - sess->SendPacket(sys.Write()); -} - -// One side as the add-on writes it: money, then entry and count of traded slots 1-6 (0:0 for an empty slot). -std::string TradeSideText(TradeData const* side) -{ - std::string out = std::to_string(side->GetMoney()); - for (uint8 i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i) - { - Item const* item = side->GetItem(TradeSlots(i)); - out += ":" + std::to_string(item ? item->GetEntry() : 0u) + ":" + std::to_string(item ? item->GetCount() : 0u); - } - return out; -} - -} // anonymous - -void BotTradeRequest(Player* player, uint32 seq, std::string const& seen) -{ - WorldSession* sess = player ? player->GetSession() : nullptr; - if (!sess) - return; - - TradeData* mine = player->GetTradeData(); - Player* bot = mine ? mine->GetTrader() : nullptr; - TradeData* theirs = bot ? bot->GetTradeData() : nullptr; - // only a window between this player and a bot: a trade with a player keeps the client's own accept and its state check - if (!theirs || theirs->GetTrader() != player || !Services::Initialized() || !Services::SessionMgr().IsHeadless(bot->GetGUID())) - { - SendTradeAnswer(sess, seq, "none"); - return; - } - - if (mine->IsAccepted()) - { - SendTradeAnswer(sess, seq, "already"); - return; - } - - // what the player saw: the bot's side first, then the player's own - if (seen != TradeSideText(theirs) + ":" + TradeSideText(mine) || mine->IsInAcceptProcess() || theirs->IsInAcceptProcess()) - { - TC_LOG_DEBUG("playerbot.v2", "[bot_trade] {} with {}: window changed since the click", player->GetName(), bot->GetName()); - SendTradeAnswer(sess, seq, "changed"); - return; - } - - // The player's own accept with the bot's current state: every other check of a normal accept still runs (distance, money, - // bag room, items still there), and the bot finishes on its side as after a click. - WorldPacket packet(CMSG_ACCEPT_TRADE); - packet << uint32(theirs->GetServerStateIndex()); - WorldPackets::Trade::AcceptTrade accept(std::move(packet)); - accept.Read(); - sess->HandleAcceptTradeOpcode(accept); - SendTradeAnswer(sess, seq, "done"); -} - bool OnAddonWhisper(Player* sender, Player* /*receiver*/, std::string const& prefix, std::string const& body) { diff --git a/src/modules/PlayerbotV2/Session/AddonControl.h b/src/modules/PlayerbotV2/Session/AddonControl.h index 606d31d4bc..3e12f444c1 100644 --- a/src/modules/PlayerbotV2/Session/AddonControl.h +++ b/src/modules/PlayerbotV2/Session/AddonControl.h @@ -39,10 +39,6 @@ constexpr uint32_t kMaxReassemblyChunks = 64; // client-supplied chunk coun bool OnAddonWhisper(Player* sender, Player* receiver, std::string const& prefix, std::string const& body); -// `.bot trade ` from the ForeverBots trade window: accepts a trade with a bot when the window -// holds exactly what the player saw (BotTradeRequest in AddonControl.cpp). The answer is a TRADE_RESP frame. -void BotTradeRequest(Player* player, uint32 seq, std::string const& seen); - // Tear-down hook — reaps the per-account reassembly state and retry spool // when a session logs out. Called from PlayerbotV2 module on OnSessionLogout. void OnSessionLogout(uint32 sessionAccountId);