From fae78e61bf17a9834935c46793c5fd694d14c25b Mon Sep 17 00:00:00 2001
From: Zoey76 <zoey_76@msn.com>
Date: Fri, 23 Aug 2013 23:40:22 +0000
Subject: [PATCH] BETA: Retail like implementation of Gatekeeper Spirit. 
 * Reported by: oscard, maxstyleboy, lucan

---
 .../Teleports/GatekeeperSpirit/31111-no.html} |  0
 .../GatekeeperSpirit/{dawn.htm => 31111.html} |  2 +-
 .../Teleports/GatekeeperSpirit/31112.html}    |  2 +-
 .../GatekeeperSpirit/GatekeeperSpirit.java    | 81 ++++++++++++++-----
 .../npc/Teleports/GatekeeperSpirit/dusk.htm   |  5 --
 L2J_DataPack_BETA/dist/sql/game/teleport.sql  |  2 -
 6 files changed, 63 insertions(+), 29 deletions(-)
 rename L2J_DataPack_BETA/dist/game/data/{html/teleporter/31111.htm => scripts/ai/npc/Teleports/GatekeeperSpirit/31111-no.html} (100%)
 rename L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/{dawn.htm => 31111.html} (80%)
 rename L2J_DataPack_BETA/dist/game/data/{html/teleporter/31112.htm => scripts/ai/npc/Teleports/GatekeeperSpirit/31112.html} (60%)
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/dusk.htm

diff --git a/L2J_DataPack_BETA/dist/game/data/html/teleporter/31111.htm b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/31111-no.html
similarity index 100%
rename from L2J_DataPack_BETA/dist/game/data/html/teleporter/31111.htm
rename to L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/31111-no.html
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/dawn.htm b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/31111.html
similarity index 80%
rename from L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/dawn.htm
rename to L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/31111.html
index bffdf2bf08..2d134fcd49 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/dawn.htm
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/31111.html
@@ -1,5 +1,5 @@
 <html><body>Gatekeeper Spirit:<br>
 Behold, the sphere speaks...<br>
 You have entered the Forbidden Sanctum, resting place of <font color="LEVEL">Lilith</font> and <font color="LEVEL">Anakim</font>. I guard the path to the Sanctum. The Seal of Avarice may only be breached when the eye is open.<br>
-<a action="bypass -h npc_%objectId%_goto 451">Teleport</a>
+<a action="bypass -h Quest GatekeeperSpirit TeleportIn">Teleport.</a>
 </body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/teleporter/31112.htm b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/31112.html
similarity index 60%
rename from L2J_DataPack_BETA/dist/game/data/html/teleporter/31112.htm
rename to L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/31112.html
index 7c2660a0a0..7b39099157 100644
--- a/L2J_DataPack_BETA/dist/game/data/html/teleporter/31112.htm
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/31112.html
@@ -1,5 +1,5 @@
 <html><body>Gatekeeper Spirit:<br>
 Behold, the sphere speaks...<br>
 You must leave this place!<br>
-<a action="bypass -h npc_%objectId%_goto 452">Teleport</a>
+<a action="bypass -h Quest GatekeeperSpirit TeleportOut">Teleport.</a>
 </body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/GatekeeperSpirit.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/GatekeeperSpirit.java
