SeedingsGeneral.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class SeedingsGeneral : MonsterObject
  7. {
  8. protected virtual byte AttackRange
  9. {
  10. get
  11. {
  12. return 2;
  13. }
  14. }
  15. protected internal SeedingsGeneral(MonsterInfo info)
  16. : base(info)
  17. {
  18. }
  19. protected override bool InAttackRange()
  20. {
  21. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange);
  22. }
  23. protected override void Attack()
  24. {
  25. if (!Target.IsAttackTarget(this))
  26. {
  27. Target = null;
  28. return;
  29. }
  30. ShockTime = 0;
  31. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  32. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);
  33. if (!ranged && Envir.Random.Next(5) > 0)
  34. {
  35. ActionTime = Envir.Time + 300;
  36. AttackTime = Envir.Time + AttackSpeed;
  37. if (Envir.Random.Next(4) > 0)
  38. {
  39. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  40. //Blood Attack
  41. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  42. if (damage == 0) return;
  43. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility);
  44. ActionList.Add(action);
  45. }
  46. else
  47. {
  48. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  49. //Green Splash Attack
  50. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  51. if (damage == 0) return;
  52. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.MACAgility);
  53. ActionList.Add(action);
  54. }
  55. }
  56. else
  57. {
  58. ActionTime = Envir.Time + 600;
  59. AttackTime = Envir.Time + AttackSpeed;
  60. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  61. if (Envir.Random.Next(5) > 0)
  62. {
  63. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 });
  64. if (damage == 0) return;
  65. //Echo Shout
  66. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 300, Target, damage, DefenceType.MACAgility, false);
  67. ActionList.Add(action);
  68. }
  69. else
  70. {
  71. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 });
  72. if (damage == 0) return;
  73. //Stomp
  74. DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 300, Target, damage, DefenceType.MACAgility, true);
  75. ActionList.Add(action);
  76. }
  77. }
  78. }
  79. protected override void CompleteRangeAttack(IList<object> data)
  80. {
  81. MapObject target = (MapObject)data[0];
  82. int damage = (int)data[1];
  83. DefenceType defence = (DefenceType)data[2];
  84. bool aoe = (bool)data[3];
  85. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  86. if (aoe)
  87. {
  88. var targets = FindAllTargets(2, CurrentLocation, false);
  89. for (int i = 0; i < targets.Count; i++)
  90. {
  91. if (targets[i].Attacked(this, damage, defence) <= 0) continue;
  92. PoisonTarget(targets[i], 5, 5, PoisonType.Frozen, 1000);
  93. }
  94. }
  95. else
  96. {
  97. if (target.Attacked(this, damage, defence) <= 0) return;
  98. PoisonTarget(target, 5, 5, PoisonType.Slow, 1000);
  99. }
  100. }
  101. }
  102. }