Created
January 27, 2019 22:38
-
-
Save Langerz82/93b59a4d01f77fb95ea3b1b696873977 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/game/WorldHandlers/Spell.cpp b/src/game/WorldHandlers/Spell.cpp | |
index 28b2eab..7b8ecce 100644 | |
--- a/src/game/WorldHandlers/Spell.cpp | |
+++ b/src/game/WorldHandlers/Spell.cpp | |
@@ -1260,7 +1260,7 @@ void Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool isReflected) | |
if (IsSpellAppliesAura(m_spellInfo, effectMask)) | |
{ | |
- m_spellAuraHolder = CreateSpellAuraHolder(m_spellInfo, unit, realCaster, m_CastItem); | |
+ m_spellAuraHolder = CreateSpellAuraHolder(m_spellInfo, unit, realCaster, m_CastItem, this); | |
m_spellAuraHolder->setDiminishGroup(m_diminishGroup); | |
} | |
else | |
diff --git a/src/game/WorldHandlers/SpellAuras.cpp b/src/game/WorldHandlers/SpellAuras.cpp | |
index fb14a6f..01fdcfa 100644 | |
--- a/src/game/WorldHandlers/SpellAuras.cpp | |
+++ b/src/game/WorldHandlers/SpellAuras.cpp | |
@@ -364,9 +364,9 @@ Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* curr | |
return new Aura(spellproto, eff, currentBasePoints, holder, target, caster, castItem); | |
} | |
-SpellAuraHolder* CreateSpellAuraHolder(SpellEntry const* spellproto, Unit* target, WorldObject* caster, Item* castItem) | |
+SpellAuraHolder* CreateSpellAuraHolder(SpellEntry const* spellproto, Unit* target, WorldObject* caster, Item* castItem, Spell* spell) | |
{ | |
- return new SpellAuraHolder(spellproto, target, caster, castItem); | |
+ return new SpellAuraHolder(spellproto, target, caster, castItem, spell); | |
} | |
void Aura::SetModifier(AuraType t, int32 a, uint32 pt, int32 miscValue) | |
@@ -4925,8 +4925,8 @@ void Aura::HandleInterruptRegen(bool apply, bool Real) | |
GetTarget()->SetInDummyCombatState(apply); | |
} | |
-SpellAuraHolder::SpellAuraHolder(SpellEntry const* spellproto, Unit* target, WorldObject* caster, Item* castItem) : | |
- m_spellProto(spellproto), | |
+SpellAuraHolder::SpellAuraHolder(SpellEntry const* spellproto, Unit* target, WorldObject* caster, Item* castItem, Spell* spell) : | |
+ m_spellProto(spellproto), m_spell(spell), | |
m_target(target), m_castItemGuid(castItem ? castItem->GetObjectGuid() : ObjectGuid()), | |
m_auraSlot(MAX_AURAS), m_auraLevel(1), | |
m_procCharges(0), m_stackAmount(1), | |
@@ -5547,16 +5547,20 @@ void SpellAuraHolder::Update(uint32 diff) | |
if (caster->GetChannelObjectGuid() == m_target->GetObjectGuid()) | |
{ | |
// Get spell range | |
- float max_range = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellProto->rangeIndex)); | |
- | |
- if (Player* modOwner = caster->GetSpellModOwner()) | |
- { modOwner->ApplySpellMod(GetId(), SPELLMOD_RANGE, max_range, NULL); } | |
- | |
- if (!caster->IsWithinDistInMap(m_target, max_range)) | |
- { | |
- caster->InterruptSpell(CURRENT_CHANNELED_SPELL); | |
- return; | |
- } | |
+ // Needs to Spell Check Range. | |
+ SpellCastResult castResult = m_spell->CheckRange(false); | |
+ if (castResult == SPELL_FAILED_OUT_OF_RANGE || castResult == SPELL_FAILED_TOO_CLOSE) | |
+ { | |
+ caster->InterruptSpell(CURRENT_CHANNELED_SPELL); | |
+ return; | |
+ } | |
+ else { | |
+ if (Player* modOwner = caster->GetSpellModOwner()) | |
+ { | |
+ float max_range = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellProto->rangeIndex)); | |
+ modOwner->ApplySpellMod(GetId(), SPELLMOD_RANGE, max_range, (const Spell*) m_spell); | |
+ } | |
+ } | |
} | |
} | |
} | |
diff --git a/src/game/WorldHandlers/SpellAuras.h b/src/game/WorldHandlers/SpellAuras.h | |
index 6e15f38..75c654b 100644 | |
--- a/src/game/WorldHandlers/SpellAuras.h | |
+++ b/src/game/WorldHandlers/SpellAuras.h | |
@@ -92,7 +92,7 @@ struct ReapplyAffectedPassiveAurasHelper; | |
class SpellAuraHolder | |
{ | |
public: | |
- SpellAuraHolder(SpellEntry const* spellproto, Unit* target, WorldObject* caster, Item* castItem); | |
+ SpellAuraHolder(SpellEntry const* spellproto, Unit* target, WorldObject* caster, Item* castItem, Spell* spell = nullptr); | |
Aura* m_auras[MAX_EFFECT_INDEX]; | |
void AddAura(Aura* aura, SpellEffectIndex index); | |
@@ -215,6 +215,7 @@ class SpellAuraHolder | |
bool HeartbeatResist(uint32 diff); | |
SpellEntry const* m_spellProto; | |
+ Spell* m_spell; | |
Unit* m_target; | |
ObjectGuid m_casterGuid; | |
@@ -543,5 +544,5 @@ class SingleEnemyTargetAura : public Aura | |
}; | |
Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster = NULL, Item* castItem = NULL); | |
-SpellAuraHolder* CreateSpellAuraHolder(SpellEntry const* spellproto, Unit* target, WorldObject* caster, Item* castItem = NULL); | |
+SpellAuraHolder* CreateSpellAuraHolder(SpellEntry const* spellproto, Unit* target, WorldObject* caster, Item* castItem = NULL, Spell* spell = NULL); | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment