From 1cc5fc7187834e3af79c9784edeb3860348f5e3d Mon Sep 17 00:00:00 2001
From: Adry_85 <Adrya85@hotmail.it>
Date: Sat, 13 Apr 2013 19:10:46 +0000
Subject: [PATCH] BETA: Clan Trader from Core to DP. 	Patch by: St3eT 
 Reviewed by: Adry_85, malyelfik, !UnAfraid 	Tested by: nache

---
 .../game/data/html/clantrader/32024-1.htm     |   4 -
 .../game/data/html/clantrader/32024-2.htm     |   9 --
 .../html/clantrader/32024-ExchangeFailed.htm  |   4 -
 .../html/clantrader/32024-ExchangeSuccess.htm |   4 -
 .../dist/game/data/html/clantrader/32024.htm  |   7 -
 .../game/data/html/clantrader/32025-1.htm     |   4 -
 .../game/data/html/clantrader/32025-2.htm     |   9 --
 .../html/clantrader/32025-ExchangeFailed.htm  |   4 -
 .../html/clantrader/32025-ExchangeSuccess.htm |   4 -
 .../dist/game/data/html/clantrader/32025.htm  |   7 -
 .../dist/game/data/multisell/1236.xml         | 123 +++++++++++++++++
 L2J_DataPack_BETA/dist/game/data/scripts.cfg  |   1 +
 .../CastleBlacksmith/CastleBlacksmith.java    |   2 +-
 .../CastleChamberlain/CastleChamberlain.java  |   2 +-
 .../CastleTeleporter/CastleTeleporter.java    |   2 +-
 .../npc/CastleWarehouse/CastleWarehouse.java  |   2 +-
 .../ai/npc/ClanTrader/32024-01.html}          |   8 +-
 .../scripts/ai/npc/ClanTrader/32024-02.html   |   9 ++
 .../scripts/ai/npc/ClanTrader/32024-03.html   |   4 +
 .../scripts/ai/npc/ClanTrader/32024-04.html   |   4 +
 .../scripts/ai/npc/ClanTrader/32024-05.html   |   4 +
 .../data/scripts/ai/npc/ClanTrader/32024.html |   8 ++
 .../ai/npc/ClanTrader/32025-01.html}          |   8 +-
 .../scripts/ai/npc/ClanTrader/32025-02.html   |   9 ++
 .../scripts/ai/npc/ClanTrader/32025-03.html   |   4 +
 .../scripts/ai/npc/ClanTrader/32025-04.html   |   4 +
 .../scripts/ai/npc/ClanTrader/32025-05.html   |   4 +
 .../data/scripts/ai/npc/ClanTrader/32025.html |   8 ++
 .../scripts/ai/npc/ClanTrader/ClanTrader.java | 125 ++++++++++++++++++
 .../handlers/bypasshandlers/ChatLink.java     |  15 ++-
 L2J_DataPack_BETA/dist/sql/game/npc.sql       |   4 +-
 31 files changed, 335 insertions(+), 71 deletions(-)
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-1.htm
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-2.htm
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-ExchangeFailed.htm
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-ExchangeSuccess.htm
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/html/clantrader/32024.htm
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-1.htm
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-2.htm
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-ExchangeFailed.htm
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-ExchangeSuccess.htm
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/html/clantrader/32025.htm
 create mode 100644 L2J_DataPack_BETA/dist/game/data/multisell/1236.xml
 rename L2J_DataPack_BETA/dist/game/data/{html/clantrader/32024-no.htm => scripts/ai/npc/ClanTrader/32024-01.html} (59%)
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-02.html
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-03.html
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-04.html
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-05.html
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024.html
 rename L2J_DataPack_BETA/dist/game/data/{html/clantrader/32025-no.htm => scripts/ai/npc/ClanTrader/32025-01.html} (63%)
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-02.html
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-03.html
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-04.html
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-05.html
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025.html
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/ClanTrader.java

