From ad8265e20b1c50deb7a9a4ea4aec51e73f755718 Mon Sep 17 00:00:00 2001
From: St3eT <St3eT@users.noreply.github.com>
Date: Sat, 14 Jun 2014 19:28:07 +0000
Subject: [PATCH] BETA: Reworked '''Lekon''' AI. * Reviewed by: Zoey76,
 !UnAfraid

---
 L2J_DataPack_BETA/dist/game/data/scripts.cfg  |  2 +-
 .../npc/Lekon/32557-01.html}                  |  2 +-
 .../data/scripts/ai/npc/Lekon/32557-02.html   |  3 +
 .../data/scripts/ai/npc/Lekon/32557-03.html   |  3 +
 .../data/scripts/ai/npc/Lekon/32557-04.html   |  3 +
 .../32557.htm => ai/npc/Lekon/32557.html}     |  2 +-
 .../game/data/scripts/ai/npc/Lekon/Lekon.java | 97 +++++++++++++++++++
 .../vehicles/EngineerLekon/EngineerLekon.java | 94 ------------------
 8 files changed, 109 insertions(+), 97 deletions(-)
 rename L2J_DataPack_BETA/dist/game/data/scripts/{vehicles/EngineerLekon/32557-1.htm => ai/npc/Lekon/32557-01.html} (89%)
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-02.html
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-03.html
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-04.html
 rename L2J_DataPack_BETA/dist/game/data/scripts/{vehicles/EngineerLekon/32557.htm => ai/npc/Lekon/32557.html} (83%)
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/Lekon.java
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/vehicles/EngineerLekon/EngineerLekon.java

diff --git a/L2J_DataPack_BETA/dist/game/data/scripts.cfg b/L2J_DataPack_BETA/dist/game/data/scripts.cfg
index bd4a60478d..ff96d74b8b 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts.cfg
+++ b/L2J_DataPack_BETA/dist/game/data/scripts.cfg
@@ -37,6 +37,7 @@ ai/npc/FortuneTelling/FortuneTelling.java
 ai/npc/FreyasSteward/FreyasSteward.java
 ai/npc/Jinia/Jinia.java
 ai/npc/KetraOrcSupport/KetraOrcSupport.java
+ai/npc/Lekon/Lekon.java
 ai/npc/MercenaryCaptain/MercenaryCaptain.java
 ai/npc/Minigame/Minigame.java
 ai/npc/MonumentOfHeroes/MonumentOfHeroes.java
@@ -335,7 +336,6 @@ vehicles/BoatRunePrimeval.java
 vehicles/AirShipGludioGracia/AirShipGludioGracia.java
 
 # AirShip Controllers
-vehicles/EngineerLekon/EngineerLekon.java
 vehicles/KeucereusNorthController/KeucereusNorthController.java
 vehicles/KeucereusSouthController/KeucereusSouthController.java
 vehicles/SoIController/SoIController.java
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/vehicles/EngineerLekon/32557-1.htm b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-01.html
similarity index 89%
rename from L2J_DataPack_BETA/dist/game/data/scripts/vehicles/EngineerLekon/32557-1.htm
rename to L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-01.html
index 6efbfe5fdc..0f3af51966 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/vehicles/EngineerLekon/32557-1.htm
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-01.html
@@ -3,5 +3,5 @@ Airship, eh? If you want board an Airship, you need to first register for a Summ
 Only <font color="LEVEL">clan lords whose clan is level 5 or higher</font> may earn the license. There is also a limit on the number of Airships.<br>
 If you meet the requirements, you can obtain a Airship Summon License in exchange for <font color="LEVEL">10 Energy Star Stones</font>.<br>
 An Energy Star Stone can be made by assembling Star Stones found floating in the skies over Gracia. If you thinkk this is too time-consuming, you can also buy them from Officer Tolonis right over there..<br>
-<a action="bypass -h Quest EngineerLekon license">Obtain the Airship Summon License.</a>
+<a action="bypass -h Quest Lekon licence">Obtain the Airship Summon License.</a>
 </body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-02.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-02.html
