ManectricBlest.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 ManectricBlest : MonsterObject
  8. {
  9. private int _attackCount = 0;
  10. protected internal ManectricBlest(MonsterInfo info)
  11. : base(info)
  12. {
  13. }
  14. protected override void Attack()
  15. {
  16. if (!Target.IsAttackTarget(this))
  17. {
  18. Target = null;
  19. return;
  20. }
  21. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  22. if(_attackCount >= 5)
  23. {
  24. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 });
  25. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  26. List<MapObject> targets = FindAllTargets(3, CurrentLocation);
  27. for (int i = 0; i < targets.Count; i++)
  28. {
  29. targets[i].Attacked(this, damage, DefenceType.MAC);
  30. //TODO - Delay this
  31. if (Envir.Random.Next(Settings.PoisonResistWeight) >= targets[i].Stats[Stat.PoisonResist])
  32. {
  33. if (Envir.Random.Next(5) == 0)
  34. {
  35. targets[i].ApplyPoison(new Poison { PType = PoisonType.Frozen, Duration = 5, TickSpeed = 1000 }, this);
  36. }
  37. }
  38. }
  39. _attackCount = 0;
  40. return;
  41. }
  42. switch (Envir.Random.Next(3))
  43. {
  44. case 0:
  45. case 1:
  46. _attackCount++;
  47. base.Attack();
  48. break;
  49. case 2:
  50. {
  51. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  52. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  53. MirDirection dir = Functions.PreviousDir(Direction);
  54. Point tar;
  55. Cell cell;
  56. for (int i = 0; i < 8; i++)
  57. {
  58. tar = Functions.PointMove(CurrentLocation, dir, 1);
  59. dir = Functions.NextDir(dir);
  60. if (tar == Front) continue;
  61. if (!CurrentMap.ValidPoint(tar)) continue;
  62. cell = CurrentMap.GetCell(tar);
  63. if (cell.Objects == null) continue;
  64. for (int o = 0; o < cell.Objects.Count; o++)
  65. {
  66. MapObject ob = cell.Objects[o];
  67. if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster) continue;
  68. if (!ob.IsAttackTarget(this)) continue;
  69. ob.Attacked(this, damage, DefenceType.Agility);
  70. break;
  71. }
  72. }
  73. break;
  74. }
  75. }
  76. ActionTime = Envir.Time + 300;
  77. AttackTime = Envir.Time + AttackSpeed;
  78. ShockTime = 0;
  79. }
  80. }
  81. }