SandSnail.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class SandSnail : MonsterObject
  7. {
  8. protected internal SandSnail(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);
  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.MinMC], Stats[Stat.MaxMC]);
  37. if (damage == 0) return;
  38. DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.MAC, true);
  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. HalfmoonAttack(damage, 300);
  48. }
  49. }
  50. protected override void CompleteAttack(IList<object> data)
  51. {
  52. MapObject target = (MapObject)data[0];
  53. int damage = (int)data[1];
  54. DefenceType defence = (DefenceType)data[2];
  55. bool poison = data.Count >= 4 && (bool)data[3];
  56. if (!poison)
  57. {
  58. if (target == null || !target.IsAttackTarget(this) || target.CurrentMap != CurrentMap || target.Node == null) return;
  59. target.Attacked(this, damage, defence);
  60. }
  61. else
  62. {
  63. List<MapObject> targets = FindAllTargets(1, CurrentLocation);
  64. if (targets.Count == 0) return;
  65. for (int i = 0; i < targets.Count; i++)
  66. {
  67. if (targets[i].Attacked(this, damage, defence) <= 0) continue;
  68. PoisonTarget(targets[i], 1, 5, PoisonType.Green, 2000);
  69. }
  70. }
  71. }
  72. }
  73. }