Reorganizes Project (#41)
This commit is contained in:
parent
08bf44af9a
commit
3614a66aee
3499 changed files with 79 additions and 55 deletions
108
Projects/Scripts/Spells/Bushido/CounterAttack.cs
Normal file
108
Projects/Scripts/Spells/Bushido/CounterAttack.cs
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Spells.Bushido
|
||||
{
|
||||
public class CounterAttack : SamuraiSpell
|
||||
{
|
||||
private static SpellInfo m_Info = new SpellInfo(
|
||||
"CounterAttack", null,
|
||||
-1,
|
||||
9002
|
||||
);
|
||||
|
||||
private static Dictionary<Mobile, Timer> m_Table = new Dictionary<Mobile, Timer>();
|
||||
|
||||
public CounterAttack(Mobile caster, Item scroll) : base(caster, scroll, m_Info)
|
||||
{
|
||||
}
|
||||
|
||||
public override TimeSpan CastDelayBase => TimeSpan.FromSeconds(0.25);
|
||||
|
||||
public override double RequiredSkill => 40.0;
|
||||
public override int RequiredMana => 5;
|
||||
|
||||
public override bool CheckCast()
|
||||
{
|
||||
if (!base.CheckCast())
|
||||
return false;
|
||||
|
||||
if (Caster.FindItemOnLayer(Layer.TwoHanded) is BaseShield)
|
||||
return true;
|
||||
|
||||
if (Caster.FindItemOnLayer(Layer.OneHanded) is BaseWeapon)
|
||||
return true;
|
||||
|
||||
if (Caster.FindItemOnLayer(Layer.TwoHanded) is BaseWeapon)
|
||||
return true;
|
||||
|
||||
Caster.SendLocalizedMessage(1062944); // You must have a weapon or a shield equipped to use this ability!
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnBeginCast()
|
||||
{
|
||||
base.OnBeginCast();
|
||||
|
||||
Caster.FixedEffect(0x37C4, 10, 7, 4, 3);
|
||||
}
|
||||
|
||||
public override void OnCast()
|
||||
{
|
||||
if (CheckSequence())
|
||||
{
|
||||
Caster.SendLocalizedMessage(1063118); // You prepare to respond immediately to the next blocked blow.
|
||||
|
||||
OnCastSuccessful(Caster);
|
||||
|
||||
StartCountering(Caster);
|
||||
}
|
||||
|
||||
FinishSequence();
|
||||
}
|
||||
|
||||
public static bool IsCountering(Mobile m)
|
||||
{
|
||||
return m_Table.ContainsKey(m);
|
||||
}
|
||||
|
||||
public static void StartCountering(Mobile m)
|
||||
{
|
||||
m_Table.TryGetValue(m, out Timer timer);
|
||||
timer?.Stop();
|
||||
|
||||
m_Table[m] = timer = new InternalTimer(m);
|
||||
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
public static void StopCountering(Mobile m)
|
||||
{
|
||||
if (m_Table.TryGetValue(m, out Timer timer))
|
||||
{
|
||||
timer.Stop();
|
||||
m_Table.Remove(m);
|
||||
}
|
||||
|
||||
OnEffectEnd(m, typeof(CounterAttack));
|
||||
}
|
||||
|
||||
private class InternalTimer : Timer
|
||||
{
|
||||
private Mobile m_Mobile;
|
||||
|
||||
public InternalTimer(Mobile m) : base(TimeSpan.FromSeconds(30.0))
|
||||
{
|
||||
m_Mobile = m;
|
||||
Priority = TimerPriority.TwoFiftyMS;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
StopCountering(m_Mobile);
|
||||
m_Mobile.SendLocalizedMessage(1063119); // You return to your normal stance.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue