From 8fd80b761b490e6f816e7669d9879ebbec5816c2 Mon Sep 17 00:00:00 2001
From: Rumen Nikiforov <unafraid89@gmail.com>
Date: Sun, 6 Oct 2013 15:51:52 +0000
Subject: [PATCH] BETA: DP-Part for [L6242]

---
 .../scripts/ai/npc/Alexandria/Alexandria.java | 38 +++++++++++++------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Alexandria/Alexandria.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Alexandria/Alexandria.java
index 6c2b62c417..befbf54dd5 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Alexandria/Alexandria.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Alexandria/Alexandria.java
@@ -52,7 +52,7 @@ public final class Alexandria extends AbstractNpcAI
 	// Agathions
 	private static final QuestItemHolder[] LITTLE_DEVILS = new QuestItemHolder[]
 	{
-		new QuestItemHolder(10321, 600, 10408),
+		new AdditionalQuestItemHolder(10321, 600, 1, 10408),
 		new QuestItemHolder(10322, 10),
 		new QuestItemHolder(10323, 10),
 		new QuestItemHolder(10324, 5),
@@ -61,7 +61,7 @@ public final class Alexandria extends AbstractNpcAI
 	};
 	private static final QuestItemHolder[] LITTLE_ANGELS = new QuestItemHolder[]
 	{
-		new QuestItemHolder(10315, 600, 10408),
+		new AdditionalQuestItemHolder(10315, 600, 1, 10408),
 		new QuestItemHolder(10316, 10),
 		new QuestItemHolder(10317, 10),
 		new QuestItemHolder(10318, 5),
@@ -96,9 +96,9 @@ public final class Alexandria extends AbstractNpcAI
 			final int chance = getRandom(1000);
 			int chance2 = 0;
 			int chance3 = 0;
-			for (ItemHolder agathion : AGATHIONS.get(event))
+			for (QuestItemHolder agathion : AGATHIONS.get(event))
 			{
-				chance3 += agathion.getCount();
+				chance3 += agathion.getChance();
 				if ((chance >= chance2) && (chance2 < chance3))
 				{
 					boolean hasAllItems = true;
@@ -116,14 +116,14 @@ public final class Alexandria extends AbstractNpcAI
 						{
 							takeItems(player, item);
 						}
+						
 						giveItems(player, agathion.getId(), 1);
-						if (agathion.getCount() == 0)
+						htmltext = "30098-03.html";
+						
+						if (agathion instanceof AdditionalQuestItemHolder)
 						{
-							htmltext = "30098-03.html";
-						}
-						else
-						{
-							giveItems(player, (int) agathion.getCount(), 1);
+							final AdditionalQuestItemHolder addAgathion = (AdditionalQuestItemHolder) agathion;
+							giveItems(player, addAgathion.getAdditionalId(), 1);
 							htmltext = "30098-03a.html";
 						}
 					}
@@ -133,7 +133,7 @@ public final class Alexandria extends AbstractNpcAI
 					}
 					break;
 				}
-				chance2 += agathion.getCount();
+				chance2 += agathion.getChance();
 			}
 		}
 		return htmltext;
@@ -143,4 +143,20 @@ public final class Alexandria extends AbstractNpcAI
 	{
 		new Alexandria();
 	}
+	
+	public static class AdditionalQuestItemHolder extends QuestItemHolder
+	{
+		private final int _additionalId;
+		
+		public AdditionalQuestItemHolder(int id, int chance, long count, int additionalId)
+		{
+			super(id, chance, count);
+			_additionalId = additionalId;
+		}
+		
+		public int getAdditionalId()
+		{
+			return _additionalId;
+		}
+	}
 }
-- 
GitLab