Scripts/Auras: Lookup aura scripts by their type, not name
Port From (https://github.com/TrinityCore/TrinityCore/commit/9fc8c86e9a47194a1b271fbcf7bf9e85cb3f0826)
This commit is contained in:
@@ -362,16 +362,17 @@ namespace Game.Spells
|
|||||||
// m_casterLevel = cast item level/caster level, caster level should be saved to db, confirmed with sniffs
|
// m_casterLevel = cast item level/caster level, caster level should be saved to db, confirmed with sniffs
|
||||||
}
|
}
|
||||||
|
|
||||||
public T GetScript<T>(string scriptName) where T : AuraScript
|
public T GetScript<T>() where T : AuraScript
|
||||||
{
|
{
|
||||||
return (T)GetScriptByName(scriptName);
|
return (T)GetScriptByType(typeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuraScript GetScriptByName(string scriptName)
|
public AuraScript GetScriptByType(Type type)
|
||||||
{
|
{
|
||||||
foreach (var auraScript in m_loadedScripts)
|
foreach (var auraScript in m_loadedScripts)
|
||||||
if (auraScript._GetScriptName().Equals(scriptName))
|
if (auraScript.GetType() == type)
|
||||||
return auraScript;
|
return auraScript;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ namespace Scripts.Spells.DemonHunter
|
|||||||
if (firstTargetGUID.IsEmpty())
|
if (firstTargetGUID.IsEmpty())
|
||||||
firstTargetGUID = targetList[0].GetGUID();
|
firstTargetGUID = targetList[0].GetGUID();
|
||||||
|
|
||||||
spell_dh_first_blood script = aura.GetScript<spell_dh_first_blood>(nameof(spell_dh_first_blood));
|
spell_dh_first_blood script = aura.GetScript<spell_dh_first_blood>();
|
||||||
if (script != null)
|
if (script != null)
|
||||||
script.SetFirstTarget(firstTargetGUID);
|
script.SetFirstTarget(firstTargetGUID);
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ namespace Scripts.Spells.DemonHunter
|
|||||||
AuraEffect aurEff = GetCaster().GetAuraEffect(SpellIds.FirstBlood, 0);
|
AuraEffect aurEff = GetCaster().GetAuraEffect(SpellIds.FirstBlood, 0);
|
||||||
if (aurEff != null)
|
if (aurEff != null)
|
||||||
{
|
{
|
||||||
spell_dh_first_blood script = aurEff.GetBase().GetScript<spell_dh_first_blood>(nameof(spell_dh_first_blood));
|
spell_dh_first_blood script = aurEff.GetBase().GetScript<spell_dh_first_blood>();
|
||||||
if (script != null)
|
if (script != null)
|
||||||
if (GetHitUnit().GetGUID() == script.GetFirstTarget())
|
if (GetHitUnit().GetGUID() == script.GetFirstTarget())
|
||||||
MathFunctions.AddPct(ref damage, aurEff.GetAmount());
|
MathFunctions.AddPct(ref damage, aurEff.GetAmount());
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ namespace Scripts.Spells.Priest
|
|||||||
Aura atonement = caster.GetAura(SpellIds.Atonement);
|
Aura atonement = caster.GetAura(SpellIds.Atonement);
|
||||||
if (atonement != null)
|
if (atonement != null)
|
||||||
{
|
{
|
||||||
var script = atonement.GetScript<spell_pri_atonement>("spell_pri_atonement");
|
var script = atonement.GetScript<spell_pri_atonement>();
|
||||||
if (script != null)
|
if (script != null)
|
||||||
script.AddAtonementTarget(GetTarget().GetGUID());
|
script.AddAtonementTarget(GetTarget().GetGUID());
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ namespace Scripts.Spells.Priest
|
|||||||
Aura atonement = caster.GetAura(SpellIds.Atonement);
|
Aura atonement = caster.GetAura(SpellIds.Atonement);
|
||||||
if (atonement != null)
|
if (atonement != null)
|
||||||
{
|
{
|
||||||
var script = atonement.GetScript<spell_pri_atonement>("spell_pri_atonement");
|
var script = atonement.GetScript<spell_pri_atonement>();
|
||||||
if (script != null)
|
if (script != null)
|
||||||
script.RemoveAtonementTarget(GetTarget().GetGUID());
|
script.RemoveAtonementTarget(GetTarget().GetGUID());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace Scripts.Spells.Rogue
|
|||||||
Aura aura = GetCaster().GetAura(SpellIds.KillingSpree);
|
Aura aura = GetCaster().GetAura(SpellIds.KillingSpree);
|
||||||
if (aura != null)
|
if (aura != null)
|
||||||
{
|
{
|
||||||
var script = aura.GetScript<spell_rog_killing_spree_AuraScript>(nameof(spell_rog_killing_spree_AuraScript));
|
var script = aura.GetScript<spell_rog_killing_spree_AuraScript>();
|
||||||
if (script != null)
|
if (script != null)
|
||||||
script.AddTarget(GetHitUnit());
|
script.AddTarget(GetHitUnit());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ namespace Scripts.Spells.Shaman
|
|||||||
Aura aura = GetCaster().GetAura(SpellIds.EarthenRagePassive);
|
Aura aura = GetCaster().GetAura(SpellIds.EarthenRagePassive);
|
||||||
if (aura != null)
|
if (aura != null)
|
||||||
{
|
{
|
||||||
var earthen_rage_script = aura.GetScript<spell_sha_earthen_rage_passive>("spell_sha_earthen_rage_passive");
|
var earthen_rage_script = aura.GetScript<spell_sha_earthen_rage_passive>();
|
||||||
if (earthen_rage_script != null)
|
if (earthen_rage_script != null)
|
||||||
{
|
{
|
||||||
Unit procTarget = Global.ObjAccessor.GetUnit(GetCaster(), earthen_rage_script.GetProcTargetGuid());
|
Unit procTarget = Global.ObjAccessor.GetUnit(GetCaster(), earthen_rage_script.GetProcTargetGuid());
|
||||||
@@ -393,7 +393,7 @@ namespace Scripts.Spells.Shaman
|
|||||||
|
|
||||||
summon.CastSpell(summon, SpellIds.HealingRainVisual, true);
|
summon.CastSpell(summon, SpellIds.HealingRainVisual, true);
|
||||||
|
|
||||||
var script = aura.GetScript<spell_sha_healing_rain_AuraScript>("spell_sha_healing_rain");
|
var script = aura.GetScript<spell_sha_healing_rain_AuraScript>();
|
||||||
if (script != null)
|
if (script != null)
|
||||||
script.SetVisualDummy(summon);
|
script.SetVisualDummy(summon);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -491,7 +491,7 @@ namespace Scripts.Spells.Warlock
|
|||||||
spell_warl_soul_swap_override swapSpellScript = null;
|
spell_warl_soul_swap_override swapSpellScript = null;
|
||||||
Aura swapOverrideAura = warlock.GetAura(SpellIds.SoulSwapOverride);
|
Aura swapOverrideAura = warlock.GetAura(SpellIds.SoulSwapOverride);
|
||||||
if (swapOverrideAura != null)
|
if (swapOverrideAura != null)
|
||||||
swapSpellScript = swapOverrideAura.GetScript<spell_warl_soul_swap_override>("spell_warl_soul_swap_override");
|
swapSpellScript = swapOverrideAura.GetScript<spell_warl_soul_swap_override>();
|
||||||
|
|
||||||
if (swapSpellScript == null)
|
if (swapSpellScript == null)
|
||||||
return;
|
return;
|
||||||
@@ -530,7 +530,7 @@ namespace Scripts.Spells.Warlock
|
|||||||
Aura swapOverride = GetCaster().GetAura(SpellIds.SoulSwapOverride);
|
Aura swapOverride = GetCaster().GetAura(SpellIds.SoulSwapOverride);
|
||||||
if (swapOverride != null)
|
if (swapOverride != null)
|
||||||
{
|
{
|
||||||
spell_warl_soul_swap_override swapScript = swapOverride.GetScript<spell_warl_soul_swap_override>("spell_warl_soul_swap_override");
|
spell_warl_soul_swap_override swapScript = swapOverride.GetScript<spell_warl_soul_swap_override>();
|
||||||
if (swapScript != null)
|
if (swapScript != null)
|
||||||
swapTarget = swapScript.GetOriginalSwapSource();
|
swapTarget = swapScript.GetOriginalSwapSource();
|
||||||
}
|
}
|
||||||
@@ -552,7 +552,7 @@ namespace Scripts.Spells.Warlock
|
|||||||
Aura swapOverride = GetCaster().GetAura(SpellIds.SoulSwapOverride);
|
Aura swapOverride = GetCaster().GetAura(SpellIds.SoulSwapOverride);
|
||||||
if (swapOverride != null)
|
if (swapOverride != null)
|
||||||
{
|
{
|
||||||
spell_warl_soul_swap_override swapScript = swapOverride.GetScript<spell_warl_soul_swap_override>("spell_warl_soul_swap_override");
|
spell_warl_soul_swap_override swapScript = swapOverride.GetScript<spell_warl_soul_swap_override>();
|
||||||
if (swapScript == null)
|
if (swapScript == null)
|
||||||
return;
|
return;
|
||||||
dotList = swapScript.GetDotList();
|
dotList = swapScript.GetDotList();
|
||||||
|
|||||||
Reference in New Issue
Block a user