fix: Fixes various memory leaks and spells (#1786)

### Summary
- Fixes various memory leaks related to spells
- Fixes Spell Plague
- Added ability to determine if `sdi` should take effect for Spell Damage.
- Fixes animal form timer ticking non-stop while logged out.
This commit is contained in:
Kamron Batman 2024-05-21 19:44:42 -07:00 • committed by GitHub
parent 6747168db0
commit a552cf4138
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
51 changed files with 4164 additions and 4188 deletions

View file

@ -1,63 +1,62 @@
using System;
using Server.Mobiles;
namespace Server.Spells.Mysticism
namespace Server.Spells.Mysticism;
public class AnimatedWeaponSpell : MysticSpell, ISpellTargetingPoint3D
{
public class AnimatedWeaponSpell : MysticSpell, ISpellTargetingPoint3D
private static readonly SpellInfo _info = new(
"Animated Weapon",
"In Jux Por Ylem",
-1,
9002,
Reagent.Bone,
Reagent.BlackPearl,
Reagent.MandrakeRoot,
Reagent.Nightshade
);
public AnimatedWeaponSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
private static readonly SpellInfo _info = new(
"Animated Weapon",
"In Jux Por Ylem",
-1,
9002,
Reagent.Bone,
Reagent.BlackPearl,
Reagent.MandrakeRoot,
Reagent.Nightshade
);
public AnimatedWeaponSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
public override SpellCircle Circle => SpellCircle.Fourth;
public void Target(IPoint3D p)
{
if (Caster.Followers + 4 > Caster.FollowersMax)
{
Caster.SendLocalizedMessage(1049645); // You have too many followers to summon that creature.
return;
}
var map = Caster.Map;
SpellHelper.GetSurfaceTop(ref p);
if (map == null || Caster.Player && !map.CanSpawnMobile(p.X, p.Y, p.Z))
{
Caster.SendLocalizedMessage(501942); // That location is blocked.
}
else if (SpellHelper.CheckTown(p, Caster) && CheckSequence())
{
var level = (int)((GetBaseSkill(Caster) + GetDamageSkill(Caster)) / 2.0);
var duration = TimeSpan.FromSeconds(10 + level);
var summon = new AnimatedWeapon(Caster, level);
BaseCreature.Summon(summon, false, Caster, new Point3D(p), 0x212, duration);
summon.PlaySound(0x64A);
Effects.SendTargetParticles(summon, 0x3728, 10, 10, 0x13AA, (EffectLayer)255);
}
FinishSequence();
}
public override void OnCast()
{
Caster.Target = new SpellTargetPoint3D(this);
}
}
}
public override SpellCircle Circle => SpellCircle.Fourth;
public void Target(IPoint3D p)
{
if (Caster.Followers + 4 > Caster.FollowersMax)
{
Caster.SendLocalizedMessage(1049645); // You have too many followers to summon that creature.
return;
}
var map = Caster.Map;
SpellHelper.GetSurfaceTop(ref p);
if (map == null || Caster.Player && !map.CanSpawnMobile(p.X, p.Y, p.Z))
{
Caster.SendLocalizedMessage(501942); // That location is blocked.
}
else if (SpellHelper.CheckTown(p, Caster) && CheckSequence())
{
var level = (int)((GetBaseSkill(Caster) + GetDamageSkill(Caster)) / 2.0);
var duration = TimeSpan.FromSeconds(10 + level);
var summon = new AnimatedWeapon(Caster, level);
BaseCreature.Summon(summon, false, Caster, new Point3D(p), 0x212, duration);
summon.PlaySound(0x64A);
Effects.SendTargetParticles(summon, 0x3728, 10, 10, 0x13AA, (EffectLayer)255);
}
FinishSequence();
}
public override void OnCast()
{
Caster.Target = new SpellTargetPoint3D(this);
}
}

View file

