63 std::list<Unit*> targets;
67 for (
Unit* target : targets)
91 if (!owner || owner != caster)
165 if (Unit* target = ObjectAccessor::GetUnit(*me, _targetGUID))
166 me->EngageWithTarget(target);
265 currentTarget =
nullptr;
268 Unit* selectedTarget =
nullptr;
274 selectedTarget = initialTarget;
285 float minDistance = 0.f;
288 Unit* target = pair.second->GetOther(owner);
295 if (!selectedTarget || dist < minDistance)
297 selectedTarget = target;
307 float maxThreat = 0.f;
310 Unit* target = pair.second->GetOther(owner);
315 if (threat >= maxThreat)
317 selectedTarget = target;
std::chrono::seconds Seconds
Seconds shorthand typedef.
#define RegisterCreatureAI(ai_name)
@ UNIT_FLAG_NON_ATTACKABLE
void InitializeAI() override
std::unordered_map< ObjectGuid, PvPCombatReference * > const & GetPvPCombatRefs() const
std::unordered_map< ObjectGuid, CombatReference * > const & GetPvECombatRefs() const
bool HasPvPCombat() const
@ EVADE_REASON_NO_HOSTILES
void SetLootRecipient(Unit *unit, bool withGroup=true)
void SetLastDamagedTime(time_t val)
void DoNotReacquireSpellFocusTarget()
bool IsEngaged() const override
void SetReactState(ReactStates st)
void ResetPlayerDamageReq()
void SetCannotReachTarget(bool cannotReach)
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void SetTarget(ObjectGuid guid) override
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
void MoveFollow(Unit *target, float dist, ChaseAngle angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
static ObjectGuid const Empty
static Unit * ToUnit(Object *o)
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
TaskScheduler & CancelGroup(group_t const group)
float GetThreat(Unit const *who, bool includeOffline=false) const
virtual void JustEnteredCombat(Unit *)
void DoMeleeAttackIfReady()
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
virtual bool CanAIAttack(Unit const *) const
SpellCastResult DoCast(uint32 spellId)
ThreatManager & GetThreatManager()
bool HasBreakableByDamageCrowdControlAura(Unit *excludeCasterChannel=nullptr) const
ObjectGuid GetOwnerGUID() const override
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
MotionMaster * GetMotionMaster()
bool IsInCombatWith(Unit const *who) const
Unit * GetCharmerOrOwner() const
bool SetCanFly(bool enable, bool packetOnly=false)
bool Attack(Unit *victim, bool meleeAttack)
virtual float GetFollowAngle() const
void SetSpeedRate(UnitMoveType mtype, float rate)
bool HasUnitState(const uint32 f) const
void CombatStop(bool includingCast=false, bool mutualPvP=true)
CombatManager & GetCombatManager()
void SetUnitFlag(UnitFlags flags)
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
bool IsValidAttackTarget(WorldObject const *target, SpellInfo const *bySpell=nullptr) const
float GetDistance(WorldObject const *obj) const
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
@ SPELL_FAKE_AGGRO_RADIUS_8_YARD
@ SPELL_DK_DANCING_RUNE_WEAPON
@ SPELL_DK_SUMMON_GARGOYLE_2
@ SPELL_DK_RUNE_WEAPON_SCALING_01
@ SPELL_DISMISS_RUNEBLADE
@ SPELL_DK_PET_SCALING_03
@ SPELL_DK_DANCING_RUNE_WEAPON_VISUAL
@ SPELL_DK_RUNE_WEAPON_SCALING
@ SPELL_PET_SCALING__MASTER_SPELL_06__SPELL_HIT_EXPERTISE_SPELL_PENETRATION
@ SPELL_DK_SUMMON_GARGOYLE_1
@ SPELL_DK_RUNE_WEAPON_MARK
@ SPELL_DK_DISMISS_GARGOYLE
@ DATA_INITIAL_TARGET_GUID
void AddSC_deathknight_pet_scripts()
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
float GetPositionZ() const
float GetOrientation() const
float GetPositionX() const
float GetPositionY() const
void AttackStart(Unit *) override
void InitializeAI() override
void JustDied(Unit *) override
void SpellHit(WorldObject *caster, SpellInfo const *spellInfo) override
npc_pet_dk_ebon_gargoyle(Creature *creature)
bool CanAIAttack(Unit const *target) const override
npc_pet_dk_guardian(Creature *creature)
void JustEnteredCombat(Unit *who) override
void UpdateAI(uint32 diff) override
void EnterEvadeMode(EvadeReason) override
void IsSummonedBy(WorldObject *summoner) override
npc_pet_dk_rune_weapon(Creature *creature)
bool UpdateRuneWeaponVictim()
void SetGUID(ObjectGuid const &guid, int32 id) override
bool CanAIAttack(Unit const *who) const override