BaseTower.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 hellbound.BaseTower;
  16. import java.util.Map;
  17. import javolution.util.FastMap;
  18. import com.l2jserver.gameserver.datatables.DoorTable;
  19. import com.l2jserver.gameserver.model.L2Effect;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.base.ClassId;
  23. import com.l2jserver.gameserver.model.quest.Quest;
  24. import com.l2jserver.gameserver.skills.SkillHolder;
  25. /**
  26. * @author GKR
  27. */
  28. public class BaseTower extends Quest
  29. {
  30. private static final int GUZEN = 22362;
  31. private static final int KENDAL = 32301;
  32. private static final int BODY_DESTROYER = 22363;
  33. private static final Map<Integer, L2PcInstance> BODY_DESTROYER_TARGET_LIST = new FastMap<Integer, L2PcInstance>();
  34. private static final SkillHolder DEATH_WORD = new SkillHolder(5256, 1);
  35. public BaseTower(int questId, String name, String descr)
  36. {
  37. super(questId, name, descr);
  38. addKillId(GUZEN);
  39. addKillId(BODY_DESTROYER);
  40. addFirstTalkId(KENDAL);
  41. addAggroRangeEnterId(BODY_DESTROYER);
  42. }
  43. @Override
  44. public final String onFirstTalk(L2Npc npc, L2PcInstance player)
  45. {
  46. ClassId classId = player.getClassId();
  47. if (classId.equalsOrChildOf(ClassId.hellKnight) || classId.equalsOrChildOf(ClassId.soultaker))
  48. {
  49. return "32301-02.htm";
  50. }
  51. else
  52. {
  53. return "32301-01.htm";
  54. }
  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 isPet)
  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, isPet);
  75. }
  76. @Override
  77. public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
  78. {
  79. switch (npc.getNpcId())
  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().getLocx(), npc.getSpawn().getLocy(), npc.getSpawn().getLocz(), 0, 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. final L2Effect e = pl.getFirstEffect(DEATH_WORD.getSkill());
  95. if (e != null)
  96. {
  97. e.exit();
  98. }
  99. }
  100. BODY_DESTROYER_TARGET_LIST.remove(npc.getObjectId());
  101. }
  102. }
  103. return super.onKill(npc, killer, isPet);
  104. }
  105. public static void main(String[] args)
  106. {
  107. new BaseTower(-1, BaseTower.class.getSimpleName(), "hellbound");
  108. }
  109. }