Scripts/Spells Update Seed of Corruption script

Port From (https://github.com/TrinityCore/TrinityCore/commit/4f8cb99ad2b95d4cc5d2abba8a00e67acfdfed4f)
This commit is contained in:
Hondacrx
2024-11-09 23:49:19 -05:00
parent 9580103f3b
commit 3f87e713c5
3 changed files with 77 additions and 23 deletions
@@ -283,7 +283,6 @@ namespace Framework.Constants
MageArmor = 9, MageArmor = 9,
ElementalShield = 10, ElementalShield = 10,
MagePolymorph = 11, MagePolymorph = 11,
WarlockCorruption = 17,
Food = 19, Food = 19,
Drink = 20, Drink = 20,
FoodAndDrink = 21, FoodAndDrink = 21,
-5
View File
@@ -747,7 +747,6 @@ namespace Game.Spells
case SpellSpecificType.Curse: case SpellSpecificType.Curse:
case SpellSpecificType.Bane: case SpellSpecificType.Bane:
case SpellSpecificType.Aspect: case SpellSpecificType.Aspect:
case SpellSpecificType.WarlockCorruption:
return spellSpec == spellInfo.GetSpellSpecific(); return spellSpec == spellInfo.GetSpellSpecific();
default: default:
return false; return false;
@@ -1548,10 +1547,6 @@ namespace Game.Spells
// Warlock (Demon Armor | Demon Skin | Fel Armor) // Warlock (Demon Armor | Demon Skin | Fel Armor)
if (SpellFamilyFlags[1].HasAnyFlag(0x20000020u) || SpellFamilyFlags[2].HasAnyFlag(0x00000010u)) if (SpellFamilyFlags[1].HasAnyFlag(0x20000020u) || SpellFamilyFlags[2].HasAnyFlag(0x00000010u))
_spellSpecific = SpellSpecificType.WarlockArmor; _spellSpecific = SpellSpecificType.WarlockArmor;
//seed of corruption and corruption
if (SpellFamilyFlags[1].HasAnyFlag(0x10u) || SpellFamilyFlags[0].HasAnyFlag(0x2u))
_spellSpecific = SpellSpecificType.WarlockCorruption;
break; break;
} }
case SpellFamilyNames.Priest: case SpellFamilyNames.Priest:
+77 -17
View File
@@ -4,6 +4,7 @@
using Framework.Constants; using Framework.Constants;
using Framework.Dynamic; using Framework.Dynamic;
using Game.Entities; using Game.Entities;
using Game.Maps;
using Game.Scripting; using Game.Scripting;
using Game.Spells; using Game.Spells;
using System.Collections.Generic; using System.Collections.Generic;
@@ -13,6 +14,7 @@ namespace Scripts.Spells.Warlock
{ {
struct SpellIds struct SpellIds
{ {
public const uint CorruptionDamage = 146739;
public const uint CreateHealthstone = 23517; public const uint CreateHealthstone = 23517;
public const uint DemonicCircleAllowCast = 62388; public const uint DemonicCircleAllowCast = 62388;
public const uint DemonicCircleSummon = 48018; public const uint DemonicCircleSummon = 48018;
@@ -556,29 +558,78 @@ namespace Scripts.Spells.Warlock
} }
} }
[Script] // 27285 - Seed of Corruption [Script] // 27285 - Seed of Corruption (damage)
class spell_warl_seed_of_corruption : SpellScript class spell_warl_seed_of_corruption : SpellScript
{ {
void FilterTargets(List<WorldObject> targets) public override bool Validate(SpellInfo spellInfo)
{ {
if (GetExplTargetUnit() != null) return ValidateSpellInfo(SpellIds.CorruptionDamage);
targets.Remove(GetExplTargetUnit()); }
void HandleHit(uint effIndex)
{
GetCaster().CastSpell(GetHitUnit(), SpellIds.CorruptionDamage, true);
} }
public override void Register() public override void Register()
{ {
OnObjectAreaTargetSelect.Add(new(FilterTargets, 0, Targets.UnitDestAreaEnemy)); OnEffectHitTarget.Add(new(HandleHit, 0, SpellEffectName.SchoolDamage));
}
}
[Script]
class spell_warl_seed_of_corruption_dummy : SpellScript
{
void RemoveVisualMissile(ref WorldObject target)
{
target = null;
}
void SelectTarget(List<WorldObject> targets)
{
if (targets.Count < 2)
return;
if (!GetExplTargetUnit().HasAura(GetSpellInfo().Id, GetCaster().GetGUID()))
{
// primary target doesn't have seed, keep it
targets.Clear();
targets.Add(GetExplTargetUnit());
}
else
{
// primary target has seed, select random other target with no seed
targets.RemoveAll(new UnitAuraCheck(true, GetSpellInfo().Id, GetCaster().GetGUID()));
if (!targets.Empty())
targets.RandomResize(1);
else
targets.Add(GetExplTargetUnit());
}
}
public override void Register()
{
OnObjectTargetSelect.Add(new(RemoveVisualMissile, 0, Targets.UnitTargetEnemy));
OnObjectAreaTargetSelect.Add(new(SelectTarget, 1, Targets.UnitDestAreaEnemy));
OnObjectAreaTargetSelect.Add(new(SelectTarget, 2, Targets.UnitDestAreaEnemy));
} }
} }
[Script] // 27243 - Seed of Corruption [Script] // 27243 - Seed of Corruption
class spell_warl_seed_of_corruption_dummy : AuraScript class spell_warl_seed_of_corruption_dummy_aura : AuraScript
{ {
public override bool Validate(SpellInfo spellInfo) public override bool Validate(SpellInfo spellInfo)
{ {
return ValidateSpellInfo(SpellIds.SeedOfCorruptionDamage); return ValidateSpellInfo(SpellIds.SeedOfCorruptionDamage);
} }
void OnPeriodic(AuraEffect aurEff)
{
Unit caster = GetCaster();
if (caster != null)
caster.CastSpell(GetTarget(), SpellIds.SeedOfCorruptionDamage, aurEff);
}
void CalculateBuffer(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated) void CalculateBuffer(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated)
{ {
Unit caster = GetCaster(); Unit caster = GetCaster();
@@ -591,29 +642,38 @@ namespace Scripts.Spells.Warlock
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{ {
PreventDefaultAction(); PreventDefaultAction();
DamageInfo damageInfo = eventInfo.GetDamageInfo(); DamageInfo damageInfo = eventInfo.GetDamageInfo();
if (damageInfo == null || damageInfo.GetDamage() == 0) if (damageInfo == null)
return; return;
int amount = (int)(aurEff.GetAmount() - damageInfo.GetDamage());
if (amount > 0)
{
aurEff.SetAmount(amount);
if (!GetTarget().HealthBelowPctDamaged(1, damageInfo.GetDamage()))
return;
}
Remove();
Unit caster = GetCaster(); Unit caster = GetCaster();
if (caster == null) if (caster == null)
return; return;
if (damageInfo.GetAttacker() == null || damageInfo.GetAttacker() != caster)
return;
// other seed explosions detonate this instantly, no matter what damage amount is
if (damageInfo.GetSpellInfo() == null || damageInfo.GetSpellInfo().Id != SpellIds.SeedOfCorruptionDamage)
{
int amount = (int)(aurEff.GetAmount() - damageInfo.GetDamage());
if (amount > 0)
{
aurEff.SetAmount(amount);
if (!GetTarget().HealthBelowPctDamaged(1, damageInfo.GetDamage()))
return;
}
}
Remove();
caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionDamage, aurEff); caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionDamage, aurEff);
} }
public override void Register() public override void Register()
{ {
OnEffectPeriodic.Add(new(OnPeriodic, 1, AuraType.PeriodicDamage));
DoEffectCalcAmount.Add(new(CalculateBuffer, 2, AuraType.Dummy)); DoEffectCalcAmount.Add(new(CalculateBuffer, 2, AuraType.Dummy));
OnEffectProc.Add(new(HandleProc, 2, AuraType.Dummy)); OnEffectProc.Add(new(HandleProc, 2, AuraType.Dummy));
} }