Gate.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. using System.Drawing;
  2. using Server.MirDatabase;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class Gate : CastleGate
  7. {
  8. protected internal Gate(MonsterInfo info) : base(info)
  9. {
  10. switch (info.Effect)
  11. {
  12. case 1: //Sabuk Door
  13. BlockArray = new Point[]
  14. {
  15. new Point(0, -1),
  16. new Point(0, -2),
  17. new Point(1, -1),
  18. new Point(1, -2),
  19. new Point(-1, 0),
  20. new Point(-2, 0),
  21. new Point(-1, -1),
  22. new Point(-1, 1)
  23. };
  24. break;
  25. case 2: //West Pointing Castle Gi
  26. BlockArray = new Point[]
  27. {
  28. new Point(0, -1),
  29. new Point(-1, -1),
  30. new Point(-1, 0),
  31. new Point(0, 1),
  32. new Point(1, 1),
  33. new Point(1, 0),
  34. new Point(1, -1),
  35. new Point(0, -2),
  36. };
  37. break;
  38. case 3: // South Pointing Castle Gi
  39. {
  40. BlockArray = new Point[]
  41. {
  42. new Point(1, -1),
  43. new Point(0, -1),
  44. new Point(0, -2),
  45. new Point(-1, -1),
  46. new Point(-2, -1),
  47. new Point(-1, 0),
  48. new Point(-1, 1),
  49. new Point(-2, 0),
  50. };
  51. }
  52. break;
  53. case 4: // East Pointing Castle Gi
  54. {
  55. BlockArray = new Point[]
  56. {
  57. new Point(-2, 0),
  58. new Point(-1, 1),
  59. new Point(0, 2),
  60. new Point(0, 1),
  61. new Point(-1, 0),
  62. new Point(-1, -1),
  63. new Point(1, 1),
  64. };
  65. }
  66. break;
  67. }
  68. Direction = MirDirection.Up;
  69. }
  70. public override void Despawn()
  71. {
  72. base.Despawn();
  73. }
  74. public override int Attacked(HumanObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
  75. {
  76. CheckDirection();
  77. if (!Conquest.WarIsOn || attacker.MyGuild != null && Conquest.GuildInfo.Owner == attacker.MyGuild.Guildindex) damage = 0;
  78. return base.Attacked(attacker, damage, type, damageWeapon);
  79. }
  80. public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
  81. {
  82. CheckDirection();
  83. if (!Conquest.WarIsOn) damage = 0;
  84. return base.Attacked(attacker, damage, type);
  85. }
  86. public override void OpenDoor()
  87. {
  88. if (!Closed) return;
  89. Direction = (MirDirection)6;
  90. Closed = false;
  91. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  92. ActiveDoorWall(false);
  93. }
  94. public void CheckDirection()
  95. {
  96. MirDirection newDirection = (MirDirection)(3 - GetDamageLevel());
  97. if (newDirection != Direction)
  98. {
  99. Direction = newDirection;
  100. Broadcast(new S.ObjectTurn { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  101. }
  102. }
  103. public override void CloseDoor()
  104. {
  105. if (Closed) return;
  106. Direction = (MirDirection)(3 - GetDamageLevel());
  107. Closed = true;
  108. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  109. ActiveDoorWall(true);
  110. }
  111. public override void RepairGate()
  112. {
  113. if (HP == 0)
  114. Revive(Stats[Stat.HP], false);
  115. else
  116. SetHP(Stats[Stat.HP]);
  117. CheckDirection();
  118. }
  119. protected override int GetDamageLevel()
  120. {
  121. int level = (int)Math.Round((double)(3 * HP) / Stats[Stat.HP]);
  122. if (level < 1) level = 1;
  123. return level;
  124. }
  125. protected override bool CanRegen
  126. {
  127. get
  128. {
  129. return false;
  130. }
  131. }
  132. }
  133. }