mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 15:40:45 +01:00
Core/Pets: Pet Attack Distance
This commit is contained in:
@@ -134,7 +134,6 @@ void PetAI::UpdateAI(uint32 diff)
|
||||
// Autocast (cast only in combat or persistent spells in any state)
|
||||
if (!me->HasUnitState(UNIT_STATE_CASTING))
|
||||
{
|
||||
typedef std::vector<std::pair<Unit*, Spell*> > TargetSpellList;
|
||||
TargetSpellList targetSpellStore;
|
||||
|
||||
for (uint8 i = 0; i < me->GetPetAutoSpellSize(); ++i)
|
||||
@@ -222,7 +221,7 @@ void PetAI::UpdateAI(uint32 diff)
|
||||
}
|
||||
}
|
||||
|
||||
//found units to cast on to
|
||||
// found units to cast on to
|
||||
if (!targetSpellStore.empty())
|
||||
{
|
||||
TargetSpellList::iterator it = targetSpellStore.begin();
|
||||
@@ -462,7 +461,7 @@ void PetAI::DoAttack(Unit* target, bool chase)
|
||||
ClearCharmInfoFlags();
|
||||
me->GetCharmInfo()->SetIsCommandAttack(oldCmdAttack); // For passive pets commanded to attack so they will use spells
|
||||
me->GetMotionMaster()->Clear();
|
||||
me->GetMotionMaster()->MoveChase(target);
|
||||
me->GetMotionMaster()->MoveChase(target, me->GetPetChaseDistance());
|
||||
}
|
||||
else // (Stay && ((Aggressive || Defensive) && In Melee Range)))
|
||||
{
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
class Creature;
|
||||
class Spell;
|
||||
|
||||
typedef std::vector<std::pair<Unit*, Spell*>> TargetSpellList;
|
||||
|
||||
class TC_GAME_API PetAI : public CreatureAI
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -2575,6 +2575,28 @@ uint32 Creature::GetPetAutoSpellOnPos(uint8 pos) const
|
||||
return m_charmInfo->GetCharmSpell(pos)->GetAction();
|
||||
}
|
||||
|
||||
float Creature::GetPetChaseDistance() const
|
||||
{
|
||||
float range = MELEE_RANGE;
|
||||
|
||||
for (uint8 i = 0; i < GetPetAutoSpellSize(); ++i)
|
||||
{
|
||||
uint32 spellID = GetPetAutoSpellOnPos(i);
|
||||
if (!spellID)
|
||||
continue;
|
||||
|
||||
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID))
|
||||
{
|
||||
if (spellInfo->GetRecoveryTime() == 0 && // No cooldown
|
||||
spellInfo->RangeEntry->ID != 1 /*Self*/ && spellInfo->RangeEntry->ID != 2 /*Combat Range*/ &&
|
||||
spellInfo->GetMaxRange() > range)
|
||||
range = spellInfo->GetMinRange();
|
||||
}
|
||||
}
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
void Creature::SetPosition(float x, float y, float z, float o)
|
||||
{
|
||||
// prevent crash when a bad coord is sent by the client
|
||||
|
||||
@@ -637,6 +637,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
void setRegeneratingHealth(bool regenHealth) { m_regenHealth = regenHealth; }
|
||||
virtual uint8 GetPetAutoSpellSize() const { return MAX_SPELL_CHARM; }
|
||||
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const;
|
||||
float GetPetChaseDistance() const;
|
||||
|
||||
void SetCannotReachTarget(bool cannotReach)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user