aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI
diff options
context:
space:
mode:
authorclick <none@none>2010-07-28 19:39:56 +0200
committerclick <none@none>2010-07-28 19:39:56 +0200
commitc595eb8ae9c7c272dfc72d688acb0ec8cb5f2de9 (patch)
tree9eea18cc5e5ca1a1b1c771c7ac5d2ee6037e46d9 /src/server/game/AI
parentc173e84f252453397c5360fd74958c3ed135a06f (diff)
First part of petAI logic cleanup : Hunter PetAI change: Ignore attacking CC'ed targets unless explicitly asked for by player
(thanks to QAston, Shauren, Liberate for the discussions and codehelp to sort this out properly) --HG-- branch : trunk
Diffstat (limited to 'src/server/game/AI')
-rw-r--r--src/server/game/AI/CoreAI/PetAI.cpp35
-rw-r--r--src/server/game/AI/CoreAI/PetAI.h4
2 files changed, 27 insertions, 12 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp
index cae50668a3a..0eb8e024adb 100644
--- a/src/server/game/AI/CoreAI/PetAI.cpp
+++ b/src/server/game/AI/CoreAI/PetAI.cpp
@@ -48,12 +48,15 @@ void PetAI::EnterEvadeMode()
{
}
-bool PetAI::_needToStop() const
+bool PetAI::_needToStop()
{
// This is needed for charmed creatures, as once their target was reset other effects can trigger threat
if (me->isCharmed() && me->getVictim() == me->GetCharmer())
return true;
+ if (_CheckTargetCC(me->getVictim()) != targetHasCC)
+ return true;
+
return !me->canAttack(me->getVictim());
}
@@ -295,6 +298,9 @@ void PetAI::AttackStart(Unit *target)
if (!_CanAttack(target))
return;
+ if (_CheckTargetCC(target))
+ targetHasCC = true;
+
// We can attack, should we chase or not?
if (me->GetCharmInfo()->HasCommandState(COMMAND_FOLLOW))
DoAttack(target,true); // FOLLOW, attack with chase
@@ -315,21 +321,20 @@ Unit *PetAI::SelectNextTarget()
if (me->HasReactState(REACT_PASSIVE))
return NULL;
+ Unit *target = NULL;
+ targetHasCC = false;
+
// Check pet's attackers first to prevent dragging mobs back
// to owner
- if (me->getAttackerForHelper())
- return me->getAttackerForHelper();
-
+ if ((target = me->getAttackerForHelper()) && !_CheckTargetCC(target)) {}
// Check owner's attackers if pet didn't have any
- if (me->GetCharmerOrOwner()->getAttackerForHelper())
- return me->GetCharmerOrOwner()->getAttackerForHelper();
-
+ else if ((target = me->GetCharmerOrOwner()->getAttackerForHelper()) && !_CheckTargetCC(target)) {}
// 3.0.2 - Pets now start attacking their owners target in defensive mode as soon as the hunter does
- if (me->GetCharmerOrOwner()->getVictim())
- return me->GetCharmerOrOwner()->getVictim();
-
+ else if ((target = me->GetCharmerOrOwner()->getVictim()) && !_CheckTargetCC(target)) {}
// Default
- return NULL;
+ else return NULL;
+
+ return target;
}
void PetAI::HandleReturnMovement()
@@ -469,3 +474,11 @@ bool PetAI::_CanAttack(Unit *target)
// default, though we shouldn't ever get here
return false;
}
+
+bool PetAI::_CheckTargetCC(Unit *target)
+{
+ if (me->GetOwnerGUID() && target->HasNegativeAuraWithInterruptFlag(AURA_INTERRUPT_FLAG_TAKE_DAMAGE, me->GetOwnerGUID()))
+ return true;
+
+ return false;
+}
diff --git a/src/server/game/AI/CoreAI/PetAI.h b/src/server/game/AI/CoreAI/PetAI.h
index f6087a129ae..b1c2cd6872f 100644
--- a/src/server/game/AI/CoreAI/PetAI.h
+++ b/src/server/game/AI/CoreAI/PetAI.h
@@ -45,13 +45,14 @@ class PetAI : public CreatureAI
private:
bool _isVisible(Unit *) const;
- bool _needToStop(void) const;
+ bool _needToStop(void);
void _stopAttack(void);
void UpdateAllies();
TimeTracker i_tracker;
bool inCombat;
+ bool targetHasCC;
std::set<uint64> m_AllySet;
uint32 m_updateAlliesTimer;
@@ -59,6 +60,7 @@ class PetAI : public CreatureAI
void HandleReturnMovement();
void DoAttack(Unit *target, bool chase);
bool _CanAttack(Unit *target);
+ bool _CheckTargetCC(Unit *target);
};
#endif