Turtlegrass.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using Server.MirDatabase;
  2. using Server.MirEnvir;
  3. using S = ServerPackets;
  4. namespace Server.MirObjects.Monsters
  5. {
  6. public class TurtleGrass : ZumaMonster
  7. {
  8. protected internal TurtleGrass(MonsterInfo info)
  9. : base(info)
  10. {
  11. }
  12. protected override bool InAttackRange()
  13. {
  14. if (Target.CurrentMap != CurrentMap) return false;
  15. if (Target.CurrentLocation == CurrentLocation) return false;
  16. int x = Math.Abs(Target.CurrentLocation.X - CurrentLocation.X);
  17. int y = Math.Abs(Target.CurrentLocation.Y - CurrentLocation.Y);
  18. if (x > 2 || y > 2) return false;
  19. return (x <= 1 && y <= 1) || (x == y || x % 2 == y % 2);
  20. }
  21. protected override void Attack()
  22. {
  23. ShockTime = 0;
  24. if (!Target.IsAttackTarget(this))
  25. {
  26. Target = null;
  27. return;
  28. }
  29. Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
  30. ActionTime = Envir.Time + 300;
  31. AttackTime = Envir.Time + AttackSpeed;
  32. if (Envir.Random.Next(4) > 0)
  33. {
  34. base.Attack();
  35. }
  36. else
  37. {
  38. Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
  39. int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
  40. SinglePushAttack(damage, DefenceType.AC);
  41. }
  42. }
  43. }
  44. }