MissQueen.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Copyright (C) 2004-2013 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 custom.MissQueen;
  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. /**
  25. * Miss Queen AI. Original Jython script by DrLecter, based in Eduu, biti and Newbie contributions.
  26. * @author Nyaran
  27. */
  28. public class MissQueen extends Quest
  29. {
  30. private static final String qn = "MissQueen";
  31. private static final int COUPNE_ONE = 7832;
  32. private static final int COUPNE_TWO = 7833;
  33. private static final int[] NPCs =
  34. {
  35. 31760,
  36. 31761,
  37. 31762,
  38. 31763,
  39. 31764,
  40. 31765,
  41. 31766
  42. };
  43. // enable/disable coupon give
  44. private static boolean QUEEN_ENABLED = false;
  45. // Newbie/one time rewards section
  46. // Any quest should rely on a unique bit, but
  47. // it could be shared among quest that were mutually
  48. // exclusive or race restricted.
  49. // Bit #1 isn't used for backwards compatibility.
  50. // This script uses 2 bits, one for newbie coupons and another for travelers
  51. private static final int NEWBIE_REWARD = 16;
  52. private static final int TRAVELER_REWARD = 32;
  53. public MissQueen(int id, String name, String descr)
  54. {
  55. super(id, name, descr);
  56. for (int i : NPCs)
  57. {
  58. addStartNpc(i);
  59. addFirstTalkId(i);
  60. addTalkId(i);
  61. }
  62. }
  63. @Override
  64. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  65. {
  66. String htmltext = event;
  67. if (!QUEEN_ENABLED)
  68. {
  69. return htmltext;
  70. }
  71. QuestState st = player.getQuestState(qn);
  72. int newbie = player.getNewbie();
  73. int level = player.getLevel();
  74. int occupation_level = player.getClassId().level();
  75. int pkkills = player.getPkKills();
  76. if (event.equals("newbie_give_coupon"))
  77. {
  78. /*
  79. * TODO: check if this is the very first character for this account would need a bit of SQL, or a core method to determine it. This condition should be stored by the core in the account_data table upon character creation.
  80. */
  81. if ((level >= 6) && (level <= 25) && (pkkills == 0) && (occupation_level == 0))
  82. {
  83. if ((newbie | NEWBIE_REWARD) != newbie)
  84. {
  85. player.setNewbie(newbie | NEWBIE_REWARD);
  86. st.giveItems(COUPNE_ONE, 1);
  87. htmltext = "31760-2.htm"; // here's the coupon you requested
  88. }
  89. else
  90. {
  91. htmltext = "31760-1.htm"; // you got a coupon already!
  92. }
  93. }
  94. else
  95. {
  96. htmltext = "31760-3.htm"; // you're not eligible to get a coupon (level caps, pkkills or already changed class)
  97. }
  98. }
  99. else if (event.equals("traveller_give_coupon"))
  100. {
  101. if ((level >= 6) && (level <= 25) && (pkkills == 0) && (occupation_level == 1))
  102. { // check the player state against this quest newbie rewarding mark.
  103. if ((newbie | TRAVELER_REWARD) != newbie)
  104. {
  105. player.setNewbie(newbie | TRAVELER_REWARD);
  106. st.giveItems(COUPNE_TWO, 1);
  107. htmltext = "31760-5.htm"; // here's the coupon you requested
  108. }
  109. else
  110. {
  111. htmltext = "31760-4.htm"; // you got a coupon already!
  112. }
  113. }
  114. else
  115. {
  116. htmltext = "31760-6.htm"; // you're not eligible to get a coupon (level caps, pkkills or already changed class)
  117. }
  118. }
  119. return htmltext;
  120. }
  121. @Override
  122. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  123. {
  124. QuestState st = player.getQuestState(qn);
  125. if (st == null)
  126. {
  127. st = newQuestState(player);
  128. }
  129. return "31760.htm";
  130. }
  131. public static void main(String args[])
  132. {
  133. new MissQueen(-1, qn, "custom");
  134. }
  135. }