@ -1,36 +1,36 @@
using Server.Targeting;
using System;
namespace Server.Spells.Mysticism
{
public class BombardSpell : MysticSpell, ISpellTargetingMobile
{
private static readonly SpellInfo _info = new(
"Bombard", "Corp Por Ylem",
230,
9022,
Reagent.Bloodmoss,
Reagent.Garlic,
Reagent.SulfurousAsh,
Reagent.DragonsBlood
);
namespace Server.Spells.Mysticism;
public BombardSpell(Mobile caster, Item scroll) : base(caster, scroll, _info)
{
public class BombardSpell : MysticSpell, ISpellTargetingMobile
{
private static readonly SpellInfo _info = new(
"Bombard", "Corp Por Ylem",
230,
9022,
Reagent.Bloodmoss,
Reagent.Garlic,
Reagent.SulfurousAsh,
Reagent.DragonsBlood
);
public BombardSpell(Mobile caster, Item scroll) : base(caster, scroll, _info)
{
}
public override SpellCircle Circle => SpellCircle.Sixth;
public override bool DelayedDamage => true;
public override SpellCircle Circle => SpellCircle.Sixth;
public override bool DelayedDamage => true;
public override Type[] DelayedDamageSpellFamilyStacking => AOSNoDelayedDamageStackingSelf;
public override Type[] DelayedDamageSpellFamilyStacking => AOSNoDelayedDamageStackingSelf;
public override void OnCast()
{
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful);
}
public void Target(Mobile m)
{
public void Target(Mobile m)
{
if (CheckHSequence(m))
{
SpellHelper.Turn(Caster, m);
@ -85,5 +85,4 @@ namespace Server.Spells.Mysticism
FinishSequence();
}
}
}
}

View file

@ -5,212 +5,211 @@ using Server.Spells.Necromancy;
using Server.Targeting;
using Server.Collections;
namespace Server.Spells.Mysticism
namespace Server.Spells.Mysticism;
public class CleansingWindsSpell : MysticSpell, ISpellTargetingMobile
{
public class CleansingWindsSpell : MysticSpell, ISpellTargetingMobile
public override SpellCircle Circle => SpellCircle.Sixth;
private static readonly SpellInfo _info = new(
"Cleansing Winds", "In Vas Mani Hur",
230,
9022,
Reagent.Garlic,
Reagent.Ginseng,
Reagent.MandrakeRoot,
Reagent.DragonsBlood
);
public CleansingWindsSpell(Mobile caster, Item scroll) : base(caster, scroll, _info)
{
public override SpellCircle Circle => SpellCircle.Sixth;
}
private static readonly SpellInfo _info = new(
"Cleansing Winds", "In Vas Mani Hur",
230,
9022,
Reagent.Garlic,
Reagent.Ginseng,
Reagent.MandrakeRoot,
Reagent.DragonsBlood
);
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial);
}
public CleansingWindsSpell(Mobile caster, Item scroll) : base(caster, scroll, _info)
public void Target(Mobile m)
{
if (CheckBSequence(m))
{
}
/**
* Soothing winds attempt to neutralize poisons, lift curses,
* and heal a valid target and up to 3 party members.
*/
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Beneficial);
}
Caster.PlaySound(0x64C);
public void Target(Mobile m)
{
if (CheckBSequence(m))
var primarySkill = GetBaseSkill(Caster);
var secondarySkill = GetDamageSkill(Caster);
var cureChance = 10000 + (int)((primarySkill + secondarySkill) / 2 * 75);
using var pool = PooledRefQueue<Mobile>.Create();
pool.Enqueue(m);
var casterParty = Party.Get(Caster);
if (casterParty != null)
{
/**
* Soothing winds attempt to neutralize poisons, lift curses,
* and heal a valid target and up to 3 party members.
*/
Caster.PlaySound(0x64C);
var primarySkill = GetBaseSkill(Caster);
var secondarySkill = GetDamageSkill(Caster);
var cureChance = 10000 + (int)((primarySkill + secondarySkill) / 2 * 75);
using var pool = PooledRefQueue<Mobile>.Create();
pool.Enqueue(m);
var casterParty = Party.Get(Caster);
if (casterParty != null)
foreach (Mobile mob in Caster.Map.GetMobilesInRange(m.Location, 2))
{
foreach (Mobile mob in Caster.Map.GetMobilesInRange(m.Location, 2))
if (mob != m && casterParty.Contains(mob) && Caster.CanBeBeneficial(mob, false))
{
if (mob != m && casterParty.Contains(mob) && Caster.CanBeBeneficial(mob, false))
pool.Enqueue(mob);
if (pool.Count == 4)
{
pool.Enqueue(mob);
if (pool.Count == 4)
{
break;
}
break;
}
}
}
}
var toHeal = ((int)((primarySkill + secondarySkill) / 4.0) + Utility.RandomMinMax(-3, 3)) / pool.Count;
var toHeal = ((int)((primarySkill + secondarySkill) / 4.0) + Utility.RandomMinMax(-3, 3)) / pool.Count;
while (pool.Count > 0)
while (pool.Count > 0)
{
var target = pool.Dequeue();
Caster.DoBeneficial(target);
target.FixedParticles(0x3709, 1, 30, 9963, 13, 3, EffectLayer.Head);
var from = new Entity(Serial.Zero, new Point3D(target.X, target.Y, target.Z - 10), target.Map);
var to = new Entity(Serial.Zero, new Point3D(target.X, target.Y, target.Z + 50), target.Map);
Effects.SendMovingParticles(
from,
to,
0x2255,
1,
0,
false,
false,
13,
3,
9501,
1,
0,
EffectLayer.Head,
0x100
);
var toHealMod = toHeal;
if (target.Poisoned)
{
var target = pool.Dequeue();
var poisonLevel = target.Poison.Level + 1;
var chanceToCure = cureChance - poisonLevel * 1750;
Caster.DoBeneficial(target);
target.FixedParticles(0x3709, 1, 30, 9963, 13, 3, EffectLayer.Head);
var from = new Entity(Serial.Zero, new Point3D(target.X, target.Y, target.Z - 10), target.Map);
var to = new Entity(Serial.Zero, new Point3D(target.X, target.Y, target.Z + 50), target.Map);
Effects.SendMovingParticles(
from,
to,
0x2255,
1,
0,
false,
false,
13,
3,
9501,
1,
0,
EffectLayer.Head,
0x100
);
var toHealMod = toHeal;
if (target.Poisoned)
if (chanceToCure > 10000 || chanceToCure > Utility.Random(10000) && target.CurePoison(Caster))
{
var poisonLevel = target.Poison.Level + 1;
var chanceToCure = cureChance - poisonLevel * 1750;
if (chanceToCure > 10000 || chanceToCure > Utility.Random(10000) && target.CurePoison(Caster))
{
toHealMod -= (int)(toHeal * poisonLevel * 0.15);
}
else
{
toHealMod = 0;
}
toHealMod -= (int)(toHeal * poisonLevel * 0.15);
}
if (MortalStrike.IsWounded(target))
else
{
toHealMod = 0;
}
}
var curseLevel = RemoveCurses(target);
if (MortalStrike.IsWounded(target))
{
toHealMod = 0;
}
if (toHealMod > 0 && curseLevel > 0)
{
toHealMod -= curseLevel * 3;
toHealMod -= (int)(toHealMod * (curseLevel / 100.0));
}
var curseLevel = RemoveCurses(target);
if (toHealMod > 0)
{
SpellHelper.Heal(toHealMod, target, Caster);
}
if (toHealMod > 0 && curseLevel > 0)
{
toHealMod -= curseLevel * 3;
toHealMod -= (int)(toHealMod * (curseLevel / 100.0));
}
if (toHealMod > 0)
{
SpellHelper.Heal(toHealMod, target, Caster);
}
}
FinishSequence();
}
public static int RemoveCurses(Mobile m)
{
var curseLevel = 0;
// if (SleepSpell.EndSleep(m))
// {
// curseLevel += 2;
// }
if (EvilOmenSpell.EndEffect(m))
{
curseLevel += 1;
}
if (StrangleSpell.RemoveCurse(m))
{
curseLevel += 2;
}
if (CorpseSkinSpell.RemoveCurse(m))
{
curseLevel += 3;
}
if (CurseSpell.RemoveEffect(m))
{
curseLevel += 4;
}
if (BloodOathSpell.RemoveCurse(m))
{
curseLevel += 3;
}
if (MindRotSpell.ClearMindRotScalar(m))
{
curseLevel += 2;
}
if (SpellPlagueSpell.RemoveEffect(m))
{
curseLevel += 4;
}
var mod = m.GetStatMod("[Magic] Str Curse");
if (mod?.Offset < 0)
{
m.RemoveStatMod("[Magic] Str Curse");
}
mod = m.GetStatMod("[Magic] Dex Curse");
if (mod?.Offset < 0)
{
m.RemoveStatMod("[Magic] Dex Curse");
}
mod = m.GetStatMod("[Magic] Int Curse");
if (mod?.Offset < 0)
{
m.RemoveStatMod("[Magic] Int Curse");
}
if (MortalStrike.EndWound(m))
{
curseLevel += 2;
}
BuffInfo.RemoveBuff(m, BuffIcon.Clumsy);
BuffInfo.RemoveBuff(m, BuffIcon.FeebleMind);
BuffInfo.RemoveBuff(m, BuffIcon.Weaken);
BuffInfo.RemoveBuff(m, BuffIcon.Curse);
BuffInfo.RemoveBuff(m, BuffIcon.MassCurse);
BuffInfo.RemoveBuff(m, BuffIcon.MortalStrike);
BuffInfo.RemoveBuff(m, BuffIcon.CorpseSkin);
BuffInfo.RemoveBuff(m, BuffIcon.Strangle);
BuffInfo.RemoveBuff(m, BuffIcon.EvilOmen);
return curseLevel;
}
FinishSequence();
}
}
public static int RemoveCurses(Mobile m)
{
var curseLevel = 0;
// if (SleepSpell.EndSleep(m))
// {
// curseLevel += 2;
// }
if (EvilOmenSpell.EndEffect(m))
{
curseLevel += 1;
}
if (StrangleSpell.RemoveCurse(m))
{
curseLevel += 2;
}
if (CorpseSkinSpell.RemoveCurse(m))
{
curseLevel += 3;
}
if (CurseSpell.RemoveEffect(m))
{
curseLevel += 4;
}
if (BloodOathSpell.RemoveCurse(m))
{
curseLevel += 3;
}
if (MindRotSpell.ClearMindRotScalar(m))
{
curseLevel += 2;
}
if (SpellPlagueSpell.RemoveEffect(m))
{
curseLevel += 4;
}
var mod = m.GetStatMod("[Magic] Str Curse");
if (mod?.Offset < 0)
{
m.RemoveStatMod("[Magic] Str Curse");
}
mod = m.GetStatMod("[Magic] Dex Curse");
if (mod?.Offset < 0)
{
m.RemoveStatMod("[Magic] Dex Curse");
}
mod = m.GetStatMod("[Magic] Int Curse");
if (mod?.Offset < 0)
{
m.RemoveStatMod("[Magic] Int Curse");
}
if (MortalStrike.EndWound(m))
{
curseLevel += 2;
}
BuffInfo.RemoveBuff(m, BuffIcon.Clumsy);
BuffInfo.RemoveBuff(m, BuffIcon.FeebleMind);
BuffInfo.RemoveBuff(m, BuffIcon.Weaken);
BuffInfo.RemoveBuff(m, BuffIcon.Curse);
BuffInfo.RemoveBuff(m, BuffIcon.MassCurse);
BuffInfo.RemoveBuff(m, BuffIcon.MortalStrike);
BuffInfo.RemoveBuff(m, BuffIcon.CorpseSkin);
BuffInfo.RemoveBuff(m, BuffIcon.Strangle);
BuffInfo.RemoveBuff(m, BuffIcon.EvilOmen);
return curseLevel;
}
}