diff --git a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-1.htm b/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-1.htm
deleted file mode 100644
index 6a25253d2b..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-1.htm
+++ /dev/null
@@ -1,4 +0,0 @@
-<html><body>Clan Trader Mulia:<br>
-The maximum clan level for raising reputation is 5.<br>
-<a action="bypass -h npc_%objectId%_Chat 0">Back.</a>
-</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-2.htm b/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-2.htm
deleted file mode 100644
index 6deaf595fe..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-2.htm
+++ /dev/null
@@ -1,9 +0,0 @@
-<html><body>Clan Trader Mulia:<br>
-There are many ways to increase your clan's reputation, from capturing a castle or fortress in battle, to helping our wandering newbies. Protection a territory is also laudable, and in that spirit I wish to make you an offer if you can bring me these items:<br>
-<font color="LEVEL">1 Blood Alliance</font> to prove that you have successfully defended a castle, <font color="LEVEL">10 Blood Oaths gained by preserving civic order in a territory</font>, and finally <font color="LEVEL">100 Knight's Epaulettes to prove that you are invincible in battle</font>.<br>
-Bring me these things, and I will personally see to it that your reputation increases.<br>
-<a action="bypass -h npc_%objectId%_exchange 9911">Provide 1 Blood Alliance.</a><br>
-<a action="bypass -h npc_%objectId%_exchange 9910">Provide 10 Blood Oaths.</a><br>
-<a action="bypass -h npc_%objectId%_exchange 9912">Provide 100 Knight's Epaulettes.</a><br>
-<a action="bypass -h npc_%objectId%_Chat 0">Back.</a>
-</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-ExchangeFailed.htm b/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-ExchangeFailed.htm
deleted file mode 100644
index 8c2c5e4e2b..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-ExchangeFailed.htm
+++ /dev/null
@@ -1,4 +0,0 @@
-<html><body>Clan Trader Mulia:<br>
-You have not brought a sufficient number of the items I requested to justify an increase in reputation.<br>
-<a action="bypass -h npc_%objectId%_Chat 0">Back.</a>
-</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-ExchangeSuccess.htm b/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-ExchangeSuccess.htm
deleted file mode 100644
index 53add66c2a..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-ExchangeSuccess.htm
+++ /dev/null
@@ -1,4 +0,0 @@
-<html><body>Clan Trader Mulia:<br>
-You have successfully increase your clan reputation score.<br>
-<a action="bypass -h npc_%objectId%_Chat 0">Back.</a>
-</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024.htm b/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024.htm
deleted file mode 100644
index fa7a0cd913..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024.htm
+++ /dev/null
@@ -1,7 +0,0 @@
-<html><body>Clan Trader Mulia:<br>
-Ah, you are the one who leads the clan. Your excellent reputation precedes you! What do you wish from me?<br>
-<a action="bypass -h npc_%objectId%_multisell 1235">Buy clan items.</a><br>
-<a action="bypass -h npc_%objectId%_crp">Ask about clan reputation.</a><br>
-<a action="bypass -h npc_%objectId%_TerritoryStatus">View information about the lord and tax rate.</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/html/clantrader/32025-1.htm b/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-1.htm
deleted file mode 100644
index 8337577c72..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-1.htm
+++ /dev/null
@@ -1,4 +0,0 @@
-<html><body>Clan Trader Ilia:<br>
-The maximum clan level for raising reputation is 5.<br>
-<a action="bypass -h npc_%objectId%_Chat 0">Back.</a>
-</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-2.htm b/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-2.htm
deleted file mode 100644
index 91bcfeb4a4..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-2.htm
+++ /dev/null
@@ -1,9 +0,0 @@
-<html><body>Clan Trader Ilia:<br>
-There are many ways to increase your clan's reputation, from capturing a castle or fortress in battle, to helping our wandering newbies. Protection a territory is also laudable, and in that spirit I wish to make you an offer if you can bring me these items:<br>
-<font color="LEVEL">1 Blood Alliance</font> to prove that you have successfully defended a castle, <font color="LEVEL">10 Blood Oaths gained by preserving civic order in a territory</font>, and finally <font color="LEVEL">100 Knight's Epaulettes to prove that you are invincible in battle</font>.<br>
-Bring me these things, and I will personally see to it that your reputation increases.<br>
-<a action="bypass -h npc_%objectId%_exchange 9911">Provide 1 Blood Alliance.</a><br>
-<a action="bypass -h npc_%objectId%_exchange 9910">Provide 10 Blood Oaths.</a><br>
-<a action="bypass -h npc_%objectId%_exchange 9912">Provide 100 Knight's Epaulettes.</a><br>
-<a action="bypass -h npc_%objectId%_Chat 0">Back.</a>
-</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-ExchangeFailed.htm b/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-ExchangeFailed.htm
deleted file mode 100644
index f47048c0c1..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-ExchangeFailed.htm
+++ /dev/null
@@ -1,4 +0,0 @@
-<html><body>Clan Trader Ilia:<br>
-You have not brought a sufficient number of the items I requested to justify an increase in reputation.<br>
-<a action="bypass -h npc_%objectId%_Chat 0">Back.</a>
-</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-ExchangeSuccess.htm b/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-ExchangeSuccess.htm
deleted file mode 100644
index 7dc2b356ac..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-ExchangeSuccess.htm
+++ /dev/null
@@ -1,4 +0,0 @@
-<html><body>Clan Trader Ilia:<br>
-You have successfully increase your clan reputation score.<br>
-<a action="bypass -h npc_%objectId%_Chat 0">Back.</a>
-</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025.htm b/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025.htm
deleted file mode 100644
index f31ca669c0..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025.htm
+++ /dev/null
@@ -1,7 +0,0 @@
-<html><body>Clan Trader Ilia:<br>
-Ah! A resolution pledged with blood, and a pledge to unite. Since you are a master of that pledge, what is it you wish from me?<br>
-<a action="bypass -h npc_%objectId%_multisell 1235">Buy clan items.</a><br>
-<a action="bypass -h npc_%objectId%_crp">Ask about clan reputation.</a><br>
-<a action="bypass -h npc_%objectId%_TerritoryStatus">View information about the lord and tax rate.</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/multisell/1236.xml b/L2J_DataPack_BETA/dist/game/data/multisell/1236.xml
new file mode 100644
index 0000000000..20139ded75
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/multisell/1236.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<list applyTaxes="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/multisell.xsd">
+	<item>
+		<!-- Apella Helm -->
+		<ingredient count="1" id="7860" />
+		<!-- Clan reputation points -->
+		<ingredient count="350" id="-200" />
+		<!-- Knight's Epaulette -->
+		<ingredient count="26" id="9912" />
+		<!-- Adena -->
+		<ingredient count="704000" id="57" />
+		<!-- Improved Apella Helm -->
+		<production count="1" id="9830" />
+	</item>
+	<item>
+		<!-- Apella Plate Armor -->
+		<ingredient count="1" id="7861" />
+		<!-- Clan reputation points -->
+		<ingredient count="1824" id="-200" />
+		<!-- Knight's Epaulette -->
+		<ingredient count="115" id="9912" />
+		<!-- Adena -->
+		<ingredient count="3671000" id="57" />
+		<!-- Improved Apella Plate Armor -->
+		<production count="1" id="9831" />
+	</item>
+	<item>
+		<!-- Apella Gauntlet - Heavy Armor -->
+		<ingredient count="1" id="7862" />
+		<!-- Clan reputation points -->
+		<ingredient count="233" id="-200" />
+		<!-- Knight's Epaulette -->
+		<ingredient count="18" id="9912" />
+		<!-- Adena -->
+		<ingredient count="469160" id="57" />
+		<!-- Improved Apella Gauntlet - Heavy Armor -->
+		<production count="1" id="9832" />
+	</item>
+	<item >
+		<!-- Apella Solleret - Heavy Armor -->
+		<ingredient count="1" id="7863" />
+		<!-- Clan reputation points -->
+		<ingredient count="233" id="-200" />
+		<!-- Knight's Epaulette -->
+		<ingredient count="18" id="9912" />
+		<!-- Adena -->
+		<ingredient count="469160" id="57" />
+		<!-- Improved Apella Solleret - Heavy Armor -->
+		<production count="1" id="9833" />
+	</item>
+	<item>
+		<!-- Apella Brigandine -->
+		<ingredient count="1" id="7864" />
+		<!-- Clan reputation points -->
+		<ingredient count="1367" id="-200" />
+		<!-- Knight's Epaulette -->
+		<ingredient count="86" id="9912" />
+		<!-- Adena -->
+		<ingredient count="2751800" id="57" />
+		<!-- Improved Apella Brigandine -->
+		<production count="1" id="9834" />
+	</item>
+	<item>
+		<!-- Apella Leather Gloves - Light Armor -->
+		<ingredient count="1" id="7865" />
+		<!-- Clan reputation points -->
+		<ingredient count="233" id="-200" />
+		<!-- Knight's Epaulette -->
+		<ingredient count="18" id="9912" />
+		<!-- Adena -->
+		<ingredient count="469160" id="57" />
+		<!-- Improved Apella Leather Gloves - Light Armor -->
+		<production count="1" id="9835" />
+	</item>
+	<item>
+		<!-- Apella Boots - Light Armor -->
+		<ingredient count="1" id="7866" />
+		<!-- Clan reputation points -->
+		<ingredient count="233" id="-200" />
+		<!-- Knight's Epaulette -->
+		<ingredient count="18" id="9912" />
+		<!-- Adena -->
+		<ingredient count="469160" id="57" />
+		<!-- Improved Apella Boots - Light Armor -->
+		<production count="1" id="9836" />
+	</item>
+	<item>
+		<!-- Apella Doublet -->
+		<ingredient count="1" id="7867" />
+		<!-- Clan reputation points -->
+		<ingredient count="1367" id="-200" />
+		<!-- Knight's Epaulette -->
+		<ingredient count="86" id="9912" />
+		<!-- Adena -->
+		<ingredient count="2751800" id="57" />
+		<!-- Improved Apella Doublet -->
+		<production count="1" id="9837" />
+	</item>
+	<item>
+		<!-- Apella Silk Gloves - Robe -->
+		<ingredient count="1" id="7868" />
+		<!-- Clan reputation points -->
+		<ingredient count="233" id="-200" />
+		<!-- Knight's Epaulette -->
+		<ingredient count="18" id="9912" />
+		<!-- Adena -->
+		<ingredient count="469160" id="57" />
+		<!-- Improved Apella Silk Gloves - Robe -->
+		<production count="1" id="9838" />
+	</item>
+	<item>
+		<!-- Apella Sandals - Robe -->
+		<ingredient count="1" id="7869" />
+		<!-- Clan reputation points -->
+		<ingredient count="233" id="-200" />
+		<!-- Knight's Epaulette -->
+		<ingredient count="18" id="9912" />
+		<!-- Adena -->
+		<ingredient count="469160" id="57" />
+		<!-- Improved Apella Sandals - Robe -->
+		<production count="1" id="9839" />
+	</item>
+</list>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts.cfg b/L2J_DataPack_BETA/dist/game/data/scripts.cfg
index e547610246..2eb07da452 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts.cfg
+++ b/L2J_DataPack_BETA/dist/game/data/scripts.cfg
@@ -17,6 +17,7 @@ ai/npc/CastleBlacksmith/CastleBlacksmith.java
 ai/npc/CastleChamberlain/CastleChamberlain.java
 ai/npc/CastleTeleporter/CastleTeleporter.java
 ai/npc/CastleWarehouse/CastleWarehouse.java
