DarkOmaKing.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 DarkOmaKing : MonsterObject
  8. {
  9. private long _OrbTime;
  10. private long _MassThunderTime;
  11. protected virtual byte AttackRange
  12. {
  13. get
  14. {
  15. return 6;
  16. }
  17. }
  18. protected internal DarkOmaKing(MonsterInfo info)
  19. : base(info)
  20. {
  21. _MassThunderTime = Envir.Time + 10000;
  22. _OrbTime = Envir.Time + 20000;
  23. }
  24. protected override bool InAttackRange()
  25. {
  26. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  27. }
  28. protected override void Attack()
  29. {
  30. if (!Target.IsAttackTarget(this))
  31. {
  32. Target = null;
  33. return;
  34. }
  35. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  36. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 3);
  37. if (Envir.Time > _OrbTime)
  38. {
  39. _OrbTime = Envir.Time + 20000;
  40. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 });
  41. ActionTime = Envir.Time + AttackSpeed + 300;
  42. var attempts = 4;
  43. var distance = 8;
  44. var count = 2;
  45. for (int j = 0; j < count; j++)
  46. {
  47. for (int i = 0; i < attempts; i++)
  48. {
  49. var location = new Point(CurrentLocation.X + Envir.Random.Next(-distance, distance + 1),
  50. CurrentLocation.Y + Envir.Random.Next(-distance, distance + 1));
  51. if (location == CurrentLocation || location == Target.CurrentLocation) continue;
  52. if (PowerBead.SpawnRandom(this, location)) break;
  53. }
  54. }
  55. }
  56. if (Envir.Time > _MassThunderTime)
  57. {
  58. _MassThunderTime = Envir.Time + 10000 + Envir.Random.Next(0, 5000);
  59. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 3 });
  60. ActionTime = Envir.Time + AttackSpeed + 300;
  61. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  62. if (damage == 0) return;
  63. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, true);
  64. ActionList.Add(action);
  65. return;
  66. }
  67. if (!ranged)
  68. {
  69. if (Envir.Random.Next(4) > 0)
  70. {
  71. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  72. ActionTime = Envir.Time + AttackSpeed + 300;
  73. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  74. if (damage == 0) return;
  75. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility);
  76. ActionList.Add(action);
  77. }
  78. else
  79. {
  80. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  81. ActionTime = Envir.Time + AttackSpeed + 3400;
  82. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  83. if (damage == 0) return;
  84. FullmoonAttack(damage, 500, DefenceType.ACAgility, 1, 2);
  85. FullmoonAttack(damage, 1700, DefenceType.ACAgility, 1, 2);
  86. FullmoonAttack(damage, 2500, DefenceType.ACAgility, 1, 2);
  87. var start = 3000;
  88. SpellObject ob = new SpellObject
  89. {
  90. Spell = Spell.DarkOmaKingNuke,
  91. Value = Stats[Stat.MaxDC],
  92. ExpireTime = Envir.Time + 900 + start,
  93. TickSpeed = 1000,
  94. Direction = Direction,
  95. CurrentLocation = Functions.PointMove(CurrentLocation, Direction, 3),
  96. CastLocation = CurrentLocation,
  97. Show = true,
  98. CurrentMap = CurrentMap,
  99. Caster = this
  100. };
  101. DelayedAction action2 = new DelayedAction(DelayedType.Spawn, Envir.Time + start, ob);
  102. CurrentMap.ActionList.Add(action2);
  103. }
  104. }
  105. else
  106. {
  107. if (Envir.Random.Next(3) == 0)
  108. {
  109. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 });
  110. ActionTime = Envir.Time + AttackSpeed + 300;
  111. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  112. if (damage == 0) return;
  113. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.MAC);
  114. ActionList.Add(action);
  115. }
  116. }
  117. ShockTime = 0;
  118. AttackTime = Envir.Time + AttackSpeed;
  119. }
  120. protected override void CompleteAttack(IList<object> data)
  121. {
  122. MapObject target = (MapObject)data[0];
  123. int damage = (int)data[1];
  124. DefenceType defence = (DefenceType)data[2];
  125. bool aoe = data.Count >= 4 && (bool)data[3];
  126. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  127. if (aoe)
  128. {
  129. var targets = FindAllTargets(5, CurrentLocation, false);
  130. for (int i = 0; i < targets.Count; i++)
  131. {
  132. targets[i].Attacked(this, damage, defence);
  133. }
  134. }
  135. else
  136. {
  137. target.Attacked(this, damage, defence);
  138. }
  139. }
  140. public override void Die()
  141. {
  142. base.Die();
  143. //Kill Minions
  144. for (int i = SlaveList.Count - 1; i >= 0; i--)
  145. {
  146. if (!SlaveList[i].Dead && SlaveList[i].Node != null)
  147. {
  148. SlaveList[i].Die();
  149. }
  150. }
  151. }
  152. }
  153. }