FrozenKnight.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class FrozenKnight : MonsterObject
  7. {
  8. protected internal FrozenKnight(MonsterInfo info)
  9. : base(info)
  10. {
  11. }
  12. protected override bool InAttackRange()
  13. {
  14. if (Target.CurrentMap != CurrentMap) return false;
  15. if (Target.CurrentLocation == CurrentLocation) return false;
  16. int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
  17. int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
  18. if (x > 2 || y > 2) return false;
  19. return (x <= 1 && y <= 1) || (x == y || x % 2 == y % 2);
  20. }
  21. protected override void Attack()
  22. {
  23. if (!Target.IsAttackTarget(this))
  24. {
  25. Target = null;
  26. return;
  27. }
  28. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  29. bool range = !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  30. ActionTime = Envir.Time + 300;
  31. AttackTime = Envir.Time + AttackSpeed;
  32. ShockTime = 0;
  33. if (!range && Envir.Random.Next(3) > 0)
  34. {
  35. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  36. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  37. if (damage == 0) return;
  38. HalfmoonAttack(damage);
  39. }
  40. else
  41. {
  42. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  43. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  44. if (damage == 0) return;
  45. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 600, Target, damage, DefenceType.ACAgility);
  46. ActionList.Add(action);
  47. }
  48. }
  49. protected override void CompleteRangeAttack(IList<object> data)
  50. {
  51. MapObject target = (MapObject)data[0];
  52. int damage = (int)data[1];
  53. DefenceType defence = (DefenceType)data[2];
  54. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  55. List<MapObject> targets = FindAllTargets(2, target.CurrentLocation);
  56. for (int i = 0; i < targets.Count; i++)
  57. {
  58. targets[i].Attacked(this, damage, defence);
  59. }
  60. }
  61. }
  62. }