PailakaSongOfIceAndFire.java 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package instances.PailakaSongOfIceAndFire;
  20. import instances.AbstractInstance;
  21. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  22. import com.l2jserver.gameserver.model.Location;
  23. import com.l2jserver.gameserver.model.actor.L2Character;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
  27. import com.l2jserver.gameserver.model.zone.L2ZoneType;
  28. import com.l2jserver.gameserver.network.NpcStringId;
  29. import com.l2jserver.gameserver.network.clientpackets.Say2;
  30. /**
  31. * Pailaka Song of Ice and Fire Instance zone.
  32. * @author Gnacik, St3eT
  33. */
  34. public final class PailakaSongOfIceAndFire extends AbstractInstance
  35. {
  36. protected class PSoIWorld extends InstanceWorld
  37. {
  38. }
  39. // NPCs
  40. private static final int ADLER1 = 32497;
  41. private static final int GARGOS = 18607;
  42. private static final int BLOOM = 18616;
  43. private static final int BOTTLE = 32492;
  44. private static final int BRAZIER = 32493;
  45. // Items
  46. private static final int FIRE_ENHANCER = 13040;
  47. private static final int WATER_ENHANCER = 13041;
  48. private static final int SHIELD_POTION = 13032;
  49. private static final int HEAL_POTION = 13033;
  50. // Location
  51. private static final Location TELEPORT = new Location(-52875, 188232, -4696);
  52. // Misc
  53. private static final int TEMPLATE_ID = 43;
  54. private static final int ZONE = 20108;
  55. public PailakaSongOfIceAndFire()
  56. {
  57. super(PailakaSongOfIceAndFire.class.getSimpleName());
  58. addStartNpc(ADLER1);
  59. addTalkId(ADLER1);
  60. addAttackId(BOTTLE, BRAZIER);
  61. addExitZoneId(ZONE);
  62. addSeeCreatureId(GARGOS);
  63. addSpawnId(BLOOM);
  64. addKillId(BLOOM);
  65. }
  66. @Override
  67. public void onEnterInstance(L2PcInstance player, InstanceWorld world, boolean firstEntrance)
  68. {
  69. if (firstEntrance)
  70. {
  71. world.addAllowed(player.getObjectId());
  72. }
  73. teleportPlayer(player, TELEPORT, world.getInstanceId());
  74. }
  75. @Override
  76. public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  77. {
  78. switch (event)
  79. {
  80. case "enter":
  81. {
  82. enterInstance(player, new PSoIWorld(), "PailakaSongOfIceAndFire.xml", TEMPLATE_ID);
  83. break;
  84. }
  85. case "GARGOS_LAUGH":
  86. {
  87. broadcastNpcSay(npc, Say2.NPC_SHOUT, NpcStringId.OHHOHOH);
  88. break;
  89. }
  90. case "TELEPORT":
  91. {
  92. teleportPlayer(player, TELEPORT, player.getInstanceId());
  93. break;
  94. }
  95. case "DELETE":
  96. {
  97. if (npc != null)
  98. {
  99. npc.deleteMe();
  100. }
  101. break;
  102. }
  103. case "BLOOM_TIMER":
  104. {
  105. startQuestTimer("BLOOM_TIMER2", getRandom(2, 4) * 60 * 1000, npc, null);
  106. break;
  107. }
  108. case "BLOOM_TIMER2":
  109. {
  110. npc.setInvisible(!npc.isInvisible());
  111. startQuestTimer("BLOOM_TIMER", 5000, npc, null);
  112. break;
  113. }
  114. }
  115. return super.onAdvEvent(event, npc, player);
  116. }
  117. @Override
  118. public final String onAttack(L2Npc npc, L2PcInstance player, int damage, boolean isSummon)
  119. {
  120. if ((damage > 0) && npc.isScriptValue(0))
  121. {
  122. switch (getRandom(6))
  123. {
  124. case 0:
  125. {
  126. if (npc.getId() == BOTTLE)
  127. {
  128. npc.dropItem(player, WATER_ENHANCER, getRandom(1, 6));
  129. }
  130. break;
  131. }
  132. case 1:
  133. {
  134. if (npc.getId() == BRAZIER)
  135. {
  136. npc.dropItem(player, FIRE_ENHANCER, getRandom(1, 6));
  137. }
  138. break;
  139. }
  140. case 2:
  141. case 3:
  142. {
  143. npc.dropItem(player, SHIELD_POTION, getRandom(1, 10));
  144. break;
  145. }
  146. case 4:
  147. case 5:
  148. {
  149. npc.dropItem(player, HEAL_POTION, getRandom(1, 10));
  150. break;
  151. }
  152. }
  153. npc.setScriptValue(1);
  154. startQuestTimer("DELETE", 3000, npc, null);
  155. }
  156. return super.onAttack(npc, player, damage, isSummon);
  157. }
  158. @Override
  159. public final String onKill(L2Npc npc, L2PcInstance player, boolean isSummon)
  160. {
  161. npc.dropItem(player, getRandomBoolean() ? SHIELD_POTION : HEAL_POTION, getRandom(1, 7));
  162. return super.onKill(npc, player, isSummon);
  163. }
  164. @Override
  165. public String onExitZone(L2Character character, L2ZoneType zone)
  166. {
  167. if ((character.isPlayer()) && !character.isDead() && !character.isTeleporting() && ((L2PcInstance) character).isOnline())
  168. {
  169. final InstanceWorld world = InstanceManager.getInstance().getWorld(character.getInstanceId());
  170. if ((world != null) && (world.getTemplateId() == TEMPLATE_ID))
  171. {
  172. startQuestTimer("TELEPORT", 1000, null, (L2PcInstance) character);
  173. }
  174. }
  175. return super.onExitZone(character, zone);
  176. }
  177. @Override
  178. public String onSeeCreature(L2Npc npc, L2Character creature, boolean isSummon)
  179. {
  180. if (npc.isScriptValue(0) && creature.isPlayer())
  181. {
  182. npc.setScriptValue(1);
  183. startQuestTimer("GARGOS_LAUGH", 1000, npc, creature.getActingPlayer());
  184. }
  185. return super.onSeeCreature(npc, creature, isSummon);
  186. }
  187. @Override
  188. public String onSpawn(L2Npc npc)
  189. {
  190. npc.setInvisible(true);
  191. startQuestTimer("BLOOM_TIMER", 1000, npc, null);
  192. return super.onSpawn(npc);
  193. }
  194. }