From e45aa7861724bf758599fff64399a0ca2e81565b Mon Sep 17 00:00:00 2001
From: Adry_85 <Adrya85@hotmail.it>
Date: Thu, 20 Feb 2014 22:48:57 +0000
Subject: [PATCH] BETA: Adding save points for '''Sanctum of the Lords of
 Dawn''' instance. 	Reported by: !CostyKiller 	Reviewed by: Nos,
 St3eT, !UnAfraid 	Thanks to: Nos, !UnAfraid, Zoey76

---
 .../instances/SanctumoftheLordsofDawn.xml     | 59 +++++++------
 .../SanctumOftheLordsOfDawn.java              | 85 +++++++++++++------
 2 files changed, 92 insertions(+), 52 deletions(-)

diff --git a/L2J_DataPack_BETA/dist/game/data/instances/SanctumoftheLordsofDawn.xml b/L2J_DataPack_BETA/dist/game/data/instances/SanctumoftheLordsofDawn.xml
index 0a9ccec747..cd9a85f828 100644
--- a/L2J_DataPack_BETA/dist/game/data/instances/SanctumoftheLordsofDawn.xml
+++ b/L2J_DataPack_BETA/dist/game/data/instances/SanctumoftheLordsofDawn.xml
@@ -23,10 +23,29 @@
 			<spawn npcId="32577" x="-80152" y="205740" z="-7904" heading="0" respawn="60" />
 			<!-- Shelf -->
 			<spawn npcId="32580" x="-81393" y="205565" z="-7960" heading="0" respawn="60" />
-			<!-- Guards of the Dawn -->
-			<!-- Walking NPCs -->
+		</group>
+		<group name="high_priest_of_dawn">
+       		<spawn npcId="18828" x="-79229" y="205782" z="-7896" heading="28672" respawn="60" />
+        	<spawn npcId="18828" x="-79362" y="205706" z="-7896" heading="16383" respawn="60" />
+        	<spawn npcId="18828" x="-79495" y="205774" z="-7896" heading="4096" respawn="60" />
+        	<spawn npcId="18828" x="-79493" y="205930" z="-7896" heading="61440" respawn="60" />
+        	<spawn npcId="18828" x="-79362" y="206012" z="-7896" heading="49152" respawn="60" />
+       		<spawn npcId="18828" x="-79230" y="205935" z="-7896" heading="36864" respawn="60" />
+       	</group>
+		<group name="save_point1">
 			<spawn npcId="18834" x="-75190" y="210176" z="-7418" heading="0" respawn="60" />
 			<spawn npcId="18834" x="-74743" y="209820" z="-7418" heading="32768" respawn="60" />
+			<spawn npcId="18835" x="-75650" y="212107" z="-7322" heading="0" respawn="60" />
+			<spawn npcId="18835" x="-74854" y="212107" z="-7322" heading="32768" respawn="60" />
+			<spawn npcId="18835" x="-74534" y="212108" z="-7321" heading="0" respawn="60"  />
+			<spawn npcId="18835" x="-75200" y="211178" z="-7322" heading="16384" respawn="60" />
+			<spawn npcId="18835" x="-74701" y="211460" z="-7321" heading="49151" respawn="60" />
+			<spawn npcId="18834" x="-74934" y="213446" z="-7232" heading="33334" respawn="60" />
+			<spawn npcId="18835" x="-74951" y="211629" z="-7321" heading="16384" respawn="60" />
+			<spawn npcId="27351" x="-74619" y="209981" z="-7418" heading="30212" respawn="60" />
+			<spawn npcId="27351" x="-75301" y="209980" z="-7418" heading="1722" respawn="60" />
+		</group>
+		<group name="save_point2">
 			<spawn npcId="18834" x="-75559" y="207860" z="-7515" heading="16384" respawn="60" />
 			<spawn npcId="18834" x="-74227" y="208290" z="-7520" heading="32768" respawn="60" />
 			<spawn npcId="18834" x="-74522" y="207063" z="-7520" heading="0" respawn="60" />
@@ -38,6 +57,14 @@
 			<spawn npcId="18834" x="-76374" y="208848" z="-7616" heading="32768" respawn="60" />
 			<spawn npcId="18834" x="-76928" y="209189" z="-7616" heading="16384" respawn="60" />
 			<spawn npcId="18834" x="-77183" y="209443" z="-7616" heading="49151" respawn="60" />