+ai/npc/ClanTrader/ClanTrader.java
 ai/npc/Dorian/Dorian.java
 ai/npc/DragonVortex/DragonVortex.java
 ai/npc/ForgeOfTheGods/ForgeOfTheGods.java
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleBlacksmith/CastleBlacksmith.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleBlacksmith/CastleBlacksmith.java
index 3b2ec459ef..8f11d8c08a 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleBlacksmith/CastleBlacksmith.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleBlacksmith/CastleBlacksmith.java
@@ -26,7 +26,7 @@ import com.l2jserver.gameserver.model.actor.L2Npc;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 /**
- * Castle Blacksmith AI
+ * Castle Blacksmith AI.
  * @author malyelfik
  */
 public class CastleBlacksmith extends AbstractNpcAI
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleChamberlain/CastleChamberlain.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleChamberlain/CastleChamberlain.java
index 960dab886b..c7ade3f9b9 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleChamberlain/CastleChamberlain.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleChamberlain/CastleChamberlain.java
@@ -54,7 +54,7 @@ import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
 import com.l2jserver.gameserver.util.Util;
 
 /**
- * Castle Chamberlain AI
+ * Castle Chamberlain AI.
  * @author malyelfik
  */
 public class CastleChamberlain extends AbstractNpcAI
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleTeleporter/CastleTeleporter.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleTeleporter/CastleTeleporter.java
index b4f9502a6a..88ebfa12b4 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleTeleporter/CastleTeleporter.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleTeleporter/CastleTeleporter.java
@@ -30,7 +30,7 @@ import com.l2jserver.gameserver.network.clientpackets.Say2;
 import com.l2jserver.gameserver.network.serverpackets.NpcSay;
 
 /**
- * Castle Teleporter AI
+ * Castle Teleporter AI.
  * @author malyelfik
  */
 public class CastleTeleporter extends AbstractNpcAI
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleWarehouse/CastleWarehouse.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleWarehouse/CastleWarehouse.java
index 02ace32fb3..40b8f7bdf0 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleWarehouse/CastleWarehouse.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleWarehouse/CastleWarehouse.java
@@ -24,7 +24,7 @@ import com.l2jserver.gameserver.model.actor.L2Npc;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 /**
- * Castle Warehouse Keeper AI
+ * Castle Warehouse Keeper AI.
  * @author malyelfik
  */
 public class CastleWarehouse extends AbstractNpcAI
