32 if (victim &&
me->
Attack(victim,
true))
50 if (victim &&
me->
Attack(victim,
false))
108 Unit* target =
nullptr;
139 float range = spellInfo->GetMaxRange(
false);
169 return DoCast(victim, spellId, args);
177 return spellInfo ? spellInfo->
GetMaxRange(positive) : 0;
180#define UPDATE_TARGET(a) {if (AIInfo->target<a) AIInfo->target=a;}
187 for (
uint32 i = 0; i <
sSpellMgr->GetSpellInfoStoreSize(); ++i, ++AIInfo)
207 uint32 targetType = effect.TargetA.GetTarget();
232 if (targetList.empty())
241 return targetList.front();
263 if (ref->IsOffline())
266 targetList.push_back(ref->GetVictim());
273 targetList.push_back(currentVictim);
277 if (ref->IsOffline())
281 if (thisTarget != currentVictim)
282 targetList.push_back(thisTarget);
287 if (targetList.size() <= offset)
299 targetList.reverse();
304 targetList.pop_front();
313 if (targetList.size() <= num)
319 targetList.resize(num);
324 std::stringstream sstr;
325 sstr << std::boolalpha
331 : _me(unit), _dist(dist), _playerOnly(playerOnly), _exception(!withTank ? unit->GetThreatManager().GetLastVictim() : nullptr), _aura(aura)
352 if (_dist < 0.0f && _me->IsWithinCombatRange(target, -
_dist))
373 _caster(caster), _spellInfo(
sSpellMgr->GetSpellForDifficultyFromSpell(
sSpellMgr->GetSpellInfo(spellId), caster))
384 float minRange = 0.0f;
385 float maxRange = 0.0f;
386 float rangeMod = 0.0f;
398 float meleeRange = 0.0f;
414 minRange += rangeMod;
419 rangeMod += 8.0f / 3.0f;
422 maxRange += rangeMod;
424 minRange *= minRange;
425 maxRange *= maxRange;
448 return target != currentVictim;
467 if (_dist < 0.0f && _me->IsWithinCombatRange(target, -
_dist))
#define NOMINAL_MELEE_RANGE
@ SPELL_EFFECT_APPLY_AURA
@ TARGET_UNIT_DEST_AREA_ENEMY
@ TARGET_DEST_TARGET_ENEMY
@ TARGET_UNIT_TARGET_ENEMY
@ SPELL_ATTR3_ONLY_TARGET_PLAYERS
@ SPELL_ATTR0_CASTABLE_WHILE_DEAD
@ SPELL_FAILED_BAD_TARGETS
@ SPELL_FAILED_SPELL_IN_PROGRESS
@ TRIGGERED_IGNORE_CAST_IN_PROGRESS
Will ignore aura scaling.
@ AURA_INTERRUPT_FLAG_NOT_VICTIM
void MoveChase(Unit *target, Optional< ChaseRange > dist={}, Optional< ChaseAngle > angle={})
float GetMaxRange(bool positive=false, WorldObject *caster=nullptr, Spell *spell=nullptr) const
SpellRangeEntry const * RangeEntry
SpellCastResult CheckTarget(WorldObject const *caster, WorldObject const *target, bool implicit=true) const
bool HasAttribute(SpellAttr0 attribute) const
int32 GetDuration() const
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > const & GetEffects() const
Unit * GetCurrentVictim()
Trinity::IteratorPair< ThreatListIterator, std::nullptr_t > GetUnsortedThreatList() const
Trinity::IteratorPair< ThreatListIterator, std::nullptr_t > GetSortedThreatList() const
size_t GetThreatListSize() const
void AttackStartCaster(Unit *victim, float dist)
static void FillAISpellInfo()
bool PrepareTargetListSelection(std::list< Unit * > &targetList, SelectTargetMethod targetType, uint32 offset)
void DoMeleeAttackIfReady()
virtual void InitializeAI()
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
void SelectTargetList(std::list< Unit * > &targetList, uint32 num, SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
virtual void OnCharmed(bool isNew)
float DoGetSpellMaxRange(uint32 spellId, bool positive=false)
virtual std::string GetDebugInfo() const
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
bool DoSpellAttackIfReady(uint32 spell)
Unit * FinalizeTargetSelection(std::list< Unit * > &targetList, SelectTargetMethod targetType)
static AISpellInfoType * AISpellInfo
virtual void AttackStart(Unit *)
void FinalizeTargetListSelection(std::list< Unit * > &targetList, uint32 num, SelectTargetMethod targetType)
SpellCastResult DoCast(uint32 spellId)
bool IsWithinMeleeRange(Unit const *obj) const
ThreatManager & GetThreatManager()
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
bool haveOffhandWeapon() const
MotionMaster * GetMotionMaster()
Powers GetPowerType() const
std::string GetDebugInfo() const override
float GetCombatReach() const override
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
bool Attack(Unit *victim, bool meleeAttack)
bool HasUnitState(const uint32 f) const
void AttackerStateUpdate(Unit *victim, WeaponAttackType attType=BASE_ATTACK, bool extra=false)
bool isAttackReady(WeaponAttackType type=BASE_ATTACK) const
void resetAttackTimer(WeaponAttackType type=BASE_ATTACK)
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
bool IsWithinLOSInMap(WorldObject const *obj, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
float GetSpellMinRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
float GetSpellMaxRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
void RandomResize(C &container, std::size_t requestedSize)
DefaultTargetSelector(Unit const *unit, float dist, bool playerOnly, bool withMainTank, int32 aura)
bool operator()(Unit const *target) const
bool operator()(Unit const *target) const
bool operator()(Unit const *target) const
float GetExactDistSq(float x, float y, float z) const
SpellInfo const * _spellInfo
bool operator()(Unit const *target) const
SpellTargetSelector(Unit *caster, uint32 spellId)