AssassinHero.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using Server.MirDatabase;
  2. using Server.MirNetwork;
  3. namespace Server.MirObjects
  4. {
  5. public class AssassinHero : HeroObject
  6. {
  7. private bool HasHeavenlySword;
  8. public AssassinHero(CharacterInfo info, PlayerObject owner) : base(info, owner) { }
  9. protected override void Load(CharacterInfo info, MirConnection connection)
  10. {
  11. base.Load(info, connection);
  12. if (HasMagic(Spell.DoubleSlash))
  13. Info.DoubleSlash = true;
  14. }
  15. protected override bool InAttackRange()
  16. {
  17. if (Target.CurrentMap != CurrentMap) return false;
  18. if (HasHeavenlySword)
  19. {
  20. int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
  21. int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
  22. if (x > 2 || y > 2) return false;
  23. return (x <= 1 && y <= 1) || (x == y || x % 2 == y % 2);
  24. }
  25. return Target.CurrentLocation != CurrentLocation && Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  26. }
  27. protected override void ProcessFriend()
  28. {
  29. if (!CanCast) return;
  30. if (Target != null)
  31. {
  32. UserMagic magic = GetMagic(Spell.Haste);
  33. if (CanUseMagic(magic) && !HasBuff(BuffType.Haste))
  34. {
  35. BeginMagic(magic.Spell, Direction, ObjectID, CurrentLocation);
  36. return;
  37. }
  38. magic = GetMagic(Spell.LightBody);
  39. if (CanUseMagic(magic) && !HasBuff(BuffType.LightBody))
  40. {
  41. BeginMagic(magic.Spell, Direction, ObjectID, CurrentLocation);
  42. return;
  43. }
  44. }
  45. }
  46. protected override void ProcessAttack()
  47. {
  48. if (Target == null || Target.Dead) return;
  49. TargetDistance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
  50. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  51. UserMagic magic = GetMagic(Spell.HeavenlySword);
  52. HasHeavenlySword = CanCast && CanUseMagic(magic);
  53. if (HasHeavenlySword && TargetDistance == 2)
  54. {
  55. BeginMagic(magic.Spell, Direction, Target.ObjectID, Target.CurrentLocation);
  56. return;
  57. }
  58. }
  59. protected override void Attack()
  60. {
  61. if (Target != null && Owner.PMode == PetMode.FocusMasterTarget && !Target.IsAttackTarget(Owner))
  62. {
  63. Target = null;
  64. return;
  65. }
  66. if (Target != null && CanAttack)
  67. {
  68. Spell spell = Spell.None;
  69. if (Info.DoubleSlash)
  70. spell = Spell.DoubleSlash;
  71. Attack(Direction, spell);
  72. }
  73. }
  74. }
  75. }