ModernUO/Projects/UOContent/Items/Weapons/Abilities/WhirlwindAttack.cs
Kamron Batman 178f71c6dc
chore(content): Cleans up abilities and some spell timers (#427)
- [X] Exposes Index/Count on the timer.
- [X] Cleans up abilities
- [X] Combines some spell context/info objects with their timers to reduce allocations
- [X] Fixes a bug where immolating weapon both finishes effect or stops in the wrong order due to a race condition.
2021-01-23 16:40:53 -08:00

75 lines
2.2 KiB
C#

using System;
using System.Linq;
using Server.Spells;
namespace Server.Items
{
/// <summary>
/// A godsend to a warrior surrounded, the Whirlwind Attack allows the fighter to strike at all nearby targets in one mighty
/// spinning swing.
/// </summary>
public class WhirlwindAttack : WeaponAbility
{
public override int BaseMana => 15;
public override void OnHit(Mobile attacker, Mobile defender, int damage)
{
if (!Validate(attacker) || !CheckMana(attacker, true))
{
return;
}
ClearCurrentAbility(attacker);
var map = attacker.Map;
if (map == null)
{
return;
}
if (!(attacker.Weapon is BaseWeapon weapon))
{
return;
}
attacker.FixedEffect(0x3728, 10, 15);
attacker.PlaySound(0x2A1);
var targets = attacker.GetMobilesInRange(1)
.Where(
m =>
m?.Deleted == false && m != defender && m != attacker &&
SpellHelper.ValidIndirectTarget(attacker, m) &&
m.Map == attacker.Map && m.Alive && attacker.CanSee(m) && attacker.CanBeHarmful(m) &&
attacker.InRange(m, weapon.MaxRange) && attacker.InLOS(m)
)
.ToList();
if (targets.Count <= 0)
{
return;
}
var bushido = attacker.Skills.Bushido.Value;
var damageBonus = 1.0 + Math.Pow(targets.Count * bushido / 60, 2) / 100;
if (damageBonus > 2.0)
{
damageBonus = 2.0;
}
attacker.RevealingAction();
for (var i = 0; i < targets.Count; ++i)
{
var m = targets[i];
attacker.SendLocalizedMessage(1060161); // The whirling attack strikes a target!
m.SendLocalizedMessage(1060162); // You are struck by the whirling attack and take damage!
weapon.OnHit(attacker, m, damageBonus);
}
}
}
}