fix(Core/Pets): Manual using pet spell should not reset attack command. (#9635)
Fixes #9632
This commit is contained in:
@@ -593,16 +593,12 @@ void PetAI::DoAttack(Unit* target, bool chase)
|
|||||||
if (me->HasReactState(REACT_AGGRESSIVE) && !me->GetCharmInfo()->IsCommandAttack())
|
if (me->HasReactState(REACT_AGGRESSIVE) && !me->GetCharmInfo()->IsCommandAttack())
|
||||||
me->SendPetAIReaction(me->GetGUID());
|
me->SendPetAIReaction(me->GetGUID());
|
||||||
|
|
||||||
if (CharmInfo* ci = me->GetCharmInfo())
|
|
||||||
{
|
|
||||||
ci->SetIsAtStay(false);
|
|
||||||
ci->SetIsCommandFollow(false);
|
|
||||||
ci->SetIsFollowing(false);
|
|
||||||
ci->SetIsReturning(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chase)
|
if (chase)
|
||||||
{
|
{
|
||||||
|
bool oldCmdAttack = me->GetCharmInfo()->IsCommandAttack(); // This needs to be reset after other flags are cleared
|
||||||
|
ClearCharmInfoFlags();
|
||||||
|
me->GetCharmInfo()->SetIsCommandAttack(oldCmdAttack); // For passive pets commanded to attack so they will use spells
|
||||||
|
|
||||||
if (_canMeleeAttack())
|
if (_canMeleeAttack())
|
||||||
{
|
{
|
||||||
float angle = combatRange == 0.f && target->GetTypeId() != TYPEID_PLAYER && !target->IsPet() ? float(M_PI) : 0.f;
|
float angle = combatRange == 0.f && target->GetTypeId() != TYPEID_PLAYER && !target->IsPet() ? float(M_PI) : 0.f;
|
||||||
@@ -612,6 +608,8 @@ void PetAI::DoAttack(Unit* target, bool chase)
|
|||||||
}
|
}
|
||||||
else // (Stay && ((Aggressive || Defensive) && In Melee Range)))
|
else // (Stay && ((Aggressive || Defensive) && In Melee Range)))
|
||||||
{
|
{
|
||||||
|
ClearCharmInfoFlags();
|
||||||
|
|
||||||
me->GetCharmInfo()->SetIsAtStay(true);
|
me->GetCharmInfo()->SetIsAtStay(true);
|
||||||
me->GetMotionMaster()->MovementExpiredOnSlot(MOTION_SLOT_ACTIVE, false);
|
me->GetMotionMaster()->MovementExpiredOnSlot(MOTION_SLOT_ACTIVE, false);
|
||||||
me->GetMotionMaster()->MoveIdle();
|
me->GetMotionMaster()->MoveIdle();
|
||||||
|
|||||||
@@ -727,6 +727,8 @@ void Pet::Update(uint32 diff)
|
|||||||
GetMotionMaster()->Clear(false);
|
GetMotionMaster()->Clear(false);
|
||||||
GetMotionMaster()->MoveIdle();
|
GetMotionMaster()->MoveIdle();
|
||||||
|
|
||||||
|
bool oldCmdAttack = GetCharmInfo()->IsCommandAttack();
|
||||||
|
|
||||||
GetCharmInfo()->SetIsCommandAttack(false);
|
GetCharmInfo()->SetIsCommandAttack(false);
|
||||||
GetCharmInfo()->SetIsAtStay(true);
|
GetCharmInfo()->SetIsAtStay(true);
|
||||||
GetCharmInfo()->SetIsCommandFollow(false);
|
GetCharmInfo()->SetIsCommandFollow(false);
|
||||||
@@ -734,6 +736,8 @@ void Pet::Update(uint32 diff)
|
|||||||
GetCharmInfo()->SetIsReturning(false);
|
GetCharmInfo()->SetIsReturning(false);
|
||||||
GetCharmInfo()->SaveStayPosition(true);
|
GetCharmInfo()->SaveStayPosition(true);
|
||||||
|
|
||||||
|
GetCharmInfo()->SetIsCommandAttack(oldCmdAttack);
|
||||||
|
|
||||||
AddSpellCooldown(tempspell, 0, spellInfo->IsCooldownStartedOnEvent() ? infinityCooldownDelay : 0);
|
AddSpellCooldown(tempspell, 0, spellInfo->IsCooldownStartedOnEvent() ? infinityCooldownDelay : 0);
|
||||||
|
|
||||||
CastSpell(tempspellTarget, tempspell, false);
|
CastSpell(tempspellTarget, tempspell, false);
|
||||||
|
|||||||
@@ -19652,7 +19652,7 @@ void Unit::PetSpellFail(const SpellInfo* spellInfo, Unit* target, uint32 result)
|
|||||||
{
|
{
|
||||||
AttackStop();
|
AttackStop();
|
||||||
charmInfo->SetIsAtStay(false);
|
charmInfo->SetIsAtStay(false);
|
||||||
charmInfo->SetIsCommandAttack(!ToCreature()->HasReactState(REACT_PASSIVE));
|
charmInfo->SetIsCommandAttack(true);
|
||||||
charmInfo->SetIsReturning(false);
|
charmInfo->SetIsReturning(false);
|
||||||
charmInfo->SetIsFollowing(false);
|
charmInfo->SetIsFollowing(false);
|
||||||
|
|
||||||
@@ -19662,7 +19662,7 @@ void Unit::PetSpellFail(const SpellInfo* spellInfo, Unit* target, uint32 result)
|
|||||||
{
|
{
|
||||||
AttackStop();
|
AttackStop();
|
||||||
charmInfo->SetIsAtStay(false);
|
charmInfo->SetIsAtStay(false);
|
||||||
charmInfo->SetIsCommandAttack(!ToCreature()->HasReactState(REACT_PASSIVE));
|
charmInfo->SetIsCommandAttack(true);
|
||||||
charmInfo->SetIsReturning(false);
|
charmInfo->SetIsReturning(false);
|
||||||
charmInfo->SetIsFollowing(false);
|
charmInfo->SetIsFollowing(false);
|
||||||
|
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
|
|||||||
// Clear the flags as if owner clicked 'attack'. AI will reset them
|
// Clear the flags as if owner clicked 'attack'. AI will reset them
|
||||||
// after AttackStart, even if spell failed
|
// after AttackStart, even if spell failed
|
||||||
charmInfo->SetIsAtStay(false);
|
charmInfo->SetIsAtStay(false);
|
||||||
charmInfo->SetIsCommandAttack(!pet->ToCreature()->HasReactState(REACT_PASSIVE));
|
charmInfo->SetIsCommandAttack(true);
|
||||||
charmInfo->SetIsReturning(false);
|
charmInfo->SetIsReturning(false);
|
||||||
charmInfo->SetIsFollowing(false);
|
charmInfo->SetIsFollowing(false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user