WhiteFoxman.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class WhiteFoxman : MonsterObject
  6. {
  7. public long FearTime, TeleportTime;
  8. public byte AttackRange = 6;
  9. protected internal WhiteFoxman(MonsterInfo info)
  10. : base(info)
  11. {
  12. }
  13. protected override bool InAttackRange()
  14. {
  15. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  16. }
  17. protected override void Attack()
  18. {
  19. if (!Target.IsAttackTarget(this))
  20. {
  21. Target = null;
  22. return;
  23. }
  24. ShockTime = 0;
  25. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  26. ActionTime = Envir.Time + 300;
  27. AttackTime = Envir.Time + AttackSpeed;
  28. if (Envir.Random.Next(8) != 0)
  29. {
  30. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  31. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  32. if (damage == 0) return;
  33. int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step
  34. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.MACAgility, false);
  35. ActionList.Add(action);
  36. }
  37. else
  38. {
  39. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 });
  40. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target);
  41. ActionList.Add(action);
  42. }
  43. }
  44. protected override void CompleteAttack(IList<object> data)
  45. {
  46. MapObject target = (MapObject)data[0];
  47. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  48. int levelgap = 50 - target.Level;
  49. if (Envir.Random.Next(20) < 4 + levelgap) {
  50. PoisonTarget(target, 1, 5, PoisonType.Slow, 1000);
  51. }
  52. }
  53. protected override void ProcessTarget()
  54. {
  55. if (Target == null || !CanAttack) return;
  56. if (InAttackRange() && (Envir.Time < FearTime))
  57. {
  58. Attack();
  59. return;
  60. }
  61. FearTime = Envir.Time + 5000;
  62. if (Envir.Time < ShockTime)
  63. {
  64. Target = null;
  65. return;
  66. }
  67. int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
  68. if (dist >= AttackRange)
  69. MoveTo(Target.CurrentLocation);
  70. else
  71. {
  72. MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation);
  73. if (Walk(dir)) return;
  74. switch (Envir.Random.Next(2)) //No favour
  75. {
  76. case 0:
  77. for (int i = 0; i < 7; i++)
  78. {
  79. dir = Functions.NextDir(dir);
  80. if (Walk(dir))
  81. return;
  82. }
  83. break;
  84. default:
  85. for (int i = 0; i < 7; i++)
  86. {
  87. dir = Functions.PreviousDir(dir);
  88. if (Walk(dir))
  89. return;
  90. }
  91. break;
  92. }
  93. }
  94. }
  95. }
  96. }