using Server.MirDatabase; using S = ServerPackets; namespace Server.MirObjects.Monsters { public class HolyDeva : MonsterObject { public long FearTime; public byte AttackRange = 6; public bool Summoned; protected internal HolyDeva(MonsterInfo info) : base(info) { Direction = MirDirection.DownLeft; } protected override bool InAttackRange() { return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange); } protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); if (damage == 0) return; DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC); ActionList.Add(action); } protected override void ProcessTarget() { if (Target == null || !CanAttack) return; if (Master != null) MoveTo(Master.CurrentLocation); if (InAttackRange() && (Master != null || Envir.Time < FearTime)) { Attack(); return; } FearTime = Envir.Time + 5000; if (Envir.Time < ShockTime) { Target = null; return; } int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation); if (dist < AttackRange) { MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation); if (Walk(dir)) return; switch (Envir.Random.Next(2)) //No favour { case 0: for (int i = 0; i < 7; i++) { dir = Functions.NextDir(dir); if (Walk(dir)) return; } break; default: for (int i = 0; i < 7; i++) { dir = Functions.PreviousDir(dir); if (Walk(dir)) return; } break; } } } public override void Spawned() { base.Spawned(); Summoned = true; } public override Packet GetInfo() { var packet = (S.ObjectMonster)base.GetInfo(); packet.Image = Monster.HolyDeva; packet.Extra = Summoned; return packet; } } }