From a42ee275c63d0328fd36e70944f1eca02165d9f9 Mon Sep 17 00:00:00 2001
From: ivantotov <gmtotov@gmail.com>
Date: Sun, 7 Dec 2014 22:47:36 +0200
Subject: [PATCH] Quest: Relic Exploration (183) update. Reviewed by: @Zoey76

---
 .../Q00183_RelicExploration/30512-01.htm      |   2 +-
 .../Q00183_RelicExploration/30512-02.htm      |   2 +-
 .../{30512-00.htm => 30512-03.html}           |   0
 .../{30512-03.htm => 30512-04.htm}            |   0
 .../{30512-04.html => 30512-05.html}          |   0
 .../Q00183_RelicExploration/30673-02.html     |   4 +-
 .../Q00183_RelicExploration/30673-03.html     |   2 +-
 .../Q00183_RelicExploration.java              | 160 ++++++++++--------
 8 files changed, 99 insertions(+), 71 deletions(-)
 rename L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/{30512-00.htm => 30512-03.html} (100%)
 rename L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/{30512-03.htm => 30512-04.htm} (100%)
 rename L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/{30512-04.html => 30512-05.html} (100%)

diff --git a/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-01.htm b/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-01.htm
index c044ec0979..cc25bf3994 100644
--- a/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-01.htm
+++ b/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-01.htm
@@ -1,4 +1,4 @@
 <html><body>Head Blacksmith Kusto:<br>
-My trade is a very competitive one. I believed that the lost knowledge of the Giants would benefit me and all those with interests in the Black Anvil Guild... <br>
+My trade is a very competitive one. I believed that the lost knowledge of the Giants would benefit me and all those with interests in the Black Anvil Guild...<br>
 <a action="bypass -h Quest Q00183_RelicExploration 30512-02.htm">Listen to his story.</a>
 </body></html>
\ No newline at end of file
diff --git a/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-02.htm b/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-02.htm
index 5e0b1761cf..fd229c817c 100644
--- a/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-02.htm
+++ b/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-02.htm
@@ -1,4 +1,4 @@
 <html><body>Head Blacksmith Kusto:<br>
 I allied myself with Lorain, a member of the Bronze Key Guild. I promised that we would share equally any of the secrets we discovered in our quest. However, I think something terrible has recently happened to her. Would you help me?<br>
-<a action="bypass -h Quest Q00183_RelicExploration 30512-03.htm">"How can I help?"</a>
+<a action="bypass -h Quest Q00183_RelicExploration 30512-04.htm">"How can I help?"</a>
 </body></html>
\ No newline at end of file
diff --git a/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-00.htm b/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-03.html
similarity index 100%
rename from L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-00.htm
rename to L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-03.html
diff --git a/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-03.htm b/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-04.htm
similarity index 100%
rename from L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-03.htm
rename to L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-04.htm
diff --git a/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-04.html b/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-05.html
similarity index 100%
rename from L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-04.html
rename to L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30512-05.html
diff --git a/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30673-02.html b/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30673-02.html
index f27eacc00c..565520552c 100644
--- a/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30673-02.html
+++ b/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30673-02.html
@@ -1,5 +1,5 @@
 <html><body>Researcher Lorain:<br>
-Ah! You're the one I was promised could help me... <br>
-But you're too late. I was surprised by a monster while searching the 2nd floor, and I ended up having a big fight with that arrogant Nikola over there. He's so frustrating! I know he has a great deal of insight into these matters, but I can't stand working with him. <br>
+Ah! You're the one I was promised could help me...<br>
+But you're too late. I was surprised by a monster while searching the 2nd floor, and I ended up having a big fight with that arrogant Nikola over there. He's so frustrating! I know he has a great deal of insight into these matters, but I can't stand working with him.<br>
 <a action="bypass -h Quest Q00183_RelicExploration 30673-03.html">"But you have to continue your work!"</a>
 </body></html>
\ No newline at end of file
diff --git a/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30673-03.html b/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30673-03.html
index 3fb72a0041..c85635b362 100644
--- a/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30673-03.html
+++ b/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/30673-03.html
@@ -1,4 +1,4 @@
 <html><body>Researcher Lorain:<br>
