BlackTortoise.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class BlackTortoise : MonsterObject
  7. {
  8. protected virtual byte AttackRange
  9. {
  10. get
  11. {
  12. return 5;
  13. }
  14. }
  15. protected internal BlackTortoise(MonsterInfo info)
  16. : base(info)
  17. {
  18. }
  19. protected override bool InAttackRange()
  20. {
  21. return CurrentMap == Target.CurrentMap && CanFly(Target.CurrentLocation) && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  22. }
  23. protected override void Attack()
  24. {
  25. if (!Target.IsAttackTarget(this))
  26. {
  27. Target = null;
  28. return;
  29. }
  30. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  31. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  32. ActionTime = Envir.Time + 300;
  33. AttackTime = Envir.Time + AttackSpeed;
  34. ShockTime = 0;
  35. if (!ranged)
  36. {
  37. if (Envir.Random.Next(5) > 0)
  38. {
  39. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  40. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  41. if (damage == 0) return;
  42. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 400, Target, damage, DefenceType.ACAgility);
  43. ActionList.Add(action);
  44. }
  45. else
  46. {
  47. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  48. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  49. if (damage == 0) return;
  50. HalfmoonAttack(damage);
  51. }
  52. }
  53. else
  54. {
  55. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 });
  56. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  57. if (damage == 0) return;
  58. int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
  59. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.MACAgility);
  60. ActionList.Add(action);
  61. }
  62. }
  63. protected override void CompleteRangeAttack(IList<object> data)
  64. {
  65. MapObject target = (MapObject)data[0];
  66. int damage = (int)data[1];
  67. DefenceType defence = (DefenceType)data[2];
  68. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  69. if (target.Attacked(this, damage, defence) <= 0) return;
  70. PoisonTarget(target, 7, 5, PoisonType.Green, 1000);
  71. }
  72. protected override void ProcessTarget()
  73. {
  74. if (Target == null) return;
  75. if (InAttackRange() && CanAttack)
  76. {
  77. Attack();
  78. return;
  79. }
  80. if (Envir.Time < ShockTime)
  81. {
  82. Target = null;
  83. return;
  84. }
  85. MoveTo(Target.CurrentLocation);
  86. }
  87. }
  88. }