EvilMirBody.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using Server.MirDatabase;
  2. namespace Server.MirObjects.Monsters
  3. {
  4. public class EvilMirBody : MonsterObject
  5. {
  6. private bool _dragonlink;
  7. public bool DragonLink
  8. {
  9. get { return _dragonlink && Envir.DragonSystem != null; }
  10. set
  11. {
  12. if (_dragonlink == value) return;
  13. _dragonlink = value;
  14. }
  15. }
  16. protected override bool CanAttack { get { return false; } }
  17. protected override bool CanMove { get { return false; } }
  18. protected internal EvilMirBody(MonsterInfo info)
  19. : base(info)
  20. {
  21. DragonLink = true;
  22. }
  23. public override void Turn(MirDirection dir)
  24. {
  25. }
  26. public override bool Walk(MirDirection dir) { return false; }
  27. protected override void ProcessRoam() { }
  28. protected override void ProcessSearch() { }
  29. public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
  30. {
  31. if (DragonLink)
  32. {
  33. if (Envir.DragonSystem.LinkedMonster != null)
  34. {
  35. MonsterObject ob = Envir.DragonSystem.LinkedMonster;
  36. if (attacker.Info.AI == 6)
  37. EXPOwner = null;
  38. else if (attacker.Master != null)
  39. {
  40. if (!Functions.InRange(attacker.CurrentLocation, attacker.Master.CurrentLocation, Globals.DataRange))
  41. ob.EXPOwner = null;
  42. else
  43. {
  44. if (ob.EXPOwner == null || ob.EXPOwner.Dead)
  45. ob.EXPOwner = attacker.Master switch
  46. {
  47. HeroObject hero => hero.Owner,
  48. _ => attacker.Master
  49. };
  50. if (ob.EXPOwner == attacker.Master)
  51. ob.EXPOwnerTime = Envir.Time + EXPOwnerDelay;
  52. }
  53. }
  54. }
  55. Envir.DragonSystem.GainExp(Envir.Random.Next(1, 40));
  56. return 1;
  57. }
  58. return 0;
  59. }
  60. public override int Attacked(HumanObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
  61. {
  62. if (DragonLink)
  63. {
  64. if (Envir.DragonSystem.LinkedMonster != null)
  65. {
  66. MonsterObject ob = Envir.DragonSystem.LinkedMonster;
  67. if (ob.EXPOwner == null || ob.EXPOwner.Dead)
  68. ob.EXPOwner = GetAttacker(attacker);
  69. if (ob.EXPOwner == attacker)
  70. ob.EXPOwnerTime = Envir.Time + EXPOwnerDelay;
  71. }
  72. if (damageWeapon)
  73. attacker.DamageWeapon();
  74. Envir.DragonSystem.GainExp(Envir.Random.Next(1, 40));
  75. return 1;
  76. }
  77. return 0;
  78. }
  79. public override int Struck(int damage, DefenceType type = DefenceType.ACAgility)
  80. {
  81. return 0;
  82. }
  83. }
  84. }