IOPRace.java 3.3 KB

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