ModernUO/Projects/UOContent/Spells/Fifth/Paralyze.cs
Kamron Batman 3e8d548f38
feat: Add spawn position caching and spiral scan optimization (#2295)
### Summary

Adds spawn position caching and optimization for constrained spawners (e.g., those near houses, water, or blocked terrain).

### Key features:
- Sector-based bitmap cache (32 bytes per 16x16 sector) stores valid spawn positions
- Spiral scan progressively discovers positions from spawner center outward
- Automatic mode detects constrained spawners after 5+ non-transient failures
- Prevents mob spawning inside private houses (allows public AoS buildings)
- Deduplicates sector lookups for multi-bounds spawners (RegionSpawner)
- Cache invalidation on house placement/demolition
- Moves SpawnBounds to Spawner

### New spawner properties:
- SpawnPositionMode: Automatic (default), Enabled, Disabled, Abandoned
- MaxSpawnAttempts: Configurable attempts before optimization engages (default: 5)
2025-12-28 02:40:21 -08:00

88 lines
2.3 KiB
C#

using System;
using Server.Mobiles;
using Server.Spells.Chivalry;
using Server.Targeting;
namespace Server.Spells.Fifth
{
public class ParalyzeSpell : MagerySpell, ITargetingSpell<Mobile>
{
private static readonly SpellInfo _info = new(
"Paralyze",
"An Ex Por",
218,
9012,
Reagent.Garlic,
Reagent.MandrakeRoot,
Reagent.SpidersSilk
);
public ParalyzeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info)
{
}
public override SpellCircle Circle => SpellCircle.Fifth;
public void Target(Mobile m)
{
if (Core.AOS && (m.Frozen || m.Paralyzed || m.Spell?.IsCasting == true && m.Spell is not PaladinSpell))
{
Caster.SendLocalizedMessage(1061923); // The target is already frozen.
}
else if (CheckHSequence(m))
{
SpellHelper.Turn(Caster, m);
SpellHelper.CheckReflect((int)Circle, Caster, ref m);
double duration;
if (Core.AOS)
{
var secs = GetDamageSkill(Caster) / 10 - GetResistSkill(m) / 10;
if (!Core.AOS)
{
secs += 2;
}
if (!m.Player)
{
secs *= 3;
}
duration = Math.Max(secs, 0);
}
else
{
// Algorithm: ((20% of magery) + 7) seconds [- 50% if resisted]
duration = 7.0 + Caster.Skills.Magery.Value * 0.2;
if (CheckResisted(m))
{
duration *= 0.75;
}
}
if (m is PlagueBeastLord lord)
{
lord.OnParalyzed(Caster);
duration = 120;
}
m.Paralyze(TimeSpan.FromSeconds(duration));
m.PlaySound(0x204);
m.FixedEffect(0x376A, 6, 1);
HarmfulSpell(m);
}
}
public override void OnCast()
{
Caster.Target = new SpellTarget<Mobile>(this, TargetFlags.Harmful);
}
}
}