Jar2.cs 2.5 KB

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