Katenar.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * Copyright (C) 2004-2015 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.Katenar;
  20. import quests.Q00065_CertifiedSoulBreaker.Q00065_CertifiedSoulBreaker;
  21. import ai.npc.AbstractNpcAI;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.quest.QuestState;
  25. import com.l2jserver.gameserver.network.NpcStringId;
  26. import com.l2jserver.gameserver.network.clientpackets.Say2;
  27. /**
  28. * Katenar AI for quests Certified Soul Breaker (65)
  29. * @author ivantotov
  30. */
  31. public final class Katenar extends AbstractNpcAI
  32. {
  33. // NPC
  34. private static final int KATENAR = 32242;
  35. // Item
  36. private static final int SEALED_DOCUMENT = 9803;
  37. private Katenar()
  38. {
  39. super(Katenar.class.getSimpleName(), "ai/npc");
  40. addStartNpc(KATENAR);
  41. addTalkId(KATENAR);
  42. addFirstTalkId(KATENAR);
  43. addSpawnId(KATENAR);
  44. }
  45. @Override
  46. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  47. {
  48. final L2Npc npc0 = npc.getVariables().getObject("npc0", L2Npc.class);
  49. String htmltext = null;
  50. switch (event)
  51. {
  52. case "CREATED_50":
  53. {
  54. if (npc0 != null)
  55. {
  56. if (!npc.getVariables().getBoolean("SPAWNED", false))
  57. {
  58. npc0.getVariables().set("SPAWNED", false);
  59. }
  60. }
  61. npc.deleteMe();
  62. break;
  63. }
  64. case "GOOD_LUCK":
  65. {
  66. final QuestState qs = player.getQuestState(Q00065_CertifiedSoulBreaker.class.getSimpleName());
  67. if (qs.isMemoState(14))
  68. {
  69. if (npc0 != null)
  70. {
  71. if (!npc.getVariables().getBoolean("SPAWNED", false))
  72. {
  73. npc0.getVariables().set("SPAWNED", false);
  74. broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.GOOD_LUCK);
  75. }
  76. }
  77. npc.deleteMe();
  78. }
  79. break;
  80. }
  81. }
  82. return htmltext;
  83. }
  84. @Override
  85. public String onFirstTalk(L2Npc npc, L2PcInstance talker)
  86. {
  87. final QuestState qs = talker.getQuestState(Q00065_CertifiedSoulBreaker.class.getSimpleName());
  88. String htmltext = getNoQuestMsg(talker);
  89. final int memoState = qs.getMemoState();
  90. if (memoState == 12)
  91. {
  92. htmltext = "32242-01.html";
  93. }
  94. else if (memoState == 13)
  95. {
  96. final L2PcInstance player = npc.getVariables().getObject("player0", L2PcInstance.class);
  97. if (player == talker)
  98. {
  99. qs.setMemoState(14);
  100. qs.setCond(13, true);
  101. htmltext = "32242-02.html";
  102. }
  103. else
  104. {
  105. qs.setMemoState(14);
  106. qs.setCond(13, true);
  107. htmltext = "32242-03.html";
  108. }
  109. if (!hasQuestItems(player, SEALED_DOCUMENT))
  110. {
  111. giveItems(player, SEALED_DOCUMENT, 1);
  112. }
  113. }
  114. else if (memoState == 14)
  115. {
  116. htmltext = "32242-04.html";
  117. }
  118. return htmltext;
  119. }
  120. @Override
  121. public String onSpawn(L2Npc npc)
  122. {
  123. startQuestTimer("CREATED_50", 50000, npc, null);
  124. final L2PcInstance player = npc.getVariables().getObject("player0", L2PcInstance.class);
  125. if (player != null)
  126. {
  127. broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.I_AM_LATE);
  128. }
  129. return super.onSpawn(npc);
  130. }
  131. public static void main(String[] args)
  132. {
  133. new Katenar();
  134. }
  135. }