using Server.MirDatabase; using Server.MirEnvir; using S = ServerPackets; namespace Server.MirObjects.Monsters { //TODO - Has a retreat Animation, can't get motion accurate public class ChieftainArcher : MonsterObject { public long FearTime; protected virtual byte AttackRange { get { return 6; } } protected internal ChieftainArcher(MonsterInfo info) : base(info) { } 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; byte level = (byte)Envir.Random.Next(0, 3); Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0, Level = level }); ActionTime = Envir.Time + 300; AttackTime = Envir.Time + AttackSpeed; int damage = 0; switch (level) { case 0: default: damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); break; case 1: damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]); break; case 2: damage = GetAttackPower(Stats[Stat.MinSC], Stats[Stat.MaxSC]); break; } if (damage == 0) return; int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.ACAgility, level); ActionList.Add(action); } protected override void ProcessTarget() { if (Target == null || !CanAttack) return; if (InAttackRange() && 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) 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; } } } protected override void CompleteRangeAttack(IList data) { MapObject target = (MapObject)data[0]; int damage = (int)data[1]; DefenceType defence = (DefenceType)data[2]; byte level = (byte)data[3]; if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return; if (target.Attacked(this, damage, defence) <= 0) return; if (level == 2) { target.Pushed(this, Direction, 1); } } } }