+			<spawn npcId="18834" x="-74955" y="207611" z="-7520" heading="0" respawn="60" />
+			<spawn npcId="18834" x="-75654" y="208112" z="-7520" heading="2718" respawn="60" />
+			<spawn npcId="18834" x="-75428" y="208115" z="-7520" heading="32768" respawn="60" />
+			<spawn npcId="27351" x="-74282" y="208784" z="-7520" heading="40959" respawn="60" />
+			<spawn npcId="27351" x="-74558" y="206625" z="-7520" heading="65102" respawn="60" />
+			<spawn npcId="27351" x="-75454" y="206740" z="-7520" heading="34645" respawn="60" />
+		</group>
+		<group name="save_point3">
 			<spawn npcId="18834" x="-78921" y="206110" z="-7904" heading="7872" respawn="60" />
 			<spawn npcId="18834" x="-78855" y="206443" z="-7896" heading="24784" respawn="60" />
 			<spawn npcId="18834" x="-79357" y="206713" z="-7904" heading="49151" respawn="60" />
@@ -48,24 +75,12 @@
 			<spawn npcId="18834" x="-79363" y="205379" z="-7904" heading="49151" respawn="60" />
 			<spawn npcId="18834" x="-78870" y="205253" z="-7904" heading="24792" respawn="60" />
 			<spawn npcId="18834" x="-78928" y="205585" z="-7904" heading="-8184" respawn="60" />
-			<spawn npcId="18835" x="-75650" y="212107" z="-7322" heading="0" respawn="60" />
-			<spawn npcId="18835" x="-74854" y="212107" z="-7322" heading="32768" respawn="60" />
-			<spawn npcId="18835" x="-74534" y="212108" z="-7321" heading="0" respawn="60" />
-			<spawn npcId="18835" x="-75200" y="211178" z="-7322" heading="16384" respawn="60" />
-			<spawn npcId="18835" x="-74701" y="211460" z="-7321" heading="49151" respawn="60" />
 			<spawn npcId="18835" x="-78054" y="208464" z="-7712" heading="0" respawn="60" />
 			<spawn npcId="18835" x="-78521" y="208035" z="-7712" heading="0" respawn="60" />
 			<spawn npcId="18835" x="-76881" y="208037" z="-7712" heading="32768" respawn="60" />
 			<spawn npcId="18835" x="-78335" y="207793" z="-7712" heading="0" respawn="60" />
 			<spawn npcId="18835" x="-77702" y="207414" z="-7712" heading="16384" respawn="60" />
 			<spawn npcId="18835" x="-77337" y="207428" z="-7712" heading="57279" respawn="60" />
-			<spawn npcId="27351" x="-81938" y="205856" z="-8000" heading="0" respawn="60" />
-			<!-- Static NPCs -->
-			<spawn npcId="18834" x="-74934" y="213446" z="-7232" heading="33334" respawn="60" />
-			<spawn npcId="18834" x="-74955" y="207611" z="-7520" heading="0" respawn="60" />
-			<spawn npcId="18834" x="-75654" y="208112" z="-7520" heading="2718" respawn="60" />
-			<spawn npcId="18834" x="-75428" y="208115" z="-7520" heading="32768" respawn="60" />
-			<spawn npcId="18835" x="-74951" y="211629" z="-7321" heading="16384" respawn="60" />
 			<spawn npcId="18835" x="-77718" y="207512" z="-7712" heading="24550" respawn="60" />
 			<spawn npcId="18835" x="-77216" y="208297" z="-7712" heading="35486" respawn="60" />
 			<spawn npcId="18835" x="-77558" y="207138" z="-7712" heading="17906" respawn="60" />
@@ -79,21 +94,11 @@
 			<spawn npcId="27351" x="-79813" y="205426" z="-7904" heading="9231" respawn="60" />
 			<spawn npcId="27351" x="-79814" y="206277" z="-7904" heading="59013" respawn="60" />
 			<spawn npcId="27351" x="-78891" y="206272" z="-7904" heading="59013" respawn="60" />
+		</group>
+		<group name="save_point4">
+			<spawn npcId="27351" x="-81938" y="205856" z="-8000" heading="0" respawn="60" />
 			<spawn npcId="27351" x="-81535" y="205503" z="-8000" heading="16384" respawn="60" />
 			<spawn npcId="27351" x="-81536" y="206223" z="-8000" heading="49151" respawn="60" />
