BoneLord.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class BoneLord : MonsterObject
  6. {
  7. public byte AttackRange = 7;
  8. public byte _stage = 3;
  9. protected internal BoneLord(MonsterInfo info)
  10. : base(info)
  11. {
  12. }
  13. protected override bool InAttackRange()
  14. {
  15. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  16. }
  17. protected override void Attack()
  18. {
  19. if (!Target.IsAttackTarget(this))
  20. {
  21. Target = null;
  22. return;
  23. }
  24. ShockTime = 0;
  25. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  26. bool range = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  27. AttackTime = Envir.Time + AttackSpeed;
  28. ActionTime = Envir.Time + 300;
  29. if (range)
  30. {
  31. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 });
  32. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  33. if (damage == 0) return;
  34. int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
  35. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.MACAgility);
  36. ActionList.Add(action);
  37. }
  38. else
  39. {
  40. base.Attack();
  41. }
  42. }
  43. protected override void ProcessTarget()
  44. {
  45. if (Target == null) return;
  46. if (Stats[Stat.HP] >= 3)
  47. {
  48. byte stage = (byte)(HP / (Stats[Stat.HP] / 3));
  49. if (stage < _stage)
  50. {
  51. SpawnSlaves();
  52. _stage = stage;
  53. return;
  54. }
  55. }
  56. if (InAttackRange() && CanAttack)
  57. {
  58. Attack();
  59. return;
  60. }
  61. if (Envir.Time < ShockTime)
  62. {
  63. Target = null;
  64. return;
  65. }
  66. MoveTo(Target.CurrentLocation);
  67. }
  68. private void SpawnSlaves()
  69. {
  70. int count = Math.Min(8, 40 - SlaveList.Count);
  71. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  72. ActionTime = Envir.Time + 300;
  73. AttackTime = Envir.Time + AttackSpeed;
  74. for (int i = 0; i < count; i++)
  75. {
  76. MonsterObject mob = null;
  77. switch (Envir.Random.Next(4))
  78. {
  79. case 0:
  80. mob = GetMonster(Envir.GetMonsterInfo(Settings.BoneMonster1));
  81. break;
  82. case 1:
  83. mob = GetMonster(Envir.GetMonsterInfo(Settings.BoneMonster2));
  84. break;
  85. case 2:
  86. mob = GetMonster(Envir.GetMonsterInfo(Settings.BoneMonster3));
  87. break;
  88. case 3:
  89. mob = GetMonster(Envir.GetMonsterInfo(Settings.BoneMonster4));
  90. break;
  91. }
  92. if (mob == null) continue;
  93. if (!mob.Spawn(CurrentMap, Front))
  94. mob.Spawn(CurrentMap, CurrentLocation);
  95. mob.Target = Target;
  96. mob.ActionTime = Envir.Time + 2000;
  97. SlaveList.Add(mob);
  98. }
  99. }
  100. }
  101. }