TucsonWarrior.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class TucsonWarrior : MonsterObject
  7. {
  8. protected internal TucsonWarrior(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 > 2 || y > 2) return false;
  19. return (x <= 1 && y <= 1) || (x == y || x % 2 == y % 2);
  20. }
  21. protected override void Attack()
  22. {
  23. if (!Target.IsAttackTarget(this))
  24. {
  25. Target = null;
  26. return;
  27. }
  28. ActionTime = Envir.Time + 300;
  29. AttackTime = Envir.Time + AttackSpeed;
  30. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  31. bool range = !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  32. if (!range && Envir.Random.Next(5) > 0)
  33. {
  34. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  35. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  36. if (damage == 0) return;
  37. HalfmoonAttack(damage, 300);
  38. }
  39. else
  40. {
  41. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  42. SmashAttack(1);
  43. }
  44. ShockTime = 0;
  45. }
  46. private void SmashAttack(int radius)
  47. {
  48. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  49. if (damage == 0) return;
  50. var targets = FindAllTargets(radius, Target.CurrentLocation, false);
  51. for (int i = 0; i < targets.Count; i++)
  52. {
  53. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, targets[i], damage, DefenceType.ACAgility);
  54. ActionList.Add(action);
  55. }
  56. }
  57. }
  58. }