MudZombie.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class MudZombie : MonsterObject
  7. {
  8. protected internal MudZombie(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 override void Attack()
  17. {
  18. if (!Target.IsAttackTarget(this))
  19. {
  20. Target = null;
  21. return;
  22. }
  23. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  24. ActionTime = Envir.Time + 300;
  25. AttackTime = Envir.Time + AttackSpeed;
  26. ShockTime = 0;
  27. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 2);
  28. if (!ranged)
  29. {
  30. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  31. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  32. if (damage == 0) return;
  33. LineAttack(damage, 2);
  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. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC);
  42. ActionList.Add(action);
  43. }
  44. }
  45. protected override void CompleteAttack(IList<object> data)
  46. {
  47. MapObject target = (MapObject)data[0];
  48. int damage = (int)data[1];
  49. DefenceType defence = (DefenceType)data[2];
  50. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  51. if (target.Attacked(this, damage, defence) <= 0) return;
  52. PoisonTarget(target, 5, 8, PoisonType.Green, 2000);
  53. }
  54. protected override void CompleteRangeAttack(IList<object> data)
  55. {
  56. MapObject target = (MapObject)data[0];
  57. int damage = (int)data[1];
  58. DefenceType defence = (DefenceType)data[2];
  59. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  60. if (target.Attacked(this, damage, defence) <= 0) return;
  61. PoisonTarget(target, 5, 8, PoisonType.Green, 2000);
  62. }
  63. protected override void ProcessTarget()
  64. {
  65. if (Target == null) return;
  66. if (InAttackRange() && CanAttack)
  67. {
  68. Attack();
  69. return;
  70. }
  71. if (Envir.Time < ShockTime)
  72. {
  73. Target = null;
  74. return;
  75. }
  76. MoveTo(Target.CurrentLocation);
  77. }
  78. }
  79. }