| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- 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<object> 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);
- }
- }
- }
- }
- }
|