FreyaCelebration.java 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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.FreyaCelebration;
  16. import com.l2jserver.gameserver.instancemanager.QuestManager;
  17. import com.l2jserver.gameserver.model.L2Object;
  18. import com.l2jserver.gameserver.model.L2Skill;
  19. import com.l2jserver.gameserver.model.actor.L2Npc;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. import com.l2jserver.gameserver.model.quest.Quest;
  22. import com.l2jserver.gameserver.model.quest.QuestState;
  23. import com.l2jserver.gameserver.model.quest.State;
  24. import com.l2jserver.gameserver.network.NpcStringId;
  25. import com.l2jserver.gameserver.network.SystemMessageId;
  26. import com.l2jserver.gameserver.network.clientpackets.Say2;
  27. import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
  28. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  29. import com.l2jserver.gameserver.util.Util;
  30. import com.l2jserver.util.Rnd;
  31. /**
  32. ** @author Gnacik
  33. **
  34. ** Retail Event : 'Freya Celebration'
  35. */
  36. public class FreyaCelebration extends Quest
  37. {
  38. private static final int _freya = 13296;
  39. private static final int _freya_potion = 15440;
  40. private static final int _freya_gift = 17138;
  41. private static final int _hours = 20;
  42. private static final int[] _skills = { 9150, 9151, 9152, 9153, 9154, 9155, 9156 };
  43. private static final NpcStringId[] _freya_texts =
  44. {
  45. NpcStringId.EVEN_THOUGH_YOU_BRING_SOMETHING_CALLED_A_GIFT_AMONG_YOUR_HUMANS_IT_WOULD_JUST_BE_PROBLEMATIC_FOR_ME,
  46. NpcStringId.I_JUST_DONT_KNOW_WHAT_EXPRESSION_I_SHOULD_HAVE_IT_APPEARED_ON_ME_ARE_HUMANS_EMOTIONS_LIKE_THIS_FEELING,
  47. NpcStringId.THE_FEELING_OF_THANKS_IS_JUST_TOO_MUCH_DISTANT_MEMORY_FOR_ME,
  48. NpcStringId.BUT_I_KIND_OF_MISS_IT_LIKE_I_HAD_FELT_THIS_FEELING_BEFORE,
  49. NpcStringId.I_AM_ICE_QUEEN_FREYA_THIS_FEELING_AND_EMOTION_ARE_NOTHING_BUT_A_PART_OF_MELISSAA_MEMORIES
  50. };
  51. private static final int[][] _spawns = {
  52. { -119494, 44882, 360, 24576 },
  53. { -117239, 46842, 360, 49151 },
  54. { -84023, 243051, -3728, 4096 },
  55. { -84411, 244813, -3728, 57343 },
  56. { 46908, 50856, -2992, 8192 },
  57. { 45538, 48357, -3056, 18000 },
  58. { -45372, -114104, -240, 16384 },
  59. { -45278, -112766, -240, 0 },
  60. { 9929, 16324, -4568, 62999 },
  61. { 11546, 17599, -4584, 46900 },
  62. { 115096, -178370, -880, 0 },
  63. { -13727, 122117, -2984, 16384 },
  64. { -14129, 123869, -3112, 40959 },
  65. { -83156, 150994, -3120, 0 },
  66. { -81031, 150038, -3040, 0 },
  67. { 16111, 142850, -2696, 16000 },
  68. { 17275, 145000, -3032, 25000 },
  69. { 111004, 218928, -3536, 16384 },
  70. { 81755, 146487, -3528, 32768 },
  71. { 82145, 148609, -3464, 0 },
  72. { 83037, 149324, -3464, 44000 },
  73. { 81987, 53723, -1488, 0 },
  74. { 147200, 25614, -2008, 16384 },
  75. { 148557, 26806, -2200, 32768 },
  76. { 147421, -55435, -2728, 49151 },
  77. { 148206, -55786, -2776, 61439 },
  78. { 85584, -142490, -1336, 0 },
  79. { 86865, -142915, -1336, 26000 },
  80. { 43966, -47709, -792, 49999 },
  81. { 43165, -48461, -792, 17000 }
  82. };
  83. @Override
  84. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  85. {
  86. QuestState st = player.getQuestState(getName());
  87. Quest q = QuestManager.getInstance().getQuest(getName());
  88. if (st == null || q == null)
  89. return null;
  90. if (event.equalsIgnoreCase("give_potion"))
  91. {
  92. if (st.getQuestItemsCount(57) > 1)
  93. {
  94. long _curr_time = System.currentTimeMillis();
  95. String value = q.loadGlobalQuestVar(player.getAccountName());
  96. long _reuse_time = value == "" ? 0 : Long.parseLong(value);
  97. if (_curr_time > _reuse_time)
  98. {
  99. st.setState(State.STARTED);
  100. st.takeItems(57, 1);
  101. st.giveItems(_freya_potion, 1);
  102. q.saveGlobalQuestVar(player.getAccountName(), Long.toString(System.currentTimeMillis() + (_hours * 3600000)));
  103. }
  104. else
  105. {
  106. long remainingTime = (_reuse_time - System.currentTimeMillis()) / 1000;
  107. int hours = (int) (remainingTime / 3600);
  108. int minutes = (int) ((remainingTime % 3600) / 60);
  109. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.AVAILABLE_AFTER_S1_S2_HOURS_S3_MINUTES);
  110. sm.addItemName(_freya_potion);
  111. sm.addNumber(hours);
  112. sm.addNumber(minutes);
  113. player.sendPacket(sm);
  114. }
  115. }
  116. else
  117. {
  118. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S2_UNIT_OF_THE_ITEM_S1_REQUIRED);
  119. sm.addItemName(57);
  120. sm.addNumber(1);
  121. player.sendPacket(sm);
  122. }
  123. }
  124. return null;
  125. }
  126. @Override
  127. public String onSkillSee(L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
  128. {
  129. if ((caster == null) || (npc == null))
  130. return null;
  131. if ((npc.getNpcId() == _freya) && Util.contains(targets, npc) && Util.contains(_skills, skill.getId()))
  132. {
  133. if (Rnd.get(100) < 5)
  134. {
  135. CreatureSay cs = new CreatureSay(npc.getObjectId(), Say2.ALL, npc.getName(), NpcStringId.DEAR_S1_THINK_OF_THIS_AS_MY_APPRECIATION_FOR_THE_GIFT_TAKE_THIS_WITH_YOU_THERES_NOTHING_STRANGE_ABOUT_IT_ITS_JUST_A_BIT_OF_MY_CAPRICIOUSNESS);
  136. cs.addStringParameter(caster.getName());
  137. npc.broadcastPacket(cs);
  138. caster.addItem("FreyaCelebration", _freya_gift, 1, npc, true);
  139. }
  140. else
  141. {
  142. if (Rnd.get(10) < 2)
  143. {
  144. npc.broadcastPacket(new CreatureSay(npc.getObjectId(), Say2.ALL, npc.getName(), _freya_texts[Rnd.get(_freya_texts.length - 1)]));
  145. }
  146. }
  147. }
  148. return super.onSkillSee(npc, caster, skill, targets, isPet);
  149. }
  150. @Override
  151. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  152. {
  153. QuestState st = player.getQuestState(getName());
  154. if (st == null)
  155. {
  156. Quest q = QuestManager.getInstance().getQuest(getName());
  157. st = q.newQuestState(player);
  158. }
  159. return "13296.htm";
  160. }
  161. public FreyaCelebration(int questId, String name, String descr)
  162. {
  163. super(questId, name, descr);
  164. addStartNpc(_freya);
  165. addFirstTalkId(_freya);
  166. addTalkId(_freya);
  167. addSkillSeeId(_freya);
  168. for (int[] _spawn : _spawns)
  169. {
  170. addSpawn(_freya, _spawn[0], _spawn[1], _spawn[2], _spawn[3], false, 0);
  171. }
  172. }
  173. public static void main(String[] args)
  174. {
  175. new FreyaCelebration(-1, "FreyaCelebration", "events");
  176. }
  177. }