BaseTower.java 3.8 KB

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