FlamingMutant.cs 4.2 KB

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