From b141f4d0be27db41e8a74264c25e11a2dc0901dc Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 21 Aug 2016 10:38:40 +0000 Subject: [PATCH] Castle Dungeon instances. --- .../dist/game/data/html/default/36403.htm | 6 + .../dist/game/data/html/default/36404.htm | 6 + .../dist/game/data/html/default/36405.htm | 6 + .../dist/game/data/html/default/36406.htm | 6 + .../dist/game/data/html/default/36407.htm | 6 + .../dist/game/data/html/default/36408.htm | 6 + .../dist/game/data/html/default/36409.htm | 6 + .../dist/game/data/html/default/36410.htm | 6 + .../dist/game/data/html/default/36411.htm | 6 + .../instances/CastleDungeon/AdenDungeon.xml | 40 +++ .../instances/CastleDungeon/DionDungeon.xml | 40 +++ .../instances/CastleDungeon/GiranDungeon.xml | 40 +++ .../instances/CastleDungeon/GludioDungeon.xml | 40 +++ .../CastleDungeon/GoddardDungeon.xml | 40 +++ .../CastleDungeon/InnadrilDungeon.xml | 40 +++ .../instances/CastleDungeon/OrenDungeon.xml | 40 +++ .../instances/CastleDungeon/RuneDungeon.xml | 40 +++ .../CastleDungeon/SchuttgartDungeon.xml | 40 +++ .../CastleDungeon/CastleDungeon.java | 242 ++++++++++++++++++ .../CastleDungeon/enterRestricted.html | 4 + .../instances/CastleDungeon/hasReenter.html | 3 + .../instances/CastleDungeon/noParty.html | 3 + .../CastleDungeon/noProperPledge.html | 3 + 23 files changed, 669 insertions(+) create mode 100644 L2J_Mobius_Underground/dist/game/data/html/default/36403.htm create mode 100644 L2J_Mobius_Underground/dist/game/data/html/default/36404.htm create mode 100644 L2J_Mobius_Underground/dist/game/data/html/default/36405.htm create mode 100644 L2J_Mobius_Underground/dist/game/data/html/default/36406.htm create mode 100644 L2J_Mobius_Underground/dist/game/data/html/default/36407.htm create mode 100644 L2J_Mobius_Underground/dist/game/data/html/default/36408.htm create mode 100644 L2J_Mobius_Underground/dist/game/data/html/default/36409.htm create mode 100644 L2J_Mobius_Underground/dist/game/data/html/default/36410.htm create mode 100644 L2J_Mobius_Underground/dist/game/data/html/default/36411.htm create mode 100644 L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/AdenDungeon.xml create mode 100644 L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/DionDungeon.xml create mode 100644 L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/GiranDungeon.xml create mode 100644 L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/GludioDungeon.xml create mode 100644 L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/GoddardDungeon.xml create mode 100644 L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/InnadrilDungeon.xml create mode 100644 L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/OrenDungeon.xml create mode 100644 L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/RuneDungeon.xml create mode 100644 L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/SchuttgartDungeon.xml create mode 100644 L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/CastleDungeon.java create mode 100644 L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/enterRestricted.html create mode 100644 L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/hasReenter.html create mode 100644 L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/noParty.html create mode 100644 L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/noProperPledge.html diff --git a/L2J_Mobius_Underground/dist/game/data/html/default/36403.htm b/L2J_Mobius_Underground/dist/game/data/html/default/36403.htm new file mode 100644 index 0000000000..d86a8236b5 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/html/default/36403.htm @@ -0,0 +1,6 @@ +Prison Warden:

+This is a dangerous place. Don't come around here unless you're ready for a fight!
+ + + + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/html/default/36404.htm b/L2J_Mobius_Underground/dist/game/data/html/default/36404.htm new file mode 100644 index 0000000000..d86a8236b5 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/html/default/36404.htm @@ -0,0 +1,6 @@ +Prison Warden:

+This is a dangerous place. Don't come around here unless you're ready for a fight!
+ + + + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/html/default/36405.htm b/L2J_Mobius_Underground/dist/game/data/html/default/36405.htm new file mode 100644 index 0000000000..d86a8236b5 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/html/default/36405.htm @@ -0,0 +1,6 @@ +Prison Warden:

+This is a dangerous place. Don't come around here unless you're ready for a fight!
+ + + + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/html/default/36406.htm b/L2J_Mobius_Underground/dist/game/data/html/default/36406.htm new file mode 100644 index 0000000000..d86a8236b5 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/html/default/36406.htm @@ -0,0 +1,6 @@ +Prison Warden:

+This is a dangerous place. Don't come around here unless you're ready for a fight!
+ + + + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/html/default/36407.htm b/L2J_Mobius_Underground/dist/game/data/html/default/36407.htm new file mode 100644 index 0000000000..d86a8236b5 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/html/default/36407.htm @@ -0,0 +1,6 @@ +Prison Warden:

+This is a dangerous place. Don't come around here unless you're ready for a fight!
+ + + + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/html/default/36408.htm b/L2J_Mobius_Underground/dist/game/data/html/default/36408.htm new file mode 100644 index 0000000000..d86a8236b5 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/html/default/36408.htm @@ -0,0 +1,6 @@ +Prison Warden:

