GasToad.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class GasToad : MonsterObject
  7. {
  8. protected internal GasToad(MonsterInfo info)
  9. : base(info)
  10. {
  11. }
  12. protected override void Attack()
  13. {
  14. if (!Target.IsAttackTarget(this))
  15. {
  16. Target = null;
  17. return;
  18. }
  19. ShockTime = 0;
  20. ActionTime = Envir.Time + 300;
  21. AttackTime = Envir.Time + AttackSpeed;
  22. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  23. if (Envir.Random.Next(7) > 0)
  24. {
  25. if (Envir.Random.Next(2) > 0)
  26. {
  27. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation });
  28. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  29. if (damage == 0) return;
  30. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, false, false);
  31. ActionList.Add(action);
  32. }
  33. else
  34. {
  35. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2 });
  36. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  37. if (damage == 0) return;
  38. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, true, false);
  39. ActionList.Add(action);
  40. }
  41. }
  42. else
  43. {
  44. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  45. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  46. if (damage == 0) return;
  47. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, false, true);
  48. ActionList.Add(action);
  49. }
  50. }
  51. protected override void CompleteAttack(IList<object> data)
  52. {
  53. MapObject target = (MapObject)data[0];
  54. int damage = (int)data[1];
  55. DefenceType defence = (DefenceType)data[2];
  56. bool poison = data.Count >= 4 && (bool)data[3];
  57. bool slam = data.Count >= 5 && (bool)data[4];
  58. if (!poison)
  59. {
  60. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  61. target.Attacked(this, damage, defence);
  62. if (slam)
  63. {
  64. PoisonTarget(target, 1, 5, PoisonType.Paralysis, 2000);
  65. }
  66. }
  67. else
  68. {
  69. List<MapObject> targets = FindAllTargets(1, CurrentLocation);
  70. if (targets.Count == 0) return;
  71. for (int i = 0; i < targets.Count; i++)
  72. {
  73. if (targets[i].Attacked(this, damage, defence) <= 0) continue;
  74. PoisonTarget(targets[i], 1, 5, PoisonType.Green, 2000);
  75. }
  76. }
  77. }
  78. }
  79. }