SuspiciousStones.java 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package ai.npc;
  16. import quests.Q00114_ResurrectionOfAnOldManager.Q00114_ResurrectionOfAnOldManager;
  17. import com.l2jserver.gameserver.datatables.SpawnTable;
  18. import com.l2jserver.gameserver.model.L2Spawn;
  19. import com.l2jserver.gameserver.model.actor.L2Npc;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. import com.l2jserver.gameserver.model.quest.QuestState;
  22. import com.l2jserver.gameserver.network.NpcStringId;
  23. import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
  24. /**
  25. * Suspicious-Looking Pile of Stones AI
  26. * @author malyelfik
  27. */
  28. public class SuspiciousStones extends AbstractNpcAI
  29. {
  30. private static final int npcId = 32046;
  31. @Override
  32. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  33. {
  34. if (event.equalsIgnoreCase("check"))
  35. {
  36. for (L2PcInstance pl : npc.getKnownList().getKnownPlayers().values())
  37. {
  38. if (pl != null)
  39. {
  40. final QuestState st = pl.getQuestState(Q00114_ResurrectionOfAnOldManager.class.getSimpleName());
  41. if ((st != null) && st.isCond(17))
  42. {
  43. st.takeItems(8090, 1);
  44. st.giveItems(8091, 1);
  45. st.setCond(18, true);
  46. pl.sendPacket(new ExShowScreenMessage(NpcStringId.THE_RADIO_SIGNAL_DETECTOR_IS_RESPONDING_A_SUSPICIOUS_PILE_OF_STONES_CATCHES_YOUR_EYE, 2, 4500));
  47. }
  48. }
  49. }
  50. }
  51. return event;
  52. }
  53. public SuspiciousStones(String name, String descr)
  54. {
  55. super(name, descr);
  56. L2Npc npc = null;
  57. for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable())
  58. {
  59. if ((spawn != null) && (spawn.getNpcid() == npcId))
  60. {
  61. npc = spawn.getLastSpawn();
  62. }
  63. }
  64. if (npc != null)
  65. {
  66. startQuestTimer("check", 1000, npc, null, true);
  67. }
  68. else
  69. {
  70. _log.warning("SuspiciousStones: Can't find npc!");
  71. }
  72. }
  73. public static void main(String[] args)
  74. {
  75. new SuspiciousStones(SuspiciousStones.class.getSimpleName(), "ai/npc");
  76. }
  77. }