new file mode 100644
index 0000000000..87d67450f9
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-02.html
@@ -0,0 +1,3 @@
+<html><body>Engineer Lekon:<br>
+Only a clan lord whose clan is level 5 or above can be issued an Airship Summon License.
+</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-03.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-03.html
new file mode 100644
index 0000000000..5181edc909
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-03.html
@@ -0,0 +1,3 @@
+<html><head><body>Engineer Lekon:<br>
+You don't have enough Energy Star Stones yet. You can make them by assembling Star Stones found floating in the skies over Gracia. If you prefer, you can also purchase them from Officer Tolonis.
+</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-04.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-04.html
new file mode 100644
index 0000000000..e68195a3cd
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557-04.html
@@ -0,0 +1,3 @@
+<html><body>Engineer Lekon:<br>
+Hey, I see here that you already have a Airship Summon License! Haven't you registered it yet? Or did you lose it already?
+</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/vehicles/EngineerLekon/32557.htm b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557.html
similarity index 83%
rename from L2J_DataPack_BETA/dist/game/data/scripts/vehicles/EngineerLekon/32557.htm
rename to L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557.html
index bdf8a412c7..3d43159cf4 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/vehicles/EngineerLekon/32557.htm
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/32557.html
@@ -2,6 +2,6 @@
 I'm too busy to take a breath! I'm supposed to maintain all these Airships and air vehicles by myself?! How does that make sense?<br>
 And it's all very detailed, time-consuming work with no margin for error. Somebody up there must really hate me!<br>
 Well, at least they supply me with the materials I need. Hey, adventurer! You must know how to use Airships or air vehicles. Care to lend me a hand?<br>
-<a action="bypass -h Quest EngineerLekon 32557-1.htm">Ask about Airship Summon License.</a><br>
+<a action="bypass -h Quest Lekon 32557-01.html">Ask about Airship Summon License.</a><br>
 <a action="bypass -h npc_%objectId%_Quest">Quest</a>
 </body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/Lekon.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/Lekon.java
