ConquestArcher.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. namespace Server.MirObjects.Monsters
  4. {
  5. public class ConquestArcher : TownArcher
  6. {
  7. public ConquestObject Conquest;
  8. public int ArcherIndex;
  9. protected override bool CanMove
  10. {
  11. get { return Route.Count > 0 && !Dead && Envir.Time > MoveTime && Envir.Time > ActionTime && Envir.Time > ShockTime; }
  12. }
  13. protected internal ConquestArcher(MonsterInfo info)
  14. : base(info)
  15. {
  16. }
  17. public override bool IsAttackTarget(MonsterObject attacker) { return false; }
  18. public override void Die()
  19. {
  20. base.Die();
  21. }
  22. protected override void FindTarget()
  23. {
  24. for (int d = 0; d <= Info.ViewRange; d++)
  25. {
  26. for (int y = CurrentLocation.Y - d; y <= CurrentLocation.Y + d; y++)
  27. {
  28. if (y < 0) continue;
  29. if (y >= CurrentMap.Height) break;
  30. for (int x = CurrentLocation.X - d; x <= CurrentLocation.X + d; x += Math.Abs(y - CurrentLocation.Y) == d ? 1 : d * 2)
  31. {
  32. if (x < 0) continue;
  33. if (x >= CurrentMap.Width) break;
  34. Cell cell = CurrentMap.GetCell(x, y);
  35. if (!cell.Valid || cell.Objects == null) continue;
  36. for (int i = 0; i < cell.Objects.Count; i++)
  37. {
  38. MapObject ob = cell.Objects[i];
  39. switch (ob.Race)
  40. {
  41. case ObjectType.Player:
  42. PlayerObject playerob = (PlayerObject)ob;
  43. if (!ob.IsAttackTarget(this)) continue;
  44. if (playerob.MyGuild != null && playerob.MyGuild.Conquest != null && Conquest.Info.Index == playerob.MyGuild.Conquest.Info.Index || ob.Hidden && (!CoolEye || Level < ob.Level) || !Conquest.WarIsOn) continue;
  45. Target = ob;
  46. return;
  47. default:
  48. continue;
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }
  55. public override int Attacked(HumanObject attacker, int damage, DefenceType type = DefenceType.ACAgility, bool damageWeapon = true)
  56. {
  57. if (!Conquest.WarIsOn || attacker.MyGuild != null && Conquest.GuildInfo.Owner == attacker.MyGuild.Guildindex) damage = 0;
  58. return base.Attacked(attacker, damage, type, damageWeapon);
  59. }
  60. public override int Attacked(MonsterObject attacker, int damage, DefenceType type = DefenceType.ACAgility)
  61. {
  62. if (!Conquest.WarIsOn) damage = 0;
  63. return base.Attacked(attacker, damage, type);
  64. }
  65. }
  66. }