chore(content): Cleans up frenzied whirlwind (#428)

This commit is contained in:
Kamron Batman 2021-01-24 12:34:54 -08:00 committed by GitHub
parent 178f71c6dc
commit 8580139544
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Server.Mobiles;
using Server.Spells; using Server.Spells;
namespace Server.Items namespace Server.Items
@ -12,8 +13,7 @@ namespace Server.Items
{ {
public override int BaseMana => 30; public override int BaseMana => 30;
public static Dictionary<Mobile, FrenziedWirlwindTimer> Registry { get; } = public static Dictionary<Mobile, FrenziedWirlwindTimer> Registry { get; } = new();
new();
public override bool CheckSkills(Mobile from) public override bool CheckSkills(Mobile from)
{ {
@ -43,44 +43,44 @@ namespace Server.Items
return; return;
} }
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 || !CheckMana(attacker, true))
{
return;
}
attacker.FixedEffect(0x3728, 10, 15);
attacker.PlaySound(0x2A1);
// 5-15 damage // 5-15 damage
var amount = (int)(10.0 * ((Math.Max( var amount = (int)(10.0 * ((Math.Max(
attacker.Skills.Bushido.Value, attacker.Skills.Bushido.Value,
attacker.Skills.Ninjitsu.Value attacker.Skills.Ninjitsu.Value
) - 50.0) / 70.0 + 5)); ) - 50.0) / 70.0 + 5));
for (var i = 0; i < targets.Count; ++i) bool didEffect = false;
var eable = attacker.GetMobilesInRange(1);
foreach (var m in eable)
{ {
var m = targets[i]; if (m?.Deleted == false && m != defender && m != attacker &&
attacker.DoHarmful(m, true); SpellHelper.ValidIndirectTarget(attacker, m) &&
m.Map == attacker.Map && m.Alive && attacker.CanSee(m) && attacker.CanBeHarmful(m) &&
if (Registry.TryGetValue(m, out var timer)) attacker.InRange(m, weapon.MaxRange) && attacker.InLOS(m))
{ {
timer.Stop(); attacker.DoHarmful(m, true);
Registry.Remove(m);
}
timer = new FrenziedWirlwindTimer(attacker, m, amount); if (Registry.TryGetValue(m, out var timer))
timer.Start(); {
Registry.Add(m, timer); timer.Stop();
Registry.Remove(m);
}
timer = new FrenziedWirlwindTimer(attacker, m, amount);
timer.Start();
Registry.Add(m, timer);
didEffect = true;
}
}
eable.Free();
if (didEffect)
{
attacker.FixedEffect(0x3728, 10, 15);
attacker.PlaySound(0x2A1);
} }
Timer.DelayCall(TimeSpan.FromSeconds(2.0), RepeatEffect, attacker); Timer.DelayCall(TimeSpan.FromSeconds(2.0), RepeatEffect, attacker);