StoningStatue.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class StoningStatue : MonsterObject
  7. {
  8. private long _areaTime = long.MaxValue;
  9. private const byte AttackRange = 2;
  10. protected internal StoningStatue(MonsterInfo info)
  11. : base(info)
  12. {
  13. }
  14. protected override bool InAttackRange()
  15. {
  16. if (Target.CurrentMap != CurrentMap) return false;
  17. if (Target.CurrentLocation == CurrentLocation) return false;
  18. int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
  19. int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
  20. if (x > 2 || y > 2) return false;
  21. return (x <= 1 && y <= 1) || (x == y || x % 2 == y % 2);
  22. }
  23. protected override void Attack()
  24. {
  25. if (!Target.IsAttackTarget(this))
  26. {
  27. Target = null;
  28. return;
  29. }
  30. if (_areaTime == long.MaxValue)
  31. {
  32. _areaTime = Envir.Time + 10000;
  33. }
  34. ShockTime = 0;
  35. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  36. if (Envir.Time < _areaTime)
  37. {
  38. ActionTime = Envir.Time + 300;
  39. AttackTime = Envir.Time + AttackSpeed;
  40. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  41. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  42. if (damage == 0) return;
  43. LineAttack(damage, AttackRange);
  44. }
  45. else
  46. {
  47. _areaTime = Envir.Time + 5000 + Envir.Random.Next(10) * 1000;
  48. ActionTime = Envir.Time + 500;
  49. AttackTime = Envir.Time + (AttackSpeed * 2);
  50. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  51. var damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  52. if (damage == 0) return;
  53. ActionList.Add(new DelayedAction(DelayedType.Damage, Envir.Time + 1600, Target, 0, DefenceType.MACAgility, true));
  54. }
  55. }
  56. protected override void CompleteAttack(IList<object> data)
  57. {
  58. MapObject target = (MapObject)data[0];
  59. int damage = (int)data[1];
  60. DefenceType defence = (DefenceType)data[2];
  61. bool area = data.Count >= 4 && (bool)data[3];
  62. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  63. if (!area)
  64. {
  65. target.Attacked(this, damage, defence);
  66. }
  67. else
  68. {
  69. List<MapObject> targets = FindAllTargets(2, CurrentLocation, false);
  70. if (targets.Count == 0) return;
  71. for (int i = 0; i < targets.Count; i++)
  72. {
  73. targets[i].Attacked(this, Stats[Stat.MaxMC], defence);
  74. PoisonTarget(targets[i], 2, Envir.Random.Next(5, 10), PoisonType.Dazed, 1000);
  75. }
  76. }
  77. }
  78. }
  79. }