ShadowWeapons.java 3.2 KB

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