Implement generic script loaders to greatly reduce code duplication
This commit is contained in:
+82
-127
@@ -41,177 +41,132 @@ namespace Scripts.Spells.Rogue
|
||||
public const uint HonorAmongThievesEnergize = 51699;
|
||||
public const uint T52pSetBonus = 37169;
|
||||
}
|
||||
|
||||
|
||||
[Script] // 51690 - Killing Spree
|
||||
class spell_rog_killing_spree : SpellScriptLoader
|
||||
class spell_rog_killing_spree : SpellScript
|
||||
{
|
||||
public spell_rog_killing_spree() : base("spell_rog_killing_spree") { }
|
||||
|
||||
class spell_rog_killing_spree_SpellScript : SpellScript
|
||||
void FilterTargets(List<WorldObject> targets)
|
||||
{
|
||||
void FilterTargets(List<WorldObject> targets)
|
||||
{
|
||||
if (targets.Empty() || GetCaster().GetVehicleBase())
|
||||
FinishCast(SpellCastResult.OutOfRange);
|
||||
}
|
||||
if (targets.Empty() || GetCaster().GetVehicleBase())
|
||||
FinishCast(SpellCastResult.OutOfRange);
|
||||
}
|
||||
|
||||
void HandleDummy(uint effIndex)
|
||||
void HandleDummy(uint effIndex)
|
||||
{
|
||||
Aura aura = GetCaster().GetAura(SpellIds.KillingSpree);
|
||||
if (aura != null)
|
||||
{
|
||||
Aura aura = GetCaster().GetAura(SpellIds.KillingSpree);
|
||||
if (aura != null)
|
||||
var script = aura.GetScript<spell_rog_killing_spree_AuraScript>(nameof(spell_rog_killing_spree_AuraScript));
|
||||
if (script != null)
|
||||
script.AddTarget(GetHitUnit());
|
||||
}
|
||||
}
|
||||
|
||||
public override void Register()
|
||||
{
|
||||
OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEnemy));
|
||||
OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 1, SpellEffectName.Dummy));
|
||||
}
|
||||
}
|
||||
|
||||
public class spell_rog_killing_spree_AuraScript : AuraScript
|
||||
{
|
||||
public override bool Validate(SpellInfo spellInfo)
|
||||
{
|
||||
return ValidateSpellInfo(SpellIds.KillingSpreeTeleport, SpellIds.KillingSpreeWeaponDmg, SpellIds.KillingSpreeDmgBuff);
|
||||
}
|
||||
|
||||
void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode)
|
||||
{
|
||||
GetTarget().CastSpell(GetTarget(), SpellIds.KillingSpreeDmgBuff, true);
|
||||
}
|
||||
|
||||
void HandleEffectPeriodic(AuraEffect aurEff)
|
||||
{
|
||||
while (!_targets.Empty())
|
||||
{
|
||||
ObjectGuid guid = _targets.SelectRandom();
|
||||
Unit target = Global.ObjAccessor.GetUnit(GetTarget(), guid);
|
||||
if (target)
|
||||
{
|
||||
var script = aura.GetScript<spell_rog_killing_spree_AuraScript>(nameof(spell_rog_killing_spree_AuraScript));
|
||||
if (script != null)
|
||||
script.AddTarget(GetHitUnit());
|
||||
GetTarget().CastSpell(target, SpellIds.KillingSpreeTeleport, true);
|
||||
GetTarget().CastSpell(target, SpellIds.KillingSpreeWeaponDmg, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Register()
|
||||
{
|
||||
OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitDestAreaEnemy));
|
||||
OnEffectHitTarget.Add(new EffectHandler(HandleDummy, 1, SpellEffectName.Dummy));
|
||||
else
|
||||
_targets.Remove(guid);
|
||||
}
|
||||
}
|
||||
|
||||
public override SpellScript GetSpellScript()
|
||||
void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode)
|
||||
{
|
||||
return new spell_rog_killing_spree_SpellScript();
|
||||
GetTarget().RemoveAurasDueToSpell(SpellIds.KillingSpreeDmgBuff);
|
||||
}
|
||||
|
||||
public class spell_rog_killing_spree_AuraScript : AuraScript
|
||||
public override void Register()
|
||||
{
|
||||
public override bool Validate(SpellInfo spellInfo)
|
||||
{
|
||||
return ValidateSpellInfo(SpellIds.KillingSpreeTeleport, SpellIds.KillingSpreeWeaponDmg, SpellIds.KillingSpreeDmgBuff);
|
||||
}
|
||||
|
||||
void HandleApply(AuraEffect aurEff, AuraEffectHandleModes mode)
|
||||
{
|
||||
GetTarget().CastSpell(GetTarget(), SpellIds.KillingSpreeDmgBuff, true);
|
||||
}
|
||||
|
||||
void HandleEffectPeriodic(AuraEffect aurEff)
|
||||
{
|
||||
while (!_targets.Empty())
|
||||
{
|
||||
ObjectGuid guid = _targets.SelectRandom();
|
||||
Unit target = Global.ObjAccessor.GetUnit(GetTarget(), guid);
|
||||
if (target)
|
||||
{
|
||||
GetTarget().CastSpell(target, SpellIds.KillingSpreeTeleport, true);
|
||||
GetTarget().CastSpell(target, SpellIds.KillingSpreeWeaponDmg, true);
|
||||
break;
|
||||
}
|
||||
else
|
||||
_targets.Remove(guid);
|
||||
}
|
||||
}
|
||||
|
||||
void HandleRemove(AuraEffect aurEff, AuraEffectHandleModes mode)
|
||||
{
|
||||
GetTarget().RemoveAurasDueToSpell(SpellIds.KillingSpreeDmgBuff);
|
||||
}
|
||||
|
||||
public override void Register()
|
||||
{
|
||||
AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real));
|
||||
OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy));
|
||||
AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real));
|
||||
}
|
||||
|
||||
public void AddTarget(Unit target)
|
||||
{
|
||||
_targets.Add(target.GetGUID());
|
||||
}
|
||||
|
||||
List<ObjectGuid> _targets = new List<ObjectGuid>();
|
||||
AfterEffectApply.Add(new EffectApplyHandler(HandleApply, 0, AuraType.Dummy, AuraEffectHandleModes.Real));
|
||||
OnEffectPeriodic.Add(new EffectPeriodicHandler(HandleEffectPeriodic, 0, AuraType.PeriodicDummy));
|
||||
AfterEffectRemove.Add(new EffectApplyHandler(HandleRemove, 0, AuraType.PeriodicDummy, AuraEffectHandleModes.Real));
|
||||
}
|
||||
|
||||
public override AuraScript GetAuraScript()
|
||||
public void AddTarget(Unit target)
|
||||
{
|
||||
return new spell_rog_killing_spree_AuraScript();
|
||||
_targets.Add(target.GetGUID());
|
||||
}
|
||||
|
||||
List<ObjectGuid> _targets = new List<ObjectGuid>();
|
||||
}
|
||||
|
||||
[Script] // 70805 - Rogue T10 2P Bonus -- THIS SHOULD BE REMOVED WITH NEW PROC SYSTEM.
|
||||
class spell_rog_t10_2p_bonus : SpellScriptLoader
|
||||
class spell_rog_t10_2p_bonus : AuraScript
|
||||
{
|
||||
public spell_rog_t10_2p_bonus() : base("spell_rog_t10_2p_bonus") { }
|
||||
|
||||
class spell_rog_t10_2p_bonus_AuraScript : AuraScript
|
||||
bool CheckProc(ProcEventInfo eventInfo)
|
||||
{
|
||||
bool CheckProc(ProcEventInfo eventInfo)
|
||||
{
|
||||
return eventInfo.GetActor() == eventInfo.GetActionTarget();
|
||||
}
|
||||
|
||||
public override void Register()
|
||||
{
|
||||
DoCheckProc.Add(new CheckProcHandler(CheckProc));
|
||||
}
|
||||
return eventInfo.GetActor() == eventInfo.GetActionTarget();
|
||||
}
|
||||
|
||||
public override AuraScript GetAuraScript()
|
||||
public override void Register()
|
||||
{
|
||||
return new spell_rog_t10_2p_bonus_AuraScript();
|
||||
DoCheckProc.Add(new CheckProcHandler(CheckProc));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Script] // 2098 - Eviscerate
|
||||
class spell_rog_eviscerate : SpellScriptLoader
|
||||
class spell_rog_eviscerate : SpellScript
|
||||
{
|
||||
public spell_rog_eviscerate() : base("spell_rog_eviscerate") { }
|
||||
|
||||
class spell_rog_eviscerate_SpellScript : SpellScript
|
||||
void CalculateDamage(uint effIndex)
|
||||
{
|
||||
void CalculateDamage(uint effIndex)
|
||||
{
|
||||
int damagePerCombo = (int)(GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.559f);
|
||||
AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52pSetBonus, 0);
|
||||
if (t5 != null)
|
||||
damagePerCombo += t5.GetAmount();
|
||||
int damagePerCombo = (int)(GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.559f);
|
||||
AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52pSetBonus, 0);
|
||||
if (t5 != null)
|
||||
damagePerCombo += t5.GetAmount();
|
||||
|
||||
SetEffectValue(GetEffectValue() + damagePerCombo * GetCaster().GetPower(PowerType.ComboPoints));
|
||||
}
|
||||
|
||||
public override void Register()
|
||||
{
|
||||
OnEffectLaunchTarget.Add(new EffectHandler(CalculateDamage, 0, SpellEffectName.SchoolDamage));
|
||||
}
|
||||
SetEffectValue(GetEffectValue() + damagePerCombo * GetCaster().GetPower(PowerType.ComboPoints));
|
||||
}
|
||||
|
||||
public override SpellScript GetSpellScript()
|
||||
public override void Register()
|
||||
{
|
||||
return new spell_rog_eviscerate_SpellScript();
|
||||
OnEffectLaunchTarget.Add(new EffectHandler(CalculateDamage, 0, SpellEffectName.SchoolDamage));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Script] // 32645 - Envenom
|
||||
class spell_rog_envenom : SpellScriptLoader
|
||||
class spell_rog_envenom : SpellScript
|
||||
{
|
||||
public spell_rog_envenom() : base("spell_rog_envenom") { }
|
||||
|
||||
class spell_rog_envenom_SpellScript : SpellScript
|
||||
void CalculateDamage(uint effIndex)
|
||||
{
|
||||
void CalculateDamage(uint effIndex)
|
||||
{
|
||||
int damagePerCombo = (int)(GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.417f);
|
||||
AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52pSetBonus, 0);
|
||||
if (t5 != null)
|
||||
damagePerCombo += t5.GetAmount();
|
||||
int damagePerCombo = (int)(GetCaster().GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.417f);
|
||||
AuraEffect t5 = GetCaster().GetAuraEffect(SpellIds.T52pSetBonus, 0);
|
||||
if (t5 != null)
|
||||
damagePerCombo += t5.GetAmount();
|
||||
|
||||
SetEffectValue(GetEffectValue() + damagePerCombo * GetCaster().GetPower(PowerType.ComboPoints));
|
||||
}
|
||||
|
||||
public override void Register()
|
||||
{
|
||||
OnEffectLaunchTarget.Add(new EffectHandler(CalculateDamage, 0, SpellEffectName.SchoolDamage));
|
||||
}
|
||||
SetEffectValue(GetEffectValue() + damagePerCombo * GetCaster().GetPower(PowerType.ComboPoints));
|
||||
}
|
||||
|
||||
public override SpellScript GetSpellScript()
|
||||
public override void Register()
|
||||
{
|
||||
return new spell_rog_envenom_SpellScript();
|
||||
OnEffectLaunchTarget.Add(new EffectHandler(CalculateDamage, 0, SpellEffectName.SchoolDamage));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user