Core/PetAI: When commanding your pet to attack while being Passive, it will actually start attacking.

Fixes the PetAI so that your pet stops attacking when the target is Crowd Controlled (including Frost Nova, Fear, etc) unless you specifically ask it to.
Tested extensively with click.

--HG--
branch : trunk
This commit is contained in:
Liberate
2010-09-15 14:16:10 +02:00
parent a72fc44f9a
commit 97a93573cb
2 changed files with 12 additions and 16 deletions
+8 -16
View File
@@ -42,6 +42,7 @@ PetAI::PetAI(Creature *c) : CreatureAI(c), i_tracker(TIME_INTERVAL_LOOK)
{
m_AllySet.clear();
UpdateAllies();
targetHasCC = false;
}
void PetAI::EnterEvadeMode()
@@ -54,7 +55,7 @@ bool PetAI::_needToStop()
if (me->isCharmed() && me->getVictim() == me->GetCharmer())
return true;
if (_CheckTargetCC(me->getVictim()) != targetHasCC)
if (_CheckTargetCC(me->getVictim()) && !targetHasCC)
return true;
return !me->canAttack(me->getVictim());
@@ -100,6 +101,7 @@ void PetAI::UpdateAI(const uint32 diff)
_stopAttack();
return;
}
targetHasCC = _CheckTargetCC(me->getVictim());
DoMeleeAttackIfReady();
}
@@ -107,10 +109,10 @@ void PetAI::UpdateAI(const uint32 diff)
{
Unit *nextTarget = SelectNextTarget();
if (nextTarget)
AttackStart(nextTarget);
if (me->HasReactState(REACT_PASSIVE))
_stopAttack();
else if (nextTarget)
AttackStart(nextTarget);
else
HandleReturnMovement();
}
@@ -300,19 +302,9 @@ void PetAI::AttackStart(Unit *target)
if (!_CanAttack(target))
return;
if (_CheckTargetCC(target))
targetHasCC = true;
targetHasCC = _CheckTargetCC(target);
// We can attack, should we chase or not?
if (me->GetCharmInfo()->HasCommandState(COMMAND_FOLLOW))
DoAttack(target,true); // FOLLOW, attack with chase
else
{
if (me->GetCharmInfo()->IsCommandAttack())
DoAttack(target,true); // STAY or FOLLOW, player clicked "attack" so attack with chase
else
DoAttack(target,false); // STAY, target in range, attack not clicked so attack without chase
}
DoAttack(target, true);
}
Unit *PetAI::SelectNextTarget()
@@ -479,7 +471,7 @@ bool PetAI::_CanAttack(Unit *target)
bool PetAI::_CheckTargetCC(Unit *target)
{
if (me->GetOwnerGUID() && target->HasNegativeAuraWithInterruptFlag(AURA_INTERRUPT_FLAG_TAKE_DAMAGE, me->GetOwnerGUID()))
if (target->HasCCAura())
return true;
return false;
+4
View File
@@ -1640,6 +1640,10 @@ class Unit : public WorldObject
bool HasAuraTypeWithAffectMask(AuraType auratype, SpellEntry const * affectedSpell) const;
bool HasAuraTypeWithValue(AuraType auratype, int32 value) const;
bool HasNegativeAuraWithInterruptFlag(uint32 flag, uint64 guid = 0);
bool HasCCAura() {
return (HasAuraType(SPELL_AURA_MOD_CONFUSE) || HasAuraType(SPELL_AURA_MOD_FEAR) || HasAuraType(SPELL_AURA_MOD_STUN) ||
HasAuraType(SPELL_AURA_MOD_ROOT) || HasAuraType(SPELL_AURA_TRANSFORM));
}
AuraEffect * IsScriptOverriden(SpellEntry const * spell, int32 script) const;
uint32 GetDiseasesByCaster(uint64 casterGUID, bool remove = false);