View file

@ -1,77 +1,76 @@
using System;
using Server.Targeting;
namespace Server.Spells.Mysticism
namespace Server.Spells.Mysticism;
public class EagleStrikeSpell : MysticSpell, ISpellTargetingMobile
{
public class EagleStrikeSpell : MysticSpell, ISpellTargetingMobile
private static readonly SpellInfo _info = new(
"Eagle Strike",
"Kal Por Xen",
-1,
9002,
Reagent.Bloodmoss,
Reagent.Bone,
Reagent.SpidersSilk,
Reagent.MandrakeRoot
);
public EagleStrikeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
private static readonly SpellInfo _info = new(
"Eagle Strike",
"Kal Por Xen",
-1,
9002,
Reagent.Bloodmoss,
Reagent.Bone,
Reagent.SpidersSilk,
Reagent.MandrakeRoot
);
}
public EagleStrikeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
public override SpellCircle Circle => SpellCircle.Third;
public void Target(Mobile m)
{
if (CheckHSequence(m))
{
}
SpellHelper.Turn(Caster, m);
public override SpellCircle Circle => SpellCircle.Third;
public void Target(Mobile m)
{
if (CheckHSequence(m))
{
SpellHelper.Turn(Caster, m);
if (Core.SA && HasDelayedDamageContext(m))
{
DoHurtFizzle();
return;
}
var source = Caster;
if (SpellHelper.CheckReflect(2, ref source, ref m))
{
Timer.StartTimer(TimeSpan.FromSeconds(0.5), () =>
{
/* Conjures a magical eagle that assaults the Target with its talons, dealing energy damage. */
source.MovingEffect(m, 0x407A, 8, 1, false, true, 0, 0);
source.PlaySound(0x2EE);
});
}
Caster.MovingParticles(m, 0x407A, 7, 0, false, true, 0, 0, 0xBBE, 0xFA6, 0xFFFF, 0);
Caster.PlaySound(0x2EE);
Timer.StartTimer(TimeSpan.FromSeconds(1.0), () => Damage(m));
}
FinishSequence();
}
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful);
}
private void Damage(Mobile to)
{
if (to == null)
if (Core.SA && HasDelayedDamageContext(m))
{
DoHurtFizzle();
return;
}
double damage = GetNewAosDamage(19, 1, 5, to);
var source = Caster;
SpellHelper.Damage(this, to, damage, 0, 0, 0, 0, 100);
if (SpellHelper.CheckReflect(2, ref source, ref m))
{
Timer.StartTimer(TimeSpan.FromSeconds(0.5), () =>
{
/* Conjures a magical eagle that assaults the Target with its talons, dealing energy damage. */
source.MovingEffect(m, 0x407A, 8, 1, false, true, 0, 0);
source.PlaySound(0x2EE);
});
}
to.PlaySound(0x64D);
Caster.MovingParticles(m, 0x407A, 7, 0, false, true, 0, 0, 0xBBE, 0xFA6, 0xFFFF, 0);
Caster.PlaySound(0x2EE);
Timer.StartTimer(TimeSpan.FromSeconds(1.0), () => Damage(m));
}
FinishSequence();
}
}
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful);
}
private void Damage(Mobile to)
{
if (to == null)
{
return;
}
double damage = GetNewAosDamage(19, 1, 5, to);
SpellHelper.Damage(this, to, damage, 0, 0, 0, 0, 100);
to.PlaySound(0x64D);
}
}