diff --git a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-no.htm b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-01.html
similarity index 59%
rename from L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-no.htm
rename to L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-01.html
index 5efb1faf9c..36661f290f 100644
--- a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32024-no.htm
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-01.html
@@ -1,5 +1,5 @@
-<html><body>Clan Trader Mulia:<br>
-I seek the leader of a Clan!<br>
-That person alone can validate their Clan's reputation and be justly rewarded for doing so...<br>
-<a action="bypass -h npc_%objectId%_Quest">Quest</a>
+<html><head><body>Clan Trader Mulia:<br>
+I seek the leader of a Clan!<br>
+That person alone can validate their Clan's reputation and be justly rewarded for doing so...<br>
+<a action="bypass -h npc_%objectId%_Quest">Quest</a><br>
 </body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-02.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-02.html
new file mode 100644
index 0000000000..3c01193dc0
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-02.html
@@ -0,0 +1,9 @@
+<html><head><body>Clan Trader Mulia:<br>
+There are many ways to increase your clan's reputation, from capturing a castle or fortress in battle, to helping out wandering newbies. Protecting a territory is also laudable, and in that spirit I wish to make you an offer if you can bring me these items: <br><br>
+<font color = "LEVEL">1 Blood Alliance</font> to prove that you have successfully defended a castle, <font color = "LEVEL">10 Blood Oaths gained by preserving civic order in a territory</font>, and finally <font color = "LEVEL">100 Knight's Epaulettes to prove that you are invincible in battle</font>.<br><br>
+Bring me these things, and I will personally see to it that your reputation increases.<br><br>
+<a action="bypass -h Quest ClanTrader exchange-ba">Provide 1 Blood Alliance.</a><br>
+<a action="bypass -h Quest ClanTrader exchange-bo">Provide 10 Blood Oaths.</a><br>
+<a action="bypass -h Quest ClanTrader exchange-ke">Provide 100 Knight's Epaulettes.</a><br>
+<a action="bypass -h Quest ClanTrader 32024.html">Back.</a>
+</body></html>
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-03.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-03.html
new file mode 100644
index 0000000000..594cd91872
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-03.html
@@ -0,0 +1,4 @@
+<html><head><body>Clan Trader Mulia:<br>
+You have not brought a sufficient number of the items I requested to justify an increase in reputation.<br><br>
+<a action="bypass -h Quest ClanTrader 32024.html">Back.</a><br>
+</body></html>
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-04.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-04.html
new file mode 100644
index 0000000000..cc26a7e080
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-04.html
@@ -0,0 +1,4 @@
+<html><head><body>Clan Trader Mulia:<br>
+Your reputation has been increased.<br><br>
+<a action="bypass -h Quest ClanTrader 32024.html">Back.</a><br>
+</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-05.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-05.html
new file mode 100644
index 0000000000..04d698062f
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024-05.html
@@ -0,0 +1,4 @@
+<html><head><body>Clan Trader Mulia:<br>
+The maximum clan level for raising reputation is 5.<br><br>
+<a action="bypass -h Quest ClanTrader 32024.html">Back.</a><br>
+</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024.html
new file mode 100644
index 0000000000..d4b051415e
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32024.html
@@ -0,0 +1,8 @@
+<html><head><body>Clan Trader Mulia:<br>
+Oh, renowned leader of the clan! What business do you have with me?<br>
+<a action="bypass -h npc_%objectId%_multisell 1235">Buy a Clan Item.</a><br>
+<a action="bypass -h npc_%objectId%_multisell 1236">Upgrade a clan item.</a><br>
+<a action="bypass -h Quest ClanTrader repinfo">Ask about Clan Reputation Points.</a><br>
+<a action="bypass -h npc_%objectId%_TerritoryStatus">Ask about the local lord and tax rate.</a><br>
+<a action="bypass -h npc_%objectId%_Quest">Quest.</a><br>
+</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-no.htm b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-01.html
similarity index 63%
rename from L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-no.htm
rename to L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-01.html
index ad167c04d5..2a07ef283a 100644
--- a/L2J_DataPack_BETA/dist/game/data/html/clantrader/32025-no.htm
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-01.html
@@ -1,5 +1,5 @@
-<html><body>Clan Trader Ilia:<br>
-I seek a partner to a blood oath, the most sacred pledge of allegiance!<br>
-I will not release any item to anyone else! Our reputation depends on it!<br>
-<a action="bypass -h npc_%objectId%_Quest">Quest</a>
+<html><head><body>Clan Trader Ilia:<br>
+I seek a partner to a blood oath, the most sacred pledge of allegiance!<br>
+I will not release any item to anyone else! Our reputation depends on it!<br>
+<a action="bypass -h npc_%objectId%_Quest">Quest</a><br>
 </body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-02.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-02.html
