Nadz.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class Nadz : MonsterObject
  7. {
  8. protected internal Nadz(MonsterInfo info)
  9. : base(info)
  10. {
  11. }
  12. protected override bool InAttackRange()
  13. {
  14. if (Target.CurrentMap != CurrentMap) return false;
  15. if (Target.CurrentLocation == CurrentLocation) return false;
  16. int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
  17. int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
  18. if (x > 3 || y > 3) return false;
  19. return (x <= 3 && y <= 3) || (x == y || x % 3 == y % 3);
  20. }
  21. protected override void Attack()
  22. {
  23. if (!Target.IsAttackTarget(this))
  24. {
  25. Target = null;
  26. return;
  27. }
  28. ShockTime = 0;
  29. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  30. ActionTime = Envir.Time + 300;
  31. AttackTime = Envir.Time + AttackSpeed;
  32. if (Envir.Random.Next(3) > 0)
  33. {
  34. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  35. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, 0, DefenceType.AC, true);
  36. ActionList.Add(action);
  37. }
  38. else
  39. {
  40. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  41. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  42. SinglePushAttack(damage);
  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. bool halfmoon = data.Count >= 4 && (bool)data[3];
  51. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  52. if (halfmoon)
  53. {
  54. List<MapObject> targets = FindAllTargets(3, CurrentLocation);
  55. if (targets.Count == 0) return;
  56. for (int i = 0; i < targets.Count; i++)
  57. {
  58. int damage2 = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  59. if (damage2 == 0) return;
  60. if (targets[i].Attacked(this, damage2, defence) <= 0) return;
  61. }
  62. }
  63. else
  64. {
  65. if (target.Attacked(this, damage, defence) <= 0) return;
  66. PoisonTarget(target, 3, 5, PoisonType.Paralysis);
  67. }
  68. }
  69. }
  70. }