-Would you work with someone who abandoned you in the face of danger? You and I can work together, and I'm sure we'll make progress. Of course, it is going to be harder to find the area we need... <br>
+Would you work with someone who abandoned you in the face of danger? You and I can work together, and I'm sure we'll make progress. Of course, it is going to be harder to find the area we need...<br>
 <a action="bypass -h Quest Q00183_RelicExploration 30673-04.html">"Give me some time and I'll see if I can patch things up between you two."</a>
 </body></html>
\ No newline at end of file
diff --git a/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/Q00183_RelicExploration.java b/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/Q00183_RelicExploration.java
index 55a0235607..8893cd6f78 100644
--- a/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/Q00183_RelicExploration.java
+++ b/L2J_DataPack/dist/game/data/scripts/quests/Q00183_RelicExploration/Q00183_RelicExploration.java
@@ -18,16 +18,18 @@
  */
 package quests.Q00183_RelicExploration;
 
+import quests.Q00184_ArtOfPersuasion.Q00184_ArtOfPersuasion;
+import quests.Q00185_NikolasCooperation.Q00185_NikolasCooperation;
+
 import com.l2jserver.gameserver.instancemanager.QuestManager;
 import com.l2jserver.gameserver.model.actor.L2Npc;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.quest.Quest;
 import com.l2jserver.gameserver.model.quest.QuestState;
