## Summary Implements T2A-accurate mechanics for the three defensive spells based on UO98 demo scripts. Pre-UOR (`!Core.UOR`) triggers the new behavior; UOR and AOS paths are unchanged. - **Reactive Armor**: percentage-based melee damage reflection (10-35% based on target Magery), targeted, timed (25-75s). Guards exempt, ranged attacks beyond 1 tile unaffected. Reflected damage is sourceless. - **Protection**: temporary AC bonus (casterMagery/10, 1-10 AR) via VirtualArmorMod, targeted, timed (12-120s). Shared table with Arch Protection — only one protection buff per mobile. - **Magic Reflect**: single-use spell reflection using MagicDamageAbsorb as a flag. No timer, no DefensiveSpell lock. Consumed on first reflected spell. - **Arch Protection**: T2A path applies Protection via shared table with area sound (0x1F7 vs 0x1ED). - No DefensiveSpell mutual exclusion for T2A — all three spells operate independently. ## Test plan - [x] Set expansion to T2A - [x] Cast Reactive Armor on self → verify particles (0x376A) and sound (0x1F2) - [x] Get hit in melee → verify attacker takes reflected damage with spark effect and sound - [x] Get hit by ranged weapon from > 1 tile → verify no reflection - [x] Wait for RA to expire → verify effect ends silently - [x] Cast RA on target that already has it → verify "This spell is already in effect" - [x] Cast Protection on another player → verify particles (0x375A) and sound (0x1ED) - [x] Check target's AR → verify it increased by casterMagery/10 - [x] Wait for Protection to expire → verify AR returns to normal - [x] Cast Protection on self, then cast Protection on another player → verify both succeed - [x] Cast Arch Protection on ground near allies → verify each gets AR bonus with sound 0x1F7 - [x] Cast Arch Protection near a target already protected → verify that target is skipped - [x] Cast Magic Reflect on self → verify particles (0x375A) and sound (0x1E9) - [x] Have an enemy cast a harmful spell at you → verify spell reflects back, effect consumed - [x] Cast Magic Reflect again → verify it can be recast after consumption - [x] Cast Magic Reflect when already active → verify "This spell is already in effect" - [x] Verify all three spells can be active simultaneously on the same mobile - [x] Switch expansion to UOR → verify existing UOR behavior unchanged - [x] Switch expansion to AOS → verify existing AOS behavior unchanged
142 lines
4.3 KiB
C#
142 lines
4.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Server.Collections;
|
|
using Server.Engines.PartySystem;
|
|
using Server.Spells.Second;
|
|
|
|
namespace Server.Spells.Fourth
|
|
{
|
|
public class ArchProtectionSpell : MagerySpell, ITargetingSpell<IPoint3D>
|
|
{
|
|
private static readonly SpellInfo _info = new(
|
|
"Arch Protection",
|
|
"Vas Uus Sanct",
|
|
Core.AOS ? 239 : 215,
|
|
9011,
|
|
Reagent.Garlic,
|
|
Reagent.Ginseng,
|
|
Reagent.MandrakeRoot,
|
|
Reagent.SulfurousAsh
|
|
);
|
|
|
|
private static readonly Dictionary<Mobile, int> _table = new();
|
|
|
|
public ArchProtectionSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
|
|
{
|
|
}
|
|
|
|
public override SpellCircle Circle => SpellCircle.Fourth;
|
|
|
|
public void Target(IPoint3D p)
|
|
{
|
|
if (Caster.Map == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (CheckSequence())
|
|
{
|
|
SpellHelper.Turn(Caster, p);
|
|
SpellHelper.GetSurfaceTop(ref p);
|
|
|
|
var loc = new Point3D(p);
|
|
|
|
if (!Core.AOS)
|
|
{
|
|
Effects.PlaySound(loc, Caster.Map, 0x299);
|
|
}
|
|
|
|
using var targets = PooledRefQueue<Mobile>.Create();
|
|
foreach (var m in Caster.Map.GetMobilesInRange(loc, Core.AOS ? 2 : 3))
|
|
{
|
|
if (Caster.CanBeBeneficial(m, false))
|
|
{
|
|
targets.Enqueue(m);
|
|
}
|
|
}
|
|
|
|
if (Core.AOS)
|
|
{
|
|
var party = Party.Get(Caster);
|
|
|
|
while (targets.Count > 0)
|
|
{
|
|
var m = targets.Dequeue();
|
|
if (m == Caster || party?.Contains(m) == true)
|
|
{
|
|
Caster.DoBeneficial(m);
|
|
ProtectionSpell.Toggle(Caster, m);
|
|
}
|
|
}
|
|
}
|
|
else if (!Core.UOR)
|
|
{
|
|
while (targets.Count > 0)
|
|
{
|
|
var m = targets.Dequeue();
|
|
if (!ProtectionSpell.HasT2AProtection(m))
|
|
{
|
|
Caster.DoBeneficial(m);
|
|
ProtectionSpell.ApplyT2AProtection(Caster, m);
|
|
m.PlaySound(0x1F7);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var val = (int)(Caster.Skills.Magery.Value / 10.0 + 1);
|
|
|
|
while (targets.Count > 0)
|
|
{
|
|
var m = targets.Dequeue();
|
|
if (m.BeginAction<ArchProtectionSpell>())
|
|
{
|
|
Caster.DoBeneficial(m);
|
|
m.VirtualArmorMod += val;
|
|
|
|
AddEntry(m, val);
|
|
new InternalTimer(m, Caster).Start();
|
|
|
|
m.FixedParticles(0x375A, 9, 20, 5027, EffectLayer.Waist);
|
|
m.PlaySound(0x1F7);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void OnCast()
|
|
{
|
|
Caster.Target = new SpellTarget<IPoint3D>(this, allowGround: true);
|
|
}
|
|
|
|
private static void AddEntry(Mobile m, int v)
|
|
{
|
|
_table[m] = v;
|
|
}
|
|
|
|
public static void RemoveEntry(Mobile m)
|
|
{
|
|
if (_table.Remove(m, out var v))
|
|
{
|
|
m.EndAction<ArchProtectionSpell>();
|
|
m.VirtualArmorMod -= Math.Min(v, m.VirtualArmorMod);
|
|
}
|
|
}
|
|
|
|
private class InternalTimer : Timer
|
|
{
|
|
private readonly Mobile _owner;
|
|
|
|
public InternalTimer(Mobile target, Mobile caster) : base(GetDelay(caster)) => _owner = target;
|
|
|
|
private static TimeSpan GetDelay(Mobile caster) =>
|
|
TimeSpan.FromSeconds(Math.Min(144, caster.Skills.Magery.Value * 1.2));
|
|
|
|
protected override void OnTick()
|
|
{
|
|
RemoveEntry(_owner);
|
|
}
|
|
}
|
|
}
|
|
}
|