NewbieCoupons.java 5.0 KB

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