mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 17:05:44 +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:
@@ -873,7 +873,7 @@ void Unit::CastStop(uint32 except_spellid)
|
||||
{
|
||||
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++)
|
||||
if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id!=except_spellid)
|
||||
InterruptSpell(i,false);
|
||||
InterruptSpell(CurrentSpellTypes(i),false);
|
||||
}
|
||||
|
||||
void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster)
|
||||
@@ -2904,13 +2904,9 @@ SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool
|
||||
}
|
||||
}
|
||||
if (isNormal || m_currentSpells[CURRENT_MELEE_SPELL])
|
||||
{
|
||||
misschance = 5.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
misschance = 24.0f;
|
||||
}
|
||||
}
|
||||
|
||||
// PvP : PvE melee misschances per leveldif > 2
|
||||
@@ -3314,9 +3310,11 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell )
|
||||
// set new current spell
|
||||
m_currentSpells[CSpellType] = pSpell;
|
||||
pSpell->SetReferencedFromCurrent(true);
|
||||
|
||||
pSpell->m_selfContainer = &(m_currentSpells[pSpell->GetCurrentContainer()]);
|
||||
}
|
||||
|
||||
void Unit::InterruptSpell(uint32 spellType, bool withDelayed, bool withInstant)
|
||||
void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool withInstant)
|
||||
{
|
||||
assert(spellType < CURRENT_MAX_SPELL);
|
||||
|
||||
@@ -3345,6 +3343,18 @@ void Unit::InterruptSpell(uint32 spellType, bool withDelayed, bool withInstant)
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::FinishSpell(CurrentSpellTypes spellType, bool ok /*= true*/)
|
||||
{
|
||||
Spell* spell = m_currentSpells[spellType];
|
||||
if (!spell)
|
||||
return;
|
||||
|
||||
if (spellType == CURRENT_CHANNELED_SPELL)
|
||||
spell->SendChannelUpdate(0);
|
||||
|
||||
spell->finish(ok);
|
||||
}
|
||||
|
||||
bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skipAutorepeat, bool isAutoshoot) const
|
||||
{
|
||||
// We don't do loop here to explicitly show that melee spell is excluded.
|
||||
|
||||
Reference in New Issue
Block a user