ManectricClaw.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 ManectricClaw : MonsterObject
  8. {
  9. private const byte AttackRange = 3;
  10. private long _thrustTime;
  11. protected internal ManectricClaw(MonsterInfo info)
  12. : base(info)
  13. {
  14. }
  15. protected override bool InAttackRange()
  16. {
  17. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  18. }
  19. protected override void Attack()
  20. {
  21. if (!Target.IsAttackTarget(this))
  22. {
  23. Target = null;
  24. return;
  25. }
  26. ShockTime = 0;
  27. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  28. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  29. if(ranged || Envir.Time > _thrustTime)
  30. {
  31. if (ranged && Envir.Random.Next(2) == 0)
  32. {
  33. MoveTo(Target.CurrentLocation);
  34. ActionTime = Envir.Time + 300;
  35. return;
  36. }
  37. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID });
  38. AttackTime = Envir.Time + AttackSpeed;
  39. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500);
  40. ActionList.Add(action);
  41. _thrustTime = Envir.Time + 5000;
  42. return;
  43. }
  44. base.Attack();
  45. }
  46. protected override void CompleteRangeAttack(IList<object> data)
  47. {
  48. IceThrust();
  49. }
  50. private void IceThrust()
  51. {
  52. Point location = CurrentLocation;
  53. MirDirection direction = Direction;
  54. Cell cell;
  55. int nearDamage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  56. int farDamage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  57. int col = 3;
  58. int row = 3;
  59. Point[] loc = new Point[col]; //0 = left 1 = center 2 = right
  60. loc[0] = Functions.PointMove(location, Functions.PreviousDir(direction), 1);
  61. loc[1] = Functions.PointMove(location, direction, 1);
  62. loc[2] = Functions.PointMove(location, Functions.NextDir(direction), 1);
  63. for (int i = 0; i < col; i++)
  64. {
  65. Point startPoint = loc[i];
  66. for (int j = 0; j < row; j++)
  67. {
  68. Point hitPoint = Functions.PointMove(startPoint, direction, j);
  69. if (!CurrentMap.ValidPoint(hitPoint)) continue;
  70. cell = CurrentMap.GetCell(hitPoint);
  71. if (cell.Objects == null) continue;
  72. for (int k = 0; k < cell.Objects.Count; k++)
  73. {
  74. MapObject target = cell.Objects[k];
  75. switch (target.Race)
  76. {
  77. case ObjectType.Monster:
  78. case ObjectType.Player:
  79. if (target.IsAttackTarget(this))
  80. {
  81. if (target.Attacked(this, j <= 1 ? nearDamage : farDamage, DefenceType.MAC) > 0)
  82. {
  83. PoisonTarget(target, 5, target.Race == ObjectType.Player ? 4 : 5 + Envir.Random.Next(5), PoisonType.Slow, 1000);
  84. PoisonTarget(target, 5, target.Race == ObjectType.Player ? 2 : 5 + Envir.Random.Next(this.Stats[Stat.Freezing]), PoisonType.Frozen, 1000);
  85. }
  86. }
  87. break;
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }
  94. }