mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 08:28:32 +01:00
Core/Spells: Refactored SpellInfo::CalcCastTime() to prevent accidental mod charge losses caused by its incorrect usage
This commit is contained in:
@@ -3050,18 +3050,20 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
|
||||
// Prepare data for triggers
|
||||
prepareDataForTriggerSystem(triggeredByAura);
|
||||
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
|
||||
// calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
|
||||
m_casttime = m_spellInfo->CalcCastTime(m_caster, this);
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
if (Player* player = m_caster->ToPlayer())
|
||||
{
|
||||
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
|
||||
|
||||
// Set casttime to 0 if .cheat casttime is enabled.
|
||||
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_CASTTIME))
|
||||
m_casttime = 0;
|
||||
if (!m_caster->ToPlayer()->GetCommandStatus(CHEAT_CASTTIME))
|
||||
{
|
||||
m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
|
||||
// calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
|
||||
m_casttime = m_spellInfo->CalcCastTime(this);
|
||||
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
|
||||
}
|
||||
else
|
||||
m_casttime = 0; // Set cast time to 0 if .cheat casttime is enabled.
|
||||
}
|
||||
else
|
||||
m_casttime = m_spellInfo->CalcCastTime(this);
|
||||
|
||||
// don't allow channeled spells / spells with cast time to be casted while moving
|
||||
// (even if they are interrupted on moving, spells with almost immediate effect get to have their effect processed before movement interrupter kicks in)
|
||||
|
||||
@@ -2057,7 +2057,7 @@ int32 SpellInfo::GetMaxDuration() const
|
||||
return (DurationEntry->Duration[2] == -1) ? -1 : abs(DurationEntry->Duration[2]);
|
||||
}
|
||||
|
||||
uint32 SpellInfo::CalcCastTime(Unit* caster, Spell* spell) const
|
||||
uint32 SpellInfo::CalcCastTime(Spell* spell /*= NULL*/) const
|
||||
{
|
||||
// not all spells have cast time index and this is all is pasiive abilities
|
||||
if (!CastTimeEntry)
|
||||
@@ -2065,8 +2065,8 @@ uint32 SpellInfo::CalcCastTime(Unit* caster, Spell* spell) const
|
||||
|
||||
int32 castTime = CastTimeEntry->CastTime;
|
||||
|
||||
if (caster)
|
||||
caster->ModSpellCastTime(this, castTime, spell);
|
||||
if (spell)
|
||||
spell->GetCaster()->ModSpellCastTime(this, castTime, spell);
|
||||
|
||||
if (Attributes & SPELL_ATTR0_REQ_AMMO && (!IsAutoRepeatRangedSpell()))
|
||||
castTime += 500;
|
||||
|
||||
@@ -444,7 +444,7 @@ public:
|
||||
|
||||
uint32 GetMaxTicks() const;
|
||||
|
||||
uint32 CalcCastTime(Unit* caster = NULL, Spell* spell = NULL) const;
|
||||
uint32 CalcCastTime(Spell* spell = NULL) const;
|
||||
uint32 GetRecoveryTime() const;
|
||||
|
||||
int32 CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const;
|
||||
|
||||
Reference in New Issue
Block a user