From d0ddb0a82aefce9920b1f380b27480ac612da293 Mon Sep 17 00:00:00 2001 From: Karrz1 <127596890+Karrz1@users.noreply.github.com> Date: Sun, 15 Nov 2026 08:27:51 +0000 Subject: [PATCH] Bots: a hunter bot revives its pet after the body is gone When a hunter bot's pet died and its body despawned, the bot had no pet guid left, so it cast Call Pet again and again, and the core refused each one because the pet is saved dead; Revive Pet only ran while the body was still there (Discord, 2026-11-14). The stable snapshot now carries which active pets are saved with 0 health: Call Pet waits while one is, and Revive Pet runs for it with or without a body. Idea from SIN's fix pack for 0.1.37; written again here. --- src/modules/PlayerbotV2/Bot/BotSnapshot.h | 1 + .../PlayerbotV2/Bot/BotSnapshotBuilder.cpp | 1 + .../Combat/Apl/Apl_Classic_Hunter.cpp | 21 ++++++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/modules/PlayerbotV2/Bot/BotSnapshot.h b/src/modules/PlayerbotV2/Bot/BotSnapshot.h index cb2196b185..5f41fd031c 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshot.h +++ b/src/modules/PlayerbotV2/Bot/BotSnapshot.h @@ -1735,6 +1735,7 @@ 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 523b264593..ef402a93ef 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp +++ b/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp @@ -10817,6 +10817,7 @@ 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/Combat/Apl/Apl_Classic_Hunter.cpp b/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Hunter.cpp index 7f65a4a20b..b83cfaf43d 100644 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Hunter.cpp +++ b/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Hunter.cpp @@ -143,9 +143,22 @@ 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) @@ -156,9 +169,11 @@ void DoCallPet(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(CALL_PET bool ShouldRevivePet(ApPredicateContext const& ctx) { - // 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); + // 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); } void DoRevivePet(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(REVIVE_PET); }