aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-04-13 03:18:20 -0300
committerariel- <ariel-@users.noreply.github.com>2017-04-13 03:18:20 -0300
commit232e631390a504b51d82a7b678b7cf26d49d182a (patch)
tree36d4c1b9faf1d7ba9e72de1797c43029a1ffafa5 /src/server
parentd914c55c0585fe31a9a1b9fe4e9d4a9b498e8e8f (diff)
Core/Spell: check aura positivity per effect on spell hit
- Fixes applying DR to positive effects, and changing duration of whole aura Closes #19447
Diffstat (limited to 'src/server')
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp7
-rw-r--r--src/server/game/Entities/Unit/Unit.h2
-rw-r--r--src/server/game/Spells/Spell.cpp25
3 files changed, 21 insertions, 13 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index bd7fdb49e8a..593b82f5316 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -9911,11 +9911,11 @@ void Unit::IncrDiminishing(SpellInfo const* auraSpellInfo, bool triggered)
++diminish.hitCount;
}
-float Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool triggered, int32& duration, Unit* caster, DiminishingLevels previousLevel)
+bool Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool triggered, int32& duration, Unit* caster, DiminishingLevels previousLevel) const
{
DiminishingGroup const group = auraSpellInfo->GetDiminishingReturnsGroupForSpell(triggered);
if (duration == -1 || group == DIMINISHING_NONE)
- return 1.0f;
+ return true;
int32 const limitDuration = auraSpellInfo->GetDiminishingReturnsLimitDuration(triggered);
@@ -9936,7 +9936,6 @@ float Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool trig
}
float mod = 1.0f;
-
if (group == DIMINISHING_TAUNT)
{
if (GetTypeId() == TYPEID_UNIT && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_TAUNT_DIMINISH))
@@ -9971,7 +9970,7 @@ float Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool trig
}
duration = int32(duration * mod);
- return mod;
+ return (duration != 0);
}
void Unit::ApplyDiminishingAura(DiminishingGroup group, bool apply)
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index a5903aaf995..cd7e6e6a13b 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1306,7 +1306,7 @@ class TC_GAME_API Unit : public WorldObject
DiminishingLevels GetDiminishing(DiminishingGroup group);
void IncrDiminishing(SpellInfo const* auraSpellInfo, bool triggered);
- float ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool triggered, int32& duration, Unit* caster, DiminishingLevels previousLevel);
+ bool ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, bool triggered, int32& duration, Unit* caster, DiminishingLevels previousLevel) const;
void ApplyDiminishingAura(DiminishingGroup group, bool apply);
void ClearDiminishings();
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 302579da128..e14fc60e78e 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -2568,7 +2568,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
// Select rank for aura with level requirements only in specific cases
// Unit has to be target only of aura effect, both caster and target have to be players, target has to be other than unit target
SpellInfo const* aurSpellInfo = m_spellInfo;
- int32 basePoints[3];
+ int32 basePoints[MAX_SPELL_EFFECTS];
if (scaleAura)
{
aurSpellInfo = m_spellInfo->GetAuraRankForLevel(unitTarget->getLevel());
@@ -2602,11 +2602,24 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
}
// Now Reduce spell duration using data received at spell hit
+ // check whatever effects we're going to apply, diminishing returns only apply to negative aura effects
+ bool positive = true;
+ if (m_originalCaster == unit || !m_originalCaster->IsFriendlyTo(unit))
+ {
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ {
+ if ((effectMask & (1 << i)) && !aurSpellInfo->IsPositiveEffect(i))
+ {
+ positive = false;
+ break;
+ }
+ }
+ }
+
int32 duration = m_spellAura->GetMaxDuration();
- float diminishMod = unit->ApplyDiminishingToDuration(aurSpellInfo, triggered, duration, m_originalCaster, diminishLevel);
// unit is immune to aura if it was diminished to 0 duration
- if (diminishMod == 0.0f)
+ if (!positive && !unit->ApplyDiminishingToDuration(aurSpellInfo, triggered, duration, m_originalCaster, diminishLevel))
{
m_spellAura->Remove();
bool found = false;
@@ -2618,11 +2631,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
}
else
{
- ((UnitAura*)m_spellAura)->SetDiminishGroup(diminishGroup);
-
- bool positive = m_spellAura->GetSpellInfo()->IsPositive();
- if (AuraApplication* aurApp = m_spellAura->GetApplicationOfTarget(m_originalCaster->GetGUID()))
- positive = aurApp->IsPositive();
+ static_cast<UnitAura*>(m_spellAura)->SetDiminishGroup(diminishGroup);
duration = m_originalCaster->ModSpellDuration(aurSpellInfo, unit, duration, positive, effectMask);