-			<spawn npcId="27351" x="-74619" y="209981" z="-7418" heading="30212" respawn="60" />
-			<spawn npcId="27351" x="-75301" y="209980" z="-7418" heading="1722" respawn="60" />
-			<spawn npcId="27351" x="-74282" y="208784" z="-7520" heading="40959" respawn="60" />
-			<spawn npcId="27351" x="-74558" y="206625" z="-7520" heading="65102" respawn="60" />
-			<spawn npcId="27351" x="-75454" y="206740" z="-7520" heading="34645" respawn="60" />
 		</group>
-		<group name="high_priest_of_dawn">
-       		<spawn npcId="18828" x="-79229" y="205782" z="-7896" heading="28672" respawn="60" />
-        	<spawn npcId="18828" x="-79362" y="205706" z="-7896" heading="16383" respawn="60" />
-        	<spawn npcId="18828" x="-79495" y="205774" z="-7896" heading="4096" respawn="60" />
-        	<spawn npcId="18828" x="-79493" y="205930" z="-7896" heading="61440" respawn="60" />
-        	<spawn npcId="18828" x="-79362" y="206012" z="-7896" heading="49152" respawn="60" />
-       		<spawn npcId="18828" x="-79230" y="205935" z="-7896" heading="36864" respawn="60" />
-       	</group>
 	</spawnlist>
 </instance>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/instances/SanctumOftheLordsOfDawn/SanctumOftheLordsOfDawn.java b/L2J_DataPack_BETA/dist/game/data/scripts/instances/SanctumOftheLordsOfDawn/SanctumOftheLordsOfDawn.java
index cfcc26c1ca..84d9a713f0 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/instances/SanctumOftheLordsOfDawn/SanctumOftheLordsOfDawn.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/instances/SanctumOftheLordsOfDawn/SanctumOftheLordsOfDawn.java
@@ -18,7 +18,13 @@
  */
 package instances.SanctumOftheLordsOfDawn;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
 import quests.Q00195_SevenSignsSecretRitualOfThePriests.Q00195_SevenSignsSecretRitualOfThePriests;
+import ai.npc.AbstractNpcAI;
 
 import com.l2jserver.gameserver.instancemanager.InstanceManager;
 import com.l2jserver.gameserver.model.L2World;
@@ -28,7 +34,6 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.entity.Instance;
 import com.l2jserver.gameserver.model.holders.SkillHolder;
 import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
-import com.l2jserver.gameserver.model.quest.Quest;
 import com.l2jserver.gameserver.model.quest.QuestState;
 import com.l2jserver.gameserver.network.NpcStringId;
 import com.l2jserver.gameserver.network.SystemMessageId;
@@ -39,12 +44,18 @@ import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  * Sanctum of the Lords of Dawn instance zone.
  * @author Adry_85
  */
