FurbolgGuard.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System.Drawing;
  2. using Server.MirDatabase;
  3. using Server.MirEnvir;
  4. using S = ServerPackets;
  5. namespace Server.MirObjects.Monsters
  6. {
  7. public class FurbolgGuard : MonsterObject
  8. {
  9. protected virtual byte AttackRange
  10. {
  11. get
  12. {
  13. return 8;
  14. }
  15. }
  16. protected internal FurbolgGuard(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. //else
  25. //{
  26. // int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
  27. // int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
  28. // if (x > 2 || y > 2) return false;
  29. // return (x <= 1 && y <= 1) || (x == y || x % 2 == y % 2);
  30. //}
  31. protected override void Attack()
  32. {
  33. if (!Target.IsAttackTarget(this))
  34. {
  35. Target = null;
  36. return;
  37. }
  38. ActionTime = Envir.Time + 300;
  39. AttackTime = Envir.Time + AttackSpeed;
  40. ShockTime = 0;
  41. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  42. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  43. if (damage == 0) return;
  44. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  45. if (!ranged)
  46. {
  47. int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
  48. Point location = Functions.PointMove(CurrentLocation, Functions.ReverseDirection(Direction), 3);
  49. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  50. if (dist <= 2 && CurrentMap.ValidPoint(location) && Envir.Random.Next(3) == 0)
  51. {
  52. LineAttack(damage, 3, 500, DefenceType.ACAgility, true);
  53. JumpBack(3);
  54. return;
  55. }
  56. LineAttack(damage,3, 500);
  57. }
  58. else
  59. {
  60. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  61. ProjectileAttack(damage);
  62. }
  63. }
  64. protected override void ProcessTarget()
  65. {
  66. if (Target == null) return;
  67. if (InAttackRange() && CanAttack)
  68. {
  69. Attack();
  70. return;
  71. }
  72. if (Envir.Time < ShockTime)
  73. {
  74. Target = null;
  75. return;
  76. }
  77. MoveTo(Target.CurrentLocation);
  78. }
  79. }
  80. }