FurbolgArcher.cs 3.6 KB

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