22 if (creature->
IsPet())
36 if (
me->IsCharmed() &&
me->GetVictim() ==
me->GetCharmer())
39 return !
me->IsValidAttackTarget(
me->GetVictim());
46 SF_LOG_DEBUG(
"misc",
"Creature stoped attacking cuz his dead [guid=%u]",
me->GetGUIDLow());
47 me->GetMotionMaster()->Clear();
48 me->GetMotionMaster()->MoveIdle();
50 me->getHostileRefManager().deleteReferences();
56 me->InterruptNonMeleeSpells(
false);
57 me->SendMeleeAttackStop();
58 me->GetCharmInfo()->SetIsCommandAttack(
false);
65 if (!
me->IsAlive() || !
me->GetCharmInfo())
68 Unit* owner =
me->GetCharmerOrOwner();
76 if (
me->GetVictim() &&
me->GetVictim()->IsAlive())
79 if (
me->GetVictim()->HasBreakableByDamageCrowdControlAura(
me))
81 me->InterruptNonMeleeSpells(
false);
87 SF_LOG_DEBUG(
"misc",
"Pet AI stopped attacking [guid=%u]",
me->GetGUIDLow());
95 if (
me->GetCharmInfo()->IsCommandAttack() || (
me->GetCharmInfo()->IsAtStay() &&
me->IsWithinMeleeRange(
me->GetVictim())))
124 typedef std::vector<std::pair<Unit*, Spell*> > TargetSpellList;
125 TargetSpellList targetSpellStore;
127 for (
uint8 i = 0; i <
me->GetPetAutoSpellSize(); ++i)
129 uint32 spellID =
me->GetPetAutoSpellOnPos(i);
137 if (
me->GetCharmInfo() &&
me->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))
145 if (
me->HasSpellCooldown(spellInfo->
Id))
149 if (!
me->IsInCombat() && !
me->GetCharmInfo()->IsCommandAttack())
154 bool spellUsed =
false;
158 Unit* target =
me->getAttackerForHelper();
159 if (!target && owner)
166 targetSpellStore.push_back(std::make_pair(target, spell));
177 for (std::set<uint64>::const_iterator tar =
m_AllySet.begin(); tar !=
m_AllySet.end(); ++tar)
187 targetSpellStore.push_back(std::make_pair(ally, spell));
202 targetSpellStore.push_back(std::make_pair(
me->GetVictim(), spell));
209 if (!targetSpellStore.empty())
211 uint32 index = std::rand() % targetSpellStore.size();
213 Spell* spell = targetSpellStore[index].second;
214 Unit* target = targetSpellStore[index].first;
216 targetSpellStore.erase(targetSpellStore.begin() + index);
221 if (!
me->HasInArc(
M_PI, target))
223 me->SetInFront(target);
237 for (TargetSpellList::const_iterator itr = targetSpellStore.begin(); itr != targetSpellStore.end(); ++itr)
251 Unit* owner =
me->GetCharmerOrOwner();
257 group = player->GetGroup();
273 Player* Target = itr->GetSource();
291 if (
me->GetVictim() &&
me->GetVictim() != victim)
299 me->InterruptNonMeleeSpells(
false);
300 me->SendMeleeAttackStop();
334 if (
me->GetVictim() &&
me->GetVictim()->IsAlive())
355 if (
me->GetVictim() &&
me->GetVictim()->IsAlive())
374 if (
Unit* myAttacker =
me->getAttackerForHelper())
375 if (!myAttacker->HasBreakableByDamageCrowdControlAura())
379 if (!
me->GetCharmerOrOwner())
383 if (
Unit* ownerAttacker =
me->GetCharmerOrOwner()->getAttackerForHelper())
384 if (!ownerAttacker->HasBreakableByDamageCrowdControlAura())
385 return ownerAttacker;
389 if (
Unit* ownerVictim =
me->GetCharmerOrOwner()->GetVictim())
397 if (!
me->GetCharmInfo()->IsReturning() ||
me->GetCharmInfo()->IsFollowing() ||
me->GetCharmInfo()->IsAtStay())
398 if (
Unit* nearTarget =
me->ToCreature()->SelectNearestHostileUnitInAggroRange(
true))
417 if (!
me->GetCharmInfo()->IsAtStay() && !
me->GetCharmInfo()->IsReturning())
422 me->GetCharmInfo()->GetStayPosition(x, y, z);
424 me->GetCharmInfo()->SetIsReturning(
true);
425 me->GetMotionMaster()->Clear();
426 me->GetMotionMaster()->MovePoint(
me->GetGUIDLow(), x, y, z);
431 if (!
me->GetCharmInfo()->IsFollowing() && !
me->GetCharmInfo()->IsReturning())
434 me->GetCharmInfo()->SetIsReturning(
true);
435 me->GetMotionMaster()->Clear();
446 if (
me->Attack(target,
true))
448 if (
Unit* owner =
me->GetOwner())
449 owner->SetInCombatWith(target);
453 me->SendPetAIReaction(
me->GetGUID());
457 bool oldCmdAttack =
me->GetCharmInfo()->IsCommandAttack();
459 me->GetCharmInfo()->SetIsCommandAttack(oldCmdAttack);
460 me->GetMotionMaster()->Clear();
461 me->GetMotionMaster()->MoveChase(target);
466 me->GetCharmInfo()->SetIsAtStay(
true);
467 me->GetMotionMaster()->Clear();
468 me->GetMotionMaster()->MoveIdle();
482 if (data ==
me->GetGUIDLow() &&
me->GetCharmInfo()->IsReturning())
485 me->GetCharmInfo()->SetIsAtStay(
true);
486 me->GetMotionMaster()->Clear();
487 me->GetMotionMaster()->MoveIdle();
495 if (
me->GetCharmerOrOwner() &&
me->GetCharmInfo() && data ==
me->GetCharmerOrOwner()->GetGUIDLow() &&
me->GetCharmInfo()->IsReturning())
498 me->GetCharmInfo()->SetIsFollowing(
true);
520 me->InterruptNonMeleeSpells(
false);
521 me->SendMeleeAttackStop();
527 return me->GetCharmInfo()->IsCommandAttack();
531 return me->GetCharmInfo()->IsCommandAttack();
534 if (
me->GetCharmInfo()->IsReturning())
535 return !
me->GetCharmInfo()->IsCommandFollow();
539 return (
me->IsWithinMeleeRange(target) ||
me->GetCharmInfo()->IsCommandAttack());
542 if (
me->GetVictim() &&
me->GetVictim() != target)
545 Unit* ownerTarget = NULL;
546 if (
Player* owner =
me->GetCharmerOrOwner()->ToPlayer())
547 ownerTarget = owner->GetSelectedUnit();
549 ownerTarget =
me->GetCharmerOrOwner()->GetVictim();
551 if (ownerTarget &&
me->GetCharmInfo()->IsCommandAttack())
557 return !
me->GetCharmInfo()->IsReturning();
565 if (
me->GetOwnerGUID() &&
me->GetOwnerGUID() == player->
GetGUID())
569 if (
me->IsPet() &&
me->ToPet()->IsPetGhoul())
573 if (
me->IsPet() &&
me->ToPet()->IsPetGhoul())
577 if (
me->IsPet() &&
me->ToPet()->IsPetGhoul())
581 if (
me->IsPet() &&
me->ToPet()->IsPetGhoul())
616 if (
me->GetVictim() &&
me->GetVictim()->IsAlive())
#define TIME_INTERVAL_LOOK
#define SF_LOG_DEBUG(filterType__,...)
@ EMOTE_ONESHOT_OMNICAST_GHOUL
CreatureAI(Creature *creature)
uint32 GetMembersCount() const
GroupReference * GetFirstMember()
bool SameSubGroup(uint64 guid1, uint64 guid2) const
static Unit * GetUnit(WorldObject const &, uint64 guid)
void OwnerAttacked(Unit *target) OVERRIDE
bool CanAttack(Unit *target)
static int Permissible(const Creature *)
void AttackedBy(Unit *attacker) OVERRIDE
void KilledUnit(Unit *) OVERRIDE
void DoAttack(Unit *target, bool chase)
void MovementInform(uint32 moveType, uint32 data) OVERRIDE
void OwnerAttackedBy(Unit *attacker) OVERRIDE
void ClearCharmInfoFlags()
uint32 m_updateAlliesTimer
void AttackStart(Unit *target) OVERRIDE
Unit * SelectNextTarget(bool allowAutoSelect) const
void ReceiveEmote(Player *player, uint32 textEmote) OVERRIDE
void HandleReturnMovement()
std::set< uint64 > m_AllySet
void UpdateAI(uint32) OVERRIDE
== Triggered Actions Requested ==================
void SetUnitTarget(Unit *target)
void prepare(SpellCastTargets const *targets, AuraEffect const *triggeredByAura=NULL)
SpellInfo const *const m_spellInfo
bool CanAutoCast(Unit *target)
bool CanBeUsedInCombat() const
bool HasEffect(SpellEffects effect) const
void DoMeleeAttackIfReady()
Unit * getAttackerForHelper() const
bool HasBreakableByDamageCrowdControlAura(Unit *excludeCasterChannel=NULL) const
void SetIsCommandFollow(bool val)
void SetIsAtStay(bool val)
void SetIsFollowing(bool val)
void SetIsReturning(bool val)
void SetIsCommandAttack(bool val)