mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-09 08:17:56 +00:00
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:
@@ -60,6 +60,11 @@ bool PetAI::_needToStop()
|
|||||||
return !me->CanCreatureAttack(me->GetVictim());
|
return !me->CanCreatureAttack(me->GetVictim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PetAI::PetStopAttack()
|
||||||
|
{
|
||||||
|
_stopAttack();
|
||||||
|
}
|
||||||
|
|
||||||
void PetAI::_stopAttack()
|
void PetAI::_stopAttack()
|
||||||
{
|
{
|
||||||
if (!me->IsAlive())
|
if (!me->IsAlive())
|
||||||
@@ -174,7 +179,7 @@ void PetAI::UpdateAI(uint32 diff)
|
|||||||
else
|
else
|
||||||
_doMeleeAttack();
|
_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())
|
if (me->HasReactState(REACT_AGGRESSIVE) || me->GetCharmInfo()->IsAtStay())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ public:
|
|||||||
void EnterEvadeMode() override {} // For fleeing, pets don't use this type of Evade mechanic
|
void EnterEvadeMode() override {} // For fleeing, pets don't use this type of Evade mechanic
|
||||||
void SpellHit(Unit* caster, const SpellInfo* spellInfo) override;
|
void SpellHit(Unit* caster, const SpellInfo* spellInfo) override;
|
||||||
|
|
||||||
|
void PetStopAttack() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _isVisible(Unit*) const;
|
bool _isVisible(Unit*) const;
|
||||||
bool _needToStop(void);
|
bool _needToStop(void);
|
||||||
|
|||||||
@@ -177,6 +177,8 @@ public:
|
|||||||
|
|
||||||
virtual bool CanBeSeen(Player const* /*seer*/) { return true; }
|
virtual bool CanBeSeen(Player const* /*seer*/) { return true; }
|
||||||
|
|
||||||
|
virtual void PetStopAttack() { }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void MoveInLineOfSight(Unit* /*who*/);
|
virtual void MoveInLineOfSight(Unit* /*who*/);
|
||||||
|
|
||||||
|
|||||||
@@ -511,13 +511,18 @@ void Pet::Update(uint32 diff)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
|
if (IsAIEnabled)
|
||||||
GetCharmInfo()->SetIsCommandAttack(false);
|
AI()->PetStopAttack();
|
||||||
GetCharmInfo()->SetIsAtStay(false);
|
else
|
||||||
GetCharmInfo()->SetIsReturning(true);
|
{
|
||||||
GetCharmInfo()->SetIsCommandFollow(true);
|
GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
|
||||||
GetCharmInfo()->SetIsFollowing(false);
|
GetCharmInfo()->SetIsCommandAttack(false);
|
||||||
GetMotionMaster()->MoveFollow(charmer, PET_FOLLOW_DIST, GetFollowAngle());
|
GetCharmInfo()->SetIsAtStay(false);
|
||||||
|
GetCharmInfo()->SetIsReturning(true);
|
||||||
|
GetCharmInfo()->SetIsCommandFollow(true);
|
||||||
|
GetCharmInfo()->SetIsFollowing(false);
|
||||||
|
GetMotionMaster()->MoveFollow(charmer, PET_FOLLOW_DIST, GetFollowAngle());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_tempoldTarget = nullptr;
|
m_tempoldTarget = nullptr;
|
||||||
|
|||||||
@@ -169,6 +169,9 @@ public:
|
|||||||
static void HandleAsynchLoadFailed(AsynchPetSummon* info, Player* player, uint8 asynchLoadType, uint8 loadResult);
|
static void HandleAsynchLoadFailed(AsynchPetSummon* info, Player* player, uint8 asynchLoadType, uint8 loadResult);
|
||||||
uint8 GetAsynchLoadType() const { return asynchLoadType; }
|
uint8 GetAsynchLoadType() const { return asynchLoadType; }
|
||||||
void SetAsynchLoadType(uint8 type) { asynchLoadType = type; }
|
void SetAsynchLoadType(uint8 type) { asynchLoadType = type; }
|
||||||
|
|
||||||
|
[[nodiscard]] bool HasTempSpell() const { return m_tempspell != 0; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Player* m_owner;
|
Player* m_owner;
|
||||||
int32 m_happinessTimer;
|
int32 m_happinessTimer;
|
||||||
|
|||||||
@@ -890,7 +890,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
|
|||||||
charmInfo->SetIsCommandFollow(false);
|
charmInfo->SetIsCommandFollow(false);
|
||||||
charmInfo->SetIsReturning(false);
|
charmInfo->SetIsReturning(false);
|
||||||
|
|
||||||
pet->GetMotionMaster()->MoveChase(unit_target);
|
pet->GetMotionMaster()->MoveFollow(unit_target, PET_FOLLOW_DIST, rand_norm() * 2 * M_PI);
|
||||||
|
|
||||||
if (pet->IsPet() && ((Pet*)pet)->getPetType() == SUMMON_PET && pet != unit_target && urand(0, 100) < 10)
|
if (pet->IsPet() && ((Pet*)pet)->getPetType() == SUMMON_PET && pet != unit_target && urand(0, 100) < 10)
|
||||||
pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL);
|
pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL);
|
||||||
|
|||||||
Reference in New Issue
Block a user