TurtleKing.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. using System.Drawing;
  2. using Server.MirDatabase;
  3. using S = ServerPackets;
  4. using Server.MirEnvir;
  5. namespace Server.MirObjects.Monsters
  6. {
  7. public class TurtleKing : MonsterObject
  8. {
  9. public byte AttackRange = 7;
  10. public byte CloseRange = 2;
  11. private byte _stage = 5;
  12. protected internal TurtleKing(MonsterInfo info)
  13. : base(info)
  14. {
  15. }
  16. protected override bool InAttackRange()
  17. {
  18. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  19. }
  20. protected override void ProcessAI()
  21. {
  22. if (Dead) return;
  23. if (Stats[Stat.HP] >= 5)
  24. {
  25. byte stage = (byte)(HP / (Stats[Stat.HP] / 5));
  26. if (stage < _stage)
  27. {
  28. SpawnSlaves();
  29. _stage = stage;
  30. }
  31. }
  32. base.ProcessAI();
  33. }
  34. protected override void Attack()
  35. {
  36. if (!Target.IsAttackTarget(this))
  37. {
  38. Target = null;
  39. return;
  40. }
  41. ShockTime = 0;
  42. ActionTime = Envir.Time + 300;
  43. AttackTime = Envir.Time + AttackSpeed;
  44. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  45. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, CloseRange);
  46. if (!ranged)
  47. {
  48. switch (Envir.Random.Next(5))
  49. {
  50. case 0:
  51. case 1:
  52. {
  53. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  54. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  55. if (damage == 0) return;
  56. LineAttack(damage, 2, 300);
  57. }
  58. break;
  59. case 2:
  60. case 3:
  61. {
  62. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  63. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  64. if (damage == 0) return;
  65. LineAttack(damage, 3, 300);
  66. }
  67. break;
  68. case 4:
  69. {
  70. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  71. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  72. if (damage == 0) return;
  73. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC);
  74. ActionList.Add(action);
  75. }
  76. break;
  77. }
  78. }
  79. else
  80. {
  81. if (!Functions.InRange(CurrentLocation, Target.CurrentLocation, CloseRange) && Envir.Random.Next(4) == 0)
  82. {
  83. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  84. Point target = Functions.PointMove(CurrentLocation, Direction, 1);
  85. Target.Teleport(CurrentMap, target, true, 6);
  86. }
  87. else if (!Functions.InRange(CurrentLocation, Target.CurrentLocation, CloseRange) && Envir.Random.Next(4) == 0)
  88. {
  89. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 });
  90. Point target = Functions.PointMove(Target.CurrentLocation, Target.Direction, 1);
  91. Teleport(CurrentMap, target, true, 6);
  92. }
  93. else
  94. {
  95. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  96. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  97. if (damage == 0) return;
  98. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC);
  99. ActionList.Add(action);
  100. }
  101. }
  102. }
  103. protected override void CompleteAttack(IList<object> data)
  104. {
  105. MapObject target = (MapObject)data[0];
  106. int damage = (int)data[1];
  107. DefenceType defence = (DefenceType)data[2];
  108. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  109. if (target.Attacked(this, damage, defence) <= 0) return;
  110. PoisonTarget(target, 8, 3, PoisonType.Dazed, 1000);
  111. }
  112. protected override void CompleteRangeAttack(IList<object> data)
  113. {
  114. MapObject target = (MapObject)data[0];
  115. int damage = (int)data[1];
  116. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  117. List<MapObject> targets = FindAllTargets(AttackRange, CurrentLocation);
  118. if (targets.Count == 0) return;
  119. for (int i = 0; i < targets.Count; i++)
  120. {
  121. Broadcast(new S.ObjectEffect { ObjectID = Target.ObjectID, Effect = SpellEffect.TurtleKing });
  122. if (targets[i].Attacked(this, damage, DefenceType.MAC) <= 0) return;
  123. PoisonTarget(targets[i], 5, 15, PoisonType.Slow, 1000);
  124. PoisonTarget(targets[i], 5, 5, PoisonType.Paralysis, 1000);
  125. }
  126. }
  127. private void SpawnSlaves()
  128. {
  129. int count = Math.Min(8, 30 - SlaveList.Count);
  130. for (int i = 0; i < count; i++)
  131. {
  132. MonsterObject mob = null;
  133. switch (Envir.Random.Next(7))
  134. {
  135. case 0:
  136. mob = GetMonster(Envir.GetMonsterInfo(Settings.Turtle1));
  137. break;
  138. case 1:
  139. mob = GetMonster(Envir.GetMonsterInfo(Settings.Turtle2));
  140. break;
  141. case 2:
  142. mob = GetMonster(Envir.GetMonsterInfo(Settings.Turtle3));
  143. break;
  144. case 3:
  145. mob = GetMonster(Envir.GetMonsterInfo(Settings.Turtle4));
  146. break;
  147. case 4:
  148. mob = GetMonster(Envir.GetMonsterInfo(Settings.Turtle5));
  149. break;
  150. }
  151. if (mob == null) continue;
  152. if (!mob.Spawn(CurrentMap, Front))
  153. mob.Spawn(CurrentMap, CurrentLocation);
  154. //mob.Master = this;
  155. mob.Target = Target;
  156. mob.ActionTime = Envir.Time + 2000;
  157. SlaveList.Add(mob);
  158. }
  159. }
  160. }
  161. }