From 087acc58bf2a107461ce6b01d9ff209c7d74acca Mon Sep 17 00:00:00 2001 From: Saqra1 <161769195+Saqra1@users.noreply.github.com> Date: Mon, 19 Aug 2024 11:15:39 -0500 Subject: [PATCH] fix(Core/PetHandler): Allow PetAI to handle flags (#19446) When a pet ability was cast, PetHandler reset all CharmInfo flags before calling PetAI methods, setting the attack flag to true every time. This commands the pet to go and chase the target which is not correct when the state is COMMAND_STAY. PetAI already handles the scenario, it just wasn't getting the actual pet attack state. --- src/server/game/Entities/Pet/Pet.cpp | 5 ----- src/server/game/Handlers/PetHandler.cpp | 7 ------- 2 files changed, 12 deletions(-) diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 117b8f6a5..535a85186 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -754,17 +754,12 @@ void Pet::Update(uint32 diff) GetMotionMaster()->Clear(false); GetMotionMaster()->MoveIdle(); - bool oldCmdAttack = GetCharmInfo()->IsCommandAttack(); - - GetCharmInfo()->SetIsCommandAttack(false); GetCharmInfo()->SetIsAtStay(true); GetCharmInfo()->SetIsCommandFollow(false); GetCharmInfo()->SetIsFollowing(false); GetCharmInfo()->SetIsReturning(false); GetCharmInfo()->SaveStayPosition(true); - GetCharmInfo()->SetIsCommandAttack(oldCmdAttack); - AddSpellCooldown(tempspell, 0, spellInfo->IsCooldownStartedOnEvent() ? infinityCooldownDelay : 0); CastSpell(tempspellTarget, tempspell, false); diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index 2f313c701..c0f66a02b 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -355,13 +355,6 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe return; } - // Clear the flags as if owner clicked 'attack'. AI will reset them - // after AttackStart, even if spell failed - charmInfo->SetIsAtStay(false); - charmInfo->SetIsCommandAttack(true); - charmInfo->SetIsReturning(false); - charmInfo->SetIsFollowing(false); - TriggerCastFlags triggerCastFlags = TRIGGERED_NONE; if (spellInfo->IsPassive())