servuo/Scripts/Abilities/ColdWind.cs
TrueUO e78c0795a9 Books now once again work correctly in the CC and EC.
Travesty now uses the proper weapon specials. Specials when in natual form have also been toned down
Controlled creatures no longer lose focus when attacking on kill/attack control order
Temporarily removed looting rights for healing as this is suspected in causing a shard lockup. It will either be refactored or investigated further
Fixed issue where boat courses were not working properly and the tillerman was piloting the boat in the wrong DirectionL
Boat course no longer works in the corgul region
Corgul Island map now indicates when the encounter will Expire
Simplified code used to determine if an item or subclass of an item can be crafted
2020-04-19 13:26:24 -04:00

89 lines
2.7 KiB
C#

using System;
using System.Collections.Generic;
using Server.Network;
namespace Server.Items
{
/// <summary>
/// Currently on EA, this is only available for Creatures
/// </summary>
public class ColdWind : WeaponAbility
{
private static readonly Dictionary<Mobile, ExpireTimer> m_Table = new Dictionary<Mobile, ExpireTimer>();
public override int BaseMana => 20;
public override double DamageScalar => 1.5;
public override void OnHit(Mobile attacker, Mobile defender, int damage)
{
if (!Validate(attacker) || !CheckMana(attacker, true))
return;
if (attacker.Map == null || attacker.Map == Map.Internal)
return;
ExpireTimer timer = null;
if (m_Table.ContainsKey(defender))
timer = m_Table[defender];
if (timer != null)
{
timer.DoExpire();
defender.SendLocalizedMessage(1070831); // The freezing wind continues to blow!
}
else
defender.SendLocalizedMessage(1070832); // An icy wind surrounds you, freezing your lungs as you breathe!
timer = new ExpireTimer(defender, attacker);
timer.Start();
m_Table[defender] = timer;
}
private class ExpireTimer : Timer
{
private readonly Mobile m_Mobile;
private readonly Mobile m_From;
private int m_Count;
public ExpireTimer(Mobile m, Mobile from)
: base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
{
m_Mobile = m;
m_From = from;
Priority = TimerPriority.TwoFiftyMS;
}
public void DoExpire()
{
Stop();
m_Table.Remove(m_Mobile);
}
public void DrainLife()
{
if (m_Mobile.Alive)
{
AOS.Damage(m_Mobile, m_From, 14, 0, 0, 100, 0, 0);
Effects.SendPacket(m_Mobile.Location, m_Mobile.Map, new ParticleEffect(EffectType.FixedFrom, m_Mobile.Serial, Serial.Zero, 0x374A, m_Mobile.Location, m_Mobile.Location, 1, 15, false, false, 97, 0, 4, 9502, 1, m_Mobile.Serial, 163, 0));
}
else
{
DoExpire();
}
}
protected override void OnTick()
{
DrainLife();
if (++m_Count >= 5)
{
DoExpire();
m_Mobile.SendLocalizedMessage(1070830); // The icy wind dissipates.
}
}
}
}
}