BlackHammerCat.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class BlackHammerCat : MonsterObject
  7. {
  8. protected internal BlackHammerCat(MonsterInfo info)
  9. : 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. 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. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  45. if (damage == 0) return;
  46. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility);
  47. ActionList.Add(action);
  48. damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  49. if (damage == 0) return;
  50. LineAttack(damage, 2, 300);
  51. }
  52. }
  53. }
  54. }