AvengingSpirit.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class AvengingSpirit : AxeSkeleton
  6. {
  7. protected internal AvengingSpirit(MonsterInfo info)
  8. : base(info)
  9. {
  10. }
  11. protected override bool InAttackRange()
  12. {
  13. return CurrentMap == Target.CurrentMap && CanFly(Target.CurrentLocation) && 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. if (!ranged)
  28. {
  29. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  30. if (Envir.Random.Next(3) == 0)
  31. {
  32. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  33. SinglePushAttack(damage);
  34. }
  35. else
  36. {
  37. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  38. int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 400; //50 MS per Step
  39. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.ACAgility);
  40. ActionList.Add(action);
  41. }
  42. }
  43. else
  44. {
  45. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 });
  46. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  47. if (damage == 0) return;
  48. int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
  49. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.MACAgility, true);
  50. ActionList.Add(action);
  51. }
  52. }
  53. protected override void CompleteRangeAttack(IList<object> data)
  54. {
  55. MapObject target = (MapObject)data[0];
  56. int damage = (int)data[1];
  57. DefenceType defence = (DefenceType)data[2];
  58. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  59. var finalDamage = target.Attacked(this, damage, defence);
  60. if (finalDamage > 0)
  61. {
  62. PoisonTarget(target, 7, 5, PoisonType.Green, 1000);
  63. }
  64. }
  65. }
  66. }