FrozenAxeman.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class FrozenAxeman : MonsterObject
  7. {
  8. public long PullTime;
  9. protected internal FrozenAxeman(MonsterInfo info)
  10. : base(info)
  11. {
  12. }
  13. protected override bool InAttackRange()
  14. {
  15. if (Target.CurrentMap != CurrentMap) return false;
  16. if (Target.CurrentLocation == CurrentLocation) return false;
  17. int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
  18. int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
  19. if (x > 2 || y > 2) return false;
  20. return (x <= 1 && y <= 1) || (x == y || x % 2 == y % 2);
  21. }
  22. protected override void Attack()
  23. {
  24. if (!Target.IsAttackTarget(this))
  25. {
  26. Target = null;
  27. return;
  28. }
  29. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  30. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  31. if (damage == 0) return;
  32. bool range = !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  33. if (!range && Envir.Random.Next(3) > 0)
  34. {
  35. if (Envir.Time >= PullTime)
  36. {
  37. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 });
  38. PullTime = Envir.Time + 10000;
  39. AttackTime = Envir.Time + AttackSpeed;
  40. ActionTime = Envir.Time + 300;
  41. Target.Pushed(this, Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation), 2 + Envir.Random.Next(3));
  42. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.AC);
  43. ActionList.Add(action);
  44. }
  45. else
  46. {
  47. base.Attack();
  48. }
  49. }
  50. else
  51. {
  52. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  53. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage * 2, DefenceType.AC);
  54. ActionList.Add(action);
  55. }
  56. ActionTime = Envir.Time + 300;
  57. AttackTime = Envir.Time + AttackSpeed;
  58. ShockTime = 0;
  59. }
  60. }
  61. }