MissQueen.java 4.1 KB

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