aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLiberate <none@none>2010-09-15 14:16:10 +0200
committerLiberate <none@none>2010-09-15 14:16:10 +0200
commit97a93573cbb677032ab51afc57f4d7627bc14f7e (patch)
treeb570832d4fca3cd0a9138636b36ee751ecb4de8f /src
parenta72fc44f9a86d5016b00dbb472e6e4f795a59a17 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CoreAI/PetAI.cpp24
-rw-r--r--src/server/game/Entities/Unit/Unit.h4
2 files changed, 12 insertions, 16 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp
index f975f3f96ba..1975e68be0a 100644
--- a/src/server/game/AI/CoreAI/PetAI.cpp
+++ b/src/server/game/AI/CoreAI/PetAI.cpp
@@ -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;
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 71ab27eb654..0976a2c2d2e 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -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);