HeavyMedal.java 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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 events.HeavyMedal;
  16. import com.l2jserver.gameserver.model.Location;
  17. import com.l2jserver.gameserver.model.actor.L2Npc;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.model.quest.Quest;
  20. import com.l2jserver.gameserver.model.quest.QuestState;
  21. /**
  22. * Retail Event : 'Heavy Medals'
  23. * @author Gnacik
  24. */
  25. public class HeavyMedal extends Quest
  26. {
  27. private final static int CAT_ROY = 31228;
  28. private final static int CAT_WINNIE = 31229;
  29. private final static int GLITTERING_MEDAL = 6393;
  30. private final static int WIN_CHANCE = 50;
  31. private final static int[] MEDALS =
  32. {
  33. 5, 10, 20, 40
  34. };
  35. private final static int[] BADGES =
  36. {
  37. 6399, 6400, 6401, 6402
  38. };
  39. private static final Location[] _spawns_winnie =
  40. {
  41. new Location(-44342, -113726, -240, 0),
  42. new Location(-44671, -115437, -240, 22500),
  43. new Location(-13073, 122841, -3117, 0),
  44. new Location(-13972, 121893, -2988, 32768),
  45. new Location(-14843, 123710, -3117, 8192),
  46. new Location(11327, 15682, -4584, 25000),
  47. new Location(11243, 17712, -4574, 57344),
  48. new Location(18154, 145192, -3054, 7400),
  49. new Location(19214, 144327, -3097, 32768),
  50. new Location(19459, 145775, -3086, 48000),
  51. new Location(17418, 170217, -3507, 36000),
  52. new Location(47146, 49382, -3059, 32000),
  53. new Location(44157, 50827, -3059, 57344),
  54. new Location(79798, 55629, -1560, 0),
  55. new Location(83328, 55769, -1525, 32768),
  56. new Location(80986, 54452, -1525, 32768),
  57. new Location(83329, 149095, -3405, 49152),
  58. new Location(82277, 148564, -3467, 0),
  59. new Location(81620, 148689, -3464, 32768),
  60. new Location(81691, 145610, -3467, 32768),
  61. new Location(114719, -178742, -821, 0),
  62. new Location(115708, -182422, -1449, 0),
  63. new Location(-80731, 151152, -3043, 28672),
  64. new Location(-84097, 150171, -3129, 4096),
  65. new Location(-82678, 151666, -3129, 49152),
  66. new Location(117459, 76664, -2695, 38000),
  67. new Location(115936, 76488, -2711, 59000),
  68. new Location(119576, 76940, -2275, 40960),
  69. new Location(-84516, 243015, -3730, 34000),
  70. new Location(-86031, 243153, -3730, 60000),
  71. new Location(147124, 27401, -2192, 40960),
  72. new Location(147985, 25664, -2000, 16384),
  73. new Location(111724, 221111, -3543, 16384),
  74. new Location(107899, 218149, -3675, 0),
  75. new Location(114920, 220080, -3632, 32768),
  76. new Location(147924, -58052, -2979, 49000),
  77. new Location(147285, -56461, -2776, 33000),
  78. new Location(44176, -48688, -800, 33000),
  79. new Location(44294, -47642, -792, 50000)
  80. };
  81. private static final Location[] _spawns_roy =
  82. {
  83. new Location(-44337, -113669, -224, 0),
  84. new Location(-44628, -115409, -240, 22500),
  85. new Location(-13073, 122801, -3117, 0),
  86. new Location(-13949, 121934, -2988, 32768),
  87. new Location(-14786, 123686, -3117, 8192),
  88. new Location(11281, 15652, -4584, 25000),
  89. new Location(11303, 17732, -4574, 57344),
  90. new Location(18178, 145149, -3054, 7400),
  91. new Location(19208, 144380, -3097, 32768),
  92. new Location(19508, 145775, -3086, 48000),
  93. new Location(17396, 170259, -3507, 36000),
  94. new Location(47151, 49436, -3059, 32000),
  95. new Location(44122, 50784, -3059, 57344),
  96. new Location(79806, 55570, -1560, 0),
  97. new Location(83328, 55824, -1525, 32768),
  98. new Location(80986, 54504, -1525, 32768),
  99. new Location(83332, 149160, -3405, 49152),
  100. new Location(82277, 148598, -3467, 0),
  101. new Location(81621, 148725, -3467, 32768),
  102. new Location(81680, 145656, -3467, 32768),
  103. new Location(114733, -178691, -821, 0),
  104. new Location(115708, -182362, -1449, 0),
  105. new Location(-80789, 151073, -3043, 28672),
  106. new Location(-84049, 150176, -3129, 4096),
  107. new Location(-82623, 151666, -3129, 49152),
  108. new Location(117498, 76630, -2695, 38000),
  109. new Location(115914, 76449, -2711, 59000),
  110. new Location(119536, 76988, -2275, 40960),
  111. new Location(-84516, 242971, -3730, 34000),
  112. new Location(-86003, 243205, -3730, 60000),
  113. new Location(147184, 27405, -2192, 17000),
  114. new Location(147920, 25664, -2000, 16384),
  115. new Location(111776, 221104, -3543, 16384),
  116. new Location(107904, 218096, -3675, 0),
  117. new Location(114920, 220020, -3632, 32768),
  118. new Location(147888, -58048, -2979, 49000),
  119. new Location(147262, -56450, -2776, 33000),
  120. new Location(44176, -48732, -800, 33000),
  121. new Location(44319, -47640, -792, 50000)
  122. };
  123. public HeavyMedal(int questId, String name, String descr)
  124. {
  125. super(questId, name, descr);
  126. addStartNpc(CAT_ROY);
  127. addStartNpc(CAT_WINNIE);
  128. addTalkId(CAT_ROY);
  129. addTalkId(CAT_WINNIE);
  130. addFirstTalkId(CAT_ROY);
  131. addFirstTalkId(CAT_WINNIE);
  132. for (Location loc : _spawns_roy)
  133. {
  134. addSpawn(CAT_ROY, loc, false, 0);
  135. }
  136. for (Location loc : _spawns_winnie)
  137. {
  138. addSpawn(CAT_WINNIE, loc, false, 0);
  139. }
  140. }
  141. @Override
  142. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  143. {
  144. final QuestState st = player.getQuestState(getName());
  145. if (st == null)
  146. {
  147. return getNoQuestMsg(player);
  148. }
  149. String htmltext = event;
  150. int level = checkLevel(st);
  151. if (event.equalsIgnoreCase("game"))
  152. {
  153. htmltext = st.getQuestItemsCount(GLITTERING_MEDAL) < MEDALS[level] ? "31229-no.htm" : "31229-game.htm";
  154. }
  155. else if (event.equalsIgnoreCase("heads") || event.equalsIgnoreCase("tails"))
  156. {
  157. if (st.getQuestItemsCount(GLITTERING_MEDAL) < MEDALS[level])
  158. {
  159. htmltext = "31229-" + event.toLowerCase() + "-10.htm";
  160. }
  161. else
  162. {
  163. st.takeItems(GLITTERING_MEDAL, MEDALS[level]);
  164. if (getRandom(100) > WIN_CHANCE)
  165. {
  166. level = 0;
  167. }
  168. else
  169. {
  170. if (level > 0)
  171. {
  172. st.takeItems(BADGES[level - 1], -1);
  173. }
  174. st.giveItems(BADGES[level], 1);
  175. st.playSound("Itemsound.quest_itemget");
  176. level++;
  177. }
  178. htmltext = "31229-" + event.toLowerCase() + "-" + String.valueOf(level) + ".htm";
  179. }
  180. }
  181. else if (event.equalsIgnoreCase("talk"))
  182. {
  183. htmltext = String.valueOf(npc.getNpcId()) + "-lvl-" + String.valueOf(level) + ".htm";
  184. }
  185. return htmltext;
  186. }
  187. @Override
  188. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  189. {
  190. if (player.getQuestState(getName()) == null)
  191. {
  192. newQuestState(player);
  193. }
  194. return npc.getNpcId() + ".htm";
  195. }
  196. public int checkLevel(QuestState st)
  197. {
  198. int _lev = 0;
  199. if (st.hasQuestItems(6402))
  200. {
  201. _lev = 4;
  202. }
  203. else if (st.hasQuestItems(6401))
  204. {
  205. _lev = 3;
  206. }
  207. else if (st.hasQuestItems(6400))
  208. {
  209. _lev = 2;
  210. }
  211. else if (st.hasQuestItems(6399))
  212. {
  213. _lev = 1;
  214. }
  215. return _lev;
  216. }
  217. public static void main(String[] args)
  218. {
  219. new HeavyMedal(-1, "HeavyMedal", "events");
  220. }
  221. }