mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 09:39:11 +00:00
refactor(Core/Spells): Add helpers for HasAuraType (#20802)
This commit is contained in:
@@ -2836,7 +2836,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy
|
||||
// Dodge chance
|
||||
|
||||
// only players can't dodge if attacker is behind
|
||||
if (victim->IsPlayer() && !victim->HasInArc(M_PI, this) && !victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))
|
||||
if (victim->IsPlayer() && !victim->HasInArc(M_PI, this) && !victim->HasIgnoreHitDirectionAura())
|
||||
{
|
||||
//LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: attack came from behind and victim was a player.");
|
||||
}
|
||||
@@ -2871,7 +2871,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy
|
||||
// parry & block chances
|
||||
|
||||
// check if attack comes from behind, nobody can parry or block if attacker is behind
|
||||
if (!victim->HasInArc(M_PI, this) && !victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))
|
||||
if (!victim->HasInArc(M_PI, this) && !victim->HasIgnoreHitDirectionAura())
|
||||
{
|
||||
LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: attack came from behind.");
|
||||
}
|
||||
@@ -3103,7 +3103,7 @@ bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttac
|
||||
if (spellProto && spellProto->HasAttribute(SPELL_ATTR0_NO_ACTIVE_DEFENSE))
|
||||
return false;
|
||||
|
||||
if (victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION) || victim->HasInArc(M_PI, this))
|
||||
if (victim->HasIgnoreHitDirectionAura() || victim->HasInArc(M_PI, this))
|
||||
{
|
||||
// Check creatures flags_extra for disable block
|
||||
if (victim->IsCreature() &&
|
||||
@@ -3201,7 +3201,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo
|
||||
if (attType == RANGED_ATTACK)
|
||||
{
|
||||
// only if in front
|
||||
if (!victim->HasUnitState(UNIT_STATE_STUNNED) && (victim->HasInArc(M_PI, this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)))
|
||||
if (!victim->HasUnitState(UNIT_STATE_STUNNED) && (victim->HasInArc(M_PI, this) || victim->HasIgnoreHitDirectionAura()))
|
||||
{
|
||||
int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100;
|
||||
tmp += deflect_chance;
|
||||
@@ -3217,7 +3217,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo
|
||||
// xinef: if from behind or spell requires cast from behind
|
||||
if (!victim->HasInArc(M_PI, this))
|
||||
{
|
||||
if (!victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION) || spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET))
|
||||
if (!victim->HasIgnoreHitDirectionAura() || spellInfo->HasAttribute(SPELL_ATTR0_CU_REQ_CASTER_BEHIND_TARGET))
|
||||
{
|
||||
// Can`t dodge from behind in PvP (but its possible in PvE)
|
||||
if (victim->IsPlayer())
|
||||
@@ -3448,7 +3448,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo
|
||||
return SPELL_MISS_RESIST;
|
||||
|
||||
// cast by caster in front of victim
|
||||
if (!victim->HasUnitState(UNIT_STATE_STUNNED) && (victim->HasInArc(M_PI, this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)))
|
||||
if (!victim->HasUnitState(UNIT_STATE_STUNNED) && (victim->HasInArc(M_PI, this) || victim->HasIgnoreHitDirectionAura()))
|
||||
{
|
||||
int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100;
|
||||
tmp += deflect_chance;
|
||||
@@ -10315,11 +10315,11 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
|
||||
}
|
||||
|
||||
// Unit with SPELL_AURA_SPIRIT_OF_REDEMPTION can not attack
|
||||
if (HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
|
||||
if (HasSpiritOfRedemptionAura())
|
||||
return false;
|
||||
|
||||
// remove SPELL_AURA_MOD_UNATTACKABLE at attack (in case non-interruptible spells stun aura applied also that not let attack)
|
||||
if (HasAuraType(SPELL_AURA_MOD_UNATTACKABLE))
|
||||
if (HasUnattackableAura())
|
||||
RemoveAurasByType(SPELL_AURA_MOD_UNATTACKABLE);
|
||||
|
||||
if (m_attacking)
|
||||
@@ -10996,7 +10996,7 @@ bool RedirectSpellEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
if (Unit* auraOwner = ObjectAccessor::GetUnit(_self, _auraOwnerGUID))
|
||||
{
|
||||
// Xinef: already removed
|
||||
if (!auraOwner->HasAuraType(SPELL_AURA_SPELL_MAGNET))
|
||||
if (!auraOwner->HasSpellMagnetAura())
|
||||
return true;
|
||||
|
||||
Unit::AuraEffectList const& magnetAuras = auraOwner->GetAuraEffectsByType(SPELL_AURA_SPELL_MAGNET);
|
||||
@@ -11873,7 +11873,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui
|
||||
}
|
||||
|
||||
// xinef: sanctified wrath talent
|
||||
if (caster && TakenTotalMod < 1.0f && caster->HasAuraType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST))
|
||||
if (caster && TakenTotalMod < 1.0f && caster->HasIgnoreTargetResistAura())
|
||||
{
|
||||
float ignoreModifier = 1.0f - TakenTotalMod;
|
||||
bool addModifier = false;
|
||||
@@ -12080,7 +12080,7 @@ float Unit::SpellTakenCritChance(Unit const* caster, SpellInfo const* spellProto
|
||||
{
|
||||
// Modify critical chance by victim SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE
|
||||
// xinef: apply max and min only
|
||||
if (HasAuraType(SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE))
|
||||
if (HasAttackerSpellCritChanceAura())
|
||||
{
|
||||
crit_chance += GetMaxNegativeAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE, schoolMask);
|
||||
crit_chance += GetMaxPositiveAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE, schoolMask);
|
||||
@@ -12762,7 +12762,7 @@ bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasSpiritOfRedemptionAura())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -12795,7 +12795,7 @@ bool Unit::IsImmunedToDamage(Spell const* spell) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasSpiritOfRedemptionAura())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -12842,7 +12842,7 @@ bool Unit::IsImmunedToSchool(SpellSchoolMask meleeSchoolMask) const
|
||||
|
||||
bool Unit::IsImmunedToSchool(SpellInfo const* spellInfo) const
|
||||
{
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasSpiritOfRedemptionAura())
|
||||
return false;
|
||||
|
||||
uint32 schoolMask = spellInfo->GetSchoolMask();
|
||||
@@ -12866,7 +12866,7 @@ bool Unit::IsImmunedToSchool(SpellInfo const* spellInfo) const
|
||||
bool Unit::IsImmunedToSchool(Spell const* spell) const
|
||||
{
|
||||
SpellInfo const* spellInfo = spell->GetSpellInfo();
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasSpiritOfRedemptionAura())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -12929,7 +12929,7 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo, Spell const* spell)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasSpiritOfRedemptionAura())
|
||||
return false;
|
||||
|
||||
if (spellInfo->Dispel)
|
||||
@@ -13007,7 +13007,7 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR4_OWNER_POWER_SCALING))
|
||||
return false;
|
||||
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasSpiritOfRedemptionAura())
|
||||
return false;
|
||||
|
||||
//If m_immuneToEffect type contain this effect type, IMMUNE effect.
|
||||
@@ -13349,7 +13349,7 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackT
|
||||
}
|
||||
|
||||
// xinef: sanctified wrath talent
|
||||
if (TakenTotalMod < 1.0f && attacker->HasAuraType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST))
|
||||
if (TakenTotalMod < 1.0f && attacker->HasIgnoreTargetResistAura())
|
||||
{
|
||||
float ignoreModifier = 1.0f - TakenTotalMod;
|
||||
bool addModifier = false;
|
||||
@@ -14635,7 +14635,7 @@ bool Unit::CanHaveThreatList(bool skipAliveCheck) const
|
||||
|
||||
float Unit::ApplyTotalThreatModifier(float fThreat, SpellSchoolMask schoolMask)
|
||||
{
|
||||
if (!HasAuraType(SPELL_AURA_MOD_THREAT) || fThreat < 0)
|
||||
if (!HasThreatAura() || fThreat < 0)
|
||||
return fThreat;
|
||||
|
||||
SpellSchools school = GetFirstSchoolInMask(schoolMask);
|
||||
@@ -17838,7 +17838,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp
|
||||
if (AuraEffect* aurEff = victim->GetAuraEffectDummy(20711))
|
||||
{
|
||||
// Xinef: aura_spirit_of_redemption is triggered by 27827 shapeshift
|
||||
if (victim->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION) || victim->HasAura(27827))
|
||||
if (victim->HasSpiritOfRedemptionAura() || victim->HasAura(27827))
|
||||
{
|
||||
/*LOG_INFO("misc", "Player ({}) died with spirit of redemption. Killer (Entry: {}, Name: {}), Map: {}, x: {}, y: {}, z: {}",
|
||||
victim->GetGUID().ToString(), killer ? killer->GetEntry() : 1, killer ? killer->GetName() : "", victim->GetMapId(), victim->GetPositionX(),
|
||||
@@ -18082,7 +18082,7 @@ void Unit::SetControlled(bool apply, UnitState state, Unit* source /*= nullptr*/
|
||||
switch (state)
|
||||
{
|
||||
case UNIT_STATE_STUNNED:
|
||||
if (HasAuraType(SPELL_AURA_MOD_STUN))
|
||||
if (HasStunAura())
|
||||
return;
|
||||
ClearUnitState(state);
|
||||
SetStunned(false);
|
||||
@@ -18097,19 +18097,19 @@ void Unit::SetControlled(bool apply, UnitState state, Unit* source /*= nullptr*/
|
||||
}
|
||||
}
|
||||
|
||||
if (HasAuraType(SPELL_AURA_MOD_ROOT) || GetVehicle())
|
||||
if (HasRootAura() || GetVehicle())
|
||||
return;
|
||||
ClearUnitState(state);
|
||||
SetRooted(false);
|
||||
break;
|
||||
case UNIT_STATE_CONFUSED:
|
||||
if (HasAuraType(SPELL_AURA_MOD_CONFUSE))
|
||||
if (HasConfuseAura())
|
||||
return;
|
||||
ClearUnitState(state);
|
||||
SetConfused(false);
|
||||
break;
|
||||
case UNIT_STATE_FLEEING:
|
||||
if (HasAuraType(SPELL_AURA_MOD_FEAR))
|
||||
if (HasFearAura())
|
||||
return;
|
||||
ClearUnitState(state);
|
||||
SetFeared(false);
|
||||
@@ -18120,19 +18120,19 @@ void Unit::SetControlled(bool apply, UnitState state, Unit* source /*= nullptr*/
|
||||
|
||||
//ClearUnitState(state);
|
||||
|
||||
if (HasUnitState(UNIT_STATE_STUNNED) || HasAuraType(SPELL_AURA_MOD_STUN))
|
||||
if (HasUnitState(UNIT_STATE_STUNNED) || HasStunAura())
|
||||
SetStunned(true);
|
||||
else
|
||||
{
|
||||
if (HasUnitState(UNIT_STATE_ROOT) || HasAuraType(SPELL_AURA_MOD_ROOT))
|
||||
if (HasUnitState(UNIT_STATE_ROOT) || HasRootAura())
|
||||
SetRooted(true);
|
||||
|
||||
if (HasUnitState(UNIT_STATE_CONFUSED) || HasAuraType(SPELL_AURA_MOD_CONFUSE))
|
||||
if (HasUnitState(UNIT_STATE_CONFUSED) || HasConfuseAura())
|
||||
SetConfused(true);
|
||||
else if (HasUnitState(UNIT_STATE_FLEEING) || HasAuraType(SPELL_AURA_MOD_FEAR))
|
||||
else if (HasUnitState(UNIT_STATE_FLEEING) || HasFearAura())
|
||||
{
|
||||
bool isFear = false;
|
||||
if (HasAuraType(SPELL_AURA_MOD_FEAR))
|
||||
if (HasFearAura())
|
||||
{
|
||||
isFear = true;
|
||||
source = ObjectAccessor::GetUnit(*this, GetAuraEffectsByType(SPELL_AURA_MOD_FEAR).front()->GetCasterGUID());
|
||||
@@ -19168,7 +19168,7 @@ void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ)
|
||||
|
||||
player->GetSession()->SendPacket(&data);
|
||||
|
||||
if (player->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) || player->HasAuraType(SPELL_AURA_FLY))
|
||||
if (player->HasIncreaseMountedFlightSpeedAura() || player->HasFlyAura())
|
||||
player->SetCanFly(true, true);
|
||||
|
||||
player->SetCanKnockback(true);
|
||||
|
||||
Reference in New Issue
Block a user