fix(Core/Pets): Properly cast spells on friendly target if not in LoS… (#9570)

* fix(Core/Pets): Properly cast spells on friendly target if not in LoS or out of range.

Fixes #7790
This commit is contained in:
UltraNix
2021-12-12 13:25:10 +01:00
committed by GitHub
parent 5e65ce72cc
commit 4e93671b3c
6 changed files with 26 additions and 9 deletions

View File

@@ -60,6 +60,11 @@ bool PetAI::_needToStop()
return !me->CanCreatureAttack(me->GetVictim());
}
void PetAI::PetStopAttack()
{
_stopAttack();
}
void PetAI::_stopAttack()
{
if (!me->IsAlive())
@@ -174,7 +179,7 @@ void PetAI::UpdateAI(uint32 diff)
else
_doMeleeAttack();
}
else if (!me->GetCharmInfo() || (!me->GetCharmInfo()->GetForcedSpell() && !me->HasUnitState(UNIT_STATE_CASTING)))
else if (!me->GetCharmInfo() || (!me->GetCharmInfo()->GetForcedSpell() && !(me->IsPet() && me->ToPet()->HasTempSpell()) && !me->HasUnitState(UNIT_STATE_CASTING)))
{
if (me->HasReactState(REACT_AGGRESSIVE) || me->GetCharmInfo()->IsAtStay())
{

View File

@@ -67,6 +67,8 @@ public:
void EnterEvadeMode() override {} // For fleeing, pets don't use this type of Evade mechanic
void SpellHit(Unit* caster, const SpellInfo* spellInfo) override;
void PetStopAttack() override;
private:
bool _isVisible(Unit*) const;
bool _needToStop(void);

View File

@@ -177,6 +177,8 @@ public:
virtual bool CanBeSeen(Player const* /*seer*/) { return true; }
virtual void PetStopAttack() { }
protected:
virtual void MoveInLineOfSight(Unit* /*who*/);