Core/Spell: restore old proc system behaviour on auras self proc.

This commit is contained in:
hondacrx
2018-01-13 13:10:33 -05:00
parent b36ee2ef1c
commit 5587505199
11 changed files with 81 additions and 70 deletions
+4 -4
View File
@@ -1719,10 +1719,10 @@ namespace Game.Entities
public void ProcSkillsAndAuras(Unit actionTarget, ProcFlags typeMaskActor, ProcFlags typeMaskActionTarget, ProcFlagsSpellType spellTypeMask, ProcFlagsSpellPhase spellPhaseMask, ProcFlagsHit hitMask, Spell spell, DamageInfo damageInfo, HealInfo healInfo)
{
WeaponAttackType attType = damageInfo != null ? damageInfo.GetAttackType() : WeaponAttackType.BaseAttack;
if (typeMaskActor != 0 && CanProc())
if (typeMaskActor != 0)
ProcSkillsAndReactives(false, actionTarget, typeMaskActor, hitMask, attType);
if (typeMaskActionTarget != 0 && actionTarget && actionTarget.CanProc())
if (typeMaskActionTarget != 0 && actionTarget)
actionTarget.ProcSkillsAndReactives(true, this, typeMaskActionTarget, hitMask, attType);
TriggerAurasProcOnEvent(null, null, actionTarget, typeMaskActor, typeMaskActionTarget, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo);
@@ -1832,7 +1832,7 @@ namespace Game.Entities
// prepare data for self trigger
ProcEventInfo myProcEventInfo = new ProcEventInfo(this, actionTarget, actionTarget, typeMaskActor, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo);
List<Tuple<uint, AuraApplication>> myAurasTriggeringProc = new List<Tuple<uint, AuraApplication>>();
if (typeMaskActor != 0 && CanProc())
if (typeMaskActor != 0)
{
GetProcAurasTriggeredOnEvent(myAurasTriggeringProc, myProcAuras, myProcEventInfo);
@@ -1856,7 +1856,7 @@ namespace Game.Entities
// prepare data for target trigger
ProcEventInfo targetProcEventInfo = new ProcEventInfo(this, actionTarget, this, typeMaskActionTarget, spellTypeMask, spellPhaseMask, hitMask, spell, damageInfo, healInfo);
List<Tuple<uint, AuraApplication>> targetAurasTriggeringProc = new List<Tuple<uint, AuraApplication>>();
if (typeMaskActionTarget != 0 && actionTarget && actionTarget.CanProc())
if (typeMaskActionTarget != 0 && actionTarget)
actionTarget.GetProcAurasTriggeredOnEvent(targetAurasTriggeringProc, targetProcAuras, targetProcEventInfo);
TriggerAurasProcOnEvent(myProcEventInfo, myAurasTriggeringProc);
+27 -23
View File
@@ -1651,6 +1651,29 @@ namespace Game.Spells
if (procEntry == null)
return 0;
// check spell triggering us
Spell spell = eventInfo.GetProcSpell();
if (spell)
{
// Do not allow auras to proc from effect triggered from itself
if (spell.IsTriggeredByAura(m_spellInfo))
return 0;
// check if aura can proc when spell is triggered (exception for hunter auto shot & wands)
if (spell.IsTriggered() && !procEntry.AttributesMask.HasAnyFlag(ProcAttributes.TriggeredCanProc) && !eventInfo.GetTypeMask().HasAnyFlag(ProcFlags.AutoAttackMask))
if (!GetSpellInfo().HasAttribute(SpellAttr3.CanProcWithTriggered))
return 0;
}
// check don't break stealth attr present
if (m_spellInfo.HasAura(Difficulty.None, AuraType.ModStealth))
{
SpellInfo eventSpellInfo = eventInfo.GetSpellInfo();
if (eventSpellInfo != null)
if (eventSpellInfo.HasAttribute(SpellCustomAttributes.DontBreakStealth))
return 0;
}
// check if we have charges to proc with
if (IsUsingCharges())
{
@@ -1659,9 +1682,9 @@ namespace Game.Spells
if (procEntry.AttributesMask.HasAnyFlag(ProcAttributes.ReqSpellmod))
{
Spell spell = eventInfo.GetProcSpell();
if (spell != null)
if (!spell.m_appliedMods.Contains(this))
Spell eventSpell = eventInfo.GetProcSpell();
if (eventSpell != null)
if (!eventSpell.m_appliedMods.Contains(this))
return 0;
}
}
@@ -1671,28 +1694,9 @@ namespace Game.Spells
return 0;
// do checks against db data
if (!Global.SpellMgr.CanSpellTriggerProcOnEvent(procEntry, eventInfo))
if (!SpellManager.CanSpellTriggerProcOnEvent(procEntry, eventInfo))
return 0;
// check don't break stealth attr present
if (m_spellInfo.HasAura(Difficulty.None, AuraType.ModStealth))
{
SpellInfo spell = eventInfo.GetSpellInfo();
if (spell != null)
if (spell.HasAttribute(SpellCustomAttributes.DontBreakStealth))
return 0;
}
// check if aura can proc when spell is triggered (exception for hunter auto shot & wands)
if (!procEntry.AttributesMask.HasAnyFlag(ProcAttributes.TriggeredCanProc) && !eventInfo.GetTypeMask().HasAnyFlag(ProcFlags.AutoAttackMask))
{
Spell spell = eventInfo.GetProcSpell();
if (spell)
if (spell.IsTriggered())
if (!GetSpellInfo().HasAttribute(SpellAttr3.CanProcWithTriggered))
return 0;
}
// do checks using conditions table
if (!Global.ConditionMgr.IsObjectMeetingNotGroupedConditions(ConditionSourceType.SpellProc, GetId(), eventInfo.GetActor(), eventInfo.GetActionTarget()))
return 0;
+12 -6
View File
@@ -1881,7 +1881,7 @@ namespace Game.Spells
m_spellAura = null;
//Spells with this flag cannot trigger if effect is cast on self
bool canEffectTrigger = !m_spellInfo.HasAttribute(SpellAttr3.CantTriggerProc) && (CanExecuteTriggersOnHit(mask) || missInfo == SpellMissInfo.Immune || missInfo == SpellMissInfo.Immune2);
bool canEffectTrigger = !m_spellInfo.HasAttribute(SpellAttr3.CantTriggerProc) && unitTarget.CanProc() && (CanExecuteTriggersOnHit(mask) || missInfo == SpellMissInfo.Immune || missInfo == SpellMissInfo.Immune2);
Unit spellHitTarget = null;
@@ -7008,12 +7008,10 @@ namespace Game.Spells
int auraBaseAmount = aurEff.GetBaseAmount();
// proc chance is stored in effect amount
int chance = m_caster.CalculateSpellDamage(null, aurEff.GetSpellInfo(), aurEff.GetEffIndex(), auraBaseAmount);
chance *= aurEff.GetBase().GetStackAmount();
// build trigger and add to the list
HitTriggerSpell spellTriggerInfo;
spellTriggerInfo.triggeredSpell = spellInfo;
spellTriggerInfo.triggeredByAura = aurEff.GetSpellInfo();
spellTriggerInfo.chance = chance * aurEff.GetBase().GetStackAmount();
m_hitTriggerSpells.Add(spellTriggerInfo);
m_hitTriggerSpells.Add(new HitTriggerSpell(spellInfo, aurEff.GetSpellInfo(), chance));
}
}
}
@@ -7133,6 +7131,7 @@ namespace Game.Spells
}
public bool IsTriggered() { return _triggeredCastFlags.HasAnyFlag(TriggerCastFlags.FullMask); }
public bool IsTriggeredByAura(SpellInfo auraSpellInfo) { return (auraSpellInfo == m_triggeredByAuraSpell); }
public bool IsIgnoringCooldowns() { return _triggeredCastFlags.HasAnyFlag(TriggerCastFlags.IgnoreSpellAndCategoryCD); }
public bool IsProcDisabled() { return _triggeredCastFlags.HasAnyFlag(TriggerCastFlags.DisallowProcEvents); }
public bool IsChannelActive() { return m_caster.GetChannelSpellId() != 0; }
@@ -7382,6 +7381,13 @@ namespace Game.Spells
public struct HitTriggerSpell
{
public HitTriggerSpell(SpellInfo spellInfo, SpellInfo auraSpellInfo, int procChance)
{
triggeredSpell = spellInfo;
triggeredByAura = auraSpellInfo;
chance = procChance;
}
public SpellInfo triggeredSpell;
public SpellInfo triggeredByAura;
// ubyte triggeredByEffIdx This might be needed at a later stage - No need known for now
+1 -1
View File
@@ -450,7 +450,7 @@ namespace Game.Entities
return mSpellProcMap.LookupByKey(spellId);
}
public bool CanSpellTriggerProcOnEvent(SpellProcEntry procEntry, ProcEventInfo eventInfo)
public static bool CanSpellTriggerProcOnEvent(SpellProcEntry procEntry, ProcEventInfo eventInfo)
{
// proc type doesn't match
if (!Convert.ToBoolean(eventInfo.GetTypeMask() & procEntry.ProcFlags))
+6 -6
View File
@@ -623,7 +623,7 @@ namespace Scripts.Spells.Druid
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
PreventDefaultAction();
eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.BlessingOfTheClaw, true);
eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.BlessingOfTheClaw, true, null, aurEff);
}
public override void Register()
@@ -654,7 +654,7 @@ namespace Scripts.Spells.Druid
return;
int amount = MathFunctions.CalculatePct(m.Amount, aurEff.GetAmount());
caster.CastCustomSpell(SpellIds.Exhilarate, SpellValueMod.BasePoint0, amount, (Unit)null, true);
caster.CastCustomSpell(SpellIds.Exhilarate, SpellValueMod.BasePoint0, amount, null, true, null, aurEff);
}
public override void Register()
@@ -675,7 +675,7 @@ namespace Scripts.Spells.Druid
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
PreventDefaultAction();
eventInfo.GetActor().CastSpell((Unit)null, SpellIds.Infusion, true);
eventInfo.GetActor().CastSpell((Unit)null, SpellIds.Infusion, true, null, aurEff);
}
public override void Register()
@@ -724,7 +724,7 @@ namespace Scripts.Spells.Druid
return;
if (RandomHelper.randChance(chance))
eventInfo.GetActor().CastSpell((Unit)null, spellId, true);
eventInfo.GetActor().CastSpell((Unit)null, spellId, true, null, aurEff);
}
public override void Register()
@@ -758,7 +758,7 @@ namespace Scripts.Spells.Druid
// Add remaining ticks to damage done
amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.Languish, AuraType.PeriodicDamage);
caster.CastCustomSpell(SpellIds.Languish, SpellValueMod.BasePoint0, amount, target, true);
caster.CastCustomSpell(SpellIds.Languish, SpellValueMod.BasePoint0, amount, target, true, null, aurEff);
}
public override void Register()
@@ -840,7 +840,7 @@ namespace Scripts.Spells.Druid
PreventDefaultAction();
int amount = (int)eventInfo.GetHealInfo().GetHeal();
eventInfo.GetActor().CastCustomSpell(SpellIds.RejuvenationT10Proc, SpellValueMod.BasePoint0, amount, (Unit)null, true);
eventInfo.GetActor().CastCustomSpell(SpellIds.RejuvenationT10Proc, SpellValueMod.BasePoint0, amount, null, true, null, aurEff);
}
public override void Register()
+1 -1
View File
@@ -2710,7 +2710,7 @@ namespace Scripts.Spells.Generic
Unit caster = eventInfo.GetActor();
int bp = (int)(damageInfo.GetDamage() / 2);
caster.CastCustomSpell(SpellIds.VampiricTouchHeal, SpellValueMod.BasePoint0, bp, caster, true);
caster.CastCustomSpell(SpellIds.VampiricTouchHeal, SpellValueMod.BasePoint0, bp, caster, true, null, aurEff);
}
public override void Register()
+16 -15
View File
@@ -610,7 +610,7 @@ namespace Scripts.Spells.Items
if (player.GetWeaponForAttack(WeaponAttackType.OffAttack, true) && RandomHelper.URand(0, 1) != 0)
spellId = SpellIds.ManifestAngerOffHand;
caster.CastSpell(target, spellId, true);
caster.CastSpell(target, spellId, true, null, aurEff);
}
public override void Register()
@@ -680,7 +680,7 @@ namespace Scripts.Spells.Items
PreventDefaultAction();
Unit caster = eventInfo.GetActor();
uint spellId = triggeredSpells[(int)caster.GetClass()].SelectRandom();
caster.CastSpell(caster, spellId, true);
caster.CastSpell(caster, spellId, true, null, aurEff);
if (RandomHelper.randChance(10))
caster.Say(TextIds.SayMadness);
@@ -703,7 +703,7 @@ namespace Scripts.Spells.Items
void HandlePeriodicDummy(AuraEffect aurEff)
{
PreventDefaultAction();
GetTarget().CastSpell(GetTarget(), RandomHelper.RAND(SpellIds.DementiaPos, SpellIds.DementiaNeg), true);
GetTarget().CastSpell(GetTarget(), RandomHelper.RAND(SpellIds.DementiaPos, SpellIds.DementiaNeg), true, null, aurEff);
}
public override void Register()
@@ -849,7 +849,7 @@ namespace Scripts.Spells.Items
return;
uint spellId = randomSpells.SelectRandom();
caster.CastSpell(caster, spellId, true);
caster.CastSpell(caster, spellId, true, null, aurEff);
}
public override void Register()
@@ -1115,7 +1115,7 @@ namespace Scripts.Spells.Items
int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount());
Unit caster = eventInfo.GetActor();
caster.CastCustomSpell(SpellIds.Shadowmend, SpellValueMod.BasePoint0, amount, (Unit)null, true);
caster.CastCustomSpell(SpellIds.Shadowmend, SpellValueMod.BasePoint0, amount, null, true, null, aurEff);
}
public override void Register()
@@ -1140,9 +1140,9 @@ namespace Scripts.Spells.Items
if (target)
{
if (RandomHelper.URand(0, 99) < 15)
caster.CastSpell(caster, SpellIds.GnomishDeathRaySelf, true, null); // failure
caster.CastSpell(caster, SpellIds.GnomishDeathRaySelf, true); // failure
else
caster.CastSpell(target, SpellIds.GnomishDeathRayTarget, true, null);
caster.CastSpell(target, SpellIds.GnomishDeathRayTarget, true);
}
}
@@ -1191,6 +1191,7 @@ namespace Scripts.Spells.Items
case PowerType.Rage:
spellId = _rageSpellId;
break;
// Death Knights can't use daggers, but oh well
case PowerType.RunicPower:
spellId = _rpSpellId;
break;
@@ -1198,7 +1199,7 @@ namespace Scripts.Spells.Items
return;
}
caster.CastSpell((Unit)null, spellId, true);
caster.CastSpell((Unit)null, spellId, true, null, aurEff);
}
public override void Register()
@@ -1300,7 +1301,7 @@ namespace Scripts.Spells.Items
// in that case, do not cast heal spell
PreventDefaultAction();
// but mana instead
eventInfo.GetActor().CastSpell((Unit)null, SpellIds.MarkOfConquestEnergize, true);
eventInfo.GetActor().CastSpell((Unit)null, SpellIds.MarkOfConquestEnergize, true, null, aurEff);
}
}
@@ -1529,7 +1530,7 @@ namespace Scripts.Spells.Items
int bp = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount());
Unit caster = eventInfo.GetActor();
caster.CastCustomSpell(SpellIds.HealthLink, SpellValueMod.BasePoint0, bp, (Unit)null, true);
caster.CastCustomSpell(SpellIds.HealthLink, SpellValueMod.BasePoint0, bp, null, true, null, aurEff);
}
public override void Register()
@@ -1825,7 +1826,7 @@ namespace Scripts.Spells.Items
Unit caster = eventInfo.GetActor();
int amount = (int)caster.CountPctFromMaxHealth(aurEff.GetAmount());
caster.CastCustomSpell(SpellIds.SwiftHandOfJusticeHeal, SpellValueMod.BasePoint0, amount, (Unit)null, true);
caster.CastCustomSpell(SpellIds.SwiftHandOfJusticeHeal, SpellValueMod.BasePoint0, amount, null, true, null, aurEff);
}
public override void Register()
@@ -2725,10 +2726,10 @@ namespace Scripts.Spells.Items
Unit target = eventInfo.GetProcTarget();
if (eventInfo.GetTypeMask().HasAnyFlag(ProcFlags.DoneSpellMagicDmgClassPos))
caster.CastSpell(target, _healProcSpellId, true);
caster.CastSpell(target, _healProcSpellId, true, null, aurEff);
if (eventInfo.GetTypeMask().HasAnyFlag(ProcFlags.DoneSpellMagicDmgClassNeg))
caster.CastSpell(target, _damageProcSpellId, true);
caster.CastSpell(target, _damageProcSpellId, true, null, aurEff);
}
public override void Register()
@@ -2812,10 +2813,10 @@ namespace Scripts.Spells.Items
// Aggression checks are in the spell system... just cast and forget
if (player.GetReputationRank(FactionIds.Aldor) == ReputationRank.Exalted)
player.CastSpell(target, _aldorSpellId, true);
player.CastSpell(target, _aldorSpellId, true, null, aurEff);
if (player.GetReputationRank(FactionIds.Scryers) == ReputationRank.Exalted)
player.CastSpell(target, _scryersSpellId, true);
player.CastSpell(target, _scryersSpellId, true, null, aurEff);
}
public override void Register()
+3 -3
View File
@@ -567,7 +567,7 @@ namespace Scripts.Spells.Paladin
return;
if (RandomHelper.randChance(chance))
eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), spellId, true);
eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), spellId, true, null, aurEff);
}
public override void Register()
@@ -895,7 +895,7 @@ namespace Scripts.Spells.Paladin
return;
}
caster.CastSpell(target, spellId, true);
caster.CastSpell(target, spellId, true, null, aurEff);
}
public override void Register()
@@ -929,7 +929,7 @@ namespace Scripts.Spells.Paladin
// Add remaining ticks to damage done
amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.HolyMending, AuraType.PeriodicHeal);
caster.CastCustomSpell(SpellIds.HolyMending, SpellValueMod.BasePoint0, amount, target, true);
caster.CastCustomSpell(SpellIds.HolyMending, SpellValueMod.BasePoint0, amount, target, true, null, aurEff);
}
public override void Register()
+3 -3
View File
@@ -104,7 +104,7 @@ namespace Scripts.Spells.Priest
return;
int amount = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), 10);
caster.CastCustomSpell(SpellIds.OracularHeal, SpellValueMod.BasePoint0, amount, caster, true);
caster.CastCustomSpell(SpellIds.OracularHeal, SpellValueMod.BasePoint0, amount, caster, true, null, aurEff);
}
public override void Register()
@@ -936,7 +936,7 @@ namespace Scripts.Spells.Priest
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
PreventDefaultAction();
eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.ArmorOfFaith, true);
eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.ArmorOfFaith, true, null, aurEff);
}
public override void Register()
@@ -1006,7 +1006,7 @@ namespace Scripts.Spells.Priest
Unit target = eventInfo.GetProcTarget();
amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.BlessedHealing, AuraType.PeriodicHeal);
caster.CastCustomSpell(SpellIds.BlessedHealing, SpellValueMod.BasePoint0, amount, target, true);
caster.CastCustomSpell(SpellIds.BlessedHealing, SpellValueMod.BasePoint0, amount, target, true, null, aurEff);
}
public override void Register()
+6 -6
View File
@@ -728,7 +728,7 @@ namespace Scripts.Spells.Shaman
return;
}
caster.CastSpell(target, spellId, true);
caster.CastSpell(target, spellId, true, null, aurEff);
}
public override void Register()
@@ -757,12 +757,12 @@ namespace Scripts.Spells.Shaman
int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount());
amount /= (int)spellInfo.GetMaxTicks(Difficulty.None);
// Add remaining ticks to healing done
// Add remaining ticks to damage done
Unit caster = eventInfo.GetActor();
Unit target = eventInfo.GetProcTarget();
amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.Electrified, AuraType.PeriodicDamage);
caster.CastCustomSpell(SpellIds.Electrified, SpellValueMod.BasePoint0, amount, target, true);
caster.CastCustomSpell(SpellIds.Electrified, SpellValueMod.BasePoint0, amount, target, true, null, aurEff);
}
public override void Register()
@@ -791,12 +791,12 @@ namespace Scripts.Spells.Shaman
int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount());
amount /= (int)spellInfo.GetMaxTicks(Difficulty.None);
// Add remaining ticks to healing done
// Add remaining ticks to damage done
Unit caster = eventInfo.GetActor();
Unit target = eventInfo.GetProcTarget();
amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.LavaBurstBonusDamage, AuraType.PeriodicDamage);
caster.CastCustomSpell(SpellIds.LavaBurstBonusDamage, SpellValueMod.BasePoint0, amount, target, true);
caster.CastCustomSpell(SpellIds.LavaBurstBonusDamage, SpellValueMod.BasePoint0, amount, target, true, null, aurEff);
}
public override void Register()
@@ -862,7 +862,7 @@ namespace Scripts.Spells.Shaman
Unit target = eventInfo.GetProcTarget();
amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.ChainedHeal, AuraType.PeriodicHeal);
caster.CastCustomSpell(SpellIds.ChainedHeal, SpellValueMod.BasePoint0, amount, target, true);
caster.CastCustomSpell(SpellIds.ChainedHeal, SpellValueMod.BasePoint0, amount, target, true, null, aurEff);
}
public override void Register()
+2 -2
View File
@@ -746,7 +746,7 @@ namespace Scripts.Spells.Warlock
if (!caster)
return;
caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionGeneric, true);
caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionGeneric, true, null, aurEff);
}
public override void Register()
@@ -982,7 +982,7 @@ namespace Scripts.Spells.Warlock
{
PreventDefaultAction();
Unit caster = eventInfo.GetActor();
caster.CastSpell(caster, _triggerSpell, true);
caster.CastSpell(caster, _triggerSpell, true, null, aurEff);
}
public override void Register()