new file mode 100644
index 0000000000..f61126e874
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Lekon/Lekon.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2004-2014 L2J DataPack
+ * 
+ * This file is part of L2J DataPack.
+ * 
+ * L2J DataPack 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.
+ * 
+ * L2J DataPack 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 <http://www.gnu.org/licenses/>.
+ */
+package ai.npc.Lekon;
+
+import ai.npc.AbstractNpcAI;
+
+import com.l2jserver.gameserver.instancemanager.AirShipManager;
+import com.l2jserver.gameserver.model.L2Clan;
+import com.l2jserver.gameserver.model.actor.L2Npc;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.network.SystemMessageId;
+
+/**
+ * Lekon AI.
+ * @author St3eT
+ */
+public final class Lekon extends AbstractNpcAI
+{
+	// NPCs
+	private static final int LEKON = 32557;
+	// Items
+	private static final int LICENCE = 13559; // Airship Summon License
+	private static final int STONE = 13277; // Energy Star Stone
+	// Misc
+	private static final int MIN_CLAN_LV = 5;
+	private static final int STONE_COUNT = 10;
+	
+	private Lekon()
+	{
+		super(Lekon.class.getSimpleName(), "ai/npc");
+		addFirstTalkId(LEKON);
+		addTalkId(LEKON);
+		addStartNpc(LEKON);
+	}
+	
+	@Override
+	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
+	{
+		String htmltext = null;
+		switch (event)
+		{
+			case "32557-01.html":
+			{
+				htmltext = event;
+				break;
+			}
+			case "licence":
+			{
+				final L2Clan clan = player.getClan();
+				if ((clan == null) || !player.isClanLeader() || (clan.getLevel() < MIN_CLAN_LV))
+				{
+					htmltext = "32557-02.html";
+				}
+				else if (hasAtLeastOneQuestItem(player, LICENCE))
+				{
+					htmltext = "32557-04.html";
+				}
+				else if (AirShipManager.getInstance().hasAirShipLicense(clan.getId()))
+				{
+					player.sendPacket(SystemMessageId.THE_AIRSHIP_SUMMON_LICENSE_ALREADY_ACQUIRED);
+				}
+				else if (getQuestItemsCount(player, STONE) >= STONE_COUNT)
+				{
+					takeItems(player, STONE, STONE_COUNT);
+					giveItems(player, LICENCE, 1);
+				}
+				else
+				{
+					htmltext = "32557-03.html";
+				}
+				break;
+			}
+		}
+		return htmltext;
+	}
+	
+	public static void main(String args[])
+	{
+		new Lekon();
+	}
+}
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/vehicles/EngineerLekon/EngineerLekon.java b/L2J_DataPack_BETA/dist/game/data/scripts/vehicles/EngineerLekon/EngineerLekon.java
deleted file mode 100644
index 6d0ca414fc..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/scripts/vehicles/EngineerLekon/EngineerLekon.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2004-2014 L2J DataPack
- * 
- * This file is part of L2J DataPack.
- * 
- * L2J DataPack 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.
- * 
- * L2J DataPack 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 <http://www.gnu.org/licenses/>.
- */
-package vehicles.EngineerLekon;
-
-import com.l2jserver.gameserver.instancemanager.AirShipManager;
-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.network.SystemMessageId;
-import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
-
-public final class EngineerLekon extends Quest
-{
-	private static final int LEKON = 32557;
-	
-	private static final int LICENSE = 13559;
-	private static final int STARSTONE = 13277;
-	private static final int LICENSE_COST = 10;
-	
-	private static final SystemMessage SM_NEED_CLANLVL5 = SystemMessage.getSystemMessage(SystemMessageId.THE_AIRSHIP_NEED_CLANLVL_5_TO_SUMMON);
-	private static final SystemMessage SM_NO_PRIVS = SystemMessage.getSystemMessage(SystemMessageId.THE_AIRSHIP_NO_PRIVILEGES);
-	private static final SystemMessage SM_LICENSE_ALREADY_ACQUIRED = SystemMessage.getSystemMessage(SystemMessageId.THE_AIRSHIP_SUMMON_LICENSE_ALREADY_ACQUIRED);
-	
-	private EngineerLekon()
-	{
-		super(-1, EngineerLekon.class.getSimpleName(), "vehicles");
-		addStartNpc(LEKON);
-		addFirstTalkId(LEKON);
-		addTalkId(LEKON);
-	}
-	
-	@Override
-	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
-	{
-		if ("license".equalsIgnoreCase(event))
-		{
-			if ((player.getClan() == null) || (player.getClan().getLevel() < 5))
-			{
-				player.sendPacket(SM_NEED_CLANLVL5);
-				return null;
-			}
-			if (!player.isClanLeader())
-			{
-				player.sendPacket(SM_NO_PRIVS);
-				return null;
-			}
-			if (AirShipManager.getInstance().hasAirShipLicense(player.getClanId()))
-			{
-				player.sendPacket(SM_LICENSE_ALREADY_ACQUIRED);
-				return null;
-			}
-			if (player.getInventory().getItemByItemId(LICENSE) != null)
-			{
-				player.sendPacket(SM_LICENSE_ALREADY_ACQUIRED);
-				return null;
-			}
-			if (!player.destroyItemByItemId("AirShipLicense", STARSTONE, LICENSE_COST, npc, true))
-			{
-				return null;
-			}
-			
-			player.addItem("AirShipLicense", LICENSE, 1, npc, true);
-			return null;
-		}
-		return event;
-	}
-	
-	@Override
-	public String onFirstTalk(L2Npc npc, L2PcInstance player)
-	{
-		return npc.getId() + ".htm";
-	}
-	
-	public static void main(String[] args)
-	{
-		new EngineerLekon();
-	}
-}
-- 
GitLab