FreyaCelebration.java 6.9 KB

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