diff --git a/src/modules/PlayerbotV2/Bot/BotSnapshot.h b/src/modules/PlayerbotV2/Bot/BotSnapshot.h index 278c341686..c809a457b2 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshot.h +++ b/src/modules/PlayerbotV2/Bot/BotSnapshot.h @@ -1752,6 +1752,7 @@ struct PetState std::string pet_name; std::vector pet_auras; std::vector stable_pets; + bool has_dead_active_pet = false; // Whom the pet is currently attacking (Empty if no victim). Drives // the assist-pet rule: bot picks up the pet's target so a hunter // standing idle while his cat melees a mob actually opens up too. diff --git a/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp b/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp index 48e458b3bf..3f91696030 100644 --- a/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp +++ b/src/modules/PlayerbotV2/Bot/BotSnapshotBuilder.cpp @@ -10813,6 +10813,7 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b // idle:summon_stabled_pet rule so a hunter that ends up petless (died // and despawned, abandoned) can pull a stabled pet at the next // stablemaster visit. Empty for non-hunters or pre-PetStable bots. + snap->pet.has_dead_active_pet = false; if (PetStable const* stable = p->GetPetStable()) { snap->pet.stable_pets.reserve(8); @@ -10825,6 +10826,8 @@ std::shared_ptr BotSnapshotBuilder::Build(Player* p, BotAI* b sp.creature_id = info.CreatureId; sp.name = info.Name; sp.level = info.Level; + if (info.CreatureId && info.Health == 0) + snap->pet.has_dead_active_pet = true; sp.slot_kind = 0; // active sp.slot_index = i; snap->pet.stable_pets.push_back(std::move(sp)); diff --git a/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp b/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp index 803c6b37b5..a70f0d2c01 100644 --- a/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp +++ b/src/modules/PlayerbotV2/Bot/States/State_Idle.cpp @@ -359,9 +359,11 @@ 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; - // Pet entry exists but is dead → revive - if (!s.pet_guid().IsEmpty() && s.knows_spell(REVIVE_PET) && s.is_ready(REVIVE_PET)) + // Revive also works after the corpse has despawned. + if (!s.pet_guid().IsEmpty() || s.raw().pet.has_dead_active_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 7f65a4a20b..430ac9bb6b 100644 --- a/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Hunter.cpp +++ b/src/modules/PlayerbotV2/Combat/Apl/Apl_Classic_Hunter.cpp @@ -146,7 +146,7 @@ void DoTrueshotAura(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(TRU 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; - if (!Ready(ctx, CALL_PET)) return false; + if (ctx.bot.raw().pet.has_dead_active_pet || !Ready(ctx, CALL_PET)) return false; for (auto const& sp : ctx.bot.stable_pets()) if (sp.slot_kind == 0 && sp.creature_id != 0) return true; @@ -156,8 +156,9 @@ 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() + // A saved dead pet can outlive its in-world GUID. + return !ctx.bot.owner_pet_off() && !Classic::LoneWolfKeepsPetAway(ctx.bot) && !ctx.bot.has_pet() + && (!ctx.bot.pet_guid().IsEmpty() || ctx.bot.raw().pet.has_dead_active_pet) && Ready(ctx, REVIVE_PET); } void DoRevivePet(ApPredicateContext const&, BotIntentEmitter& e) { e.cast(REVIVE_PET); }