## Summary
Pre-AOS, a Meteor Swarm target that resists should take half of its share of the damage. Instead the resist branch halves the **shared** `damage` variable:
```csharp
var toDeal = damage;
if (!Core.AOS && CheckResisted(m))
{
damage *= 0.5; // should be toDeal
```
`toDeal` has already been copied, so:
- the target that resisted takes **full** damage, and
- every target processed after it is halved, once per earlier resist, so a group where several resist ends up taking a fraction of the intended damage for reasons unrelated to their own resist.
`ChainLightning` already handles this correctly (`toDeal *= 0.5;`), and this change makes Meteor Swarm match it. The AOS path is unaffected, since resist checks only run pre-AOS.
The bug predates ModernUO (it was carried over from RunUO in the first alpha).
## Testing
- `dotnet build Projects/UOContent/UOContent.csproj`: 0 warnings, 0 errors.
- No unit test: the per-target damage sits inside `Target()`'s queue loop alongside a random resist roll, so testing it would mean refactoring the spell for a one-word fix. Happy to factor out a helper and add one if preferred.
110 lines
3.4 KiB
C#
110 lines
3.4 KiB
C#
using Server.Collections;
|
|
|
|
namespace Server.Spells.Seventh
|
|
{
|
|
public class MeteorSwarmSpell : MagerySpell, ITargetingSpell<IPoint3D>
|
|
{
|
|
private static readonly SpellInfo _info = new(
|
|
"Meteor Swarm",
|
|
"Flam Kal Des Ylem",
|
|
233,
|
|
9042,
|
|
false,
|
|
Reagent.Bloodmoss,
|
|
Reagent.MandrakeRoot,
|
|
Reagent.SulfurousAsh,
|
|
Reagent.SpidersSilk
|
|
);
|
|
|
|
public MeteorSwarmSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
|
|
{
|
|
}
|
|
|
|
public override SpellCircle Circle => SpellCircle.Seventh;
|
|
|
|
public override bool DelayedDamage => true;
|
|
|
|
public void Target(IPoint3D p)
|
|
{
|
|
if (SpellHelper.CheckTown(p, Caster) && CheckSequence())
|
|
{
|
|
SpellHelper.Turn(Caster, p);
|
|
|
|
if (p is Item item)
|
|
{
|
|
p = item.GetWorldLocation();
|
|
}
|
|
|
|
var map = Caster.Map;
|
|
|
|
var playerVsPlayer = false;
|
|
var loc = new Point3D(p);
|
|
|
|
if (map != null)
|
|
{
|
|
using var queue = PooledRefQueue<Mobile>.Create();
|
|
foreach (var m in map.GetMobilesInRange(loc, 2))
|
|
{
|
|
if (Caster == m || !SpellHelper.ValidIndirectTarget(Caster, m) ||
|
|
!Caster.CanBeHarmful(m, false) || Core.AOS && !Caster.InLOS(m))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (m.Player)
|
|
{
|
|
playerVsPlayer = true;
|
|
}
|
|
|
|
queue.Enqueue(m);
|
|
}
|
|
|
|
double damage = Core.AOS
|
|
? GetNewAosDamage(51, 1, 5, playerVsPlayer)
|
|
: Utility.Random(27, 22);
|
|
|
|
var count = queue.Count;
|
|
|
|
if (count > 0)
|
|
{
|
|
Effects.PlaySound(loc, Caster.Map, 0x160);
|
|
|
|
if (Core.AOS && count > 2)
|
|
{
|
|
damage = damage * 2 / count;
|
|
}
|
|
else if (!Core.AOS)
|
|
{
|
|
damage /= count;
|
|
}
|
|
|
|
while (queue.Count > 0)
|
|
{
|
|
var m = queue.Dequeue();
|
|
|
|
var toDeal = damage;
|
|
|
|
if (!Core.AOS && CheckResisted(m))
|
|
{
|
|
toDeal *= 0.5;
|
|
|
|
m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy.
|
|
}
|
|
|
|
toDeal *= GetDamageScalar(m);
|
|
Caster.DoHarmful(m);
|
|
SpellHelper.Damage(this, m, toDeal, 0, 100, 0, 0, 0);
|
|
|
|
Caster.MovingParticles(m, 0x36D4, 7, 0, false, true, 9501, 1, 0, 0x100);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void OnCast()
|
|
{
|
|
Caster.Target = new SpellTarget<IPoint3D>(this, allowGround: true);
|
|
}
|
|
}
|
|
}
|