DarkCaptain.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. using System.Drawing;
  2. using Server.MirDatabase;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class DarkCaptain : MonsterObject
  7. {
  8. protected long _ThunderTime;
  9. protected long _MassThunderTime;
  10. protected long _OrbTime;
  11. protected internal DarkCaptain(MonsterInfo info)
  12. : base(info)
  13. {
  14. _ThunderTime = Envir.Time + 10000;
  15. _MassThunderTime = Envir.Time + 20000;
  16. }
  17. protected override void Attack()
  18. {
  19. if (!Target.IsAttackTarget(this))
  20. {
  21. Target = null;
  22. return;
  23. }
  24. ShockTime = 0;
  25. ActionTime = Envir.Time + 300;
  26. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  27. if (_ThunderTime < Envir.Time)
  28. {
  29. AttackTime = Envir.Time + AttackSpeed;
  30. _ThunderTime = Envir.Time + 10000 + Envir.Random.Next(0, 10000);
  31. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  32. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  33. if (damage == 0) return;
  34. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.MACAgility, 2);
  35. ActionList.Add(action);
  36. return;
  37. }
  38. if (_MassThunderTime < Envir.Time)
  39. {
  40. AttackTime = Envir.Time + AttackSpeed;
  41. _MassThunderTime = Envir.Time + 20000 + Envir.Random.Next(0, 30000);
  42. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  43. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  44. if (damage == 0) return;
  45. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.MACAgility, 5);
  46. ActionList.Add(action);
  47. return;
  48. }
  49. if (_OrbTime < Envir.Time)
  50. {
  51. AttackTime = Envir.Time + AttackSpeed;
  52. _OrbTime = Envir.Time + 30000 + Envir.Random.Next(0, 10000);
  53. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 });
  54. var attempts = 4;
  55. var distance = 4;
  56. for (int i = 0; i < attempts; i++)
  57. {
  58. var location = new Point(CurrentLocation.X + Envir.Random.Next(-distance, distance + 1),
  59. CurrentLocation.Y + Envir.Random.Next(-distance, distance + 1));
  60. if (PowerBead.SpawnRandom(this, location)) break;
  61. }
  62. return;
  63. }
  64. if (Envir.Random.Next(5) == 0)
  65. {
  66. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 });
  67. TeleportBehindWeakerTarget();
  68. return;
  69. }
  70. if (Envir.Random.Next(5) > 0)
  71. {
  72. AttackTime = Envir.Time + AttackSpeed;
  73. //Sword Attack
  74. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  75. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  76. if (damage == 0) return;
  77. LineAttack(damage, 2, 300, DefenceType.ACAgility, Envir.Random.Next(5) == 0);
  78. }
  79. else
  80. {
  81. AttackTime = Envir.Time + AttackSpeed;
  82. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  83. //PushAttack
  84. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  85. if (damage == 0) return;
  86. FullmoonAttack(damage, 500, DefenceType.ACAgility, Envir.Random.Next(1, 3));
  87. }
  88. }
  89. protected override void CompleteRangeAttack(IList<object> data)
  90. {
  91. MapObject target = (MapObject)data[0];
  92. int damage = (int)data[1];
  93. DefenceType defence = (DefenceType)data[2];
  94. int range = (int)data[3];
  95. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  96. var targets = FindAllTargets(range, CurrentLocation, false);
  97. for (int i = 0; i < targets.Count; i++)
  98. {
  99. targets[i].Attacked(this, damage, defence);
  100. }
  101. }
  102. private void TeleportBehindWeakerTarget()
  103. {
  104. List<MapObject> targets = FindAllTargets(Info.ViewRange, CurrentLocation);
  105. var newTarget = Target;
  106. for (int i = 0; i < targets.Count; i++)
  107. {
  108. if (targets[i].Stats[Stat.MinDC] > Target.Stats[Stat.MinDC]) continue;
  109. newTarget = targets[i];
  110. break;
  111. }
  112. Target = newTarget;
  113. MirDirection reverse = Functions.ReverseDirection(Target.Direction);
  114. Point location = Functions.PointMove(Target.CurrentLocation, reverse, 1);
  115. Direction = Functions.DirectionFromPoint(location, Target.CurrentLocation);
  116. Teleport(CurrentMap, location, true, Info.Effect);
  117. }
  118. public override void Die()
  119. {
  120. base.Die();
  121. //Kill Minions
  122. for (int i = SlaveList.Count - 1; i >= 0; i--)
  123. {
  124. if (!SlaveList[i].Dead && SlaveList[i].Node != null)
  125. {
  126. SlaveList[i].Die();
  127. }
  128. }
  129. }
  130. }
  131. }