AxeSkeleton.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class AxeSkeleton : MonsterObject
  6. {
  7. public long FearTime;
  8. protected virtual byte AttackRange
  9. {
  10. get
  11. {
  12. return 6;
  13. }
  14. }
  15. protected internal AxeSkeleton(MonsterInfo info)
  16. : base(info)
  17. {
  18. }
  19. protected override bool InAttackRange()
  20. {
  21. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  22. }
  23. protected override void Attack()
  24. {
  25. if (!Target.IsAttackTarget(this))
  26. {
  27. Target = null;
  28. return;
  29. }
  30. ShockTime = 0;
  31. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  32. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  33. ActionTime = Envir.Time + 300;
  34. AttackTime = Envir.Time + AttackSpeed;
  35. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  36. if (damage == 0) return;
  37. ProjectileAttack(damage);
  38. }
  39. protected override void ProcessTarget()
  40. {
  41. if (Target == null || !CanAttack) return;
  42. if (InAttackRange() && Envir.Time < FearTime)
  43. {
  44. Attack();
  45. return;
  46. }
  47. FearTime = Envir.Time + 5000;
  48. if (Envir.Time < ShockTime)
  49. {
  50. Target = null;
  51. return;
  52. }
  53. int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
  54. if (dist >= AttackRange)
  55. MoveTo(Target.CurrentLocation);
  56. else
  57. {
  58. MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation);
  59. if (Walk(dir)) return;
  60. switch (Envir.Random.Next(2)) //No favour
  61. {
  62. case 0:
  63. for (int i = 0; i < 7; i++)
  64. {
  65. dir = Functions.NextDir(dir);
  66. if (Walk(dir))
  67. return;
  68. }
  69. break;
  70. default:
  71. for (int i = 0; i < 7; i++)
  72. {
  73. dir = Functions.PreviousDir(dir);
  74. if (Walk(dir))
  75. return;
  76. }
  77. break;
  78. }
  79. }
  80. }
  81. }
  82. }