RedThunderZuma.cs 2.4 KB

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