View file

@ -1,126 +1,125 @@
using Server.Collections;
namespace Server.Spells.Mysticism
namespace Server.Spells.Mysticism;
public class HailStormSpell : MysticSpell, ISpellTargetingPoint3D
{
public class HailStormSpell : MysticSpell, ISpellTargetingPoint3D
private static readonly SpellInfo _info = new(
"Hail Storm",
"Kal Des Ylem",
-1,
9002,
Reagent.DragonsBlood,
Reagent.Bloodmoss,
Reagent.BlackPearl,
Reagent.MandrakeRoot
);
public HailStormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
private static readonly SpellInfo _info = new(
"Hail Storm",
"Kal Des Ylem",
-1,
9002,
Reagent.DragonsBlood,
Reagent.Bloodmoss,
Reagent.BlackPearl,
Reagent.MandrakeRoot
);
}
public HailStormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
public override SpellCircle Circle => SpellCircle.Seventh;
public override int GetMana() => 50;
public void Target(IPoint3D p)
{
var loc = (p as Item)?.GetWorldLocation() ?? new Point3D(p);
if (SpellHelper.CheckTown(loc, Caster) && CheckSequence())
{
}
/* Summons a storm of hailstones that strikes all Targets within a radius around the Target's Location,
* dealing cold damage.
*/
public override SpellCircle Circle => SpellCircle.Seventh;
public override int GetMana() => 50;
SpellHelper.Turn(Caster, p);
public void Target(IPoint3D p)
{
var loc = (p as Item)?.GetWorldLocation() ?? new Point3D(p);
var map = Caster.Map;
if (SpellHelper.CheckTown(loc, Caster) && CheckSequence())
if (map != null)
{
/* Summons a storm of hailstones that strikes all Targets within a radius around the Target's Location,
* dealing cold damage.
*/
using var pool = PooledRefQueue<Mobile>.Create();
var pvp = false;
SpellHelper.Turn(Caster, p);
PlayEffect(loc, Caster.Map);
var map = Caster.Map;
if (map != null)
foreach (var m in map.GetMobilesInRange(loc, 2))
{
using var pool = PooledRefQueue<Mobile>.Create();
var pvp = false;
PlayEffect(loc, Caster.Map);
foreach (var m in map.GetMobilesInRange(loc, 2))
if (m == Caster || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanBeHarmful(m, false)
|| !Caster.CanSee(m) || !Caster.InLOS(m))
{
if (m == Caster || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanBeHarmful(m, false)
|| !Caster.CanSee(m) || !Caster.InLOS(m))
{
continue;
}
pool.Enqueue(m);
if (m.Player)
{
pvp = true;
}
continue;
}
double damage = GetNewAosDamage(51, 1, 5, pvp);
pool.Enqueue(m);
while (pool.Count > 0)
if (m.Player)
{
var m = pool.Dequeue();
Caster.DoHarmful(m);
SpellHelper.Damage(this, m, damage, 0, 0, 100, 0, 0);
pvp = true;
}
}
double damage = GetNewAosDamage(51, 1, 5, pvp);
while (pool.Count > 0)
{
var m = pool.Dequeue();
Caster.DoHarmful(m);
SpellHelper.Damage(this, m, damage, 0, 0, 100, 0, 0);
}
}
FinishSequence();
}
public override void OnCast()
{
Caster.Target = new SpellTargetPoint3D(this);
}
private static void PlayEffect(Point3D p, Map map)
{
Effects.PlaySound(p, map, 0x64F);
PlaySingleEffect(p, map, -1, 1, -1, 1);
PlaySingleEffect(p, map, -2, 0, -3, -1);
PlaySingleEffect(p, map, -3, -1, -1, 1);
PlaySingleEffect(p, map, 1, 3, -1, 1);
PlaySingleEffect(p, map, -1, 1, 1, 3);
}
private static void PlaySingleEffect(Point3D p, Map map, int a, int b, int c, int d)
{
var x = p.X;
var y = p.Y;
var z = p.Z + 18;
SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + c, z));
SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + b, y + c, z));
SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + d, z));
SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + a, y + d, z));
SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + a, y + c, z));
SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + c, z));
SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + b, y + d, z));
SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + d, z));
}
private static void SendEffectPacket(Point3D p, Map map, Point3D orig, Point3D dest)
{
Effects.SendMovingEffect(
p,
map,
0x36D4,
orig,
dest,
0,
0,
false,
false,
0x63,
0x4
);
}
FinishSequence();
}
}
public override void OnCast()
{
Caster.Target = new SpellTargetPoint3D(this);
}
private static void PlayEffect(Point3D p, Map map)
{
Effects.PlaySound(p, map, 0x64F);
PlaySingleEffect(p, map, -1, 1, -1, 1);
PlaySingleEffect(p, map, -2, 0, -3, -1);
PlaySingleEffect(p, map, -3, -1, -1, 1);
PlaySingleEffect(p, map, 1, 3, -1, 1);
PlaySingleEffect(p, map, -1, 1, 1, 3);
}
private static void PlaySingleEffect(Point3D p, Map map, int a, int b, int c, int d)
{
var x = p.X;
var y = p.Y;
var z = p.Z + 18;
SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + c, z));
SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + b, y + c, z));
SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + d, z));
SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + a, y + d, z));
SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + a, y + c, z));
SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + c, z));
SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + b, y + d, z));
SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + d, z));
}
private static void SendEffectPacket(Point3D p, Map map, Point3D orig, Point3D dest)
{
Effects.SendMovingEffect(
p,
map,
0x36D4,
orig,
dest,
0,
0,
false,
false,
0x63,
0x4
);
}
}

