137 bool spellUsed =
false;
142 if (!target && owner)
149 targetSpellStore.push_back(std::make_pair(target, spell));
174 targetSpellStore.push_back(std::make_pair(ally, spell));
189 targetSpellStore.push_back(std::make_pair(
me->
GetVictim(), spell));
196 if (!targetSpellStore.empty())
198 TargetSpellList::iterator it = targetSpellStore.begin();
199 std::advance(it,
urand(0, targetSpellStore.size() - 1));
201 Spell* spell = (*it).second;
202 Unit* target = (*it).first;
204 targetSpellStore.erase(it);
213 for (std::pair<Unit*, Spell*>
const& unitspellpair : targetSpellStore)
214 delete unitspellpair.second;
248 if (!target || target ==
me)
321 if (!myAttacker->HasBreakableByDamageCrowdControlAura())
330 if (!ownerAttacker->HasBreakableByDamageCrowdControlAura())
331 return ownerAttacker;
363 TC_LOG_WARN(
"scripts.ai.petai",
"me->GetCharmInfo() is NULL in PetAI::HandleReturnMovement(). Debug info: {}",
GetDebugInfo());
423 float angle = chaseDistance == 0.f ? float(
M_PI) : 0.f;
424 float tolerance = chaseDistance == 0.f ? float(
M_PI_4) : float(
M_PI * 2);
493 TC_LOG_WARN(
"scripts.ai.petai",
"me->GetCharmInfo() is NULL in PetAI::CanAttack(). Debug info: {}",
GetDebugInfo());
517 Unit* ownerTarget =
nullptr;
519 ownerTarget = owner->GetSelectedUnit();
569 if (owner->GetExactDist(
me) >= (owner->GetVisibilityRange() - 10.0f))
600 Group* group =
nullptr;
602 group = player->GetGroup();
618 Player* Target = itr->GetSource();
#define TIME_INTERVAL_LOOK
#define TC_LOG_WARN(filterType__,...)
#define TC_LOG_TRACE(filterType__,...)
std::vector< std::pair< Unit *, Spell * > > TargetSpellList
uint32 urand(uint32 min, uint32 max)
@ EMOTE_ONESHOT_OMNICAST_GHOUL
@ TRIGGERED_NONE
Not triggered.
@ UNIT_FLAG_PET_IN_COMBAT
@ UNIT_MASK_CONTROLABLE_GUARDIAN
@ CURRENT_CHANNELED_SPELL
void OnCharmed(bool isNew) override
bool HasReactState(ReactStates state) const
Unit * SelectNearestHostileUnitInAggroRange(bool useLOS=false, bool ignoreCivilians=false) const
float GetPetChaseDistance() const
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
virtual uint8 GetPetAutoSpellSize() const
uint32 GetMembersCount() const
GroupReference * GetFirstMember()
bool SameSubGroup(ObjectGuid guid1, ObjectGuid guid2) const
Difficulty GetDifficultyID() const
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
void MoveFollow(Unit *target, float dist, ChaseAngle angle, Optional< Milliseconds > duration={}, MovementSlot slot=MOTION_SLOT_ACTIVE)
void Remove(MovementGenerator *movement, MovementSlot slot=MOTION_SLOT_ACTIVE)
LowType GetCounter() const
std::string ToString() const
static ObjectGuid GetGUID(Object const *o)
static Player * ToPlayer(Object *o)
void ReceiveEmote(Player *player, uint32 textEmote) override
uint32 _updateAlliesTimer
void OwnerAttackedBy(Unit *attacker) override
void AttackStart(Unit *target) override
void OwnerAttacked(Unit *target) override
void MovementInform(uint32 type, uint32 id) override
bool CanAttack(Unit *target)
void OnCharmed(bool isNew) override
static int32 Permissible(Creature const *creature)
PetAI(Creature *creature, uint32 scriptId={})
void DoAttack(Unit *target, bool chase)
void _AttackStart(Unit *target)
void ClearCharmInfoFlags()
void KilledUnit(Unit *) override
Unit * SelectNextTarget(bool allowAutoSelect) const
void UpdateAI(uint32) override
void HandleReturnMovement()
void SetUnitTarget(Unit *target)
bool HasGlobalCooldown(SpellInfo const *spellInfo) const
bool IsReady(SpellInfo const *spellInfo, uint32 itemId=0) const
bool HasEffect(SpellEffectName effect) const
bool CanBeUsedInCombat(Unit const *caster) const
SpellCastResult prepare(SpellCastTargets const &targets, AuraEffect const *triggeredByAura=nullptr)
bool CanAutoCast(Unit *target)
virtual std::string GetDebugInfo() const
bool IsWithinMeleeRange(Unit const *obj) const
void CombatStop(bool includingCast=false, bool mutualPvP=true, bool(*unitFilter)(Unit const *otherUnit)=nullptr)
bool HasBreakableByDamageCrowdControlAura(Unit *excludeCasterChannel=nullptr) const
bool isPossessedByPlayer() const
void UpdateSpeed(UnitMoveType mtype)
ObjectGuid GetOwnerGUID() const override
Unit * GetCharmer() const
Unit * getAttackerForHelper() const
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
MotionMaster * GetMotionMaster()
CharmInfo * GetCharmInfo()
Unit * EnsureVictim() const
Unit * GetCharmerOrOwner() const
bool Attack(Unit *victim, bool meleeAttack)
void SendPetAIReaction(ObjectGuid guid)
virtual float GetFollowAngle() const
bool HasUnitState(const uint32 f) const
uint32 HasUnitTypeMask(uint32 mask) const
SpellHistory * GetSpellHistory()
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
void SetUnitFlag(UnitFlags flags)
void RemoveUnitFlag(UnitFlags flags)
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
bool IsValidAttackTarget(WorldObject const *target, SpellInfo const *bySpell=nullptr) const
bool IsInMap(WorldObject const *obj) const
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
void SetIsCommandFollow(bool val)
void SetIsAtStay(bool val)
void SetIsFollowing(bool val)
void SetIsReturning(bool val)
bool HasCommandState(CommandStates state) const
void GetStayPosition(float &x, float &y, float &z)
void SetIsCommandAttack(bool val)