LeftGuard.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class LeftGuard : RightGuard
  6. {
  7. protected internal LeftGuard(MonsterInfo info)
  8. : base(info)
  9. {
  10. }
  11. protected override void Attack()
  12. {
  13. if (!Target.IsAttackTarget(this))
  14. {
  15. Target = null;
  16. return;
  17. }
  18. ShockTime = 0;
  19. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  20. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  21. ActionTime = Envir.Time + 300;
  22. AttackTime = Envir.Time + AttackSpeed;
  23. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  24. if (!ranged)
  25. {
  26. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  27. if (damage == 0) return;
  28. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.MACAgility);
  29. ActionList.Add(action);
  30. }
  31. else
  32. {
  33. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  34. AttackTime = Envir.Time + AttackSpeed + 500;
  35. if (damage == 0) return;
  36. int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
  37. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.MAC);
  38. ActionList.Add(action);
  39. }
  40. }
  41. }
  42. }