using Server.MirDatabase; using Server.MirEnvir; using S = ServerPackets; namespace Server.MirObjects.Monsters { public class SnowYeti : MonsterObject { private const byte AttackRange = 9; protected internal SnowYeti(MonsterInfo info) : base(info) { } protected override bool InAttackRange() { return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, 1); } protected bool InRangeAttackRange() { return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange); } protected override void ProcessTarget() { if (Target == null || Dead) return; if (!InAttackRange()) { if (CanAttack) { if (Envir.Random.Next(5) == 0) RangeAttack(); } if (CurrentLocation == Target.CurrentLocation) { MirDirection direction = (MirDirection)Envir.Random.Next(8); int rotation = Envir.Random.Next(2) == 0 ? 1 : -1; for (int d = 0; d < 8; d++) { if (Walk(direction)) break; direction = Functions.ShiftDirection(direction, rotation); } } else MoveTo(Target.CurrentLocation); } if (!CanAttack) return; if (Envir.Random.Next(5) > 0) { if (InAttackRange()) Attack(); } else RangeAttack(); if (Envir.Time < ShockTime) { Target = null; return; } } protected override void Attack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); if (damage == 0) return; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation }); DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.ACAgility); ActionList.Add(action); Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 }); action = new DelayedAction(DelayedType.Damage, Envir.Time + 1500, Target, damage, DefenceType.ACAgility); ActionList.Add(action); ActionTime = Envir.Time + 1500; AttackTime = Envir.Time + AttackSpeed; ShockTime = 0; } public void RangeAttack() { if (!Target.IsAttackTarget(this)) { Target = null; return; } ShockTime = 0; ActionTime = Envir.Time + 1000; AttackTime = Envir.Time + AttackSpeed + 1000; int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]); if (damage == 0) return; Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation); int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID }); if (damage == 0) return; DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.MAC); ActionList.Add(action); } protected override void CompleteRangeAttack(IList data) { MapObject target = (MapObject)data[0]; int damage = (int)data[1]; DefenceType defence = (DefenceType)data[2]; if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return; if (target.Attacked(this, damage, DefenceType.MAC) > 0) { if (Envir.Random.Next(Settings.PoisonResistWeight) >= target.Stats[Stat.PoisonResist]) { if (Envir.Random.Next(3) == 0) target.ApplyPoison(new Poison { PType = PoisonType.Frozen, Duration = 5, TickSpeed = 1000 }, this); } } } } }