OmaCannibal.cs 3.2 KB

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