diff options
author | FAQ <ainarsh@gmail.com> | 2020-04-15 22:06:14 +0300 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2020-04-28 11:02:27 +0200 |
commit | 8d87c834e7aa933a9f19134fed702fdc756cb2a4 (patch) | |
tree | a9f75d2b7f28757244d2fe616dcaf3841029ad4d /src | |
parent | 2e42156f8d197128a1cf88274afc739ed6c75b08 (diff) |
Core/Spells: Scrolls should not be consumed, when they fail to apply.
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 5a75f6a0388..5ff5a66bcd6 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -3244,21 +3244,21 @@ void Spell::_cast(bool skipCheck) CallScriptBeforeCastHandlers(); - // skip check if done already (for instant cast spells for example) - if (!skipCheck) + auto cleanupSpell = [this, modOwner](SpellCastResult res, uint32* p1 = nullptr, uint32* p2 = nullptr) { - auto cleanupSpell = [this, modOwner](SpellCastResult res, uint32* p1 = nullptr, uint32* p2 = nullptr) - { - SendCastResult(res, p1, p2); - SendInterrupted(0); + SendCastResult(res, p1, p2); + SendInterrupted(0); - if (modOwner) - modOwner->SetSpellModTakingSpell(this, false); + if (modOwner) + modOwner->SetSpellModTakingSpell(this, false); - finish(false); - SetExecutedCurrently(false); - }; + finish(false); + SetExecutedCurrently(false); + }; + // skip check if done already (for instant cast spells for example) + if (!skipCheck) + { uint32 param1 = 0, param2 = 0; SpellCastResult castResult = CheckCast(false, ¶m1, ¶m2); if (castResult != SPELL_CAST_OK) @@ -3316,6 +3316,40 @@ void Spell::_cast(bool skipCheck) } } + // check if target already has the same type, but more powerful aura + if (modOwner) + { + for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) + { + if (!GetSpellInfo()->Effects[i].IsAura()) + continue; + + Unit::AuraEffectList const& auras = modOwner->GetAuraEffectsByType(SPELL_AURA_MOD_STAT); + for (Unit::AuraEffectList::const_iterator auraIt = auras.begin(); auraIt != auras.end(); ++auraIt) + { + // check if both spells are in same SpellGroups + if (sSpellMgr->CheckSpellGroupStackRules(GetSpellInfo(), (*auraIt)->GetSpellInfo()) == SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST) + { + // compare new aura vs existing aura + if (abs(GetSpellInfo()->Effects[i].BasePoints) < abs((*auraIt)->GetSpellInfo()->Effects[i].BasePoints)) + { + cleanupSpell(SPELL_FAILED_AURA_BOUNCED); + return; + } + else if (abs(GetSpellInfo()->Effects[i].BasePoints) == abs((*auraIt)->GetSpellInfo()->Effects[i].BasePoints)) + { + // in case when baseboints match and to avoid false positive, example, spell 8097 vs 8116 + if (abs(GetSpellInfo()->Effects[i].MiscValue) == abs((*auraIt)->GetSpellInfo()->Effects[i].MiscValue)) + { + cleanupSpell(SPELL_FAILED_AURA_BOUNCED); + return; + } + } + } + } + } + } + // if the spell allows the creature to turn while casting, then adjust server-side orientation to face the target now // client-side orientation is handled by the client itself, as the cast target is targeted due to Creature::SetSpellFocusTarget if (m_caster->GetTypeId() == TYPEID_UNIT && !m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED)) |