NewbieCoupons.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 custom.NewbieCoupons;
  20. import com.l2jserver.gameserver.data.xml.impl.MultisellData;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.quest.Quest;
  24. import com.l2jserver.gameserver.model.quest.QuestState;
  25. /**
  26. * Newbie Weapon/Accesories Coupons for the Hellbound opening event.<br>
  27. * Original Jython script by Vice.
  28. * @author Nyaran
  29. */
  30. public final class NewbieCoupons extends Quest
  31. {
  32. private static final int COUPON_ONE = 7832;
  33. private static final int COUPON_TWO = 7833;
  34. private static final int[] NPCs =
  35. {
  36. 30598,
  37. 30599,
  38. 30600,
  39. 30601,
  40. 30602,
  41. 31076,
  42. 31077,
  43. 32135
  44. };
  45. private static final int WEAPON_MULTISELL = 305986001;
  46. private static final int ACCESORIES_MULTISELL = 305986002;
  47. // enable/disable coupon give
  48. private static final boolean NEWBIE_COUPONS_ENABLED = true;
  49. /*
  50. * Newbie/one time rewards section Any quest should rely on a unique bit, but it could be shared among quests that were mutually exclusive or race restricted. Bit //1 isn't used for backwards compatibility. This script uses 2 bits, one for newbie coupons and another for travelers These 2 bits
  51. * happen to be the same used by the Miss Queen script
  52. */
  53. private static final int NEWBIE_WEAPON = 16;
  54. private static final int NEWBIE_ACCESORY = 32;
  55. private NewbieCoupons()
  56. {
  57. super(-1, NewbieCoupons.class.getSimpleName(), "custom");
  58. for (int i : NPCs)
  59. {
  60. addStartNpc(i);
  61. addTalkId(i);
  62. }
  63. }
  64. @Override
  65. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  66. {
  67. String htmltext = event;
  68. if (!NEWBIE_COUPONS_ENABLED)
  69. {
  70. return htmltext;
  71. }
  72. QuestState st = getQuestState(player, false);
  73. int newbie = player.getNewbie();
  74. int level = player.getLevel();
  75. int occupation_level = player.getClassId().level();
  76. int pkkills = player.getPkKills();
  77. if (event.equals("newbie_give_weapon_coupon"))
  78. {
  79. /*
  80. * 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.
  81. */
  82. if ((level >= 6) && (level <= 39) && (pkkills == 0) && (occupation_level == 0))
  83. {
  84. // check the player state against this quest newbie rewarding mark.
  85. if ((newbie | NEWBIE_WEAPON) != newbie)
  86. {
  87. player.setNewbie(newbie | NEWBIE_WEAPON);
  88. st.giveItems(COUPON_ONE, 5);
  89. htmltext = "30598-2.htm"; // here's the coupon you requested
  90. }
  91. else
  92. {
  93. htmltext = "30598-1.htm"; // you got a coupon already!
  94. }
  95. }
  96. else
  97. {
  98. htmltext = "30598-3.htm"; // you're not eligible to get a coupon (level caps, pkkills or already changed class)
  99. }
  100. }
  101. else if (event.equals("newbie_give_armor_coupon"))
  102. {
  103. if ((level >= 6) && (level <= 39) && (pkkills == 0) && (occupation_level == 1))
  104. {
  105. // check the player state against this quest newbie rewarding mark.
  106. if ((newbie | NEWBIE_ACCESORY) != newbie)
  107. {
  108. player.setNewbie(newbie | NEWBIE_ACCESORY);
  109. st.giveItems(COUPON_TWO, 1);
  110. htmltext = "30598-5.htm"; // here's the coupon you requested
  111. }
  112. else
  113. {
  114. htmltext = "30598-4.htm"; // you got a coupon already!
  115. }
  116. }
  117. else
  118. {
  119. htmltext = "30598-6.htm"; // you're not eligible to get a coupon (level caps, pkkills or didnt change class yet)
  120. }
  121. }
  122. else if (event.equals("newbie_show_weapon"))
  123. {
  124. if ((level >= 6) && (level <= 39) && (pkkills == 0) && (occupation_level == 0))
  125. {
  126. MultisellData.getInstance().separateAndSend(WEAPON_MULTISELL, player, npc, false);
  127. return null;
  128. }
  129. htmltext = "30598-7.htm"; // you're not eligible to use warehouse
  130. }
  131. else if (event.equals("newbie_show_armor"))
  132. {
  133. if ((level >= 6) && (level <= 39) && (pkkills == 0) && (occupation_level > 0))
  134. {
  135. MultisellData.getInstance().separateAndSend(ACCESORIES_MULTISELL, player, npc, false);
  136. return null;
  137. }
  138. htmltext = "30598-8.htm"; // you're not eligible to use warehouse
  139. }
  140. return htmltext;
  141. }
  142. @Override
  143. public String onTalk(L2Npc npc, L2PcInstance player)
  144. {
  145. getQuestState(player, true);
  146. return "30598.htm";
  147. }
  148. public static void main(String args[])
  149. {
  150. new NewbieCoupons();
  151. }
  152. }