Skip to content

Instantly share code, notes, and snippets.

@DarkLotus
Created January 2, 2022 07:39
Show Gist options
  • Save DarkLotus/b866cb5ce1a1eee35b107b109f38b9d3 to your computer and use it in GitHub Desktop.
Save DarkLotus/b866cb5ce1a1eee35b107b109f38b9d3 to your computer and use it in GitHub Desktop.
// **********
// ServUO - CoilMob.cs
// **********
namespace Server.Mobiles
{
public class CoilMob : BaseCreature
{
public int LastHitTimer { get; set; }
[Constructable]
public CoilMob() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
{
}
public CoilMob(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
writer.Write(LastHitTimer);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
LastHitTimer = reader.ReadInt();
}
public override void OnThink()
{
if (Combatant != null && LastHitTimer + 5000 < Core.TickCount)
{
LastHitTimer = Core.TickCount;
DoSpecialAbility();
}
base.OnThink();
}
void DoSpecialAbility()
{
if (Utility.RandomDouble() < 0.1)
{
Mobile target = this.Combatant;
if (target != null && target.Map == this.Map && this.InRange(target, 10))
{
this.Animate(12, 5, 1, true, false, 0);
this.PlaySound(0xEE);
int toDmg = Utility.RandomMinMax(10, 20);
target.Damage(toDmg, this);
if (target is BaseCreature)
{
BaseCreature bc_Target = target as BaseCreature;
if (bc_Target.Controlled)
{
bc_Target.ControlMaster.Damage(toDmg / 2, this);
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment