HolyDeva.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using Server.MirDatabase;
  2. using S = ServerPackets;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class HolyDeva : MonsterObject
  6. {
  7. public long FearTime;
  8. public byte AttackRange = 6;
  9. public bool Summoned;
  10. protected internal HolyDeva(MonsterInfo info)
  11. : base(info)
  12. {
  13. Direction = MirDirection.DownLeft;
  14. }
  15. protected override bool InAttackRange()
  16. {
  17. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  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. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  29. ActionTime = Envir.Time + 300;
  30. AttackTime = Envir.Time + AttackSpeed;
  31. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  32. if (damage == 0) return;
  33. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC);
  34. ActionList.Add(action);
  35. }
  36. protected override void ProcessTarget()
  37. {
  38. if (Target == null || !CanAttack) return;
  39. if (Master != null)
  40. MoveTo(Master.CurrentLocation);
  41. if (InAttackRange() && (Master != null || Envir.Time < FearTime))
  42. {
  43. Attack();
  44. return;
  45. }
  46. FearTime = Envir.Time + 5000;
  47. if (Envir.Time < ShockTime)
  48. {
  49. Target = null;
  50. return;
  51. }
  52. int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
  53. if (dist < AttackRange)
  54. {
  55. MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation);
  56. if (Walk(dir)) return;
  57. switch (Envir.Random.Next(2)) //No favour
  58. {
  59. case 0:
  60. for (int i = 0; i < 7; i++)
  61. {
  62. dir = Functions.NextDir(dir);
  63. if (Walk(dir))
  64. return;
  65. }
  66. break;
  67. default:
  68. for (int i = 0; i < 7; i++)
  69. {
  70. dir = Functions.PreviousDir(dir);
  71. if (Walk(dir))
  72. return;
  73. }
  74. break;
  75. }
  76. }
  77. }
  78. public override void Spawned()
  79. {
  80. base.Spawned();
  81. Summoned = true;
  82. }
  83. public override Packet GetInfo()
  84. {
  85. var packet = (S.ObjectMonster)base.GetInfo();
  86. packet.Image = Monster.HolyDeva;
  87. packet.Extra = Summoned;
  88. return packet;
  89. }
  90. }
  91. }