View file

@ -1,140 +1,139 @@
using System;
using Server.Items;
namespace Server.Spells.Mysticism
namespace Server.Spells.Mysticism;
public abstract class MysticSpell : Spell
{
public abstract class MysticSpell : Spell
private static int[] _manaTable = { 4, 6, 9, 11, 14, 20, 40, 50 };
private static double[] _requiredSkill = { 0.0, 8.0, 20.0, 33.0, 45.0, 58.0, 70.0, 83.0 };
public MysticSpell(Mobile caster, Item scroll, SpellInfo info) : base(caster, scroll, info)
{
private static int[] _manaTable = { 4, 6, 9, 11, 14, 20, 40, 50 };
private static double[] _requiredSkill = { 0.0, 8.0, 20.0, 33.0, 45.0, 58.0, 70.0, 83.0 };
}
public MysticSpell(Mobile caster, Item scroll, SpellInfo info) : base(caster, scroll, info)
public abstract SpellCircle Circle { get; }
public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(0.5 + 0.25 * (int)Circle);
public virtual double RequiredSkill
{
get
{
var circle = (int)Circle;
if (Scroll != null)
{
circle -= 2;
}
return _requiredSkill[circle];
}
}
public override SkillName CastSkill => SkillName.Mysticism;
/*
* As per OSI Publish 64:
* Imbuing is not the only skill associated with Mysticism now.
* Players can use EITHER their Focus skill or Imbuing skill.
* Evaluate Intelligence no longer has any effect on a Mystic’s spell power.
*/
public override double GetDamageSkill(Mobile m) => Math.Max(m.Skills.Imbuing.Value, m.Skills.Focus.Value);
public override int GetDamageFixed(Mobile m) => Math.Max(m.Skills.Imbuing.Fixed, m.Skills.Focus.Fixed);
public override void GetCastSkills(out double min, out double max)
{
var requiredSkill = RequiredSkill;
// As per Mysticism page at the UO Herald Playguide
// This means that we have 25% success chance at min Required Skill
min = requiredSkill - 12.5;
max = requiredSkill + 37.5;
}
public override int GetMana() => Scroll is BaseWand ? 0 : _manaTable[(int)Circle];
public override bool CheckCast()
{
if (!base.CheckCast())
{
return false;
}
public abstract SpellCircle Circle { get; }
var mana = ScaleMana(GetMana());
public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(0.5 + 0.25 * (int)Circle);
public virtual double RequiredSkill
if (Caster.Mana < mana)
{
get
{
var circle = (int)Circle;
if (Scroll != null)
{
circle -= 2;
}
return _requiredSkill[circle];
}
// You must have at least ~1_MANA_REQUIREMENT~ Mana to use this ability.
Caster.SendLocalizedMessage(1060174, mana.ToString());
return false;
}
public override SkillName CastSkill => SkillName.Mysticism;
var requiredSkill = RequiredSkill;
/*
* As per OSI Publish 64:
* Imbuing is not the only skill associated with Mysticism now.
* Players can use EITHER their Focus skill or Imbuing skill.
* Evaluate Intelligence no longer has any effect on a Mystic’s spell power.
*/
public override double GetDamageSkill(Mobile m) => Math.Max(m.Skills.Imbuing.Value, m.Skills.Focus.Value);
public override int GetDamageFixed(Mobile m) => Math.Max(m.Skills.Imbuing.Fixed, m.Skills.Focus.Fixed);
public override void GetCastSkills(out double min, out double max)
if (Caster.Skills[CastSkill].Value < requiredSkill)
{
var requiredSkill = RequiredSkill;
// As per Mysticism page at the UO Herald Playguide
// This means that we have 25% success chance at min Required Skill
min = requiredSkill - 12.5;
max = requiredSkill + 37.5;
// You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability.
Caster.SendLocalizedMessage(1063013, $"{requiredSkill:F1}\t{CastSkill}\t ");
return false;
}
public override int GetMana() => Scroll is BaseWand ? 0 : _manaTable[(int)Circle];
return true;
}
public override bool CheckCast()
public override void OnBeginCast()
{
base.OnBeginCast();
SendCastEffect();
}
public virtual void SendCastEffect()
{
Caster.FixedEffect(0x37C4, 10, (int)(GetCastDelay().TotalSeconds * 28), 0x66C, 3);
}
public static double GetBaseSkill(Mobile m) => m.Skills.Mysticism.Value;
public virtual bool CheckResisted(Mobile target)
{
var n = GetResistPercent(target);
n /= 100.0;
if (n <= 0.0)
{
if (!base.CheckCast())
{
return false;
}
var mana = ScaleMana(GetMana());
if (Caster.Mana < mana)
{
// You must have at least ~1_MANA_REQUIREMENT~ Mana to use this ability.
Caster.SendLocalizedMessage(1060174, mana.ToString());
return false;
}
var requiredSkill = RequiredSkill;
if (Caster.Skills[CastSkill].Value < requiredSkill)
{
// You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability.
Caster.SendLocalizedMessage(1063013, $"{requiredSkill:F1}\t{CastSkill}\t ");
return false;
}
return false;
}
if (n >= 1.0)
{
return true;
}
public override void OnBeginCast()
{
base.OnBeginCast();
var maxSkill = (1 + (int)Circle) * 10;
maxSkill += (1 + (int)Circle / 6) * 25;
SendCastEffect();
if (target.Skills.MagicResist.Value < maxSkill)
{
target.CheckSkill(SkillName.MagicResist, 0.0, target.Skills.MagicResist.Cap);
}
public virtual void SendCastEffect()
{
Caster.FixedEffect(0x37C4, 10, (int)(GetCastDelay().TotalSeconds * 28), 0x66C, 3);
}
public static double GetBaseSkill(Mobile m) => m.Skills.Mysticism.Value;
public virtual bool CheckResisted(Mobile target)
{
var n = GetResistPercent(target);
n /= 100.0;
if (n <= 0.0)
{
return false;
}
if (n >= 1.0)
{
return true;
}
var maxSkill = (1 + (int)Circle) * 10;
maxSkill += (1 + (int)Circle / 6) * 25;
if (target.Skills.MagicResist.Value < maxSkill)
{
target.CheckSkill(SkillName.MagicResist, 0.0, target.Skills.MagicResist.Cap);
}
return n >= Utility.RandomDouble();
}
public virtual double GetResistPercentForCircle(Mobile target, SpellCircle circle)
{
var magicResist = target.Skills.MagicResist.Value;
var firstPercent = magicResist / 5.0;
var secondPercent = magicResist -
((Caster.Skills[CastSkill].Value - 20.0) / 5.0 + (1 + (int)circle) * 5.0);
// Seems should be about half of what stratics says.
return (firstPercent > secondPercent ? firstPercent : secondPercent) / 2.0;
}
public virtual double GetResistPercent(Mobile target) => GetResistPercentForCircle(target, Circle);
return n >= Utility.RandomDouble();
}
}
public virtual double GetResistPercentForCircle(Mobile target, SpellCircle circle)
{
var magicResist = target.Skills.MagicResist.Value;
var firstPercent = magicResist / 5.0;
var secondPercent = magicResist -
((Caster.Skills[CastSkill].Value - 20.0) / 5.0 + (1 + (int)circle) * 5.0);
// Seems should be about half of what stratics says.
return (firstPercent > secondPercent ? firstPercent : secondPercent) / 2.0;
}
public virtual double GetResistPercent(Mobile target) => GetResistPercentForCircle(target, Circle);
}

