IOPRace.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 custom.IOPRace;
  16. import com.l2jserver.gameserver.datatables.SkillTable;
  17. import com.l2jserver.gameserver.model.L2Skill;
  18. import com.l2jserver.gameserver.model.actor.L2Npc;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.model.quest.Quest;
  21. import com.l2jserver.gameserver.model.quest.QuestState;
  22. public class IOPRace extends Quest
  23. {
  24. final private static int RIGNOS = 32349;
  25. final private static int STAMP = 10013;
  26. final private static int KEY = 9694;
  27. private int _player = -1;
  28. public IOPRace(int id, String name, String descr)
  29. {
  30. super(id, name, descr);
  31. addStartNpc(RIGNOS);
  32. addTalkId(RIGNOS);
  33. addFirstTalkId(RIGNOS);
  34. }
  35. @Override
  36. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  37. {
  38. QuestState st = player.getQuestState(getName());
  39. if (st == null)
  40. st = newQuestState(player);
  41. if (player.getLevel() < 78)
  42. return "32349-notavailable.htm";
  43. else if ((_player != -1) && (_player == player.getObjectId()) && (st.getQuestItemsCount(STAMP) == 4))
  44. return "32349-return.htm";
  45. else if (_player != -1)
  46. return "32349-notavailable.htm";
  47. npc.showChatWindow(player);
  48. return null;
  49. }
  50. @Override
  51. public String onTalk(L2Npc npc, L2PcInstance player)
  52. {
  53. QuestState st = player.getQuestState(getName());
  54. if (st == null)
  55. st = newQuestState(player);
  56. if (_player == -1)
  57. {
  58. // clean old data
  59. player.stopSkillEffects(5239);
  60. if (player.getPet() != null)
  61. player.getPet().stopSkillEffects(5239);
  62. st.takeItems(STAMP, -1);
  63. st.set("1st", "0");
  64. st.set("2nd", "0");
  65. st.set("3rd", "0");
  66. st.set("4th", "0");
  67. L2Skill skill = SkillTable.getInstance().getInfo(5239, 5);
  68. if (skill != null)
  69. {
  70. skill.getEffects(npc, player);
  71. if (player.getPet() != null)
  72. skill.getEffects(npc, player.getPet());
  73. }
  74. startQuestTimer("timer", 1800000, null, null); // 30 min
  75. _player = player.getObjectId();
  76. }
  77. return null;
  78. }
  79. @Override
  80. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  81. {
  82. String htmltext = "";
  83. if (event.equalsIgnoreCase("timer"))
  84. {
  85. _player = -1;
  86. return null;
  87. }
  88. else if (event.equalsIgnoreCase("finish"))
  89. {
  90. if (_player == player.getObjectId())
  91. {
  92. QuestState st = player.getQuestState(getName());
  93. st.giveItems(KEY, 3);
  94. st.takeItems(STAMP, -1);
  95. st.exitQuest(true);
  96. }
  97. }
  98. return htmltext;
  99. }
  100. public static void main(String[] args)
  101. {
  102. new IOPRace(-1, "IOPRace", "custom");
  103. }
  104. }