Q00158_SeedOfEvil.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 quests.Q00158_SeedOfEvil;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.quest.Quest;
  23. import com.l2jserver.gameserver.model.quest.QuestState;
  24. import com.l2jserver.gameserver.model.quest.State;
  25. import com.l2jserver.gameserver.network.NpcStringId;
  26. import com.l2jserver.gameserver.network.clientpackets.Say2;
  27. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  28. /**
  29. * Seed of Evil (158)
  30. * @author malyelfik
  31. */
  32. public class Q00158_SeedOfEvil extends Quest
  33. {
  34. // NPC
  35. private static final int BIOTIN = 30031;
  36. // Monster
  37. private static final int NERKAS = 27016;
  38. // Items
  39. private static final int ENCHANT_ARMOR_D = 956;
  40. private static final int CLAY_TABLET = 1025;
  41. // Misc
  42. private static final int MIN_LEVEL = 21;
  43. public Q00158_SeedOfEvil()
  44. {
  45. super(158, Q00158_SeedOfEvil.class.getSimpleName(), "Seed of Evil");
  46. addStartNpc(BIOTIN);
  47. addTalkId(BIOTIN);
  48. addAttackId(NERKAS);
  49. addKillId(NERKAS);
  50. registerQuestItems(CLAY_TABLET);
  51. }
  52. @Override
  53. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  54. {
  55. final QuestState st = getQuestState(player, false);
  56. if ((st != null) && event.equalsIgnoreCase("30031-03.htm"))
  57. {
  58. st.startQuest();
  59. return event;
  60. }
  61. return null;
  62. }
  63. @Override
  64. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
  65. {
  66. if (npc.isScriptValue(0))
  67. {
  68. npc.broadcastPacket(new NpcSay(npc, Say2.NPC_ALL, NpcStringId._HOW_DARE_YOU_CHALLENGE_ME));
  69. npc.setScriptValue(1);
  70. }
  71. return super.onAttack(npc, attacker, damage, isSummon);
  72. }
  73. @Override
  74. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  75. {
  76. final QuestState st = getQuestState(killer, false);
  77. if ((st != null) && !st.hasQuestItems(CLAY_TABLET))
  78. {
  79. st.giveItems(CLAY_TABLET, 1);
  80. st.setCond(2, true);
  81. }
  82. npc.broadcastPacket(new NpcSay(npc, Say2.NPC_ALL, NpcStringId.THE_POWER_OF_LORD_BELETH_RULES_THE_WHOLE_WORLD));
  83. return super.onKill(npc, killer, isSummon);
  84. }
  85. @Override
  86. public String onTalk(L2Npc npc, L2PcInstance player)
  87. {
  88. String htmltext = getNoQuestMsg(player);
  89. final QuestState st = getQuestState(player, true);
  90. if (st == null)
  91. {
  92. return htmltext;
  93. }
  94. switch (st.getState())
  95. {
  96. case State.CREATED:
  97. htmltext = (player.getLevel() >= MIN_LEVEL) ? "30031-02.htm" : "30031-01.html";
  98. break;
  99. case State.STARTED:
  100. if (st.isCond(1))
  101. {
  102. htmltext = "30031-04.html";
  103. }
  104. else if (st.isCond(2) && st.hasQuestItems(CLAY_TABLET))
  105. {
  106. st.giveItems(ENCHANT_ARMOR_D, 1);
  107. st.addExpAndSp(17818, 927);
  108. st.giveAdena(1495, true);
  109. st.exitQuest(false, true);
  110. htmltext = "30031-05.html";
  111. }
  112. break;
  113. case State.COMPLETED:
  114. htmltext = getAlreadyCompletedMsg(player);
  115. break;
  116. }
  117. return htmltext;
  118. }
  119. }