using Server.MirDatabase; using S = ServerPackets; namespace Server.MirObjects.Monsters { public class HornedWarrior : MonsterObject { private long _ShieldTime; protected byte AttackRange = 4; protected internal HornedWarrior(MonsterInfo info) : base(info) { } protected override bool InAttackRange() { if (Target.CurrentMap != CurrentMap) return false; if (Target.CurrentLocation == CurrentLocation) return false; int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X); int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y); if (x > AttackRange || y > AttackRange) return false; return (x <= 1 && y <= 1) || (x == y || x % 2 == y % 2); } protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; ShockTime = 0; if (HasBuff(BuffType.HornedWarriorShield, out _)) { return; } var hpPercent = (HP * 100) / MaxHealth; if (Envir.Time > _ShieldTime && hpPercent < 50) { _ShieldTime = Envir.Time + 15000 + Envir.Random.Next(0, 5000); var stats = new Stats { [Stat.MaxAC] = 500, [Stat.MinAC] = 500 }; Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 }); AddBuff(BuffType.HornedWarriorShield, this, Settings.Second * 10, stats); return; } int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); if (damage == 0) return; if (!ranged && Envir.Random.Next(3) > 0) { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 }); DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility); ActionList.Add(action); } else { Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); WideLineAttack(damage, 4, 500, DefenceType.ACAgility, false, 3); } } protected override void ProcessTarget() { if (Target == null || !CanAttack) return; var buff = HasBuff(BuffType.HornedWarriorShield, out _); if (InAttackRange() && !buff) { Attack(); return; } if (Envir.Time < ShockTime) { Target = null; return; } if (!buff) MoveTo(Target.CurrentLocation); else { 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; } } } } }