TucsonMage.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 TucsonMage : MonsterObject
  8. {
  9. protected internal TucsonMage(MonsterInfo info)
  10. : base(info)
  11. {
  12. }
  13. protected override bool InAttackRange()
  14. {
  15. if (Target.CurrentMap != CurrentMap) return false;
  16. if (Target.CurrentLocation == CurrentLocation) return false;
  17. int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
  18. int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
  19. if (x > 3 || y > 3) return false;
  20. return (x <= 3 && y <= 3) || (x == y || x % 3 == y % 3);
  21. }
  22. protected override void Attack()
  23. {
  24. if (!Target.IsAttackTarget(this))
  25. {
  26. Target = null;
  27. return;
  28. }
  29. ActionTime = Envir.Time + 300;
  30. AttackTime = Envir.Time + AttackSpeed;
  31. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  32. bool range = !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  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. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility);
  39. ActionList.Add(action);
  40. }
  41. else
  42. {
  43. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  44. WideLineAttack();
  45. }
  46. ShockTime = 0;
  47. }
  48. private void WideLineAttack()
  49. {
  50. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  51. if (damage == 0) return;
  52. var forward = Functions.PointMove(CurrentLocation, Direction, 1);
  53. Cell cell = CurrentMap.GetCell(forward);
  54. if (cell.Objects != null)
  55. {
  56. for (int o = 0; o < cell.Objects.Count; o++)
  57. {
  58. MapObject ob = cell.Objects[o];
  59. if (ob.Race == ObjectType.Monster || ob.Race == ObjectType.Player)
  60. {
  61. if (!ob.IsAttackTarget(this)) continue;
  62. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, ob, damage, DefenceType.ACAgility);
  63. ActionList.Add(action);
  64. }
  65. else continue;
  66. break;
  67. }
  68. }
  69. var direction = Functions.PreviousDir(Direction);
  70. for (int d = 0; d < 3; d++)
  71. {
  72. for (int i = 1; i <= 2; i++)
  73. {
  74. Point target = Functions.PointMove(forward, direction, i);
  75. if (!CurrentMap.ValidPoint(target)) continue;
  76. cell = CurrentMap.GetCell(target);
  77. if (cell.Objects == null) continue;
  78. for (int o = 0; o < cell.Objects.Count; o++)
  79. {
  80. MapObject ob = cell.Objects[o];
  81. if (ob.Race == ObjectType.Monster || ob.Race == ObjectType.Player)
  82. {
  83. if (!ob.IsAttackTarget(this)) continue;
  84. int delay = Functions.MaxDistance(CurrentLocation, ob.CurrentLocation) * 50 + 500; //50 MS per Step
  85. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, DefenceType.ACAgility);
  86. ActionList.Add(action);
  87. }
  88. else continue;
  89. break;
  90. }
  91. }
  92. direction = Functions.NextDir(direction);
  93. }
  94. }
  95. }
  96. }