FlameMage.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using Server.MirDatabase;
  2. namespace Server.MirObjects.Monsters
  3. {
  4. public class FlameMage : RightGuard
  5. {
  6. public long FearTime;
  7. protected internal FlameMage(MonsterInfo info)
  8. : base(info)
  9. {
  10. }
  11. protected override void CompleteRangeAttack(IList<object> data)
  12. {
  13. MapObject target = (MapObject)data[0];
  14. int damage = (int)data[1];
  15. DefenceType defence = (DefenceType)data[2];
  16. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  17. List<MapObject> targets = FindAllTargets(2, target.CurrentLocation);
  18. if (targets.Count == 0) return;
  19. for (int i = 0; i < targets.Count; i++)
  20. {
  21. targets[i].Attacked(this, damage, defence);
  22. }
  23. }
  24. protected override void ProcessTarget()
  25. {
  26. if (Target == null || !CanAttack) return;
  27. if (InAttackRange() && Envir.Time < FearTime)
  28. {
  29. Attack();
  30. return;
  31. }
  32. FearTime = Envir.Time + 5000;
  33. if (Envir.Time < ShockTime)
  34. {
  35. Target = null;
  36. return;
  37. }
  38. int dist = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
  39. if (dist >= AttackRange)
  40. MoveTo(Target.CurrentLocation);
  41. else
  42. {
  43. MirDirection dir = Functions.DirectionFromPoint(Target.CurrentLocation, CurrentLocation);
  44. if (Walk(dir)) return;
  45. switch (Envir.Random.Next(2)) //No favour
  46. {
  47. case 0:
  48. for (int i = 0; i < 7; i++)
  49. {
  50. dir = Functions.NextDir(dir);
  51. if (Walk(dir))
  52. return;
  53. }
  54. break;
  55. default:
  56. for (int i = 0; i < 7; i++)
  57. {
  58. dir = Functions.PreviousDir(dir);
  59. if (Walk(dir))
  60. return;
  61. }
  62. break;
  63. }
  64. }
  65. }
  66. }
  67. }