TownPets.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2004-2014 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package ai.npc.TownPets;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.Config;
  22. import com.l2jserver.gameserver.ai.CtrlIntention;
  23. import com.l2jserver.gameserver.model.Location;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. /**
  27. * Town Pets AI
  28. * @author malyelfik
  29. */
  30. public final class TownPets extends AbstractNpcAI
  31. {
  32. // Pet IDs
  33. private static final int[] PETS =
  34. {
  35. 31202, // Maximus
  36. 31203, // Moon Dancer
  37. 31204, // Georgio
  38. 31205, // Katz
  39. 31206, // Ten Ten
  40. 31207, // Sardinia
  41. 31208, // La Grange
  42. 31209, // Misty Rain
  43. 31266, // Kaiser
  44. 31593, // Dorothy
  45. 31758, // Rafi
  46. 31955, // Ruby
  47. };
  48. private TownPets()
  49. {
  50. super(TownPets.class.getSimpleName(), "ai/npc");
  51. if (Config.ALLOW_PET_WALKERS)
  52. {
  53. addSpawnId(PETS);
  54. }
  55. }
  56. @Override
  57. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  58. {
  59. if (event.equalsIgnoreCase("move"))
  60. {
  61. final int locX = (npc.getSpawn().getX() - 50) + getRandom(100);
  62. final int locY = (npc.getSpawn().getY() - 50) + getRandom(100);
  63. npc.setRunning();
  64. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(locX, locY, npc.getZ(), 0));
  65. startQuestTimer("move", 5000, npc, null);
  66. }
  67. return null;
  68. }
  69. @Override
  70. public String onSpawn(L2Npc npc)
  71. {
  72. startQuestTimer("move", 3000, npc, null);
  73. return super.onSpawn(npc);
  74. }
  75. public static void main(String[] args)
  76. {
  77. new TownPets();
  78. }
  79. }