WaterDragon.cs 3.4 KB

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