Core/Player: fix some PCT_MOD charge consumption

By xinef1

Closes #18516
This commit is contained in:
ariel-
2016-12-30 15:38:33 -03:00
parent a20fda9b2d
commit 07fb65a6f2
2 changed files with 22 additions and 5 deletions
@@ -20901,6 +20901,14 @@ void Player::RestoreAllSpellMods(uint32 ownerAuraId /*= 0*/, Aura* aura /*= null
RestoreSpellMods(spell, ownerAuraId, aura);
}
bool Player::HasSpellModApplied(SpellModifier* mod, Spell* spell)
{
if (!spell)
return false;
return spell->m_appliedMods.count(mod->ownerAura) != 0;
}
void Player::ApplyModToSpell(SpellModifier* mod, Spell* spell)
{
if (!spell)
+14 -5
View File
@@ -1610,6 +1610,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void RestoreSpellMods(Spell* spell, uint32 ownerAuraId = 0, Aura* aura = nullptr);
void RestoreAllSpellMods(uint32 ownerAuraId = 0, Aura* aura = nullptr);
static void ApplyModToSpell(SpellModifier* mod, Spell* spell);
static bool HasSpellModApplied(SpellModifier* mod, Spell* spell);
void SetSpellModTakingSpell(Spell* spell, bool apply);
void RemoveArenaSpellCooldowns(bool removeActivePetCooldowns = false);
@@ -2634,7 +2635,7 @@ void Player::ApplySpellMod(uint32 spellId, T& basevalue, Spell* spell /*= nullpt
case SPELLMOD_CASTING_TIME:
{
SpellModifier* modInstantSpell = nullptr;
for (SpellModifier* mod : m_spellMods[SPELLMOD_CASTING_TIME])
for (SpellModifier* mod : m_spellMods[op])
{
if (!IsAffectedBySpellmod(spellInfo, mod, spell))
continue;
@@ -2658,7 +2659,7 @@ void Player::ApplySpellMod(uint32 spellId, T& basevalue, Spell* spell /*= nullpt
case SPELLMOD_CRITICAL_CHANCE:
{
SpellModifier* modCritical = nullptr;
for (SpellModifier* mod : m_spellMods[SPELLMOD_CRITICAL_CHANCE])
for (SpellModifier* mod : m_spellMods[op])
{
if (!IsAffectedBySpellmod(spellInfo, mod, spell))
continue;
@@ -2694,14 +2695,22 @@ void Player::ApplySpellMod(uint32 spellId, T& basevalue, Spell* spell /*= nullpt
break;
case SPELLMOD_PCT:
{
// skip percent mods for null basevalue (most important for spell mods with charges)
// skip percent mods with null basevalue (most important for spell mods with charges)
if (basevalue == T(0))
continue;
// special case (skip > 10sec spell casts for instant cast setting)
if (op == SPELLMOD_CASTING_TIME)
if (op == SPELLMOD_CASTING_TIME && mod->value <= -100 && basevalue >= T(10000))
continue;
else if (!Player::HasSpellModApplied(mod, spell))
{
if (mod->value <= -100 && basevalue >= T(10000))
// special case for Surge of Light, don't apply critical chance reduction if other mods not applied (ie procs while casting another spell)
// (Surge of Light is the only PCT_MOD on critical chance)
if (op == SPELLMOD_CRITICAL_CHANCE)
continue;
// special case for Backdraft, dont' apply GCD reduction if cast time reduction wasn't applied (ie when Backlash is consumed first)
// (Backdraft is the only PCT_MOD on global cooldown)
else if (op == SPELLMOD_GLOBAL_COOLDOWN)
continue;
}