DarkDevourer.cs 2.9 KB

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