mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-25 19:31:59 +01:00
Fixed setting and unsetting of m_spellModTakingSpell (#19116)
- A problem when a different spell tries to overwrite existing ModTakingSpell should no longer happen
(cherrypicked from e261754c9c)
This commit is contained in:
@@ -2878,13 +2878,9 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
|
||||
}
|
||||
LoadScripts();
|
||||
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
|
||||
// Fill cost data (do not use power for item casts)
|
||||
if (!m_CastItem)
|
||||
m_powerCost = m_spellInfo->CalcPowerCost(m_caster, m_spellSchoolMask);
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
|
||||
if (m_CastItem)
|
||||
m_powerCost = m_spellInfo->CalcPowerCost(m_caster, m_spellSchoolMask, this);
|
||||
|
||||
// Set combo point requirement
|
||||
if ((_triggeredCastFlags & TRIGGERED_IGNORE_COMBO_POINTS) || m_CastItem || !m_caster->m_playerMovingMe)
|
||||
@@ -2908,11 +2904,6 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
|
||||
triggeredByAura->GetBase()->SetDuration(0);
|
||||
}
|
||||
|
||||
// cleanup after mod system
|
||||
// triggered spell pointer can be not removed in some cases
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
|
||||
|
||||
if (param1 || param2)
|
||||
SendCastResult(result, ¶m1, ¶m2);
|
||||
else
|
||||
@@ -2929,10 +2920,8 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
|
||||
{
|
||||
if (!player->GetCommandStatus(CHEAT_CASTTIME))
|
||||
{
|
||||
player->SetSpellModTakingSpell(this, true);
|
||||
// calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
|
||||
m_casttime = m_spellInfo->CalcCastTime(player->getLevel(), this);
|
||||
player->SetSpellModTakingSpell(this, false);
|
||||
}
|
||||
else
|
||||
m_casttime = 0; // Set cast time to 0 if .cheat casttime is enabled.
|
||||
@@ -3057,6 +3046,23 @@ void Spell::cancel()
|
||||
}
|
||||
|
||||
void Spell::cast(bool skipCheck)
|
||||
{
|
||||
Player* modOwner = m_caster->GetSpellModOwner();
|
||||
Spell* lastSpellMod = nullptr;
|
||||
if (modOwner)
|
||||
{
|
||||
lastSpellMod = modOwner->m_spellModTakingSpell;
|
||||
if (lastSpellMod)
|
||||
modOwner->SetSpellModTakingSpell(lastSpellMod, false);
|
||||
}
|
||||
|
||||
_cast(skipCheck);
|
||||
|
||||
if (lastSpellMod)
|
||||
modOwner->SetSpellModTakingSpell(lastSpellMod, true);
|
||||
}
|
||||
|
||||
void Spell::_cast(bool skipCheck)
|
||||
{
|
||||
// update pointers base at GUIDs to prevent access to non-existed already object
|
||||
if (!UpdatePointers())
|
||||
@@ -3114,8 +3120,6 @@ void Spell::cast(bool skipCheck)
|
||||
SendCastResult(castResult, ¶m1, ¶m2);
|
||||
SendInterrupted(0);
|
||||
|
||||
// cleanup after mod system
|
||||
// triggered spell pointer can be not removed in some cases
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
|
||||
|
||||
@@ -3139,8 +3143,6 @@ void Spell::cast(bool skipCheck)
|
||||
SendCastResult(SPELL_FAILED_DONT_REPORT);
|
||||
SendInterrupted(0);
|
||||
|
||||
// cleanup after mod system
|
||||
// triggered spell pointer can be not removed in some cases
|
||||
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
|
||||
|
||||
finish(false);
|
||||
@@ -7241,13 +7243,7 @@ void Spell::DoAllEffectOnLaunchTarget(TargetInfo& targetInfo, float* multiplier)
|
||||
}
|
||||
}
|
||||
|
||||
if (Player* modOwner = m_caster->GetSpellModOwner())
|
||||
modOwner->SetSpellModTakingSpell(this, true);
|
||||
|
||||
targetInfo.crit = m_caster->IsSpellCrit(unit, m_spellInfo, m_spellSchoolMask, m_attackType);
|
||||
|
||||
if (Player* modOwner = m_caster->GetSpellModOwner())
|
||||
modOwner->SetSpellModTakingSpell(this, false);
|
||||
}
|
||||
|
||||
SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& skillId, int32& reqSkillValue, int32& skillValue)
|
||||
|
||||
Reference in New Issue
Block a user