ManectricKing.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class ManectricKing : MonsterObject
  7. {
  8. public long FearTime;
  9. public byte AttackRange = 3;
  10. private long MassAttackTime;
  11. protected internal ManectricKing(MonsterInfo info)
  12. : base(info)
  13. {
  14. }
  15. protected override bool InAttackRange()
  16. {
  17. if (Target.CurrentMap != CurrentMap) return false;
  18. if (Target.CurrentLocation == CurrentLocation) return false;
  19. int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
  20. int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
  21. if (x > AttackRange || y > AttackRange) return false;
  22. return (x == 0) || (y == 0) || (x == y);
  23. }
  24. protected override void Attack()
  25. {
  26. if (!Target.IsAttackTarget(this))
  27. {
  28. Target = null;
  29. return;
  30. }
  31. ShockTime = 0;
  32. ActionTime = Envir.Time + 500;
  33. AttackTime = Envir.Time + AttackSpeed;
  34. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  35. if ((HP * 100 / Stats[Stat.HP]) < 20 && MassAttackTime < Envir.Time)
  36. {
  37. ShockTime = 0;
  38. ActionTime = Envir.Time + 500;
  39. AttackTime = Envir.Time + (AttackSpeed);
  40. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  41. List<MapObject> targets = FindAllTargets(7, CurrentLocation, false);
  42. if (targets.Count == 0) return;
  43. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  44. for (int i = 0; i < targets.Count; i++)
  45. {
  46. int delay = Functions.MaxDistance(CurrentLocation, targets[i].CurrentLocation) * 50 + 750; //50 MS per Step
  47. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.ACAgility);
  48. ActionList.Add(action);
  49. }
  50. MassAttackTime = Envir.Time + 2000 + (Envir.Random.Next(5) * 1000);
  51. ActionTime = Envir.Time + 800;
  52. AttackTime = Envir.Time + AttackSpeed;
  53. return;
  54. }
  55. if (Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange - 1) && Envir.Random.Next(3) == 0)
  56. {
  57. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  58. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  59. if (damage == 0) return;
  60. LineAttack(damage, AttackRange - Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) + 1, 500, DefenceType.ACAgility, true);
  61. }
  62. else
  63. {
  64. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  65. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  66. if (damage == 0) return;
  67. LineAttack(damage, AttackRange, 500, DefenceType.ACAgility, false);
  68. }
  69. }
  70. }
  71. }