From e55a93eec874f798f365099fbdd4a1e181b111cd Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Sun, 7 Nov 2021 20:41:25 +0100 Subject: [PATCH] Core/Spells: Triggered spells should not cause players to stand up (#8986) - Closes #8764 --- src/server/game/Spells/Spell.cpp | 32 ++++++++++++++++---------------- src/server/game/Spells/Spell.h | 3 +++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 6bfb3ac95..bbf1577d4 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2849,7 +2849,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA } // xinef: triggered spells should not prolong combat - if (unit->IsInCombat() && !m_spellInfo->HasAttribute(SPELL_ATTR3_SUPRESS_TARGET_PROCS) && !m_triggeredByAuraSpell.spellInfo) + if (unit->IsInCombat() && !m_spellInfo->HasAttribute(SPELL_ATTR3_SUPRESS_TARGET_PROCS) && !m_triggeredByAuraSpell) { m_caster->SetInCombatState(unit->GetCombatTimer() > 0, unit); unit->getHostileRefMgr().threatAssist(m_caster, 0.0f); @@ -2884,7 +2884,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA unit->IncrDiminishing(m_diminishGroup); } - if (m_caster != unit && m_caster->IsHostileTo(unit) && !m_spellInfo->IsPositive() && !m_triggeredByAuraSpell.spellInfo && !m_spellInfo->HasAttribute(SPELL_ATTR0_CU_DONT_BREAK_STEALTH)) + if (m_caster != unit && m_caster->IsHostileTo(unit) && !m_spellInfo->IsPositive() && !m_triggeredByAuraSpell && !m_spellInfo->HasAttribute(SPELL_ATTR0_CU_DONT_BREAK_STEALTH)) { unit->RemoveAurasByType(SPELL_AURA_MOD_STEALTH); } @@ -2983,7 +2983,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA } // xinef: apply relic cooldown, imo best place to add this - if (m_CastItem && m_CastItem->GetTemplate()->InventoryType == INVTYPE_RELIC && m_triggeredByAuraSpell.spellInfo) + if (m_CastItem && m_CastItem->GetTemplate()->InventoryType == INVTYPE_RELIC && m_triggeredByAuraSpell) m_caster->AddSpellCooldown(SPELL_RELIC_COOLDOWN, m_CastItem->GetEntry(), duration); m_spellAura->SetTriggeredByAuraSpellInfo(m_triggeredByAuraSpell.spellInfo); @@ -3417,7 +3417,7 @@ SpellCastResult Spell::prepare(SpellCastTargets const* targets, AuraEffect const LOG_DEBUG("spells.aura", "Spell::prepare: spell id %u source %u caster %d customCastFlags %u mask %u", m_spellInfo->Id, m_caster->GetEntry(), m_originalCaster ? m_originalCaster->GetEntry() : -1, _triggeredCastFlags, m_targets.GetTargetMask()); - if (!(m_spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) && !(m_spellInfo->Attributes & SPELL_ATTR0_ALLOW_WHILE_SITTING) && m_caster->IsSitState()) + if (!(m_spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED) && !(m_spellInfo->Attributes & SPELL_ATTR0_ALLOW_WHILE_SITTING) && !m_triggeredByAuraSpell && m_caster->IsSitState()) { m_caster->SetStandState(UNIT_STAND_STATE_STAND); } @@ -4179,7 +4179,7 @@ void Spell::finish(bool ok) } // potions disabled by client, send event "not in combat" if need - if (m_caster->GetTypeId() == TYPEID_PLAYER && !m_triggeredByAuraSpell.spellInfo) + if (m_caster->GetTypeId() == TYPEID_PLAYER && !m_triggeredByAuraSpell) m_caster->ToPlayer()->UpdatePotionCooldown(this); // Take mods after trigger spell (needed for 14177 to affect 48664) @@ -4358,7 +4358,7 @@ void Spell::SendSpellStart() uint32 castFlags = CAST_FLAG_HAS_TRAJECTORY; - if (((IsTriggered() && !m_spellInfo->IsAutoRepeatRangedSpell()) || m_triggeredByAuraSpell.spellInfo) && !m_cast_count && !m_spellInfo->IsChanneled()) + if (((IsTriggered() && !m_spellInfo->IsAutoRepeatRangedSpell()) || m_triggeredByAuraSpell) && !m_cast_count && !m_spellInfo->IsChanneled()) castFlags |= CAST_FLAG_PENDING; if (m_spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) || m_spellInfo->HasAttribute(SPELL_ATTR0_CU_NEEDS_AMMO_DATA)) @@ -4414,7 +4414,7 @@ void Spell::SendSpellGo() uint32 castFlags = CAST_FLAG_UNKNOWN_9; // triggered spells with spell visual != 0 - if (((IsTriggered() && !m_spellInfo->IsAutoRepeatRangedSpell()) || m_triggeredByAuraSpell.spellInfo) && !m_cast_count && !m_spellInfo->IsChanneled()) + if (((IsTriggered() && !m_spellInfo->IsAutoRepeatRangedSpell()) || m_triggeredByAuraSpell) && !m_cast_count && !m_spellInfo->IsChanneled()) castFlags |= CAST_FLAG_PENDING; if (m_spellInfo->HasAttribute(SPELL_ATTR0_USES_RANGED_SLOT) || m_spellInfo->HasAttribute(SPELL_ATTR0_CU_NEEDS_AMMO_DATA)) @@ -4897,7 +4897,7 @@ void Spell::TakeCastItem() void Spell::TakePower() { - if (m_CastItem || m_triggeredByAuraSpell.spellInfo) + if (m_CastItem || m_triggeredByAuraSpell) return; //Don't take power if the spell is cast while .cheat power is enabled. @@ -5231,7 +5231,7 @@ void Spell::HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOT SpellCastResult Spell::CheckCast(bool strict) { // check death state - if (!m_caster->IsAlive() && !m_spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) && !(m_spellInfo->HasAttribute(SPELL_ATTR0_ALLOW_CAST_WHILE_DEAD) || (IsTriggered() && !m_triggeredByAuraSpell.spellInfo))) + if (!m_caster->IsAlive() && !m_spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) && !(m_spellInfo->HasAttribute(SPELL_ATTR0_ALLOW_CAST_WHILE_DEAD) || (IsTriggered() && !m_triggeredByAuraSpell))) return SPELL_FAILED_CASTER_DEAD; // Spectator check @@ -5257,7 +5257,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (!(_triggeredCastFlags & TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD) && m_caster->ToPlayer()->HasSpellCooldown(m_spellInfo->Id)) { - if (m_triggeredByAuraSpell.spellInfo) + if (m_triggeredByAuraSpell) return SPELL_FAILED_DONT_REPORT; else return SPELL_FAILED_NOT_READY; @@ -5453,7 +5453,7 @@ SpellCastResult Spell::CheckCast(bool strict) { // Check explicit target for m_originalCaster - todo: get rid of such workarounds // Xinef: do not check explicit target for triggered spell casted on self with targetflag enemy - if (!m_triggeredByAuraSpell.spellInfo || m_targets.GetUnitTarget() != m_caster || !(m_spellInfo->GetExplicitTargetMask() & TARGET_FLAG_UNIT_ENEMY)) + if (!m_triggeredByAuraSpell || m_targets.GetUnitTarget() != m_caster || !(m_spellInfo->GetExplicitTargetMask() & TARGET_FLAG_UNIT_ENEMY)) { SpellCastResult castResult = m_spellInfo->CheckExplicitTarget((m_originalCaster && m_caster->GetEntry() != WORLD_TRIGGER) ? m_originalCaster : m_caster, m_targets.GetObjectTarget(), m_targets.GetItemTarget()); if (castResult != SPELL_CAST_OK) @@ -5573,7 +5573,7 @@ SpellCastResult Spell::CheckCast(bool strict) } // xinef: do not skip triggered spells if they posses prevention type (eg. Bladestorm vs Hand of Protection) - if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_AURAS) || (m_spellInfo->PreventionType > SPELL_PREVENTION_TYPE_NONE && m_triggeredByAuraSpell.spellInfo && m_triggeredByAuraSpell.spellInfo->IsPositive())) + if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_AURAS) || (m_spellInfo->PreventionType > SPELL_PREVENTION_TYPE_NONE && m_triggeredByAuraSpell && m_triggeredByAuraSpell.spellInfo->IsPositive())) { castResult = CheckCasterAuras(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_AURAS); if (castResult != SPELL_CAST_OK) @@ -6284,7 +6284,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_NO_COMBO_POINTS; // xinef: check relic cooldown - if (m_CastItem && m_CastItem->GetTemplate()->InventoryType == INVTYPE_RELIC && m_triggeredByAuraSpell.spellInfo) + if (m_CastItem && m_CastItem->GetTemplate()->InventoryType == INVTYPE_RELIC && m_triggeredByAuraSpell) if (m_caster->HasSpellCooldown(SPELL_RELIC_COOLDOWN) && !m_caster->HasSpellItemCooldown(SPELL_RELIC_COOLDOWN, m_CastItem->GetEntry())) return SPELL_FAILED_NOT_READY; @@ -7423,7 +7423,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const return true; // if spell is triggered, need to check for LOS disable on the aura triggering it and inherit that behaviour - if (IsTriggered() && m_triggeredByAuraSpell.spellInfo && (m_triggeredByAuraSpell.spellInfo->HasAttribute(SPELL_ATTR2_IGNORE_LINE_OF_SIGHT) || + if (IsTriggered() && m_triggeredByAuraSpell && (m_triggeredByAuraSpell.spellInfo->HasAttribute(SPELL_ATTR2_IGNORE_LINE_OF_SIGHT) || DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_triggeredByAuraSpell.spellInfo->Id, nullptr, SPELL_DISABLE_LOS))) { return true; @@ -7542,8 +7542,8 @@ bool Spell::IsAutoActionResetSpell() const bool Spell::IsNeedSendToClient(bool go) const { return m_spellInfo->SpellVisual[0] || m_spellInfo->SpellVisual[1] || m_spellInfo->IsChanneled() || - m_spellInfo->Speed > 0.0f || (!m_triggeredByAuraSpell.spellInfo && !IsTriggered()) || - (go && m_triggeredByAuraSpell.spellInfo && m_triggeredByAuraSpell.spellInfo->IsChanneled()); + m_spellInfo->Speed > 0.0f || (!m_triggeredByAuraSpell && !IsTriggered()) || + (go && m_triggeredByAuraSpell && m_triggeredByAuraSpell.spellInfo->IsChanneled()); } bool Spell::HaveTargetsForEffect(uint8 effect) const diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 464f2888a..784d13ba1 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -272,6 +272,9 @@ struct TriggeredByAuraSpellData void Init(AuraEffect const* aurEff); + operator bool() const { return spellInfo != nullptr; } + bool operator!() const { return !(bool(*this)); } + SpellInfo const* spellInfo; int8 effectIndex; uint32 tickNumber;