-import com.l2jserver.gameserver.model.quest.State;
 
 /**
  * Relic Exploration (183)
- * @author IvanTotov
+ * @author ivantotov
  */
 public final class Q00183_RelicExploration extends Quest
 {
@@ -35,6 +37,9 @@ public final class Q00183_RelicExploration extends Quest
 	private static final int HEAD_BLACKSMITH_KUSTO = 30512;
 	private static final int MAESTRO_NIKOLA = 30621;
 	private static final int RESEARCHER_LORAIN = 30673;
+	// Misc
+	private static final int MIN_LEVEL = 40;
+	private static final int MAX_LEVEL_FOR_EXP_SP = 46;
 	
 	public Q00183_RelicExploration()
 	{
@@ -46,66 +51,93 @@ public final class Q00183_RelicExploration extends Quest
 	@Override
 	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
 	{
-		QuestState st = getQuestState(player, false);
-		
-		if (st == null)
+		final QuestState qs = getQuestState(player, false);
+		if (qs == null)
 		{
 			return null;
 		}
+		
 		String htmltext = null;
 		switch (event)
 		{
-			case "30512-02.htm":
-			case "30673-02.html":
-			case "30673-03.html":
+			case "30512-04.htm":
 			{
+				qs.startQuest();
+				qs.setMemoState(1);
 				htmltext = event;
 				break;
 			}
-			case "30512-03.htm":
+			case "30512-02.htm":
 			{
-				st.startQuest();
 				htmltext = event;
 				break;
 			}
-			case "30673-04.html":
+			case "30621-02.html":
 			{
-				st.setCond(2, true);
-				htmltext = event;
+				if (qs.isMemoState(2))
+				{
+					qs.giveAdena(18100, true);
+					if (player.getLevel() < MAX_LEVEL_FOR_EXP_SP)
+					{
+						qs.addExpAndSp(60000, 3000);
+						qs.exitQuest(false, true);
+						htmltext = event;
+					}
+				}
 				break;
 			}
-			case "30621-02.html":
+			case "30673-02.html":
+			case "30673-03.html":
 			{
-				if (player.getLevel() < 43)
+				if (qs.isMemoState(1))
 				{
-					st.addExpAndSp(60000, 3000);
+					htmltext = event;
+				}
+				break;
+			}
+			case "30673-04.html":
+			{
+				if (qs.isMemoState(1))
+				{
+					qs.setMemoState(2);
+					qs.setCond(2, true);
+					htmltext = event;
 				}
-				st.giveAdena(18100, true);
-				st.exitQuest(false, true);
-				htmltext = event;
 				break;
 			}
 			case "Contract":
 			{
-				final Quest quest = QuestManager.getInstance().getQuest("184_Nikolas_Cooperation_Contract");
-				st = player.getQuestState("184_Nikolas_Cooperation_Contract");
-				if ((quest != null) && (st == null))
+				final QuestState qs184 = player.getQuestState(Q00184_ArtOfPersuasion.class.getSimpleName());
+				final QuestState qs185 = player.getQuestState(Q00185_NikolasCooperation.class.getSimpleName());
+				final Quest quest = QuestManager.getInstance().getQuest(Q00184_ArtOfPersuasion.class.getSimpleName());
+				if ((quest != null) && (qs184 == null) && (qs185 == null))
 				{
-					st = quest.newQuestState(player);
-					st.setState(State.STARTED);
-					quest.notifyEvent("30621-01.htm", npc, player);
+					if (player.getLevel() >= MIN_LEVEL)
+					{
+						quest.notifyEvent("30621-03.htm", npc, player);
+					}
+					else
+					{
+						quest.notifyEvent("30621-03a.html", npc, player);
+					}
 				}
 				break;
 			}
 			case "Consideration":
 			{
-				final Quest quest = QuestManager.getInstance().getQuest("185_Nikolas_Cooperation_Consideration");
-				st = player.getQuestState("185_Nikolas_Cooperation_Consideration");
-				if ((quest != null) && (st == null))
+				final QuestState qs184 = player.getQuestState(Q00184_ArtOfPersuasion.class.getSimpleName());
+				final QuestState qs185 = player.getQuestState(Q00185_NikolasCooperation.class.getSimpleName());
+				final Quest quest = QuestManager.getInstance().getQuest(Q00185_NikolasCooperation.class.getSimpleName());
+				if ((quest != null) && (qs184 == null) && (qs185 == null))
 				{
-					st = quest.newQuestState(player);
-					st.setState(State.STARTED);
-					quest.notifyEvent("30621-01.htm", npc, player);
+					if (player.getLevel() >= MIN_LEVEL)
+					{
+						quest.notifyEvent("30621-03.htm", npc, player);
+					}
+					else
+					{
+						quest.notifyEvent("30621-03a.html", npc, player);
+					}
 				}
 				break;
 			}
@@ -116,57 +148,53 @@ public final class Q00183_RelicExploration extends Quest
 	@Override
 	public String onTalk(L2Npc npc, L2PcInstance player)
 	{
+		final QuestState qs = getQuestState(player, true);
 		String htmltext = getNoQuestMsg(player);
-		final QuestState st = getQuestState(player, true);
-		if (st == null)
+		if (qs.isCreated())
 		{
-			return htmltext;
+			if (npc.getId() == HEAD_BLACKSMITH_KUSTO)
+			{
+				htmltext = (player.getLevel() >= MIN_LEVEL) ? "30512-01.htm" : "30512-03.html";
+			}
 		}
-		
-		switch (npc.getId())
+		else if (qs.isStarted())
 		{
-			case HEAD_BLACKSMITH_KUSTO:
+			switch (npc.getId())
 			{
-				switch (st.getState())
+				case HEAD_BLACKSMITH_KUSTO:
 				{
-					case State.CREATED:
+					htmltext = "30512-05.html";
+					break;
+				}
+				case MAESTRO_NIKOLA:
+				{
+					if (qs.isMemoState(2))
 					{
-						htmltext = (player.getLevel() < 40) ? "30512-00.htm" : "30512-01.htm";
-						break;
+						htmltext = "30621-01.html";
 					}
-					case State.STARTED:
+					break;
+				}
+				case RESEARCHER_LORAIN:
+				{
+					if (qs.isMemoState(1))
 					{
-						if (st.isCond(1))
-						{
-							htmltext = "30512-04.html";
-						}
-						break;
+						htmltext = "30673-01.html";
 					}
-					case State.COMPLETED:
+					else if (qs.isMemoState(2))
 					{
-						htmltext = getAlreadyCompletedMsg(player);
-						break;
+						htmltext = "30673-05.html";
 					}
+					break;
 				}
-				break;
-			}
-			case RESEARCHER_LORAIN:
-			{
-				if (st.isStarted())
-				{
-					htmltext = st.isCond(1) ? "30673-01.html" : "30673-05.html";
-				}
-				break;
 			}
-			case MAESTRO_NIKOLA:
+		}
+		if (qs.isCompleted())
+		{
+			if (npc.getId() == HEAD_BLACKSMITH_KUSTO)
 			{
-				if (st.isCond(2))
-				{
-					htmltext = "30621-01.html";
-				}
-				break;
+				htmltext = getAlreadyCompletedMsg(player);
 			}
 		}
 		return htmltext;
 	}
-}
+}
\ No newline at end of file
-- 
GitLab