refactor(Core/Spells): Add helpers for HasAuraType (#20802)

This commit is contained in:
Kitzunu
2024-12-01 12:50:59 +01:00
committed by GitHub
parent 55f6bd0972
commit ed008a8780
41 changed files with 183 additions and 140 deletions

View File

@@ -1536,7 +1536,7 @@ void AuraEffect::HandleModInvisibilityDetect(AuraApplication const* aurApp, uint
}
else
{
if (!target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY_DETECT))
if (!target->HasInvisibilityDetectAura())
target->m_invisibilityDetect.DelFlag(type);
target->m_invisibilityDetect.AddValue(type, -GetAmount());
@@ -1565,7 +1565,7 @@ void AuraEffect::HandleModInvisibility(AuraApplication const* aurApp, uint8 mode
}
else
{
if (!target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY))
if (!target->HasInvisibilityAura())
{
// if not have different invisibility auras.
// always remove glow vision
@@ -1628,7 +1628,7 @@ void AuraEffect::HandleModStealthDetect(AuraApplication const* aurApp, uint8 mod
}
else
{
if (!target->HasAuraType(SPELL_AURA_MOD_STEALTH_DETECT))
if (!target->HasStealthDetectAura())
target->m_stealthDetect.DelFlag(type);
target->m_stealthDetect.AddValue(type, -GetAmount());
@@ -1666,7 +1666,7 @@ void AuraEffect::HandleModStealth(AuraApplication const* aurApp, uint8 mode, boo
{
target->m_stealth.AddValue(type, -GetAmount());
if (!target->HasAuraType(SPELL_AURA_MOD_STEALTH)) // if last SPELL_AURA_MOD_STEALTH
if (!target->HasStealthAura()) // if last SPELL_AURA_MOD_STEALTH
{
target->m_stealth.DelFlag(type);
@@ -1723,7 +1723,7 @@ void AuraEffect::HandleDetectAmore(AuraApplication const* aurApp, uint8 mode, bo
}
else
{
if (target->HasAuraType(SPELL_AURA_DETECT_AMORE))
if (target->HasDetectAmoreAura())
{
Unit::AuraEffectList const& amoreAuras = target->GetAuraEffectsByType(SPELL_AURA_DETECT_AMORE);
for (AuraEffect const* aurEff : amoreAuras)
@@ -1790,7 +1790,7 @@ void AuraEffect::HandleAuraGhost(AuraApplication const* aurApp, uint8 mode, bool
}
else
{
if (target->HasAuraType(SPELL_AURA_GHOST))
if (target->HasGhostAura())
return;
target->ToPlayer()->RemovePlayerFlag(PLAYER_FLAGS_GHOST);
@@ -2025,7 +2025,7 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo
{
// reset model id if no other auras present
// may happen when aura is applied on linked event on aura removal
if (!target->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT))
if (!target->HasShapeshiftAura())
{
target->SetShapeshiftForm(FORM_NONE);
if (target->IsClass(CLASS_DRUID, CLASS_CONTEXT_ABILITY))
@@ -2933,7 +2933,7 @@ void AuraEffect::HandleModUnattackable(AuraApplication const* aurApp, uint8 mode
Unit* target = aurApp->GetTarget();
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (!apply && target->HasAuraType(SPELL_AURA_MOD_UNATTACKABLE))
if (!apply && target->HasUnattackableAura())
return;
target->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE, apply);
@@ -3035,7 +3035,7 @@ void AuraEffect::HandleAuraModSilence(AuraApplication const* aurApp, uint8 mode,
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target->HasAuraType(SPELL_AURA_MOD_SILENCE) || target->HasAuraType(SPELL_AURA_MOD_PACIFY_SILENCE))
if (target->HasSilenceAura() || target->HasPacifySilenceAura())
return;
target->RemoveUnitFlag(UNIT_FLAG_SILENCED);
@@ -3057,7 +3057,7 @@ void AuraEffect::HandleAuraModPacify(AuraApplication const* aurApp, uint8 mode,
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target->HasAuraType(SPELL_AURA_MOD_PACIFY) || target->HasAuraType(SPELL_AURA_MOD_PACIFY_SILENCE))
if (target->HasPacifyAura() || target->HasPacifySilenceAura())
return;
target->RemoveUnitFlag(UNIT_FLAG_PACIFIED);
}
@@ -3073,7 +3073,7 @@ void AuraEffect::HandleAuraModPacifyAndSilence(AuraApplication const* aurApp, ui
if (!(apply))
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target->HasAuraType(SPELL_AURA_MOD_PACIFY_SILENCE))
if (target->HasPacifySilenceAura())
return;
}
HandleAuraModPacify(aurApp, mode, apply);
@@ -3094,7 +3094,7 @@ void AuraEffect::HandleAuraAllowOnlyAbility(AuraApplication const* aurApp, uint8
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target->HasAuraType(SPELL_AURA_ALLOW_ONLY_ABILITY))
if (target->HasAllowOnlyAbilityAura())
return;
target->ToPlayer()->RemovePlayerFlag(PLAYER_ALLOW_ONLY_ABILITY);
}
@@ -3312,7 +3312,7 @@ void AuraEffect::HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode
if (!apply)
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target->HasAuraType(GetAuraType()) || target->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED))
if (target->HasAuraType(GetAuraType()) || target->HasIncreaseMountedFlightSpeedAura())
return;
}
@@ -3526,7 +3526,7 @@ void AuraEffect::HandlePreventFleeing(AuraApplication const* aurApp, uint8 mode,
Unit* target = aurApp->GetTarget();
// Since patch 3.0.2 this mechanic no longer affects fear effects. It will ONLY prevent humanoids from fleeing due to low health.
if (target->IsPlayer() || !apply || target->HasAuraType(SPELL_AURA_MOD_FEAR))
if (target->IsPlayer() || !apply || target->HasFearAura())
return;
/// @todo: find a way to cancel fleeing for assistance.
/// Currently this will only stop creatures fleeing due to low health that could not find nearby allies to flee towards.
@@ -3721,7 +3721,7 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp,
if (GetAuraType() == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED)
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (mode & AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK && (apply || (!target->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !target->HasAuraType(SPELL_AURA_FLY))))
if (mode & AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK && (apply || (!target->HasIncreaseMountedFlightSpeedAura() && !target->HasFlyAura())))
{
target->SetCanFly(apply);
@@ -5767,12 +5767,12 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
}
break;
case 62061: // Festive Holiday Mount
if (target->HasAuraType(SPELL_AURA_MOUNTED))
if (target->HasMountedAura())
{
uint32 creatureEntry = 0;
if (apply)
{
if (target->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED))
if (target->HasIncreaseMountedFlightSpeedAura())
creatureEntry = 24906;
else
creatureEntry = 15665;
@@ -5790,7 +5790,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
}
break;
case FRESH_BREWFEST_HOPS: // Festive Brewfest Mount
if (target->HasAuraType(SPELL_AURA_MOUNTED) && !target->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED))
if (target->HasMountedAura() && !target->HasIncreaseMountedFlightSpeedAura())
{
uint32 creatureEntry = 0;

View File

@@ -3105,7 +3105,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
// Xinef: Do not increase diminishing level for self cast
m_diminishGroup = GetDiminishingReturnsGroupForSpell(m_spellInfo, m_triggeredByAuraSpell.spellInfo);
// xinef: do not increase diminish level for bosses (eg. Void Reaver silence is never diminished)
if (((m_spellFlags & SPELL_FLAG_REFLECTED) && !(unit->HasAuraType(SPELL_AURA_REFLECT_SPELLS))) || (aura_effmask && m_diminishGroup && unit != m_caster && (!m_caster->IsCreature() || !m_caster->ToCreature()->isWorldBoss())))
if (((m_spellFlags & SPELL_FLAG_REFLECTED) && !(unit->HasReflectSpellsAura())) || (aura_effmask && m_diminishGroup && unit != m_caster && (!m_caster->IsCreature() || !m_caster->ToCreature()->isWorldBoss())))
{
m_diminishLevel = unit->GetDiminishing(m_diminishGroup);
DiminishingReturnsType type = GetDiminishingReturnsGroupType(m_diminishGroup);

View File

@@ -3498,7 +3498,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
// Glyph of Blood Strike
if (m_caster->GetAuraEffect(59332, EFFECT_0))
if (unitTarget->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED))
if (unitTarget->HasDecreaseSpeedAura())
AddPct(totalDamagePercentMod, 20.0f);
break;
}
@@ -4199,7 +4199,7 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/)
// xinef: if player is dead - teleport to graveyard
if (!target->IsAlive())
{
if (target->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION))
if (target->HasPreventResurectionAura())
return;
// xinef: player is in corpse

View File

@@ -1777,7 +1777,7 @@ SpellCastResult SpellInfo::CheckTarget(Unit const* caster, WorldObject const* ta
// only spells with SPELL_ATTR3_ONLY_ON_GHOSTS can target ghosts
if (IsRequiringDeadTarget())
{
if (!unitTarget->HasAuraType(SPELL_AURA_GHOST))
if (!unitTarget->HasGhostAura())
return SPELL_FAILED_TARGET_NOT_GHOST;
if (!IsDeathPersistent() && !IsAllowingDeadTarget())
return SPELL_FAILED_BAD_TARGETS;
@@ -1923,7 +1923,7 @@ SpellCastResult SpellInfo::CheckTarget(Unit const* caster, WorldObject const* ta
if (ExcludeTargetAuraSpell && unitTarget->HasAura(sSpellMgr->GetSpellIdForDifficulty(ExcludeTargetAuraSpell, caster)))
return SPELL_FAILED_TARGET_AURASTATE;
if (unitTarget->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION) && !HasAttribute(SPELL_ATTR7_BYPASS_NO_RESURRECTION_AURA))
if (unitTarget->HasPreventResurectionAura() && !HasAttribute(SPELL_ATTR7_BYPASS_NO_RESURRECTION_AURA))
if (HasEffect(SPELL_EFFECT_SELF_RESURRECT) || HasEffect(SPELL_EFFECT_RESURRECT) || HasEffect(SPELL_EFFECT_RESURRECT_NEW))
return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED;

View File

@@ -1111,10 +1111,10 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
AreaTableEntry const* pArea = sAreaTableStore.LookupEntry(player->GetAreaId());
if (!(pArea && pArea->flags & AREA_FLAG_NO_FLY_ZONE))
return false;
if (!player->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !player->HasAuraType(SPELL_AURA_FLY))
if (!player->HasIncreaseMountedFlightSpeedAura() && !player->HasFlyAura())
return false;
// Xinef: Underbelly elixir
if (player->GetPositionZ() < 637.0f && player->HasAuraType(SPELL_AURA_TRANSFORM))
if (player->GetPositionZ() < 637.0f && player->HasTransformAura())
return false;
break;
}
@@ -1124,7 +1124,7 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
return false;
Battlefield* Bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetZoneId());
if (!Bf || Bf->CanFlyIn() || (!player->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !player->HasAuraType(SPELL_AURA_FLY)))
if (!Bf || Bf->CanFlyIn() || (!player->HasIncreaseMountedFlightSpeedAura() && !player->HasFlyAura()))
return false;
break;
}