Bots: a hunter bot revives its pet after the body is gone (SIN's fix)
SIN's Hunter Bot Pet Revive for 0.1.37, as he wrote it. The snapshot marks a dead pet saved in an active stable slot; Call Pet waits while there is one, and Revive Pet runs for it with or without a body, both in the combat rotation and in the idle pet upkeep. Code by SIN (1amcoff1n). Applied unchanged.
This commit is contained in:
@@ -1752,6 +1752,7 @@ struct PetState
|
||||
std::string pet_name;
|
||||
std::vector<AuraEntry> pet_auras;
|
||||
std::vector<StablePet> 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.
|
||||
|
||||
@@ -10813,6 +10813,7 @@ std::shared_ptr<BotSnapshot const> 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<BotSnapshot const> 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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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); }
|
||||
|
||||
Reference in New Issue
Block a user