Tornado.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class Tornado : MonsterObject
  6. {
  7. private const byte AttackRange = 5;
  8. protected internal Tornado(MonsterInfo info)
  9. : base(info)
  10. {
  11. }
  12. protected override bool InAttackRange()
  13. {
  14. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  15. }
  16. protected override void Attack()
  17. {
  18. if (!Target.IsAttackTarget(this))
  19. {
  20. Target = null;
  21. return;
  22. }
  23. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  24. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  25. if (!ranged)
  26. {
  27. base.Attack();
  28. }
  29. else
  30. {
  31. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  32. List<MapObject> targets = FindAllTargets(AttackRange, CurrentLocation, false);
  33. if (targets.Count == 0) return;
  34. for (int i = 0; i < targets.Count; i++)
  35. {
  36. MirDirection dir = Functions.DirectionFromPoint(targets[i].CurrentLocation, CurrentLocation);
  37. int dist = Functions.MaxDistance(targets[i].CurrentLocation, CurrentLocation);
  38. targets[i].Pushed(this, dir, dist - 1);
  39. }
  40. }
  41. ShockTime = 0;
  42. ActionTime = Envir.Time + 300;
  43. AttackTime = Envir.Time + AttackSpeed;
  44. }
  45. }
  46. }