HornedArcher.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class HornedArcher : AxeSkeleton
  6. {
  7. public long BuffTime;
  8. protected internal HornedArcher(MonsterInfo info)
  9. : base(info)
  10. {
  11. }
  12. protected override void ProcessTarget()
  13. {
  14. if (Envir.Time > BuffTime)
  15. {
  16. var friends = FindAllFriends(Info.ViewRange, CurrentLocation);
  17. if (friends.Count > 0)
  18. {
  19. var friend = friends[Envir.Random.Next(friends.Count)];
  20. int delay = Functions.MaxDistance(CurrentLocation, friend.CurrentLocation) * 50 + 500;
  21. Direction = Functions.DirectionFromPoint(CurrentLocation, friend.CurrentLocation);
  22. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = friend.ObjectID, Type = 1 });
  23. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, friend, 0, DefenceType.MACAgility);
  24. ActionList.Add(action);
  25. BuffTime = Envir.Time + 20000;
  26. ActionTime = Envir.Time + 300;
  27. AttackTime = Envir.Time + AttackSpeed;
  28. ShockTime = 0;
  29. return;
  30. }
  31. BuffTime = Envir.Time + 10000;
  32. }
  33. base.ProcessTarget();
  34. }
  35. protected override void Attack()
  36. {
  37. if (!Target.IsAttackTarget(this))
  38. {
  39. Target = null;
  40. return;
  41. }
  42. ShockTime = 0;
  43. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  44. ActionTime = Envir.Time + 300;
  45. AttackTime = Envir.Time + AttackSpeed;
  46. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 });
  47. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  48. if (damage == 0) return;
  49. int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500;
  50. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.ACAgility);
  51. ActionList.Add(action);
  52. }
  53. protected override void CompleteAttack(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.CurrentMap != CurrentMap || target.Node == null) return;
  59. if (target.IsFriendlyTarget(this))
  60. {
  61. var friends = FindAllFriends(4, target.CurrentLocation);
  62. var min = Stats[Stat.MinMC];
  63. var max = Stats[Stat.MaxMC];
  64. for (int i = 0; i < friends.Count; i++)
  65. {
  66. if (friends[i].Node == null) continue;
  67. if (Info.Effect == 0)
  68. {
  69. var stats = new Stats { [Stat.MinDC] = min, [Stat.MaxDC] = max, [Stat.MinMC] = min, [Stat.MaxMC] = max };
  70. friends[i].AddBuff(BuffType.HornedArcherBuff, this, Settings.Second * 10, stats);
  71. }
  72. else if (Info.Effect == 1)
  73. {
  74. var stats = new Stats { [Stat.MinAC] = min, [Stat.MaxAC] = max, [Stat.MinMAC] = min, [Stat.MaxMAC] = max };
  75. friends[i].AddBuff(BuffType.ColdArcherBuff, this, Settings.Second * 10, stats);
  76. }
  77. friends[i].OperateTime = 0;
  78. }
  79. }
  80. else if (target.IsAttackTarget(this))
  81. {
  82. target.Attacked(this, damage, defence);
  83. }
  84. }
  85. }
  86. }