+This is a dangerous place. Don't come around here unless you're ready for a fight!
+ + + + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/html/default/36409.htm b/L2J_Mobius_Underground/dist/game/data/html/default/36409.htm new file mode 100644 index 0000000000..d86a8236b5 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/html/default/36409.htm @@ -0,0 +1,6 @@ +Prison Warden:

+This is a dangerous place. Don't come around here unless you're ready for a fight!
+ + + + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/html/default/36410.htm b/L2J_Mobius_Underground/dist/game/data/html/default/36410.htm new file mode 100644 index 0000000000..d86a8236b5 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/html/default/36410.htm @@ -0,0 +1,6 @@ +Prison Warden:

+This is a dangerous place. Don't come around here unless you're ready for a fight!
+ + + + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/html/default/36411.htm b/L2J_Mobius_Underground/dist/game/data/html/default/36411.htm new file mode 100644 index 0000000000..d86a8236b5 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/html/default/36411.htm @@ -0,0 +1,6 @@ +Prison Warden:

+This is a dangerous place. Don't come around here unless you're ready for a fight!
+ + + + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/AdenDungeon.xml b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/AdenDungeon.xml new file mode 100644 index 0000000000..6e30f83299 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/AdenDungeon.xml @@ -0,0 +1,40 @@ + + + + diff --git a/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/DionDungeon.xml b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/DionDungeon.xml new file mode 100644 index 0000000000..9858b7f80b --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/DionDungeon.xml @@ -0,0 +1,40 @@ + + + + diff --git a/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/GiranDungeon.xml b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/GiranDungeon.xml new file mode 100644 index 0000000000..cd083a5a8b --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/GiranDungeon.xml @@ -0,0 +1,40 @@ + + + + diff --git a/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/GludioDungeon.xml b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/GludioDungeon.xml new file mode 100644 index 0000000000..0d0ac34a66 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/GludioDungeon.xml @@ -0,0 +1,40 @@ + + + + diff --git a/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/GoddardDungeon.xml b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/GoddardDungeon.xml new file mode 100644 index 0000000000..fd1e29ba79 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/GoddardDungeon.xml @@ -0,0 +1,40 @@ + + + + diff --git a/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/InnadrilDungeon.xml b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/InnadrilDungeon.xml new file mode 100644 index 0000000000..93cb68ba97 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/InnadrilDungeon.xml @@ -0,0 +1,40 @@ + + + + diff --git a/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/OrenDungeon.xml b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/OrenDungeon.xml new file mode 100644 index 0000000000..fda9e12a6f --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/OrenDungeon.xml @@ -0,0 +1,40 @@ + + + + diff --git a/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/RuneDungeon.xml b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/RuneDungeon.xml new file mode 100644 index 0000000000..10f446adbf --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/RuneDungeon.xml @@ -0,0 +1,40 @@ + + + + diff --git a/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/SchuttgartDungeon.xml b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/SchuttgartDungeon.xml new file mode 100644 index 0000000000..2e75bb969d --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/instances/CastleDungeon/SchuttgartDungeon.xml @@ -0,0 +1,40 @@ + + + + diff --git a/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/CastleDungeon.java b/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/CastleDungeon.java new file mode 100644 index 0000000000..05c739895d --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/CastleDungeon.java @@ -0,0 +1,242 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package instances.CastleDungeon; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +import com.l2jmobius.commons.util.CommonUtil; +import com.l2jmobius.gameserver.ThreadPoolManager; +import com.l2jmobius.gameserver.enums.QuestSound; +import com.l2jmobius.gameserver.model.Location; +import com.l2jmobius.gameserver.model.actor.L2Npc; +import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.model.entity.Fort; +import com.l2jmobius.gameserver.model.instancezone.Instance; +import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate; +import com.l2jmobius.gameserver.model.quest.QuestState; + +import instances.AbstractInstance; +import quests.Q00512_BladeUnderFoot.Q00512_BladeUnderFoot; + +/** + * Castle dungeon instance for quest BladeUnderFoot (512) + * @author Mobius + */ +public final class CastleDungeon extends AbstractInstance +{ + // NPCs + private static final Map NPCS = new HashMap<>(); + static + { + NPCS.put(36403, 13); // Gludio + NPCS.put(36404, 14); // Dion + NPCS.put(36405, 15); // Giran + NPCS.put(36406, 16); // Oren + NPCS.put(36407, 17); // Aden + NPCS.put(36408, 18); // Innadril + NPCS.put(36409, 19); // Goddard + NPCS.put(36410, 20); // Rune + NPCS.put(36411, 21); // Schuttgart + } + // Monsters + private static final int[] RAIDS1 = + { + 25546, + 25549, + 25552 + }; + private static final int[] RAIDS2 = + { + 25553, + 25554, + 25557, + 25560 + }; + private static final int[] RAIDS3 = + { + 25563, + 25566, + 25569 + }; + // Item + private static final int MARK = 9798; + // Locations + private static final Location SPAWN_LOC = new Location(12230, -49139, -3013); + // Misc + private static final int MARK_COUNT = 2520; + private static final long REENTER = 24 * 3600000; // 24 hours + private static final Map REENETER_HOLDER = new ConcurrentHashMap<>(); + + public CastleDungeon() + { + // NPCs + addStartNpc(NPCS.keySet()); + addTalkId(NPCS.keySet()); + // Monsters + addKillId(RAIDS1); + addKillId(RAIDS2); + addKillId(RAIDS3); + // Instance + addInstanceCreatedId(NPCS.values()); + addInstanceDestroyId(NPCS.values()); + } + + @Override + public String onTalk(L2Npc npc, L2PcInstance player) + { + final int npcId = npc.getId(); + if (NPCS.containsKey(npcId)) + { + enterInstance(player, npc, NPCS.get(npcId)); + } + return null; + } + + @Override + public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon) + { + final Instance world = npc.getInstanceWorld(); + if (world != null) + { + if (CommonUtil.contains(RAIDS3, npc.getId())) + { + // Get players with active quest + final List members = new ArrayList<>(); + for (L2PcInstance member : world.getPlayers()) + { + final QuestState qs = member.getQuestState(Q00512_BladeUnderFoot.class.getSimpleName()); + if ((qs != null) && qs.isCond(1)) + { + members.add(member); + } + } + + // Distribute marks between them + if (!members.isEmpty()) + { + final long itemCount = MARK_COUNT / members.size(); + for (L2PcInstance member : members) + { + giveItems(member, MARK, itemCount); + playSound(member, QuestSound.ITEMSOUND_QUEST_ITEMGET); + } + } + world.finishInstance(); + } + else + { + world.incStatus(); + spawnRaid(world); + } + } + return super.onKill(npc, player, isSummon); + } + + @Override + public void onInstanceCreated(Instance instance, L2PcInstance player) + { + // Put re-enter for instance + REENETER_HOLDER.put(instance.getTemplateId(), System.currentTimeMillis() + REENTER); + // Schedule spawn of first raid + spawnRaid(instance); + } + + @Override + protected boolean validateConditions(List group, L2Npc npc, InstanceTemplate template) + { + final L2PcInstance groupLeader = group.get(0); + final Fort fort = npc.getFort(); + if (fort == null) + { + showHtmlFile(groupLeader, "noProperPledge.html"); + return false; + } + else if (REENETER_HOLDER.containsKey(template.getId())) + { + final long time = REENETER_HOLDER.get(template.getId()); + if (time > System.currentTimeMillis()) + { + showHtmlFile(groupLeader, "enterRestricted.html"); + return false; + } + REENETER_HOLDER.remove(template.getId()); + } + return true; + } + + @Override + public void onInstanceDestroy(Instance instance) + { + // Stop running spawn task + final ScheduledFuture task = instance.getParameters().getObject("spawnTask", ScheduledFuture.class); + if ((task != null) && !task.isDone()) + { + task.cancel(true); + } + instance.setParameter("spawnTask", null); + } + + /** + * Spawn raid boss according to instance status. + * @param instance instance world where instance should be spawned + */ + private void spawnRaid(Instance instance) + { + final ScheduledFuture spawnTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> + { + // Get template id of raid + final int npcId; + switch (instance.getStatus()) + { + case 0: + { + npcId = RAIDS1[getRandom(RAIDS1.length)]; + break; + } + case 1: + { + npcId = RAIDS2[getRandom(RAIDS2.length)]; + break; + } + default: + { + npcId = RAIDS3[getRandom(RAIDS3.length)]; + } + } + + // Spawn raid + addSpawn(npcId, SPAWN_LOC, false, 0, false, instance.getId()); + + // Unset spawn task reference + instance.setParameter("spawnTask", null); + }, 2, TimeUnit.MINUTES); + + // Save timer to instance world + instance.setParameter("spawnTask", spawnTask); + } + + public static void main(String[] args) + { + new CastleDungeon(); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/enterRestricted.html b/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/enterRestricted.html new file mode 100644 index 0000000000..c710675939 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/enterRestricted.html @@ -0,0 +1,4 @@ +Prison is currently closed.
+You can visit the prison once every 24 hours with your clan.
+If prison is closed, check with your clan members to see when the last session started. + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/hasReenter.html b/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/hasReenter.html new file mode 100644 index 0000000000..63a7ad985f --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/hasReenter.html @@ -0,0 +1,3 @@ + +Only a party may enter the prison. Once you visit the prison, you may not attend another one for at least 24 hours. + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/noParty.html b/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/noParty.html new file mode 100644 index 0000000000..6761e39dee --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/noParty.html @@ -0,0 +1,3 @@ + +To enter the prison, your party must include at least 2 people. + \ No newline at end of file diff --git a/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/noProperPledge.html b/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/noProperPledge.html new file mode 100644 index 0000000000..3572ec32b9 --- /dev/null +++ b/L2J_Mobius_Underground/dist/game/data/scripts/instances/CastleDungeon/noProperPledge.html @@ -0,0 +1,3 @@ + +The clan does not possess this castle. + \ No newline at end of file