ShadowWeapons.java 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.ShadowWeapons;
  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. * @author DrLecter (python), Nyaran (java)
  22. */
  23. public class ShadowWeapons extends Quest
  24. {
  25. private static final String qn = "ShadowWeapons";
  26. // NPCs that would need to figure out what to show when asked about coupons exchange
  27. private static final int[] NPC =
  28. {
  29. 30037, 30066, 30070, 30109, 30115, 30120, 30174, 30175, 30176, 30187, 30191,
  30. 30195, 30288, 30289, 30290, 30297, 30373, 30462, 30474, 30498, 30499, 30500,
  31. 30503, 30504, 30505, 30511, 30512, 30513, 30595, 30676, 30677, 30681, 30685,
  32. 30687, 30689, 30694, 30699, 30704, 30845, 30847, 30849, 30854, 30857, 30862,
  33. 30865, 30894, 30897, 30900, 30905, 30910, 30913, 31269, 31272, 31288, 31314,
  34. 31317, 31321, 31324, 31326, 31328, 31331, 31334, 31336, 31965, 31974, 31276,
  35. 31285, 31958, 31961, 31996, 31968, 31977, 32092, 32093, 32094, 32095, 32096,
  36. 32097, 32098, 32193, 32196, 32199, 32202, 32205, 32206, 32213, 32214, 32221,
  37. 32222, 32229, 32230, 32233, 32234
  38. };
  39. // itemId for shadow weapon coupons, it's not used more than once but increases readability
  40. private static final int D_COUPON = 8869;
  41. private static final int C_COUPON = 8870;
  42. public ShadowWeapons(int id, String name, String descr)
  43. {
  44. super(id, name, descr);
  45. for (int item : NPC)
  46. {
  47. addStartNpc(item);
  48. addTalkId(item);
  49. }
  50. }
  51. @Override
  52. public String onTalk(L2Npc npc, L2PcInstance player)
  53. {
  54. QuestState st = player.getQuestState(qn);
  55. String htmltext = getNoQuestMsg(player);
  56. if (st == null)
  57. return htmltext;
  58. boolean has_d = st.hasQuestItems(D_COUPON);
  59. boolean has_c = st.hasQuestItems(C_COUPON);
  60. if (has_d || has_c)
  61. {
  62. // let's assume character had both c & d-grade coupons, we'll confirm later
  63. String multisell = "306893003";
  64. if (!has_d)
  65. {
  66. // if s/he had c-grade only...
  67. multisell = "306893002";
  68. }
  69. else if (!has_c)
  70. {
  71. // or d-grade only.
  72. multisell = "306893001";
  73. }
  74. // finally, return htm with proper multisell value in it.
  75. htmltext = st.showHtmlFile("exchange.htm").replace("%msid%", multisell);
  76. }
  77. else
  78. htmltext = "exchange-no.htm";
  79. st.exitQuest(true);
  80. return htmltext;
  81. }
  82. public static void main(String args[])
  83. {
  84. new ShadowWeapons(-1, qn, "custom");
  85. }
  86. }