mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
[8381] Some refactoring work in Unit::m_currentSpells code. Author: VladimirMangos
* Restrict access, use enum args, move some repeated code parts to function.
* Make m_selfContainer set only part of Unit::SetCurrentCastedSpell
--HG--
branch : trunk
This commit is contained in:
@@ -4542,19 +4542,22 @@ void Spell::EffectInterruptCast(uint32 i)
|
||||
|
||||
// TODO: not all spells that used this effect apply cooldown at school spells
|
||||
// also exist case: apply cooldown to interrupted cast only and to all spells
|
||||
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++)
|
||||
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
|
||||
{
|
||||
if (unitTarget->m_currentSpells[i])
|
||||
if (Spell* spell = unitTarget->GetCurrentSpell(CurrentSpellTypes(i)))
|
||||
{
|
||||
SpellEntry const* curSpellInfo = spell->m_spellInfo;
|
||||
// check if we can interrupt spell
|
||||
if ( (unitTarget->m_currentSpells[i]->getState() == SPELL_STATE_CASTING || (unitTarget->m_currentSpells[i]->getState() == SPELL_STATE_PREPARING && unitTarget->m_currentSpells[i]->GetCastTime() > 0.0f)) && unitTarget->m_currentSpells[i]->m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT && unitTarget->m_currentSpells[i]->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE )
|
||||
if ((spell->getState() == SPELL_STATE_CASTING
|
||||
|| spell->getState() == SPELL_STATE_PREPARING && spell->GetCastTime() > 0.0f)
|
||||
&& curSpellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT && curSpellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE )
|
||||
{
|
||||
if(m_originalCaster)
|
||||
{
|
||||
int32 duration = m_originalCaster->ModSpellDuration(m_spellInfo, unitTarget, m_originalCaster->CalcSpellDuration(m_spellInfo), false);
|
||||
unitTarget->ProhibitSpellScholl(GetSpellSchoolMask(unitTarget->m_currentSpells[i]->m_spellInfo), duration/*GetSpellDuration(m_spellInfo)*/);
|
||||
unitTarget->ProhibitSpellScholl(GetSpellSchoolMask(curSpellInfo), duration/*GetSpellDuration(m_spellInfo)*/);
|
||||
}
|
||||
unitTarget->InterruptSpell(i,false);
|
||||
unitTarget->InterruptSpell(CurrentSpellTypes(i), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5585,10 +5588,10 @@ void Spell::EffectSanctuary(uint32 /*i*/)
|
||||
|
||||
for(uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++)
|
||||
{
|
||||
if((*iter)->m_currentSpells[i]
|
||||
&& (*iter)->m_currentSpells[i]->m_targets.getUnitTargetGUID() == unitTarget->GetGUID())
|
||||
if((*iter)->GetCurrentSpell(i)
|
||||
&& (*iter)->GetCurrentSpell(i)->m_targets.getUnitTargetGUID() == unitTarget->GetGUID())
|
||||
{
|
||||
(*iter)->InterruptSpell(i, false);
|
||||
(*iter)->InterruptSpell(CurrentSpellTypes(i), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user