Core/Spells: Add a helper function to sort spell targets based on custom scripted sorting rules

Port From (https://github.com/TrinityCore/TrinityCore/commit/2e3f3fda3fc533daa4064739b633dbb28f5115d3)
This commit is contained in:
Hondacrx
2025-10-13 13:51:38 -04:00
parent 3e028633ba
commit 43aab94a35
13 changed files with 157 additions and 124 deletions
+65
View File
@@ -1127,6 +1127,71 @@ namespace Game.Scripting
targets.AddRange(tempTargets.Select(pair => pair.Item1));
targets.Resize(maxTargets);
}
public List<PriorityRules> CreatePriorityRules(List<PriorityRules> rules) { return rules; }
public void SortTargetsWithPriorityRules(List<WorldObject> targets, int maxTargets, List<PriorityRules> rules)
{
if (targets.Count <= maxTargets)
return;
List<(WorldObject, int)> prioritizedTargets = new();
// score each target based on how many rules they satisfy.
foreach (WorldObject obj in targets)
{
Unit unit = obj?.ToUnit();
if (unit == null)
continue;
int score = 0;
foreach (PriorityRules rule in rules)
{
if (rule.condition(unit))
score += rule.weight;
}
prioritizedTargets.Add((obj, score));
}
// the higher the value, the higher the priority is.
prioritizedTargets.Sort((left, right) => left.Item2.CompareTo(right.Item2));
int cutOff = Math.Min(maxTargets, prioritizedTargets.Count);
// if there are ties at the cutoff, shuffle them to avoid selection bias.
if (cutOff < prioritizedTargets.Count)
{
int tieScore = prioritizedTargets[cutOff - 1].Item2;
bool isTieScore((WorldObject, int) entry) { return entry.Item2 == tieScore; }
// scan backwards to include tied entries before the cutoff.
int tieStart = (cutOff - 1);
while (tieStart > 0 && isTieScore(prioritizedTargets[tieStart - 1]))
--tieStart;
// scan forward to include tied entries after the cutoff.
int tieEnd = cutOff;
while (tieEnd < prioritizedTargets.Count && isTieScore(prioritizedTargets[tieEnd]))
++tieEnd;
// shuffle only the tied range to randomize final selection.
prioritizedTargets.RandomShuffle(tieStart, tieStart - tieEnd);
}
targets.Clear();
for (int i = 0; i < cutOff; ++i)
targets.Add(prioritizedTargets[i].Item1);
}
}
public struct PriorityRules
{
public int weight;
public Func<Unit, bool> condition;
}
public class AuraScript : SpellScriptBase
+2 -2
View File
@@ -340,12 +340,12 @@ class spell_dk_crimson_scourge : AuraScript
return ValidateSpellInfo(SpellIds.BloodPlague, SpellIds.CrimsonScourgeBuff, SpellIds.DeathAndDecay);
}
static bool CheckProc(AuraEffect aurEff, ProcEventInfo procInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo procInfo)
{
return procInfo.GetProcTarget().HasAura(SpellIds.BloodPlague, procInfo.GetActor().GetGUID());
}
static void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
Unit actor = eventInfo.GetActor();
actor.GetSpellHistory().RestoreCharge(Global.SpellMgr.GetSpellInfo(SpellIds.DeathAndDecay, Difficulty.None).ChargeCategoryId);
+6 -8
View File
@@ -697,7 +697,6 @@ class spell_dru_efflorescence_heal : SpellScript
{
void FilterTargets(List<WorldObject> targets)
{
// Efflorescence became a smart heal which prioritizes players and their pets in their group before any unit outside their group.
SelectRandomInjuredTargets(targets, 3, true, GetCaster());
}
@@ -1316,7 +1315,7 @@ class spell_dru_luxuriant_soil : AuraScript
return ValidateSpellInfo(SpellIds.Rejuvenation);
}
static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
return RandomHelper.randChance(aurEff.GetAmount());
}
@@ -1520,12 +1519,12 @@ class spell_dru_power_of_the_archdruid : AuraScript
return ValidateSpellEffect((SpellIds.PowerOfTheArchdruid, 0));
}
static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
return eventInfo.GetActor().HasAuraEffect(SpellIds.PowerOfTheArchdruid, 0);
}
static void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
Unit druid = eventInfo.GetActor();
Unit procTarget = eventInfo.GetActionTarget();
@@ -1700,7 +1699,7 @@ class spell_dru_shooting_stars : AuraScript
ProcessDoT(aurEff, caster, sunfires);
}
static void ProcessDoT(AuraEffect aurEff, Unit caster, List<Unit> targets)
void ProcessDoT(AuraEffect aurEff, Unit caster, List<Unit> targets)
{
if (targets.Empty())
return;
@@ -1723,7 +1722,6 @@ class spell_dru_shooting_stars : AuraScript
}
}
public override void Register()
{
OnEffectPeriodic.Add(new(OnTick, 0, AuraType.PeriodicDummy));
@@ -2361,7 +2359,7 @@ class spell_dru_umbral_embrace : AuraScript
return ValidateSpellInfo(SpellIds.EclipseLunarAura, SpellIds.EclipseSolarAura);
}
static bool CheckEclipse(ProcEventInfo eventInfo)
bool CheckEclipse(ProcEventInfo eventInfo)
{
return eventInfo.GetActor().HasAura(SpellIds.EclipseLunarAura) || eventInfo.GetActor().HasAura(SpellIds.EclipseSolarAura);
}
@@ -2437,7 +2435,7 @@ class spell_dru_ursocs_fury : AuraScript
return ValidateSpellInfo(SpellIds.UrsocsFuryShield);
}
static void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
DamageInfo damageInfo = eventInfo.GetDamageInfo();
if (damageInfo == null || damageInfo.GetDamage() == 0)
+3 -5
View File
@@ -141,12 +141,12 @@ class spell_evo_burnout : AuraScript
return ValidateSpellInfo(SpellIds.Burnout);
}
static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
return RandomHelper.randChance(aurEff.GetAmount());
}
static void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
eventInfo.GetActor().CastSpell(eventInfo.GetActor(), SpellIds.Burnout, TriggerCastFlags.IgnoreCastInProgress | TriggerCastFlags.DontReportCastError);
}
@@ -583,7 +583,6 @@ class spell_evo_pyre : SpellScript
GetCaster().CastSpell(GetHitUnit().GetPosition(), SpellIds.PyreDamage, true);
}
public override void Register()
{
OnEffectHitTarget.Add(new(HandleDamage, 0, SpellEffectName.Dummy));
@@ -607,8 +606,7 @@ class spell_evo_ruby_embers : SpellScript
return !GetCaster().HasAura(SpellIds.RubyEmbers);
}
static void PreventPeriodic(ref WorldObject target)
void PreventPeriodic(ref WorldObject target)
{
target = null;
}
+6 -6
View File
@@ -161,7 +161,7 @@ class spell_hun_aspect_of_the_fox : SpellScript
return !GetCaster().HasAura(SpellIds.AspectOfTheFox);
}
static void HandleCastWhileWalking(ref WorldObject target)
void HandleCastWhileWalking(ref WorldObject target)
{
target = null;
}
@@ -290,7 +290,7 @@ class at_hun_binding_shot(AreaTrigger areaTrigger) : AreaTriggerAI(areaTrigger)
[Script] // 204089 - Bullseye
class spell_hun_bullseye : AuraScript
{
static bool CheckEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
return eventInfo.GetActionTarget().HealthBelowPct(aurEff.GetAmount());
}
@@ -618,12 +618,12 @@ class spell_hun_manhunter : AuraScript
return ValidateSpellInfo(SpellIds.GreviousInjury);
}
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
return eventInfo.GetProcTarget().IsPlayer();
}
static void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
eventInfo.GetActor().CastSpell(eventInfo.GetActionTarget(), SpellIds.GreviousInjury, new CastSpellExtraArgs()
{
@@ -647,7 +647,7 @@ class spell_hun_master_marksman : AuraScript
return ValidateSpellInfo(SpellIds.MasterMarksman);
}
static void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
uint ticks = Global.SpellMgr.GetSpellInfo(SpellIds.MasterMarksman, Difficulty.None).GetMaxTicks();
if (ticks == 0)
@@ -1059,7 +1059,7 @@ class spell_hun_scouts_instincts : SpellScript
return !GetCaster().HasAura(SpellIds.ScoutsInstincts);
}
static void HandleMinSpeed(ref WorldObject target)
void HandleMinSpeed(ref WorldObject target)
{
target = null;
}
+2 -2
View File
@@ -1143,7 +1143,7 @@ class spell_mage_improved_scorch : AuraScript
return ValidateSpellInfo(SpellIds.ImprovedScorch);
}
static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
return eventInfo.GetProcTarget().HealthBelowPct(aurEff.GetAmount());
}
@@ -1335,7 +1335,7 @@ class spell_mage_molten_fury : AuraScript
return ValidateSpellInfo(SpellIds.MoltenFury);
}
static void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
if (!eventInfo.GetActionTarget().HealthAbovePct(aurEff.GetAmount()))
eventInfo.GetActor().CastSpell(eventInfo.GetActionTarget(), SpellIds.MoltenFury, new CastSpellExtraArgs()
+1 -1
View File
@@ -341,7 +341,7 @@ class spell_monk_pressure_points : SpellScript
return !GetCaster().HasAura(SpellIds.PressurePoints);
}
static void PreventDispel(ref WorldObject target)
void PreventDispel(ref WorldObject target)
{
target = null;
}
+2 -2
View File
@@ -120,7 +120,7 @@ class spell_pal_a_just_reward : AuraScript
return ValidateSpellInfo(SpellIds.AJustRewardHeal);
}
static void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
eventInfo.GetActor().CastSpell(eventInfo.GetActionTarget(), SpellIds.AJustRewardHeal, new CastSpellExtraArgs()
{
@@ -311,7 +311,7 @@ class spell_pal_blade_of_vengeance : SpellScript
return !GetCaster().HasAura(SpellIds.BladeOfVengeance);
}
static void PreventProc(ref WorldObject target)
void PreventProc(ref WorldObject target)
{
target = null;
}
+40 -61
View File
@@ -358,7 +358,7 @@ class spell_pri_aq_3p_bonus : AuraScript
[Script] // 81749 - Atonement
class spell_pri_atonement : AuraScript
{
List<ObjectGuid> _appliedAtonements;
List<ObjectGuid> _appliedAtonements = new();
public override bool Validate(SpellInfo spellInfo)
{
@@ -366,7 +366,7 @@ class spell_pri_atonement : AuraScript
&& ValidateSpellEffect((spellInfo.Id, 1), (SpellIds.SinsOfTheMany, 2));
}
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
return eventInfo.GetDamageInfo() != null;
}
@@ -598,7 +598,7 @@ class spell_pri_atonement_passive : AuraScript
return ValidateSpellEffect((SpellIds.Atonement, 0));
}
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
return eventInfo.GetDamageInfo() != null;
}
@@ -848,7 +848,7 @@ class spell_pri_divine_image : AuraScript
return ValidateSpellInfo(SpellIds.DivineImageSummon, SpellIds.DivineImageEmpower, SpellIds.DivineImageEmpowerStack);
}
static void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
Unit target = eventInfo.GetActor();
if (target == null)
@@ -930,7 +930,7 @@ class spell_pri_divine_image_spell_triggered : AuraScript
);
}
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
return DivineImageHelpers.GetSummon(eventInfo.GetActor()) != null;
}
@@ -1151,7 +1151,7 @@ class spell_pri_epiphany : AuraScript
return ValidateSpellInfo(SpellIds.PrayerOfMending, SpellIds.EpiphanyHighlight);
}
static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
return RandomHelper.randChance(aurEff.GetAmount());
}
@@ -1272,7 +1272,7 @@ class spell_pri_guardian_spirit : AuraScript
return true;
}
static void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated)
void CalculateAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated)
{
// Set absorbtion amount to unlimited
amount = -1;
@@ -1308,12 +1308,12 @@ class spell_pri_heavens_wrath : AuraScript
return ValidateSpellInfo(SpellIds.UltimatePenitence);
}
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
return !(eventInfo.GetSpellInfo().Id == SpellIds.UltimatePenitenceDamage || eventInfo.GetSpellInfo().Id == SpellIds.UltimatePenitenceHeal);
}
static void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
Unit caster = eventInfo.GetActor();
if (caster == null)
@@ -1373,12 +1373,12 @@ class spell_pri_holy_mending : AuraScript
return ValidateSpellInfo(SpellIds.Renew, SpellIds.HolyMendingHeal);
}
static bool CheckProc(AuraEffect aurEff, ProcEventInfo procInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo procInfo)
{
return procInfo.GetProcTarget().HasAura(SpellIds.Renew, procInfo.GetActor().GetGUID());
}
static void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.HolyMendingHeal, new CastSpellExtraArgs(aurEff));
}
@@ -1763,7 +1763,7 @@ class spell_pri_painful_punishment : AuraScript
return ValidateSpellInfo(SpellIds.ShadowWordPain, SpellIds.PurgeTheWickedPeriodic);
}
static void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
Unit caster = eventInfo.GetActor();
Unit target = eventInfo.GetActionTarget();
@@ -1916,7 +1916,7 @@ class spell_pri_power_leech_passive : AuraScript
&& ValidateSpellEffect((SpellIds.PowerLeechShadowfiendInsanity, 0), (SpellIds.PowerLeechShadowfiendMana, 0), (SpellIds.PowerLeechMindbenderInsanity, 0), (SpellIds.PowerLeechMindbenderMana, 0));
}
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
return eventInfo.GetDamageInfo() != null;
}
@@ -2042,6 +2042,8 @@ class spell_pri_power_of_the_dark_side_healing_bonus : SpellScript
[Script] // 194509 - Power Word: Radiance
class spell_pri_power_word_radiance : SpellScript
{
List<ObjectGuid> _visualTargets = new();
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(SpellIds.AtonementEffect);
@@ -2049,26 +2051,13 @@ class spell_pri_power_word_radiance : SpellScript
void FilterTargets(List<WorldObject> targets)
{
Unit caster = GetCaster();
Unit explTarget = GetExplTargetUnit();
// we must add one since explicit target is always chosen.
uint maxTargets = (uint)GetEffectInfo(2).CalcValue(GetCaster()) + 1;
int maxTargets = GetEffectInfo(2).CalcValue(GetCaster()) + 1;
if (targets.Count > maxTargets)
{
// priority is: a) no Atonement b) injured c) anything else (excluding explicit target which is always added).
targets.Sort((lhs, rhs) =>
{
if (lhs == explTarget) // explTarget > anything: always true
return 1;
if (rhs == explTarget) // anything > explTarget: always false
return -1;
return MakeSortTuple(lhs).Equals(MakeSortTuple(rhs)) ? 1 : -1;
});
targets.Resize(maxTargets);
}
SortTargetsWithPriorityRules(targets, maxTargets, GetRadianceRules(caster, explTarget));
foreach (WorldObject target in targets)
{
@@ -2089,33 +2078,23 @@ class spell_pri_power_word_radiance : SpellScript
}
}
List<PriorityRules> GetRadianceRules(Unit caster, Unit explTarget)
{
return new List<PriorityRules>()
{
new PriorityRules() { weight = 1, condition = target => target.IsInRaidWith(caster) },
new PriorityRules() { weight = 2, condition = target => target.IsPlayer() || (target.IsCreature() && target.ToCreature().IsTreatedAsRaidUnit()) },
new PriorityRules() { weight = 4, condition = target => !target.IsFullHealth() },
new PriorityRules() { weight = 8, condition = target => !target.HasAura(SpellIds.AtonementEffect, caster.GetGUID()) },
new PriorityRules() { weight = 16, condition = target => target == explTarget }
};
}
public override void Register()
{
OnObjectAreaTargetSelect.Add(new(FilterTargets, 1, Targets.UnitDestAreaAlly));
OnEffectHitTarget.Add(new(HandleEffectHitTarget, 0, SpellEffectName.Dummy));
}
(bool, bool) MakeSortTuple(WorldObject obj)
{
return (IsUnitWithNoAtonement(obj), IsUnitInjured(obj));
}
// Returns true if obj is a unit but has no atonement
bool IsUnitWithNoAtonement(WorldObject obj)
{
Unit unit = obj.ToUnit();
return unit != null && !unit.HasAura(SpellIds.AtonementEffect, GetCaster().GetGUID());
}
// Returns true if obj is a unit and is injured
static bool IsUnitInjured(WorldObject obj)
{
Unit unit = obj.ToUnit();
return unit != null && !unit.IsFullHealth();
}
List<ObjectGuid> _visualTargets;
}
[Script] // 17 - Power Word: Shield
@@ -2227,12 +2206,12 @@ class spell_pri_divine_aegis : AuraScript
return ValidateSpellEffect((SpellIds.DivineAegisAbsorb, 0));
}
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
return eventInfo.GetHealInfo() != null;
}
static void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
Unit caster = eventInfo.GetActor();
if (caster == null)
@@ -2486,7 +2465,7 @@ class spell_pri_holy_10_1_class_set_2pc : AuraScript
&& ValidateSpellEffect((SpellIds.PrayerOfMending, 0));
}
static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
return RandomHelper.randChance(aurEff.GetAmount());
}
@@ -3055,7 +3034,7 @@ class spell_pri_shadow_mend_periodic_damage : AuraScript
GetTarget().CastSpell(GetTarget(), SpellIds.ShadowMendDamage, args);
}
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
return eventInfo.GetDamageInfo() != null;
}
@@ -3133,7 +3112,7 @@ class spell_pri_surge_of_light : AuraScript
return ValidateSpellInfo(SpellIds.Smite, SpellIds.SurgeOfLightEffect);
}
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
if (eventInfo.GetSpellInfo().Id == SpellIds.Smite)
return true;
@@ -3185,7 +3164,7 @@ class spell_pri_t5_heal_2p_bonus : AuraScript
return ValidateSpellInfo(SpellIds.ItemEfficiency);
}
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
HealInfo healInfo = eventInfo.GetHealInfo();
if (healInfo != null)
@@ -3312,13 +3291,13 @@ class spell_pri_train_of_thought : AuraScript
return ValidateSpellInfo(SpellIds.PowerWordShield, SpellIds.Penance);
}
static bool CheckEffect0(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckEffect0(AuraEffect aurEff, ProcEventInfo eventInfo)
{
// Renew & Flash Heal
return eventInfo.GetSpellInfo().IsAffected(SpellFamilyNames.Priest, new FlagArray128(0x840));
}
static bool Check1(AuraEffect aurEff, ProcEventInfo eventInfo)
bool Check1(AuraEffect aurEff, ProcEventInfo eventInfo)
{
// Smite
return eventInfo.GetSpellInfo().IsAffected(SpellFamilyNames.Priest, new FlagArray128(0x80));
@@ -3347,7 +3326,7 @@ class spell_pri_train_of_thought : AuraScript
[Script] // 265259 - Twist of Fate (Discipline)
class spell_pri_twist_of_fate : AuraScript
{
static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
return eventInfo.GetProcTarget().GetHealthPct() < aurEff.GetAmount();
}
@@ -3422,7 +3401,7 @@ class spell_pri_vampiric_embrace : AuraScript
return ValidateSpellInfo(SpellIds.VampiricEmbraceHeal);
}
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
// Not proc from Mind Sear
return (eventInfo.GetDamageInfo().GetSpellInfo().SpellFamilyFlags[1] & 0x80000) == 0;
+1 -1
View File
@@ -366,7 +366,7 @@ class spell_rog_deepening_shadows : AuraScript
return ValidateSpellInfo(SpellIds.ShadowDance);
}
static bool CheckProc(AuraEffect aurEff, ProcEventInfo procEvent)
bool CheckProc(AuraEffect aurEff, ProcEventInfo procEvent)
{
Spell procSpell = procEvent.GetProcSpell();
if (procSpell != null)
+17 -22
View File
@@ -357,7 +357,7 @@ class spell_sha_aftershock : AuraScript
return ValidateSpellInfo(SpellIds.AftershockEnergize);
}
static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
Spell procSpell = eventInfo.GetProcSpell();
if (procSpell != null)
@@ -370,7 +370,7 @@ class spell_sha_aftershock : AuraScript
return false;
}
static void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
Spell procSpell = eventInfo.GetProcSpell();
eventInfo.GetActor().CastSpell(eventInfo.GetActor(), SpellIds.AftershockEnergize, new CastSpellExtraArgs()
@@ -397,7 +397,7 @@ class spell_sha_ancestral_guidance : AuraScript
return ValidateSpellInfo(SpellIds.AncestralGuidanceHeal);
}
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
if (eventInfo.GetSpellInfo() != null && eventInfo.GetSpellInfo().Id == SpellIds.AncestralGuidanceHeal)
return false;
@@ -433,11 +433,6 @@ class spell_sha_ancestral_guidance : AuraScript
[Script] // 114911 - Ancestral Guidance Heal
class spell_sha_ancestral_guidance_heal : SpellScript
{
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(SpellIds.AncestralGuidance);
}
void ResizeTargets(List<WorldObject> targets)
{
SelectRandomInjuredTargets(targets, 3, true);
@@ -511,7 +506,7 @@ class spell_sha_ascendance_restoration : AuraScript
return ValidateSpellInfo(SpellIds.RestorativeMists);
}
static bool CheckProc(ProcEventInfo procInfo)
bool CheckProc(ProcEventInfo procInfo)
{
return procInfo.GetHealInfo() != null && procInfo.GetHealInfo().GetOriginalHeal() != 0 && procInfo.GetSpellInfo().Id != SpellIds.RestorativeMistsInitial;
}
@@ -1030,7 +1025,7 @@ class spell_sha_earthen_rage_passive : AuraScript
return ValidateSpellInfo(SpellIds.EarthenRagePeriodic, SpellIds.EarthenRageDamage);
}
static bool CheckProc(ProcEventInfo procInfo)
bool CheckProc(ProcEventInfo procInfo)
{
return procInfo.GetSpellInfo() != null && procInfo.GetSpellInfo().Id != SpellIds.EarthenRageDamage;
}
@@ -1581,7 +1576,7 @@ class spell_sha_healing_stream_totem_heal : SpellScript
[Script] // 201900 - Hot Hand
class spell_sha_hot_hand : AuraScript
{
static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
return eventInfo.GetActor().HasAura(SpellIds.FlametongueWeaponAura);
}
@@ -1714,7 +1709,7 @@ class spell_sha_item_mana_surge : AuraScript
return ValidateSpellInfo(SpellIds.ItemManaSurge);
}
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
return eventInfo.GetProcSpell() != null;
}
@@ -2165,13 +2160,13 @@ class spell_sha_mastery_elemental_overload : AuraScript
);
}
static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
SpellInfo spellInfo = eventInfo.GetSpellInfo();
if (spellInfo == null || eventInfo.GetProcSpell() == null)
return false;
if (GetTriggeredSpellId(spellInfo.Id) == null)
if (GetTriggeredSpellId(spellInfo.Id) == 0)
return false;
float chance = aurEff.GetAmount(); // Mastery % amount
@@ -2380,13 +2375,13 @@ class spell_sha_natures_guardian : AuraScript
return ValidateSpellInfo(SpellIds.NaturesGuardianCooldown);
}
static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
return eventInfo.GetActionTarget().HealthBelowPct(aurEff.GetAmount())
&& !eventInfo.GetActionTarget().HasAura(SpellIds.NaturesGuardianCooldown);
}
static void StartCooldown(AuraEffect aurEff, ProcEventInfo eventInfo)
void StartCooldown(AuraEffect aurEff, ProcEventInfo eventInfo)
{
Unit shaman = eventInfo.GetActionTarget();
shaman.CastSpell(shaman, SpellIds.NaturesGuardianCooldown, new CastSpellExtraArgs()
@@ -2766,7 +2761,7 @@ class spell_sha_stormsurge : AuraScript
return ValidateSpellInfo(SpellIds.StormsurgeProc);
}
static void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
eventInfo.GetActor().CastSpell(eventInfo.GetActor(), SpellIds.StormsurgeProc, new CastSpellExtraArgs()
{
@@ -3194,7 +3189,7 @@ class spell_sha_unlimited_power : AuraScript
return ValidateSpellInfo(SpellIds.UnlimitedPowerBuff);
}
static void HandleProc(AuraEffect aurEff, ProcEventInfo procInfo)
void HandleProc(AuraEffect aurEff, ProcEventInfo procInfo)
{
Unit caster = procInfo.GetActor();
Aura aura = caster.GetAura(SpellIds.UnlimitedPowerBuff);
@@ -3329,7 +3324,7 @@ class spell_sha_voltaic_blaze : SpellScript
[Script] // 470058 - Voltaic Blaze
class spell_sha_voltaic_blaze_aura : AuraScript
{
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
// 470057 - Voltaic Blaze does not have any unique SpellFamilyFlags, check by id
return eventInfo.GetSpellInfo().Id == SpellIds.VoltaicBlazeDamage;
@@ -3344,12 +3339,12 @@ class spell_sha_voltaic_blaze_aura : AuraScript
[Script] // 470053 - Voltaic Blaze
class spell_sha_voltaic_blaze_talent : AuraScript
{
static bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
return RandomHelper.randChance(aurEff.GetAmount());
}
static void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
eventInfo.GetActor().CastSpell(eventInfo.GetActor(), SpellIds.VoltaicBlazeOverride);
}
@@ -3474,7 +3469,7 @@ class areatrigger_sha_wind_rush_totem(AreaTrigger areaTrigger) : AreaTriggerAI(a
CastSpeedBuff(caster, unit);
}
static void CastSpeedBuff(Unit caster, Unit unit)
void CastSpeedBuff(Unit caster, Unit unit)
{
if (!caster.IsValidAssistTarget(unit))
return;
+1 -3
View File
@@ -1282,9 +1282,7 @@ class spell_warl_shadowburn : SpellScript
OnCalcCritChance.Add(new(CalcCritChance));
}
public
static void TryEnergize(Player caster, Unit target, SpellInfo spellInfo,
Spell triggeringSpell, AuraEffect triggeringAura)
public static void TryEnergize(Player caster, Unit target, SpellInfo spellInfo, Spell triggeringSpell, AuraEffect triggeringAura)
{
if (caster == null)
return;
+11 -11
View File
@@ -114,7 +114,7 @@ namespace Scripts.Spells.Warrior
static uint[] FurySpellIds = [SpellIds.Recklessness, SpellIds.Bladestorm, SpellIds.Ravager];
static uint[] ProtectionSpellIds = [SpellIds.Avatar, SpellIds.ShieldWall];
static bool ValidateProc(AuraEffect aurEff, ProcEventInfo eventInfo, ChrSpecialization spec)
bool ValidateProc(AuraEffect aurEff, ProcEventInfo eventInfo, ChrSpecialization spec)
{
if (aurEff.GetAmount() == 0)
return false;
@@ -133,7 +133,7 @@ namespace Scripts.Spells.Warrior
return player.GetPrimarySpecialization() == spec;
}
static bool CheckArmsProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckArmsProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
if (!ValidateProc(aurEff, eventInfo, ChrSpecialization.WarriorArms))
return false;
@@ -145,12 +145,12 @@ namespace Scripts.Spells.Warrior
return true;
}
static bool CheckFuryProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckFuryProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
return ValidateProc(aurEff, eventInfo, ChrSpecialization.WarriorFury);
}
static bool CheckProtectionProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckProtectionProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
return ValidateProc(aurEff, eventInfo, ChrSpecialization.WarriorProtection);
}
@@ -200,7 +200,7 @@ namespace Scripts.Spells.Warrior
[Script] // 392536 - Ashen Juggernaut
class spell_warr_ashen_juggernaut : AuraScript
{
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
// should only proc on primary target
return eventInfo.GetActionTarget() == eventInfo.GetProcSpell().m_targets.GetUnitTarget();
@@ -544,7 +544,7 @@ namespace Scripts.Spells.Warrior
return ValidateSpellInfo(SpellIds.FreshMeatTalent, SpellIds.FreshMeatDebuff);
}
static bool CheckRampageProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckRampageProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
SpellInfo spellInfo = eventInfo.GetSpellInfo();
if (spellInfo == null || !spellInfo.IsAffected(SpellFamilyNames.Warrior, new FlagArray128(0x0, 0x0, 0x0, 0x8000000))) // Rampage
@@ -553,13 +553,13 @@ namespace Scripts.Spells.Warrior
return true;
}
static bool IsBloodthirst(SpellInfo spellInfo)
bool IsBloodthirst(SpellInfo spellInfo)
{
// Bloodthirst/Bloodbath
return spellInfo.IsAffected(SpellFamilyNames.Warrior, new FlagArray128(0x0, 0x400));
}
static bool CheckBloodthirstProc(AuraEffect aurEff, ProcEventInfo eventInfo)
bool CheckBloodthirstProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
SpellInfo spellInfo = eventInfo.GetSpellInfo();
if (spellInfo == null || !IsBloodthirst(spellInfo))
@@ -630,7 +630,7 @@ namespace Scripts.Spells.Warrior
[Script] // 260798 - Execute (Arms, Protection)
class spell_warr_execute_damage : SpellScript
{
static void CalculateExecuteDamage(SpellEffectInfo spellEffectInfo, Unit victim, ref int damageOrHealing, ref int flatMod, ref float pctMod)
void CalculateExecuteDamage(SpellEffectInfo spellEffectInfo, Unit victim, ref int damageOrHealing, ref int flatMod, ref float pctMod)
{
// tooltip has 2 multiplier hardcoded in it $damage=${2.0*$260798s1}
pctMod *= 2.0f;
@@ -1288,7 +1288,7 @@ namespace Scripts.Spells.Warrior
&& ValidateSpellEffect((SpellIds.Strategist, 0));
}
static bool CheckProc(AuraEffect aurEff, ProcEventInfo procEvent)
bool CheckProc(AuraEffect aurEff, ProcEventInfo procEvent)
{
return RandomHelper.randChance(aurEff.GetAmount());
}
@@ -1310,7 +1310,7 @@ namespace Scripts.Spells.Warrior
[Script] // 280776 - Sudden Death
class spell_warr_sudden_death : AuraScript
{
static bool CheckProc(ProcEventInfo eventInfo)
bool CheckProc(ProcEventInfo eventInfo)
{
// should only proc on primary target
return eventInfo.GetActionTarget() == eventInfo.GetProcSpell().m_targets.GetUnitTarget();