FurbolgCommander.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class FurbolgCommander : MonsterObject
  6. {
  7. protected virtual byte AttackRange
  8. {
  9. get
  10. {
  11. return 8;
  12. }
  13. }
  14. protected internal FurbolgCommander(MonsterInfo info)
  15. : base(info)
  16. {
  17. }
  18. protected override bool InAttackRange()
  19. {
  20. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  21. }
  22. protected override void Attack()
  23. {
  24. if (!Target.IsAttackTarget(this))
  25. {
  26. Target = null;
  27. return;
  28. }
  29. ShockTime = 0;
  30. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  31. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  32. ActionTime = Envir.Time + 300;
  33. AttackTime = Envir.Time + AttackSpeed;
  34. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  35. if (!ranged)
  36. {
  37. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  38. if (damage == 0) return;
  39. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility);
  40. ActionList.Add(action);
  41. }
  42. else
  43. {
  44. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  45. AttackTime = Envir.Time + AttackSpeed + 500;
  46. if (damage == 0) return;
  47. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MACAgility);
  48. ActionList.Add(action);
  49. }
  50. }
  51. protected override void ProcessTarget()
  52. {
  53. if (Target == null) return;
  54. if (InAttackRange() && CanAttack)
  55. {
  56. Attack();
  57. return;
  58. }
  59. if (Envir.Time < ShockTime)
  60. {
  61. Target = null;
  62. return;
  63. }
  64. MoveTo(Target.CurrentLocation);
  65. }
  66. }
  67. }