mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Spells: Scrolls should not be consumed, when they fail to apply.
This commit is contained in:
@@ -3244,21 +3244,21 @@ void Spell::_cast(bool skipCheck)
|
||||
|
||||
CallScriptBeforeCastHandlers();
|
||||
|
||||
auto cleanupSpell = [this, modOwner](SpellCastResult res, uint32* p1 = nullptr, uint32* p2 = nullptr)
|
||||
{
|
||||
SendCastResult(res, p1, p2);
|
||||
SendInterrupted(0);
|
||||
|
||||
if (modOwner)
|
||||
modOwner->SetSpellModTakingSpell(this, false);
|
||||
|
||||
finish(false);
|
||||
SetExecutedCurrently(false);
|
||||
};
|
||||
|
||||
// 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)
|
||||
{
|
||||
SendCastResult(res, p1, p2);
|
||||
SendInterrupted(0);
|
||||
|
||||
if (modOwner)
|
||||
modOwner->SetSpellModTakingSpell(this, false);
|
||||
|
||||
finish(false);
|
||||
SetExecutedCurrently(false);
|
||||
};
|
||||
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user