FurbolgWarrior.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 FurbolgWarrior : MonsterObject
  8. {
  9. protected internal FurbolgWarrior(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 > 2 || y > 2) return false;
  20. return (x <= 1 && y <= 1) || (x == y || x % 2 == y % 2);
  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. ShockTime = 0;
  32. bool isCrit = false;
  33. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  34. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  35. if (damage == 0) return;
  36. int critBonus = (int)Math.Round((double)damage * 0.5);
  37. if (ranged)
  38. {
  39. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  40. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  41. for (int i = 1; i <= 2; i++)
  42. {
  43. if (Envir.Random.Next(10) == 0)
  44. isCrit = true;
  45. if (isCrit)
  46. damage += critBonus;
  47. Point target = Functions.PointMove(CurrentLocation, Direction, i);
  48. if (!CurrentMap.ValidPoint(target)) continue;
  49. Cell cell = CurrentMap.GetCell(target);
  50. if (cell.Objects == null) continue;
  51. for (int o = 0; o < cell.Objects.Count; o++)
  52. {
  53. MapObject ob = cell.Objects[o];
  54. if (ob.Race == ObjectType.Monster || ob.Race == ObjectType.Player)
  55. {
  56. if (!ob.IsAttackTarget(this)) continue;
  57. int delay = Functions.MaxDistance(CurrentLocation, ob.CurrentLocation) * 50 + 500;
  58. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, DefenceType.ACAgility);
  59. ActionList.Add(action);
  60. if (isCrit)
  61. {
  62. DelayedAction action1 = new DelayedAction(DelayedType.SpellEffect, Envir.Time + delay, ob, SpellEffect.FurbolgWarriorCritical);
  63. ActionList.Add(action1);
  64. }
  65. }
  66. else
  67. continue;
  68. break;
  69. }
  70. if (isCrit)
  71. isCrit = false;
  72. }
  73. }
  74. else
  75. {
  76. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  77. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1});
  78. MirDirection dir = Functions.PreviousDir(Direction);
  79. for (int i = 0; i < 6; i++)
  80. {
  81. if (Envir.Random.Next(10) == 0)
  82. isCrit = true;
  83. if (isCrit)
  84. damage += critBonus;
  85. Point target = Functions.PointMove(CurrentLocation, dir, 1);
  86. dir = Functions.NextDir(dir);
  87. if (!CurrentMap.ValidPoint(target)) continue;
  88. Cell cell = CurrentMap.GetCell(target);
  89. if (cell.Objects == null) continue;
  90. for (int o = 0; o < cell.Objects.Count; o++)
  91. {
  92. MapObject ob = cell.Objects[o];
  93. if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) continue;
  94. if (!ob.IsAttackTarget(this)) continue;
  95. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 600, ob, damage, DefenceType.ACAgility);
  96. ActionList.Add(action);
  97. if (isCrit)
  98. {
  99. DelayedAction action1 = new DelayedAction(DelayedType.SpellEffect, Envir.Time + 600, ob, SpellEffect.FurbolgWarriorCritical);
  100. ActionList.Add(action1);
  101. }
  102. break;
  103. }
  104. if (isCrit)
  105. isCrit = false;
  106. }
  107. }
  108. }
  109. }
  110. }