KingScorpion.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 KingScorpion : MonsterObject
  8. {
  9. protected internal KingScorpion(MonsterInfo info) : base(info)
  10. {
  11. }
  12. protected override bool InAttackRange()
  13. {
  14. if (Target.CurrentMap != CurrentMap) return false;
  15. if (Target.CurrentLocation == CurrentLocation) return false;
  16. int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
  17. int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
  18. if (x > 2 || y > 2) return false;
  19. return (x <= 1 && y <= 1) || (x == y || x % 2 == y % 2);
  20. }
  21. protected override void Attack()
  22. {
  23. if (!Target.IsAttackTarget(this))
  24. {
  25. Target = null;
  26. return;
  27. }
  28. ActionTime = Envir.Time + 300;
  29. AttackTime = Envir.Time + AttackSpeed;
  30. ShockTime = 0;
  31. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  32. Point target = Functions.PointMove(CurrentLocation, Direction, 2);
  33. bool range = false;
  34. if (CurrentMap.ValidPoint(target))
  35. {
  36. Cell cell = CurrentMap.GetCell(target);
  37. if (cell.Objects != null)
  38. for (int o = 0; o < cell.Objects.Count; o++)
  39. {
  40. MapObject ob = cell.Objects[o];
  41. if (ob.Race != ObjectType.Monster && ob.Race != ObjectType.Player) continue;
  42. if (!ob.IsAttackTarget(this)) continue;
  43. range = true;
  44. break;
  45. }
  46. }
  47. if (range || Envir.Random.Next(5) == 0)
  48. {
  49. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  50. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  51. if (damage == 0) return;
  52. LineAttack(damage, 2, 300, DefenceType.MACAgility);
  53. }
  54. else
  55. {
  56. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  57. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  58. if (damage == 0) return;
  59. LineAttack(damage, 2, 300, DefenceType.ACAgility);
  60. }
  61. }
  62. }
  63. }