ModernUO/Projects/UOContent/Mobiles/Monsters/Misc/Melee/SandVortex.cs
Kamron Batman fb915992dd
fix(core): Adds Hashed & Hierarchical Timer Wheel (#655)
- Removes TimerPriority
- Removes TimerThread
- Adds a [Hashed & Hierarchical Timer Wheel](http://www.cs.columbia.edu/~nahum/w6998/papers/ton97-timing-wheels.pdf)
2021-07-11 22:42:06 -07:00

114 lines
3 KiB
C#

using System;
using Server.Items;
namespace Server.Mobiles
{
public class SandVortex : BaseCreature
{
private DateTime m_NextAttack;
[Constructible]
public SandVortex() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
{
Body = 790;
BaseSoundID = 263;
SetStr(96, 120);
SetDex(171, 195);
SetInt(76, 100);
SetHits(51, 62);
SetDamage(3, 16);
SetDamageType(ResistanceType.Physical, 90);
SetDamageType(ResistanceType.Fire, 10);
SetResistance(ResistanceType.Physical, 80, 90);
SetResistance(ResistanceType.Fire, 60, 70);
SetResistance(ResistanceType.Cold, 60, 70);
SetResistance(ResistanceType.Poison, 60, 70);
SetResistance(ResistanceType.Energy, 60, 70);
SetSkill(SkillName.MagicResist, 150.0);
SetSkill(SkillName.Tactics, 70.0);
SetSkill(SkillName.Wrestling, 80.0);
Fame = 4500;
Karma = -4500;
VirtualArmor = 28;
PackItem(new Bone());
}
public SandVortex(Serial serial) : base(serial)
{
}
public override string CorpseName => "a sand vortex corpse";
public override string DefaultName => "a sand vortex";
public override void GenerateLoot()
{
AddLoot(LootPack.Meager, 2);
}
public override void OnActionCombat()
{
var combatant = Combatant;
if (combatant?.Deleted != false || combatant.Map != Map || !InRange(combatant, 12) ||
!CanBeHarmful(combatant) || !InLOS(combatant))
{
return;
}
if (Core.Now >= m_NextAttack)
{
SandAttack(combatant);
m_NextAttack = Core.Now + TimeSpan.FromSeconds(10.0 + 10.0 * Utility.RandomDouble());
}
}
public void SandAttack(Mobile m)
{
DoHarmful(m);
m.FixedParticles(0x36B0, 10, 25, 9540, 2413, 0, EffectLayer.Waist);
new InternalTimer(m, this).Start();
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
private class InternalTimer : Timer
{
private readonly Mobile m_From;
private readonly Mobile m_Mobile;
public InternalTimer(Mobile m, Mobile from) : base(TimeSpan.FromSeconds(1.0))
{
m_Mobile = m;
m_From = from;
}
protected override void OnTick()
{
m_Mobile.PlaySound(0x4CF);
AOS.Damage(m_Mobile, m_From, Utility.RandomMinMax(1, 40), 90, 10, 0, 0, 0);
}
}
}
}