Skip to content

Commit

Permalink
fix(Core/PetHandler): Allow PetAI to handle flags (azerothcore#19446)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Saqra1 authored Aug 19, 2024
1 parent 337135b commit 087acc5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 12 deletions.
5 changes: 0 additions & 5 deletions src/server/game/Entities/Pet/Pet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 0 additions & 7 deletions src/server/game/Handlers/PetHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 087acc5

Please sign in to comment.