new file mode 100644
index 0000000000..9d3c7c392a
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-02.html
@@ -0,0 +1,9 @@
+<html><head><body>Clan Trader Ilia:<br>
+There are many ways to increase your clan's reputation, from capturing a castle or fortress in battle, to helping out wandering newbies. Protecting a territory is also laudable, and in that spirit I wish to make you an offer if you can bring me these items:<br><br>
+<font color = "LEVEL">1 Blood Alliance</font> to prove that you have successfully defended a castle, <font color = "LEVEL">10 Blood Oaths gained by preserving civic order in a territory</font>, and finally <font color = "LEVEL">100 Knight's Epaulettes to prove that you are invincible in battle</font>.<br><br>
+Bring me these things, and I will personally see to it that your reputation increases.<br><br>
+<a action="bypass -h Quest ClanTrader exchange-ba">Provide 1 Blood Alliance.</a><br>
+<a action="bypass -h Quest ClanTrader exchange-bo">Provide 10 Blood Oaths.</a><br>
+<a action="bypass -h Quest ClanTrader exchange-ke">Provide 100 Knight's Epaulettes.</a><br>
+<a action="bypass -h Quest ClanTrader 32025.html">Back.</a><br>
+</body></html>
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-03.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-03.html
new file mode 100644
index 0000000000..ad018618fc
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-03.html
@@ -0,0 +1,4 @@
+<html><head><body>Clan Trader Ilia:<br>
+You have not brought a sufficient number of the items I requested to justify an increase in reputation.<br><br>
+<a action="bypass -h Quest ClanTrader 32025.html">Back.</a><br>
+</body></html>
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-04.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-04.html
new file mode 100644
index 0000000000..acf3dac81d
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-04.html
@@ -0,0 +1,4 @@
+<html><head><body>Clan Trader Ilia:<br>
+Your reputation has been increased.<br><br>
+<a action="bypass -h Quest ClanTrader 32025.html">Back.</a><br>
+</body></html>
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-05.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-05.html
new file mode 100644
index 0000000000..70052277ae
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025-05.html
@@ -0,0 +1,4 @@
+<html><head><body>Clan Trader Ilia:<br>
+The maximum clan level for raising reputation is 5.<br><br>
+<a action="bypass -h Quest ClanTrader 32025.html">Back.</a><br>
+</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025.html
new file mode 100644
index 0000000000..4e10737209
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/32025.html
@@ -0,0 +1,8 @@
+<html><head><body>Clan Trader Ilia:<br>
+We swore the blood oath together, did we not? If you are that oath-holder, come speak with me.<br>
+<a action="bypass -h npc_%objectId%_multisell 1235">Buy a Clan Item.</a><br>
+<a action="bypass -h npc_%objectId%_multisell 1236">Upgrade a clan item.</a><br>
+<a action="bypass -h Quest ClanTrader repinfo">Ask about Clan Reputation Points.</a><br>
+<a action="bypass -h npc_%objectId%_TerritoryStatus">Ask about the local lord and tax rate.</a><br>
+<a action="bypass -h npc_%objectId%_Quest">Quest.</a><br>
+</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/ClanTrader.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/ClanTrader.java
new file mode 100644
index 0000000000..b21dfa606f
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ClanTrader/ClanTrader.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2004-2013 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.ClanTrader;
+
+import ai.npc.AbstractNpcAI;
+
+import com.l2jserver.Config;
+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;
+import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
+
+/**
+ * Clan Trader AI.
+ * @author St3eT
+ */
+public class ClanTrader extends AbstractNpcAI
+{
+	// Npc
+	private static final int[] CLAN_TRADER =
+	{
+		32024, // Mulia
+		32025, // Ilia
+	};
+	// Items
+	private static final int BLOOD_ALLIANCE = 9911; // Blood Alliance
+	private static final int BLOOD_ALLIANCE_COUNT = 1; // Blood Alliance Count
+	private static final int BLOOD_OATH = 9910; // Blood Oath
+	private static final int BLOOD_OATH_COUNT = 10; // Blood Oath Count
+	private static final int KNIGHTS_EPAULETTE = 9912; // Knight's Epaulette
+	private static final int KNIGHTS_EPAULETTE_COUNT = 100; // Knight's Epaulette Count
+	
+	private ClanTrader(String name, String descr)
+	{
+		super(name, descr);
+		addStartNpc(CLAN_TRADER);
+		addTalkId(CLAN_TRADER);
+		addFirstTalkId(CLAN_TRADER);
+	}
+	
+	private String giveReputation(L2Npc npc, L2PcInstance player, int count, int itemId, int itemCount)
+	{
+		if (getQuestItemsCount(player, itemId) >= itemCount)
+		{
+			takeItems(player, itemId, itemCount);
+			player.getClan().addReputationScore(count, true);
+			
+			final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_ADDED_S1S_POINTS_TO_REPUTATION_SCORE);
+			sm.addNumber(count);
+			player.sendPacket(sm);
+			return npc.getNpcId() + "-04.html";
+		}
+		return npc.getNpcId() + "-03.html";
+	}
+	
+	@Override
+	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
+	{
+		String htmltext = null;
+		switch (event)
+		{
+			case "32024.html":
+			case "32024-02.html":
+			case "32025.html":
+			case "32025-02.html":
+			{
+				htmltext = event;
+				break;
+			}
+			case "repinfo":
+			{
+				htmltext = (player.getClan().getLevel() > 4) ? npc.getNpcId() + "-02.html" : npc.getNpcId() + "-05.html";
+				break;
+			}
+			case "exchange-ba":
+			{
+				htmltext = giveReputation(npc, player, Config.BLOODALLIANCE_POINTS, BLOOD_ALLIANCE, BLOOD_ALLIANCE_COUNT);
+				break;
+			}
+			case "exchange-bo":
+			{
+				htmltext = giveReputation(npc, player, Config.BLOODOATH_POINTS, BLOOD_OATH, BLOOD_OATH_COUNT);
+				break;
+			}
+			case "exchange-ke":
+			{
+				htmltext = giveReputation(npc, player, Config.KNIGHTSEPAULETTE_POINTS, KNIGHTS_EPAULETTE, KNIGHTS_EPAULETTE_COUNT);
+				break;
+			}
+		}
+		return htmltext;
+	}
+	
+	@Override
+	public String onFirstTalk(L2Npc npc, L2PcInstance player)
+	{
+		if (player.isClanLeader() || ((player.getClanPrivileges() & L2Clan.CP_CL_TROOPS_FAME) == L2Clan.CP_CL_TROOPS_FAME))
+		{
+			return npc.getNpcId() + ".html";
+		}
+		return npc.getNpcId() + "-01.html";
+	}
+	
+	public static void main(String[] args)
+	{
+		new ClanTrader(ClanTrader.class.getSimpleName(), "ai/npc");
+	}
+}
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/bypasshandlers/ChatLink.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/bypasshandlers/ChatLink.java
index daa6bbda17..cbbddd8385 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/bypasshandlers/ChatLink.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/bypasshandlers/ChatLink.java
@@ -18,10 +18,14 @@
  */
 package handlers.bypasshandlers;
 