-public final class SanctumOftheLordsOfDawn extends Quest
+public final class SanctumOftheLordsOfDawn extends AbstractNpcAI
 {
-	protected class HSWorld extends InstanceWorld
+	protected static final class HSWorld extends InstanceWorld
 	{
 		protected long storeTime = 0;
 		protected int doorst = 0;
+		protected final static Map<Integer, List<L2Npc>> _save_point = new HashMap<>();
+		
+		public static Map<Integer, List<L2Npc>> getMonsters()
+		{
+			return _save_point;
+		}
 	}
 	
 	// Instance
@@ -70,9 +81,17 @@ public final class SanctumOftheLordsOfDawn extends Quest
 	private static final Location ENTER = new Location(-76161, 213401, -7120, 0, 0);
 	private static final Location EXIT = new Location(-12585, 122305, -2989, 0, 0);
 	
+	private static final Location[] SAVE_POINT = new Location[]
+	{
+		new Location(-75775, 213415, -7120),
+		new Location(-74959, 209240, -7472),
+		new Location(-77699, 208905, -7640),
+		new Location(-79939, 205857, -7888),
+	};
+	
 	private SanctumOftheLordsOfDawn()
 	{
-		super(-1, SanctumOftheLordsOfDawn.class.getSimpleName(), "instances");
+		super(SanctumOftheLordsOfDawn.class.getSimpleName(), "instances");
 		addStartNpc(LIGHT_OF_DAWN);
 		addTalkId(LIGHT_OF_DAWN, IDENTITY_CONFIRM_DEVICE, PASSWORD_ENTRY_DEVICE, DARKNESS_OF_DAWN, SHELF);
 		addAggroRangeEnterId(GUARDS_OF_THE_DAWN, GUARDS_OF_THE_DAWN_2, GUARDS_OF_THE_DAWN_3);
@@ -102,55 +121,71 @@ public final class SanctumOftheLordsOfDawn extends Quest
 					case GUARDS_OF_THE_DAWN:
 					{
 						npc.broadcastPacket(new NpcSay(npc.getObjectId(), 0, npc.getId(), NpcStringId.INTRUDER_PROTECT_THE_PRIESTS_OF_DAWN));
-						player.teleToLocation(-75987, 213470, -7123);
 						break;
 					}
 					case GUARDS_OF_THE_DAWN_2:
 					{
 						npc.broadcastPacket(new NpcSay(npc.getObjectId(), 0, npc.getId(), NpcStringId.HOW_DARE_YOU_INTRUDE_WITH_THAT_TRANSFORMATION_GET_LOST));
-						player.teleToLocation(-75987, 213470, -7123);
 						break;
 					}
 					case GUARDS_OF_THE_DAWN_3:
 					{
 						npc.broadcastPacket(new NpcSay(npc.getObjectId(), 0, npc.getId(), NpcStringId.WHO_ARE_YOU_A_NEW_FACE_LIKE_YOU_CANT_APPROACH_THIS_PLACE));
-						player.teleToLocation(-75987, 213470, -7123);
 						break;
 					}
 				}
-				break;
+				
+				OUTTER:
+				for (Entry<Integer, List<L2Npc>> entry : HSWorld._save_point.entrySet())
+				{
+					for (L2Npc monster : entry.getValue())
+					{
+						if (monster.getObjectId() == npc.getObjectId())
+						{
+							player.teleToLocation(SAVE_POINT[entry.getKey()]);
+							break OUTTER;
+						}
+					}
+				}
 			}
 		}
 		return super.onAdvEvent(event, npc, player);
 	}
 	
-	protected int enterInstance(L2PcInstance player, String template, Location loc)
+	private void enterInstance(L2PcInstance player, String template, Location loc)
 	{
-		// check for existing instances for this player
 		InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
-		// existing instance
 		if (world != null)
 		{
 			if (!(world instanceof HSWorld))
 			{
 				player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
-				return 0;
 			}
+			else
+			{
+				teleportPlayer(player, loc, world.getInstanceId());
+			}
+		}
+		else
+		{
+			// New instance,
+			world = new HSWorld();
+			world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(template));
+			world.setTemplateId(INSTANCEID);
+			world.setStatus(0);
+			((HSWorld) world).storeTime = System.currentTimeMillis();
+			InstanceManager.getInstance().addWorld(world);
+			_log.info("Sanctum of the Lords of Dawn started " + template + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
+			// Teleport players.
 			teleportPlayer(player, loc, world.getInstanceId());
-			return world.getInstanceId();
+			world.addAllowed(player.getObjectId());
+			final Map<Integer, List<L2Npc>> save_point = HSWorld.getMonsters();
+			final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
+			save_point.put(0, inst.spawnGroup("save_point1"));
+			save_point.put(1, inst.spawnGroup("save_point2"));
+			save_point.put(2, inst.spawnGroup("save_point3"));
+			save_point.put(3, inst.spawnGroup("save_point4"));
 		}
-		// New instance
-		world = new HSWorld();
-		world.setInstanceId(InstanceManager.getInstance().createDynamicInstance(template));
-		world.setTemplateId(INSTANCEID);
-		world.setStatus(0);
-		((HSWorld) world).storeTime = System.currentTimeMillis();
-		InstanceManager.getInstance().addWorld(world);
-		_log.info("SevenSign started " + template + " Instance: " + world.getInstanceId() + " created by player: " + player.getName());
-		// teleport players
-		teleportPlayer(player, loc, world.getInstanceId());
-		world.addAllowed(player.getObjectId());
-		return world.getInstanceId();
 	}
 	
 	@Override
-- 
GitLab