BaseTower.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright (C) 2004-2014 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 hellbound.BaseTower;
  20. import java.util.Map;
  21. import javolution.util.FastMap;
  22. import com.l2jserver.gameserver.datatables.DoorTable;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.base.ClassId;
  26. import com.l2jserver.gameserver.model.holders.SkillHolder;
  27. import com.l2jserver.gameserver.model.quest.Quest;
  28. /**
  29. * @author GKR
  30. */
  31. public class BaseTower extends Quest
  32. {
  33. private static final int GUZEN = 22362;
  34. private static final int KENDAL = 32301;
  35. private static final int BODY_DESTROYER = 22363;
  36. private static final Map<Integer, L2PcInstance> BODY_DESTROYER_TARGET_LIST = new FastMap<>();
  37. private static final SkillHolder DEATH_WORD = new SkillHolder(5256, 1);
  38. public BaseTower(int questId, String name, String descr)
  39. {
  40. super(questId, name, descr);
  41. addKillId(GUZEN);
  42. addKillId(BODY_DESTROYER);
  43. addFirstTalkId(KENDAL);
  44. addAggroRangeEnterId(BODY_DESTROYER);
  45. }
  46. @Override
  47. public final String onFirstTalk(L2Npc npc, L2PcInstance player)
  48. {
  49. ClassId classId = player.getClassId();
  50. if (classId.equalsOrChildOf(ClassId.hellKnight) || classId.equalsOrChildOf(ClassId.soultaker))
  51. {
  52. return "32301-02.htm";
  53. }
  54. return "32301-01.htm";
  55. }
  56. @Override
  57. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  58. {
  59. if (event.equalsIgnoreCase("close"))
  60. {
  61. DoorTable.getInstance().getDoor(20260004).closeMe();
  62. }
  63. return null;
  64. }
  65. @Override
  66. public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
  67. {
  68. if (!BODY_DESTROYER_TARGET_LIST.containsKey(npc.getObjectId()))
  69. {
  70. BODY_DESTROYER_TARGET_LIST.put(npc.getObjectId(), player);
  71. npc.setTarget(player);
  72. npc.doSimultaneousCast(DEATH_WORD.getSkill());
  73. }
  74. return super.onAggroRangeEnter(npc, player, isSummon);
  75. }
  76. @Override
  77. public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
  78. {
  79. switch (npc.getId())
  80. {
  81. case GUZEN:
  82. // Should Kendal be despawned before Guzen's spawn? Or it will be crowd of Kendal's
  83. addSpawn(KENDAL, npc.getSpawn().getLocation(), false, npc.getSpawn().getRespawnDelay(), false);
  84. DoorTable.getInstance().getDoor(20260003).openMe();
  85. DoorTable.getInstance().getDoor(20260004).openMe();
  86. startQuestTimer("close", 60000, npc, null, false);
  87. break;
  88. case BODY_DESTROYER:
  89. if (BODY_DESTROYER_TARGET_LIST.containsKey(npc.getObjectId()))
  90. {
  91. final L2PcInstance pl = BODY_DESTROYER_TARGET_LIST.get(npc.getObjectId());
  92. if ((pl != null) && pl.isOnline() && !pl.isDead())
  93. {
  94. pl.stopSkillEffects(true, DEATH_WORD.getSkillId());
  95. }
  96. BODY_DESTROYER_TARGET_LIST.remove(npc.getObjectId());
  97. }
  98. }
  99. return super.onKill(npc, killer, isSummon);
  100. }
  101. public static void main(String[] args)
  102. {
  103. new BaseTower(-1, BaseTower.class.getSimpleName(), "hellbound");
  104. }
  105. }