PeacockSpider.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class PeacockSpider : MonsterObject
  7. {
  8. private long _PoisonTime;
  9. private long _PoisonRainTime;
  10. protected internal PeacockSpider(MonsterInfo info)
  11. : base(info)
  12. {
  13. }
  14. protected override bool InAttackRange()
  15. {
  16. return CurrentMap == Target.CurrentMap && Functions.InRange(CurrentLocation, Target.CurrentLocation, Info.ViewRange);
  17. }
  18. protected override void Attack()
  19. {
  20. if (!Target.IsAttackTarget(this))
  21. {
  22. Target = null;
  23. return;
  24. }
  25. ActionTime = Envir.Time + 300;
  26. AttackTime = Envir.Time + AttackSpeed;
  27. ShockTime = 0;
  28. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  29. bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 3);
  30. if (Envir.Time > _PoisonRainTime)
  31. {
  32. //TODO - Animation broken as too large
  33. //Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 });
  34. //int damage = GetAttackPower(Stats[Stat.MinSC], Stats[Stat.MaxSC] * 2);
  35. //if (damage == 0) return;
  36. //DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.ACAgility, true);
  37. //ActionList.Add(action);
  38. _PoisonRainTime = Envir.Time + 30000;
  39. //return;
  40. }
  41. if (!ranged && Envir.Random.Next(4) > 0)
  42. {
  43. if (Envir.Time > _PoisonTime) //Poison
  44. {
  45. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 });
  46. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  47. if (damage == 0) return;
  48. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MACAgility, true, false);
  49. ActionList.Add(action);
  50. _PoisonTime = Envir.Time + 20000;
  51. return;
  52. }
  53. if (Envir.Random.Next(3) > 0) //Normal
  54. {
  55. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
  56. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  57. if (damage == 0) return;
  58. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.ACAgility, false, false);
  59. ActionList.Add(action);
  60. }
  61. else //Front Stomp
  62. {
  63. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  64. var damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  65. if (damage == 0) return;
  66. TriangleAttack(damage, 3, 2, 500, DefenceType.ACAgility, false);
  67. }
  68. }
  69. else
  70. {
  71. if (Envir.Random.Next(5) == 0)
  72. {
  73. Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 });
  74. int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
  75. if (damage == 0) return;
  76. ProjectileAttack(damage, DefenceType.MACAgility);
  77. }
  78. }
  79. }
  80. protected override void CompleteAttack(IList<object> data)
  81. {
  82. MapObject target = (MapObject)data[0];
  83. int damage = (int)data[1];
  84. DefenceType defence = (DefenceType)data[2];
  85. bool poisonCloud = data.Count >= 4 && (bool)data[3];
  86. bool daze = data.Count < 5 || (bool)data[4];
  87. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  88. if (poisonCloud)
  89. {
  90. var targets = FindAllTargets(3, CurrentLocation, false);
  91. for (int i = 0; i < targets.Count; i++)
  92. {
  93. if (targets[i].Attacked(this, damage, defence) <= 0) continue;
  94. PoisonTarget(targets[i], 2, Envir.Random.Next(2, 6), PoisonType.Green, 1000);
  95. }
  96. return;
  97. }
  98. if (daze)
  99. {
  100. if (target.Attacked(this, damage, defence) <= 0) return;
  101. PoisonTarget(target, 2, Envir.Random.Next(2, 6), PoisonType.Dazed, 1000);
  102. return;
  103. }
  104. target.Attacked(this, damage, defence);
  105. }
  106. protected override void CompleteRangeAttack(IList<object> data)
  107. {
  108. MapObject target = (MapObject)data[0];
  109. int damage = (int)data[1];
  110. DefenceType defence = (DefenceType)data[2];
  111. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  112. if (target.Attacked(this, damage, defence) <= 0) return;
  113. PoisonTarget(target, 4, 5, PoisonType.Paralysis, 1000);
  114. }
  115. protected override void ProcessTarget()
  116. {
  117. if (Target == null) return;
  118. if (InAttackRange() && CanAttack)
  119. {
  120. Attack();
  121. return;
  122. }
  123. if (Envir.Time < ShockTime)
  124. {
  125. Target = null;
  126. return;
  127. }
  128. MoveTo(Target.CurrentLocation);
  129. }
  130. }
  131. }