View file

@ -1,140 +1,139 @@
using Server.Collections;
namespace Server.Spells.Mysticism
namespace Server.Spells.Mysticism;
public class NetherCycloneSpell : MysticSpell, ISpellTargetingPoint3D
{
public class NetherCycloneSpell : MysticSpell, ISpellTargetingPoint3D
private static readonly SpellInfo _info = new(
"Nether Cyclone",
"Grav Hur",
-1,
9002,
Reagent.MandrakeRoot,
Reagent.Nightshade,
Reagent.SulfurousAsh,
Reagent.Bloodmoss
);
public NetherCycloneSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
private static readonly SpellInfo _info = new(
"Nether Cyclone",
"Grav Hur",
-1,
9002,
Reagent.MandrakeRoot,
Reagent.Nightshade,
Reagent.SulfurousAsh,
Reagent.Bloodmoss
);
}
public NetherCycloneSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
public override SpellCircle Circle => SpellCircle.Eighth;
public void Target(IPoint3D p)
{
var loc = (p as Item)?.GetWorldLocation() ?? new Point3D(p);
if (SpellHelper.CheckTown(loc, Caster) && CheckSequence())
{
}
/* Summons a gale of lethal winds that strikes all Targets within a radius around
* the Target's Location, dealing chaos damage. In addition to inflicting damage,
* each Target of the Nether Cyclone temporarily loses a percentage of mana and
* stamina. The effectiveness of the Nether Cyclone is determined by a comparison
* between the Caster's Mysticism and either Focus or Imbuing (whichever is greater)
* skills and the Resisting Spells skill of the Target.
*/
public override SpellCircle Circle => SpellCircle.Eighth;
SpellHelper.Turn(Caster, p);
public void Target(IPoint3D p)
{
var loc = (p as Item)?.GetWorldLocation() ?? new Point3D(p);
var map = Caster.Map;
if (SpellHelper.CheckTown(loc, Caster) && CheckSequence())
if (map != null)
{
/* Summons a gale of lethal winds that strikes all Targets within a radius around
* the Target's Location, dealing chaos damage. In addition to inflicting damage,
* each Target of the Nether Cyclone temporarily loses a percentage of mana and
* stamina. The effectiveness of the Nether Cyclone is determined by a comparison
* between the Caster's Mysticism and either Focus or Imbuing (whichever is greater)
* skills and the Resisting Spells skill of the Target.
*/
using var pool = PooledRefQueue<Mobile>.Create();
var pvp = false;
SpellHelper.Turn(Caster, p);
PlayEffect(loc, Caster.Map);
var map = Caster.Map;
if (map != null)
foreach (var m in map.GetMobilesInRange(loc, 2))
{
using var pool = PooledRefQueue<Mobile>.Create();
var pvp = false;
PlayEffect(loc, Caster.Map);
foreach (var m in map.GetMobilesInRange(loc, 2))
if (m == Caster)
{
if (m == Caster)
continue;
}
if (SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false) && Caster.CanSee(m))
{
if (!Caster.InLOS(m))
{
continue;
}
if (SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false) && Caster.CanSee(m))
pool.Enqueue(m);
if (m.Player)
{
if (!Caster.InLOS(m))
{
continue;
}
pool.Enqueue(m);
if (m.Player)
{
pvp = true;
}
pvp = true;
}
}
}
var damage = GetNewAosDamage(51, 1, 5, pvp);
var reduction = (GetBaseSkill(Caster) + GetDamageSkill(Caster)) / 1200.0;
var damage = GetNewAosDamage(51, 1, 5, pvp);
var reduction = (GetBaseSkill(Caster) + GetDamageSkill(Caster)) / 1200.0;
while (pool.Count > 0)
{
var m = pool.Dequeue();
Caster.DoHarmful(m);
SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 0, 100);
while (pool.Count > 0)
{
var m = pool.Dequeue();
Caster.DoHarmful(m);
SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 0, 100);
var resistedReduction = reduction - m.Skills.MagicResist.Value / 800.0;
var resistedReduction = reduction - m.Skills.MagicResist.Value / 800.0;
m.Stam -= (int)(m.StamMax * resistedReduction);
m.Mana -= (int)(m.ManaMax * resistedReduction);
}
m.Stam -= (int)(m.StamMax * resistedReduction);
m.Mana -= (int)(m.ManaMax * resistedReduction);
}
}
FinishSequence();
}
public override void OnCast()
{
Caster.Target = new SpellTargetPoint3D(this);
}
private static void PlayEffect(Point3D p, Map map)
{
Effects.PlaySound(p, map, 0x64F);
PlaySingleEffect(p, map, -1, 1, -1, 1);
PlaySingleEffect(p, map, -2, 0, -3, -1);
PlaySingleEffect(p, map, -3, -1, -1, 1);
PlaySingleEffect(p, map, 1, 3, -1, 1);
PlaySingleEffect(p, map, -1, 1, 1, 3);
}
private static void PlaySingleEffect(Point3D p, Map map, int a, int b, int c, int d)
{
int x = p.X, y = p.Y, z = p.Z + 18;
SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + c, z));
SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + b, y + c, z));
SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + d, z));
SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + a, y + d, z));
SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + a, y + c, z));
SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + c, z));
SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + b, y + d, z));
SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + d, z));
}
private static void SendEffectPacket(Point3D p, Map map, Point3D orig, Point3D dest)
{
Effects.SendMovingEffect(
p,
map,
0x375A,
orig,
dest,
0,
0,
false,
false,
0x49A,
0x4
);
}
FinishSequence();
}
}
public override void OnCast()
{
Caster.Target = new SpellTargetPoint3D(this);
}
private static void PlayEffect(Point3D p, Map map)
{
Effects.PlaySound(p, map, 0x64F);
PlaySingleEffect(p, map, -1, 1, -1, 1);
PlaySingleEffect(p, map, -2, 0, -3, -1);
PlaySingleEffect(p, map, -3, -1, -1, 1);
PlaySingleEffect(p, map, 1, 3, -1, 1);
PlaySingleEffect(p, map, -1, 1, 1, 3);
}
private static void PlaySingleEffect(Point3D p, Map map, int a, int b, int c, int d)
{
int x = p.X, y = p.Y, z = p.Z + 18;
SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + c, z));
SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + b, y + c, z));
SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + d, z));
SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + a, y + d, z));
SendEffectPacket(p, map, new Point3D(x + b, y + c, z), new Point3D(x + a, y + c, z));
SendEffectPacket(p, map, new Point3D(x + b, y + d, z), new Point3D(x + b, y + c, z));
SendEffectPacket(p, map, new Point3D(x + a, y + d, z), new Point3D(x + b, y + d, z));
SendEffectPacket(p, map, new Point3D(x + a, y + c, z), new Point3D(x + a, y + d, z));
}
private static void SendEffectPacket(Point3D p, Map map, Point3D orig, Point3D dest)
{
Effects.SendMovingEffect(
p,
map,
0x375A,
orig,
dest,
0,
0,
false,
false,
0x49A,
0x4
);
}
}

