mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 01:37:01 +00:00
[11740] Restore spellmod charges used by fail spell cast
Signed-off-by: VladimirMangos <vladimir@getmangos.com> Also * Prevent more one charge use for same spell cast * Cleanup enum SpellState from unused cases * Propertly remove spellmod charges at spell finish in case pet/totem caster
This commit is contained in:
parent
f1bec402e9
commit
222612fa51
5 changed files with 63 additions and 26 deletions
|
|
@ -361,7 +361,7 @@ Spell::Spell( Unit* caster, SpellEntry const *info, bool triggered, ObjectGuid o
|
|||
for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
|
||||
m_currentBasePoints[i] = m_spellInfo->CalculateSimpleValue(SpellEffectIndex(i));
|
||||
|
||||
m_spellState = SPELL_STATE_NULL;
|
||||
m_spellState = SPELL_STATE_PREPARING;
|
||||
|
||||
m_castPositionX = m_castPositionY = m_castPositionZ = 0;
|
||||
m_TriggerSpells.clear();
|
||||
|
|
@ -3494,21 +3494,27 @@ void Spell::update(uint32 difftime)
|
|||
|
||||
void Spell::finish(bool ok)
|
||||
{
|
||||
if(!m_caster)
|
||||
if (!m_caster)
|
||||
return;
|
||||
|
||||
if(m_spellState == SPELL_STATE_FINISHED)
|
||||
if (m_spellState == SPELL_STATE_FINISHED)
|
||||
return;
|
||||
|
||||
// remove/restore spell mods before m_spellState update
|
||||
if (Player* modOwner = m_caster->GetSpellModOwner())
|
||||
{
|
||||
if (ok || m_spellState != SPELL_STATE_PREPARING) // fail after start channeling or throw to target not affect spell mods
|
||||
modOwner->RemoveSpellMods(this);
|
||||
else
|
||||
modOwner->ResetSpellModsDueToCanceledSpell(this);
|
||||
}
|
||||
|
||||
m_spellState = SPELL_STATE_FINISHED;
|
||||
|
||||
// other code related only to successfully finished spells
|
||||
if(!ok)
|
||||
return;
|
||||
|
||||
// remove spell mods
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)m_caster)->RemoveSpellMods(this);
|
||||
// other code related only to successfully finished spells
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
// handle SPELL_AURA_ADD_TARGET_TRIGGER auras
|
||||
Unit::AuraList const& targetTriggers = m_caster->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue