WarriorHero.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. namespace Server.MirObjects
  4. {
  5. public class WarriorHero : HeroObject
  6. {
  7. public WarriorHero(CharacterInfo info, PlayerObject owner) : base(info, owner) { }
  8. protected override bool InAttackRange()
  9. {
  10. if (Target.CurrentMap != CurrentMap) return false;
  11. if (Info.Thrusting)
  12. {
  13. int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
  14. int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
  15. if (x > 2 || y > 2) return false;
  16. return (x <= 1 && y <= 1) || (x == y || x % 2 == y % 2);
  17. }
  18. return Target.CurrentLocation != CurrentLocation && Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  19. }
  20. protected override void ProcessFriend()
  21. {
  22. if (!CanCast) return;
  23. if (Target != null)
  24. {
  25. UserMagic magic = GetMagic(Spell.Rage);
  26. if (CanUseMagic(magic) && !HasBuff(BuffType.Rage))
  27. {
  28. BeginMagic(magic.Spell, Direction, ObjectID, CurrentLocation);
  29. return;
  30. }
  31. magic = GetMagic(Spell.ProtectionField);
  32. if (CanUseMagic(magic) && !HasBuff(BuffType.ProtectionField))
  33. {
  34. BeginMagic(magic.Spell, Direction, ObjectID, CurrentLocation);
  35. return;
  36. }
  37. }
  38. }
  39. protected override void ProcessAttack()
  40. {
  41. if (Target == null || Target.Dead) return;
  42. TargetDistance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
  43. if (HasMagic(Spell.FlamingSword) && Envir.Time > FlamingSwordTime)
  44. SpellToggle(Spell.FlamingSword, SpellToggleState.True);
  45. }
  46. protected override void Attack()
  47. {
  48. if (Target != null && Owner.PMode == PetMode.FocusMasterTarget && !Target.IsAttackTarget(Owner))
  49. {
  50. Target = null;
  51. return;
  52. }
  53. if (Target != null && CanAttack)
  54. {
  55. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  56. var behindEnemyLocation = Functions.PointMove(Target.CurrentLocation, Direction, 1);
  57. var thrustCell = CurrentMap.GetCell(behindEnemyLocation);
  58. bool ThrustObject = false;
  59. if (thrustCell.Objects != null && thrustCell.Objects.Count != 0) ThrustObject = true;
  60. Spell spell = Spell.None;
  61. if (Info.Thrusting && ((TargetDistance == 2) || (TargetDistance == 1 && ThrustObject == true)))
  62. {
  63. spell = Spell.Thrusting;
  64. }
  65. if (spell == Spell.None && Slaying)
  66. spell = Spell.Slaying;
  67. if (spell == Spell.None)
  68. {
  69. if (Info.HalfMoon)
  70. spell = Spell.HalfMoon;
  71. if (Info.CrossHalfMoon)
  72. spell = Spell.CrossHalfMoon;
  73. if (TwinDrakeBlade)
  74. spell = Spell.TwinDrakeBlade;
  75. if (FlamingSword)
  76. spell = Spell.FlamingSword;
  77. }
  78. Attack(Direction, spell);
  79. }
  80. }
  81. }
  82. }