OmaWitchDoctor.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 OmaWitchDoctor : MonsterObject
  7. {
  8. protected internal OmaWitchDoctor(MonsterInfo info)
  9. : base(info)
  10. {
  11. }
  12. protected override bool InAttackRange()
  13. {
  14. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, Info.ViewRange);
  15. }
  16. protected bool InLineAttackRange()
  17. {
  18. if (Target.CurrentMap != CurrentMap) return false;
  19. if (Target.CurrentLocation == CurrentLocation) return false;
  20. int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
  21. int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
  22. if (x > 6 || y > 6) return false;
  23. return (x == 0) || (y == 0) || (x == y);
  24. }
  25. protected override void Attack()
  26. {
  27. if (!Target.IsAttackTarget(this))
  28. {
  29. Target = null;
  30. return;
  31. }
  32. ShockTime = 0;
  33. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  34. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  35. ActionTime = Envir.Time + 300;
  36. AttackTime = Envir.Time + AttackSpeed;
  37. if (!ranged)
  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 + 500, Target, damage, DefenceType.ACAgility);
  43. ActionList.Add(action);
  44. }
  45. else
  46. {
  47. if (InLineAttackRange())
  48. {
  49. AttackTime = Envir.Time + AttackSpeed + 500;
  50. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 });
  51. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  52. if (damage == 0) return;
  53. LineAttack(damage, 6, 500, DefenceType.MACAgility);
  54. }
  55. else
  56. {
  57. AttackTime = Envir.Time + AttackSpeed + 500;
  58. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 });
  59. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  60. if (damage == 0) return;
  61. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC);
  62. ActionList.Add(action);
  63. }
  64. }
  65. }
  66. protected override void ProcessTarget()
  67. {
  68. if (Target == null) return;
  69. if (InAttackRange() && CanAttack)
  70. {
  71. Attack();
  72. return;
  73. }
  74. if (Envir.Time < ShockTime)
  75. {
  76. Target = null;
  77. return;
  78. }
  79. if (!InLineAttackRange())
  80. {
  81. MoveTo(Target.CurrentLocation);
  82. }
  83. }
  84. }
  85. }