FinialTurtle.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class FinialTurtle : MonsterObject
  7. {
  8. private const byte AttackRange = 6;
  9. protected internal FinialTurtle(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. ActionTime = Envir.Time + 300;
  26. AttackTime = Envir.Time + AttackSpeed;
  27. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  28. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  29. if (!ranged)
  30. {
  31. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  32. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  33. if (damage == 0) return;
  34. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility);
  35. ActionList.Add(action);
  36. }
  37. else
  38. {
  39. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  40. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  41. if (damage == 0) return;
  42. int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
  43. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.MACAgility);
  44. ActionList.Add(action);
  45. }
  46. }
  47. protected override void CompleteRangeAttack(IList<object> data)
  48. {
  49. MapObject target = (MapObject)data[0];
  50. int damage = (int)data[1];
  51. DefenceType defence = (DefenceType)data[2];
  52. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  53. if (target.Attacked(this, damage, defence) <= 0) return;
  54. PoisonTarget(target, 8, 15, PoisonType.Slow, 1000);
  55. PoisonTarget(target, 15, 5, PoisonType.Frozen, 1000);
  56. }
  57. protected override void ProcessTarget()
  58. {
  59. if (Target == null) return;
  60. if (InAttackRange() && CanAttack)
  61. {
  62. Attack();
  63. return;
  64. }
  65. if (Envir.Time < ShockTime)
  66. {
  67. Target = null;
  68. return;
  69. }
  70. MoveTo(Target.CurrentLocation);
  71. }
  72. }
  73. }