StoneGolem.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System.Drawing;
  2. using Server.MirDatabase;
  3. using Server.MirEnvir;
  4. using S = ServerPackets;
  5. namespace Server.MirObjects.Monsters
  6. {
  7. public class StoneGolem : MonsterObject
  8. {
  9. protected virtual byte AttackRange
  10. {
  11. get
  12. {
  13. return 4;
  14. }
  15. }
  16. protected internal StoneGolem(MonsterInfo info)
  17. : base(info)
  18. {
  19. }
  20. protected override bool InAttackRange()
  21. {
  22. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  23. }
  24. protected override void Attack()
  25. {
  26. if (!Target.IsAttackTarget(this))
  27. {
  28. Target = null;
  29. return;
  30. }
  31. ShockTime = 0;
  32. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  33. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  34. ActionTime = Envir.Time + 300;
  35. AttackTime = Envir.Time + AttackSpeed;
  36. if (!ranged)
  37. {
  38. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  39. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  40. if (damage == 0) return;
  41. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.AC);
  42. ActionList.Add(action);
  43. }
  44. else
  45. {
  46. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  47. var location = Functions.PointMove(CurrentLocation, Direction, 3);
  48. for (int y = location.Y - 2; y <= location.Y + 2; y++)
  49. {
  50. if (y < 0) continue;
  51. if (y >= CurrentMap.Height) break;
  52. for (int x = location.X - 2; x <= location.X + 2; x++)
  53. {
  54. if (x < 0) continue;
  55. if (x >= CurrentMap.Width) break;
  56. var cell = CurrentMap.GetCell(x, y);
  57. if (!cell.Valid) continue;
  58. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  59. var start = 500;
  60. SpellObject ob = new SpellObject
  61. {
  62. Spell = Spell.StoneGolemQuake,
  63. Value = damage,
  64. ExpireTime = Envir.Time + 800 + start,
  65. TickSpeed = 1000,
  66. Direction = Direction,
  67. CurrentLocation = new Point(x, y),
  68. CastLocation = CurrentLocation,
  69. Show = location.X == x && location.Y == y,
  70. CurrentMap = CurrentMap,
  71. Caster = this
  72. };
  73. DelayedAction action = new DelayedAction(DelayedType.Spawn, Envir.Time + start, ob);
  74. CurrentMap.ActionList.Add(action);
  75. }
  76. }
  77. }
  78. }
  79. }
  80. }