+import java.util.List;
+
 import com.l2jserver.gameserver.handler.IBypassHandler;
 import com.l2jserver.gameserver.model.actor.L2Character;
 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.Quest.QuestEventType;
 
 public class ChatLink implements IBypassHandler
 {
@@ -47,8 +51,17 @@ public class ChatLink implements IBypassHandler
 		{
 			
 		}
-		((L2Npc) target).showChatWindow(activeChar, val);
 		
+		final L2Npc npc = (L2Npc) target;
+		final List<Quest> firstTalk = npc.getTemplate().getEventQuests(QuestEventType.ON_FIRST_TALK);
+		if ((val == 0) && (firstTalk != null) && (firstTalk.size() == 1))
+		{
+			firstTalk.get(0).notifyFirstTalk(npc, activeChar);
+		}
+		else
+		{
+			npc.showChatWindow(activeChar, val);
+		}
 		return false;
 	}
 	
diff --git a/L2J_DataPack_BETA/dist/sql/game/npc.sql b/L2J_DataPack_BETA/dist/sql/game/npc.sql
index fbd92fddb4..db4d358e68 100644
--- a/L2J_DataPack_BETA/dist/sql/game/npc.sql
+++ b/L2J_DataPack_BETA/dist/sql/game/npc.sql
@@ -8080,8 +8080,8 @@ INSERT INTO `npc` VALUES
 (32021, 32021, "Ice Sculpture", 0, "", 0, "LineageNpcEV.ice_sculpture_c", 16, 20.5, 70, "etc", "L2Npc", 40, 2444.46819, 1345.8, 7.5, 2.7, 40, 43, 30, 21, 20, 20, 0, 0, 688.86373, 295.91597, 470.40463, 216.53847, 253, 4, 333, 0, 0, 0, 50, 120, 0, 1),
 (32022, 32022, "Kier", 0, "", 0, "LineageNpcEV.ice_sculpture_b", 12, 24, 70, "etc", "L2Npc", 40, 2444.46819, 1345.8, 7.5, 2.7, 40, 43, 30, 21, 20, 20, 0, 0, 688.86373, 295.91597, 470.40463, 216.53847, 253, 4, 333, 0, 0, 0, 50, 120, 0, 1),
 (32023, 32023, "Ice Shelf", 0, "", 0, "LineageNpcEV.ice_shelf", 35, 14.5, 70, "etc", "L2Npc", 40, 2444.46819, 1345.8, 7.5, 2.7, 40, 43, 30, 21, 20, 20, 0, 0, 688.86373, 295.91597, 470.40463, 216.53847, 253, 4, 333, 0, 0, 0, 50, 120, 0, 1),
