Shinsu.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class Shinsu : MonsterObject
  7. {
  8. public bool Mode = false;
  9. public bool Summoned;
  10. public long ModeTime;
  11. protected override bool CanAttack
  12. {
  13. get
  14. {
  15. return base.CanAttack && Mode;
  16. }
  17. }
  18. protected internal Shinsu(MonsterInfo info) : base(info)
  19. {
  20. ActionTime = Envir.Time + 1000;
  21. }
  22. protected override void ProcessAI()
  23. {
  24. if (!Dead && Envir.Time > ActionTime)
  25. {
  26. if (Target != null) ModeTime = Envir.Time + 30000;
  27. if (!Mode && Envir.Time < ModeTime)
  28. {
  29. Mode = true;
  30. Broadcast(new S.ObjectShow { ObjectID = ObjectID });
  31. ActionTime = Envir.Time + 1000;
  32. }
  33. else if (Mode && Envir.Time > ModeTime)
  34. {
  35. Mode = false;
  36. Broadcast(new S.ObjectHide { ObjectID = ObjectID });
  37. ActionTime = Envir.Time + 1000;
  38. }
  39. }
  40. base.ProcessAI();
  41. }
  42. protected override bool InAttackRange()
  43. {
  44. if (Target.CurrentMap != CurrentMap) return false;
  45. if (Target.CurrentLocation == CurrentLocation) return false;
  46. int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
  47. int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
  48. if (x > 2 || y > 2) return false;
  49. return (x <= 1 && y <= 1) || (x == y || x % 2 == y % 2);
  50. }
  51. protected override void Attack()
  52. {
  53. if (!Target.IsAttackTarget(this))
  54. {
  55. Target = null;
  56. return;
  57. }
  58. ActionTime = Envir.Time + 300;
  59. AttackTime = Envir.Time + AttackSpeed;
  60. ShockTime = 0;
  61. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  62. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  63. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  64. if (damage == 0) return;
  65. LineAttack(damage, 2);
  66. }
  67. public override void Spawned()
  68. {
  69. base.Spawned();
  70. Summoned = true;
  71. }
  72. public override Packet GetInfo()
  73. {
  74. var packet = (S.ObjectMonster)base.GetInfo();
  75. packet.Image = Mode ? Monster.Shinsu1 : Monster.Shinsu;
  76. packet.Extra = Summoned;
  77. return packet;
  78. }
  79. }
  80. }