From 5514523a7c181c49b915b0b938c18f80c8a342c3 Mon Sep 17 00:00:00 2001 From: ille Date: Thu, 20 Oct 2011 18:28:37 +0200 Subject: use effectMask to calculate mechanicMask in ModSpellDuration --- src/server/game/Entities/Unit/Unit.cpp | 6 +++--- src/server/game/Entities/Unit/Unit.h | 2 +- src/server/game/Spells/Spell.cpp | 2 +- src/server/game/Spells/SpellEffects.cpp | 2 +- src/server/game/Spells/SpellInfo.cpp | 11 +++++++++++ src/server/game/Spells/SpellInfo.h | 1 + 6 files changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index d23c3c842d6..e7d4e69a247 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -13042,16 +13042,16 @@ int32 Unit::CalcSpellDuration(SpellInfo const* spellProto) return duration; } -int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive) +int32 Unit::ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive, uint32 effectMask) { - // don't mod permament auras duration + // don't mod permanent auras duration if (duration < 0) return duration; // cut duration only of negative effects if (!positive) { - int32 mechanic = spellProto->GetAllEffectsMechanicMask(); + int32 mechanic = spellProto->GetSpellMechanicMaskByEffectMask(effectMask); int32 durationMod; int32 durationMod_always = 0; diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 064542bb013..39b07d885f6 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -2068,7 +2068,7 @@ class Unit : public WorldObject float ApplyEffectModifiers(SpellInfo const* spellProto, uint8 effect_index, float value) const; int32 CalculateSpellDamage(Unit const* target, SpellInfo const* spellProto, uint8 effect_index, int32 const* basePoints = NULL) const; int32 CalcSpellDuration(SpellInfo const* spellProto); - int32 ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive); + int32 ModSpellDuration(SpellInfo const* spellProto, Unit const* target, int32 duration, bool positive, uint32 effectMask); void ModSpellCastTime(SpellInfo const* spellProto, int32 & castTime, Spell* spell=NULL); float CalculateLevelPenalty(SpellInfo const* spellProto) const; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 4d7534509e4..c3afe94d2ff 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -1537,7 +1537,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, const uint32 effectMask, bool if (AuraApplication* aurApp = m_spellAura->GetApplicationOfTarget(m_originalCaster->GetGUID())) positive = aurApp->IsPositive(); - duration = m_originalCaster->ModSpellDuration(aurSpellInfo, unit, duration, positive); + duration = m_originalCaster->ModSpellDuration(aurSpellInfo, unit, duration, positive, effectMask); // Haste modifies duration of channeled spells if (m_spellInfo->IsChanneled()) diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 83cecf7d884..5cd81e1f4cd 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -4331,7 +4331,7 @@ void Spell::EffectInterruptCast(SpellEffIndex effIndex) { if (m_originalCaster) { - int32 duration = m_originalCaster->ModSpellDuration(m_spellInfo, unitTarget, m_originalCaster->CalcSpellDuration(m_spellInfo), false); + int32 duration = m_originalCaster->ModSpellDuration(m_spellInfo, unitTarget, m_originalCaster->CalcSpellDuration(m_spellInfo), false, 1 << effIndex); unitTarget->ProhibitSpellSchool(curSpellInfo->GetSchoolMask(), duration/*GetSpellDuration(m_spellInfo)*/); } ExecuteLogEffectInterruptCast(effIndex, unitTarget, curSpellInfo->Id); diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 543baa82789..972276c7d26 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1735,6 +1735,17 @@ uint32 SpellInfo::GetEffectMechanicMask(uint8 effIndex) const return mask; } +uint32 SpellInfo::GetSpellMechanicMaskByEffectMask(uint32 effectMask) const +{ + uint32 mask = 0; + if (Mechanic) + mask |= 1<< Mechanic; + for (int i = 0; i < MAX_SPELL_EFFECTS; ++i) + if ((effectMask & (1 << i)) && Effects[i].Mechanic) + mask |= 1<< Effects[i].Mechanic; + return mask; +} + Mechanics SpellInfo::GetEffectMechanic(uint8 effIndex) const { if (Effects[effIndex].IsEffect() && Effects[effIndex].Mechanic) diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index b4f4ca8c11e..7faf0de890d 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -444,6 +444,7 @@ public: SpellSchoolMask GetSchoolMask() const; uint32 GetAllEffectsMechanicMask() const; uint32 GetEffectMechanicMask(uint8 effIndex) const; + uint32 GetSpellMechanicMaskByEffectMask(uint32 effectMask) const; Mechanics GetEffectMechanic(uint8 effIndex) const; uint32 GetDispelMask() const; static uint32 GetDispelMask(DispelType type); -- cgit v1.2.3