-(32024, 32024, "Mulia", 0, "Clan Trader", 0, "LineageNPC.e_smith_master_MDwarf", 8, 16.5, 70, "male", "L2ClanTrader", 40, 2444.46819, 1345.8, 7.5, 2.7, 40, 43, 30, 21, 20, 20, 0, 0, 688.86373, 295.91597, 470.40463, 216.53847, 253, 4, 333, 0, 0, 0, 50, 120, 0, 1),
-(32025, 32025, "Ilia", 0, "Clan Trader", 0, "LineageNPC.e_smith_Fdwarf", 8, 17.5, 70, "female", "L2ClanTrader", 40, 2444.46819, 1345.8, 7.5, 2.7, 40, 43, 30, 21, 20, 20, 0, 0, 688.86373, 295.91597, 470.40463, 216.53847, 253, 4, 333, 0, 0, 0, 50, 120, 0, 1),
+(32024, 32024, "Mulia", 0, "Clan Trader", 0, "LineageNPC.e_smith_master_MDwarf", 8, 16.5, 70, "male", "L2Npc", 40, 2444.46819, 1345.8, 7.5, 2.7, 40, 43, 30, 21, 20, 20, 0, 0, 688.86373, 295.91597, 470.40463, 216.53847, 253, 4, 333, 0, 0, 0, 50, 120, 0, 1),
+(32025, 32025, "Ilia", 0, "Clan Trader", 0, "LineageNPC.e_smith_Fdwarf", 8, 17.5, 70, "female", "L2Npc", 40, 2444.46819, 1345.8, 7.5, 2.7, 40, 43, 30, 21, 20, 20, 0, 0, 688.86373, 295.91597, 470.40463, 216.53847, 253, 4, 333, 0, 0, 0, 50, 120, 0, 1),
 (32026, 32026, "Hestui Guard", 0, "", 0, "LineageNPC.e_fighterguild_teacher_MOrc", 8, 28.5, 70, "male", "L2Npc", 40, 2444.46819, 1345.8, 7.5, 2.7, 40, 43, 30, 21, 20, 20, 0, 0, 688.86373, 295.91597, 470.40463, 216.53847, 253, 4, 333, 0, 0, 0, 50, 120, 0, 1),
 (32027, 32027, "Holy Brazier", 0, "", 0, "LineageNpcEV.grail_brazier_b", 30, 31, 78, "etc", "L2Npc", 40, 2974.356864, 1607.4, 8.5, 3, 40, 43, 30, 21, 20, 20, 0, 0, 890.50086, 332.70061, 608.09666, 243.45587, 253, 4, 333, 0, 0, 0, 50, 120, 0, 1),
 (32028, 32028, "Holy Grail", 0, "", 0, "LineageNpcEV.holy_grail", 6.2, 7, 70, "etc", "L2Npc", 40, 2444.46819, 1345.8, 7.5, 2.7, 40, 43, 30, 21, 20, 20, 0, 0, 688.86373, 295.91597, 470.40463, 216.53847, 253, 4, 333, 0, 0, 0, 50, 120, 0, 1),
-- 
GitLab