diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2016-12-28 23:38:03 -0300 |
|---|---|---|
| committer | DoctorKraft <DoctorKraft@users.noreply.github.com> | 2018-03-18 00:19:42 +0100 |
| commit | 18b4e5d4bdadca44f97edb24031113f501ad9a9d (patch) | |
| tree | 7f3d09d4e45d13aa27c836ff32a363fd729d69be | |
| parent | f8840410800a71f15e490045d25518c413b70a10 (diff) | |
Core/Spell: reverted stun aura handling
Partial revert of 50a3ce5703bdaa4fe16e2e773eabafa9a4818083
Closes #18487
Closes #18490
Closes #18497
(cherry picked from commit 27fb5fc16d88c0002898981009bedc6b8001cac7)
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index f2c8973ad1c..587bb40e50f 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -5889,14 +5889,54 @@ SpellCastResult Spell::CheckCasterAuras(uint32* param1) const // Get unit state uint32 const unitflag = m_caster->GetUInt32Value(UNIT_FIELD_FLAGS); + + // this check should only be done when player does cast directly + // (ie not when it's called from a script) Breaks for example PlayerAI when charmed + /* if (!m_caster->GetCharmerGUID().IsEmpty()) { if (Unit* charmer = m_caster->GetCharmer()) if (charmer->GetUnitBeingMoved() != m_caster && !CheckSpellCancelsCharm(param1)) result = SPELL_FAILED_CHARMED; } - else if (unitflag & UNIT_FLAG_STUNNED && !usableWhileStunned && !CheckSpellCancelsStun(param1)) - result = SPELL_FAILED_STUNNED; + */ + + if (unitflag & UNIT_FLAG_STUNNED) + { + // spell is usable while stunned, check if caster has allowed stun auras, another stun types must prevent cast spell + if (usableWhileStunned) + { + static uint32 const allowedStunMask = + 1 << MECHANIC_STUN + | 1 << MECHANIC_SLEEP; + + bool foundNotStun = false; + Unit::AuraEffectList const& stunAuras = m_caster->GetAuraEffectsByType(SPELL_AURA_MOD_STUN); + for (AuraEffect const* stunEff : stunAuras) + { + uint32 const stunMechanicMask = stunEff->GetSpellInfo()->GetAllEffectsMechanicMask(); + if (stunMechanicMask && !(stunMechanicMask & allowedStunMask)) + { + foundNotStun = true; + + // fill up aura mechanic info to send client proper error message + if (param1) + { + *param1 = stunEff->GetSpellInfo()->GetEffect(stunEff->GetEffIndex())->Mechanic; + if (!*param1) + *param1 = stunEff->GetSpellInfo()->Mechanic; + } + break; + } + } + + if (foundNotStun) + result = SPELL_FAILED_STUNNED; + } + // Not usable while stunned, however spell might provide some immunity that allows to cast it anyway + else if (!CheckSpellCancelsStun(param1)) + result = SPELL_FAILED_STUNNED; + } else if (unitflag & UNIT_FLAG_SILENCED && m_spellInfo->PreventionType & SPELL_PREVENTION_TYPE_SILENCE && !CheckSpellCancelsSilence(param1)) result = SPELL_FAILED_SILENCED; else if (unitflag & UNIT_FLAG_PACIFIED && m_spellInfo->PreventionType & SPELL_PREVENTION_TYPE_PACIFY && !CheckSpellCancelsPacify(param1)) |