View file

@ -2,219 +2,199 @@ using System;
using System.Collections.Generic;
using Server.Targeting;
namespace Server.Spells.Mysticism
namespace Server.Spells.Mysticism;
public class SpellPlagueSpell : MysticSpell, ISpellTargetingMobile
{
public class SpellPlagueSpell : MysticSpell
private static readonly SpellInfo _info = new(
"Spell Plague",
"Vas Rel Jux Ort",
-1,
9002,
Reagent.DaemonBone,
Reagent.DragonsBlood,
Reagent.Nightshade,
Reagent.SulfurousAsh
);
private static readonly Dictionary<Mobile, SpellPlagueTimer> _table = new();
public SpellPlagueSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
private static readonly SpellInfo _info = new(
"Spell Plague",
"Vas Rel Jux Ort",
-1,
9002,
Reagent.DaemonBone,
Reagent.DragonsBlood,
Reagent.Nightshade,
Reagent.SulfurousAsh
);
}
private static readonly Dictionary<Mobile, SpellPlagueTimer> _table = new();
public override SpellCircle Circle => SpellCircle.Seventh;
public SpellPlagueSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
public static void Initialize()
{
EventSink.PlayerDeath += OnPlayerDeath;
}
public override void OnCast()
{
Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful);
}
public void Target(Mobile targeted)
{
if (CheckHSequence(targeted))
{
}
SpellHelper.Turn(Caster, targeted);
public override SpellCircle Circle => SpellCircle.Seventh;
SpellHelper.CheckReflect(6, Caster, ref targeted);
public static void Initialize()
{
EventSink.PlayerDeath += OnPlayerDeath;
}
/* The target is hit with an explosion of chaos damage and then inflicted
* with the spell plague curse. Each time the target is damaged while under
* the effect of the spell plague, they may suffer an explosion of chaos
* damage. The initial chance to trigger the explosion starts at 90% and
* reduces by 30% every time an explosion occurs. Once the target is
* afflicted by 3 explosions or 8 seconds have passed, that spell plague
* is removed from the target. Spell Plague will stack with other spell
* plagues so that they are applied one after the other.
*/
public override void OnCast()
{
Caster.Target = new InternalTarget(this);
}
VisualEffect(targeted);
public void Target(Mobile targeted)
{
if (CheckHSequence(targeted))
// Before Time of Legends, SDI was not applied to initial damage.
var damage = GetNewAosDamage(33, 1, 5, Core.TOL, targeted);
SpellHelper.Damage(this, targeted, damage, 0, 0, 0, 0, 0);
var timer = new SpellPlagueTimer(this, targeted);
if (_table.TryGetValue(targeted, out var oldtimer))
{
SpellHelper.Turn(Caster, targeted);
SpellHelper.CheckReflect(6, Caster, ref targeted);
/* The target is hit with an explosion of chaos damage and then inflicted
* with the spell plague curse. Each time the target is damaged while under
* the effect of the spell plague, they may suffer an explosion of chaos
* damage. The initial chance to trigger the explosion starts at 90% and
* reduces by 30% every time an explosion occurs. Once the target is
* afflicted by 3 explosions or 8 seconds have passed, that spell plague
* is removed from the target. Spell Plague will stack with other spell
* plagues so that they are applied one after the other.
*/
VisualEffect(targeted);
var damage = GetNewAosDamage(33, 1, 5, targeted);
SpellHelper.Damage(this, targeted, damage, 0, 0, 0, 0, 0);
var timer = new SpellPlagueTimer(this, targeted);
if (_table.TryGetValue(targeted, out var oldtimer))
{
oldtimer.SetNext(timer);
}
else
{
_table[targeted] = timer;
timer.StartPlague();
}
oldtimer.SetNext(timer);
}
FinishSequence();
}
public static bool UnderEffect(Mobile m) => _table.ContainsKey(m);
public static bool RemoveEffect(Mobile m)
{
if (_table.Remove(m, out var context))
else
{
context.Stop();
BuffInfo.RemoveBuff(m, BuffIcon.SpellPlague);
return true;
}
return false;
}
public static void CheckPlague(Mobile m)
{
if (_table.TryGetValue(m, out var context))
{
context.OnDamage();
_table[targeted] = timer;
timer.StartPlague();
}
}
private static void OnPlayerDeath(Mobile m)
FinishSequence();
}
public static bool UnderEffect(Mobile m) => _table.ContainsKey(m);
public static bool RemoveEffect(Mobile m)
{
if (_table.Remove(m, out var timer))
{
RemoveEffect(m);
timer.Stop();
BuffInfo.RemoveBuff(m, BuffIcon.SpellPlague);
return true;
}
protected void VisualEffect(Mobile to)
{
to.PlaySound(0x658);
return false;
}
to.FixedParticles(0x3728, 1, 13, 0x26B8, 0x47E, 7, EffectLayer.Head, 0);
to.FixedParticles(0x3779, 1, 15, 0x251E, 0x43, 7, EffectLayer.Head, 0);
public static void OnMobileDamaged(Mobile m)
{
if (m != null && _table.TryGetValue(m, out var context))
{
context.OnDamage();
}
}
private static void OnPlayerDeath(Mobile m) => RemoveEffect(m);
private static void VisualEffect(Mobile to)
{
to.PlaySound(0x658);
to.FixedParticles(0x3728, 1, 13, 0x26B8, 0x47E, 7, EffectLayer.Head, 0);
to.FixedParticles(0x3779, 1, 15, 0x251E, 0x43, 7, EffectLayer.Head, 0);
}
private class SpellPlagueTimer : Timer
{
private readonly SpellPlagueSpell _owner;
private readonly Mobile _target;
private int _explosions;
private DateTime _nextExplosion;
private SpellPlagueTimer _next;
public SpellPlagueTimer(SpellPlagueSpell owner, Mobile target) : base(TimeSpan.FromSeconds(8.0))
{
_owner = owner;
_target = target;
}
private class SpellPlagueTimer : Timer
public void SetNext(SpellPlagueTimer timer)
{
private readonly SpellPlagueSpell m_Owner;
private readonly Mobile m_Target;
private int m_Explosions;
private DateTime m_LastExploded;
private SpellPlagueTimer m_Next;
public SpellPlagueTimer(SpellPlagueSpell owner, Mobile target) : base(TimeSpan.FromSeconds(8.0))
if (_next == null)
{
m_Owner = owner;
m_Target = target;
_next = timer;
}
public void SetNext(SpellPlagueTimer timer)
else
{
if (m_Next == null)
{
m_Next = timer;
}
else
{
m_Next.SetNext(timer);
}
}
public void StartPlague()
{
BuffInfo.AddBuff(
m_Target,
new BuffInfo(BuffIcon.SpellPlague, 1031690, 1080167, TimeSpan.FromSeconds(8.5), m_Target)
);
Start();
}
public void OnDamage()
{
if (DateTime.Now <= m_LastExploded + TimeSpan.FromSeconds(2.0))
{
return;
}
var exploChance = 90 - m_Explosions * 30;
var resist = m_Target.Skills.MagicResist.Value;
if (resist >= 70)
{
exploChance -= (int)((resist - 70.0) * 3.0 / 10.0);
}
if (exploChance > Utility.Random(100))
{
m_Owner.VisualEffect(m_Target);
var damage = m_Owner.GetNewAosDamage(15 + m_Explosions * 3, 1, 5, m_Target);
m_Explosions++;
m_LastExploded = DateTime.Now;
SpellHelper.Damage(m_Owner, m_Target, damage, 0, 0, 0, 0, 0, 100);
if (m_Explosions >= 3)
{
EndPlague();
}
}
}
public void EndPlague()
{
if (m_Next != null)
{
_table[m_Target] = m_Next;
m_Next.StartPlague();
}
else
{
_table.Remove(m_Target);
BuffInfo.RemoveBuff(m_Target, BuffIcon.SpellPlague);
}
Stop();
_next.SetNext(timer);
}
}
private class InternalTarget : Target
public void StartPlague()
{
private readonly SpellPlagueSpell _owner;
BuffInfo.AddBuff(
_target,
new BuffInfo(BuffIcon.SpellPlague, 1031690, 1080167, TimeSpan.FromSeconds(8.5), _target)
);
public InternalTarget(SpellPlagueSpell owner) : base(12, false, TargetFlags.Harmful) =>
_owner = owner;
_nextExplosion = Core.Now + TimeSpan.FromSeconds(1);
Start();
}
protected override void OnTarget(Mobile from, object o)
public void OnDamage()
{
if (Core.Now < _nextExplosion)
{
if (o is Mobile mobile)
return;
}
var exploChance = 90 - _explosions * 30;
var resist = _target.Skills.MagicResist.Fixed - 700;
if (resist > 0)
{
exploChance -= resist / 100 * 3;
}
if (exploChance > Utility.Random(100))
{
VisualEffect(_target);
var damage = _owner.GetNewAosDamage(15 + _explosions * 3, 1, 5, false, _target);
_explosions++;
_nextExplosion = Core.Now + TimeSpan.FromSeconds(1);
SpellHelper.Damage(_owner, _target, damage, 0, 0, 0, 0, 0, 100);
if (_explosions >= 3)
{
_owner.Target(mobile);
DoNextPlague();
}
}
}
protected override void OnTargetFinish(Mobile from)
protected override void OnTick() => DoNextPlague();
private void DoNextPlague()
{
if (_next != null)
{
_owner.FinishSequence();
_table[_target] = _next;
_next.StartPlague();
}
else
{
_table.Remove(_target);
BuffInfo.RemoveBuff(_target, BuffIcon.SpellPlague);
}
_next = null;
Stop();
}
}
}