Core/Player: fix some PCT_MOD charge consumption

By xinef1

Closes #18516
This commit is contained in:
ariel- authored and roc13x committed 2017-05-04 04:00:36 +01:00
1 parent a15aaf68c3
commit c1accd4537
2 files changed
+22 -5

No files matched your search

@@ -21357,6 +21357,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
@@ -1849,6 +1849,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);
@@ -2912,7 +2913,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;
@@ -2936,7 +2937,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;
@@ -2972,14 +2973,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;
}