index 1f98d7103b..fe8052cd8c 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/GatekeeperSpirit.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/GatekeeperSpirit.java
@@ -27,7 +27,7 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 /**
  * Gatekeeper Spirit AI.
- * @author Charus, lion
+ * @author Zoey76
  */
 public class GatekeeperSpirit extends AbstractNpcAI
 {
@@ -39,46 +39,87 @@ public class GatekeeperSpirit extends AbstractNpcAI
 	// Exit gatekeeper spawn locations
 	private static final Location SPAWN_LILITH_GATEKEEPER = new Location(184410, -10111, -5488);
 	private static final Location SPAWN_ANAKIM_GATEKEEPER = new Location(184410, -13102, -5488);
+	// Teleport
+	private static final Location TELEPORT_DUSK = new Location(184464, -13104, -5504);
+	private static final Location TELEPORT_DAWN = new Location(184448, -10112, -5504);
+	private static final Location EXIT = new Location(182960, -11904, -4897);
 	
 	private GatekeeperSpirit()
 	{
 		super(GatekeeperSpirit.class.getSimpleName(), "ai/npc/Teleports");
 		addStartNpc(GATEKEEPER_SPIRIT_ENTER);
 		addFirstTalkId(GATEKEEPER_SPIRIT_ENTER);
+		addTalkId(GATEKEEPER_SPIRIT_ENTER);
 		addKillId(LILITH, ANAKIM);
 	}
 	
 	@Override
-	public String onFirstTalk(L2Npc npc, L2PcInstance player)
+	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
 	{
-		int playerCabal = SevenSigns.getInstance().getPlayerCabal(player.getObjectId());
-		int sealOfAvariceOwner = SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_AVARICE);
-		int compWinner = SevenSigns.getInstance().getCabalHighestScore();
-		
-		if ((playerCabal == sealOfAvariceOwner) && (playerCabal == compWinner) && (sealOfAvariceOwner != SevenSigns.CABAL_NULL))
+		String htmltext = null;
+		switch (event)
 		{
-			return (sealOfAvariceOwner == SevenSigns.CABAL_DUSK) ? "dusk.htm" : "dawn.htm";
+			case "ANAKIM":
+			{
+				addSpawn(GATEKEEPER_SPIRIT_EXIT, SPAWN_ANAKIM_GATEKEEPER, false, 900000);
+				break;
+			}
+			case "LILITH":
+			{
+				addSpawn(GATEKEEPER_SPIRIT_EXIT, SPAWN_LILITH_GATEKEEPER, false, 900000);
+				break;
+			}
+			case "TeleportIn":
+			{
+				final int playerCabal = SevenSigns.getInstance().getPlayerCabal(player.getObjectId());
+				final int sealOfAvariceOwner = SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_AVARICE);
+				final int compWinner = SevenSigns.getInstance().getCabalHighestScore();
+				if (!SevenSigns.getInstance().isSealValidationPeriod())
+				{
+					htmltext = "31111-no.html";
+				}
+				else if ((compWinner == SevenSigns.CABAL_DUSK) && (playerCabal == SevenSigns.CABAL_DUSK) && (sealOfAvariceOwner == SevenSigns.CABAL_DUSK))
+				{
+					player.teleToLocation(TELEPORT_DUSK, false);
+				}
+				else if ((compWinner == SevenSigns.CABAL_DAWN) && (playerCabal == SevenSigns.CABAL_DAWN) && (sealOfAvariceOwner == SevenSigns.CABAL_DAWN))
+				{
+					player.teleToLocation(TELEPORT_DAWN, false);
+				}
+				else
+				{
+					htmltext = "31111-no.html";
+				}
+				break;
+			}
+			case "TeleportOut":
+			{
+				player.teleToLocation(EXIT, true);
+				break;
+			}
 		}
-		
-		npc.showChatWindow(player);
-		return super.onFirstTalk(npc, player);
+		return htmltext;
 	}
 	
 	@Override
 	public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
 	{
-		startQuestTimer(Integer.toString(npc.getId()), 10000, npc, killer);
+		switch (npc.getId())
+		{
+			case ANAKIM:
+			{
+				startQuestTimer("ANAKIM", 10000, npc, killer);
+				break;
+			}
+			case LILITH:
+			{
+				startQuestTimer("LILITH", 10000, npc, killer);
+				break;
+			}
+		}
 		return super.onKill(npc, killer, isSummon);
 	}
 	
-	@Override
-	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
-	{
-		Location loc = (event.equals(Integer.toString(LILITH)) ? SPAWN_LILITH_GATEKEEPER : SPAWN_ANAKIM_GATEKEEPER);
-		addSpawn(GATEKEEPER_SPIRIT_EXIT, loc, false, 900000);
-		return super.onAdvEvent(event, npc, player);
-	}
-	
 	public static void main(String[] args)
 	{
 		new GatekeeperSpirit();
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/dusk.htm b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/dusk.htm
deleted file mode 100644
index 3435a86f78..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Teleports/GatekeeperSpirit/dusk.htm
+++ /dev/null
@@ -1,5 +0,0 @@
-<html><body>Gatekeeper Spirit:<br>
-Behold, the sphere speaks...<br>
-You have entered the Forbidden Sanctum, resting place of <font color="LEVEL">Lilith</font> and <font color="LEVEL">Anakim</font>. I guard the path to the Sanctum. The Seal of Avarice may only be breached when the eye is open.<br>
-<a action="bypass -h npc_%objectId%_goto 450">Teleport</a>
-</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/sql/game/teleport.sql b/L2J_DataPack_BETA/dist/sql/game/teleport.sql
index c11cbc1e1e..7dc2cb77aa 100644
--- a/L2J_DataPack_BETA/dist/sql/game/teleport.sql
+++ b/L2J_DataPack_BETA/dist/sql/game/teleport.sql
@@ -234,8 +234,6 @@ INSERT INTO `teleport` VALUES
 ('Aden(hall) -> out)',415,147723,7916,-475,0,0,57),
 ('Aden(hall) -> in)',416,148580,4578,-408,0,0,57),
 ('Aden(hall) -> outofcastle)',417,147582,8753,-496,0,0,57),
-('Disciples Necropolis -> Anakim (DUSK)',450,185065,-12612,-5104,0,0,57),
-('Disciples Necropolis -> Lilith (DAWN)',451,185060,-9622,-5104,0,0,57),
 ('Anakim/Lilith -> Disciples Necropolis',452,183225,-11911,-4897,0,0,57),
 ('TI -> DE Village',1005,9709,15566,-4568,24000,0,57),
 ('TI -> Dwarven Village',1006,115120,-178224,-880,46000,0,57),
-- 
GitLab