Эх сурвалжийг харах

BETA: Rework of Alexandria AI.
* Minor NPE fix for WyvernManager.
* Removing NewbieAccountTracker, will be commited to Gracia Final.
* Reviewed by: jurchiks, Zoey76, St3et

xban1x 11 жил өмнө
parent
commit
458574bb06

+ 1 - 1
L2J_DataPack_BETA/dist/game/data/scripts.cfg

@@ -12,6 +12,7 @@ handlers/admincommandhandlers/AdminScan.js
 # AI Section
 
 # Npc
+ai/npc/Alexandria/Alexandria.java
 ai/npc/ArenaManager/ArenaManager.java
 ai/npc/AvantGarde/AvantGarde.java
 ai/npc/BlackJudge/BlackJudge.java
@@ -664,7 +665,6 @@ custom/MissQueen/MissQueen.java
 custom/NewbieCoupons/NewbieCoupons.java
 custom/RaidbossInfo/RaidbossInfo.java
 custom/NpcLocationInfo/NpcLocationInfo.java
-custom/PurchaseBracelet/PurchaseBracelet.java
 custom/IOPRace/IOPRace.java
 custom/Validators/SkillTransferValidator.java
 custom/Validators/SubClassSkills.java

+ 8 - 0
L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Alexandria/30098-02.html

@@ -0,0 +1,8 @@
+<html><body>Trader Alexandria:<br>
+Ah, you have excellent taste! This bracelet is truly unique. In fact, it is said that it contains an <font color="LEVEL">Agathion</font>. Quite a find, eh? Wondering if it is for sale? Of course it is -- that's why I'm here!<br>
+Both this <font color="LEVEL">Little Angel Agathion Bracelet</font> and this <font color="LEVEL">Little Devil Agathion Bracelet</font> were discovered by another group of adventurers while exploring some ancient ruins. I am positive that they contain Agathions! Of course, no one knows for sure the power an Agathion possesses or how long it lasts. I have been reluctant to experiment on them because it's clear that some of the bracelets possess only limited magic power.<br>
+Others have more, however. What you get will depend on your luck, I'm afraid.<br>
+If you wish to buy either the Little Angel Bracelet or the Little Devil Bracelet, bring me <font color="LEVEL">25 Big Red Nimble Fish, 50 Great Codrans, 4 Messengers' Skeletons in Crystals of Life, 5 Earth Eggs and 5 Nonliving Nuclei, 3 Dragon Hearts</font>, and <font color="LEVEL">7,500,000 Adena</font>. I wish I could part with them in exchange for crystals as normally would, but the adventurers who delivered the bracelets here insisted on these other items for payment. Even so, I still believe this is a reasonable price. After all, an Agathion isn't something you run across every day, eh? So, would you like to buy one?<br>
+<a action="bypass -h Quest Alexandria littleAngel">Purchase the Little Angel Agathion Bracelet.</a><br>
+<a action="bypass -h Quest Alexandria littleDevil">Purchase the Little Devil Agathion Bracelet.</a>
+</body></html>

+ 4 - 0
L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Alexandria/30098-03.html

@@ -0,0 +1,4 @@
+<html><body>Trader Alexandria:<br>
+Yes, I've checked the necessary items. Thank you for your hard work.<br>
+I'm telling you ahead that I don't know for sure what kind of power each bracelet has. I only can tell you that the angel-engraved bracelet has an angel-type Agathion, and the devil-engraved one has a devil-type Agathion. You can find out the capability and magic power of each Agathion on your own.
+</body></html>

+ 6 - 0
L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Alexandria/30098-03a.html

@@ -0,0 +1,6 @@
+<html><body>Trader Alexandria:<br>
+Yes, I checked the necessary items. It must have been difficult to obtain them all!<br>
+I must warn you that I do not know for sure what kind of power posessed by each bracelet. I only can tell you that the Angel's Bracelet contains an angel-type Agathion, while the Devil's Bracelet contains a devil-type Agathion. You must discover the capability and magic power of each on your own.<br>
+Here, please take this as an extra token of my appreciation for your business...<br>
+(I have a strange feeling about that bracelet -- I hope this adventurer will simply take this and leave here immediately.)
+</body></html>

+ 1 - 1
L2J_DataPack_BETA/dist/game/data/scripts/custom/PurchaseBracelet/30098-no.htm → L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Alexandria/30098-04.html

@@ -1,3 +1,3 @@
 <html><body>Trader Alexandria:<br>
-Oh, you don't have the items required to buy either the Angel's Bracelet or the Devil's Bracelet. In order to obtain one, you must first bring me <font color="LEVEL">20 Big Red Nimble Fish</font>, <font color="LEVEL">50 Great Codrans</font>, and <font color="LEVEL">4 Memento Moris, 5 Earth Eggs, 5 Nonliving Nuclei, 3 Dragon Hearts</font>, and <font color="LEVEL">7,500,000 Adena</font>.
+Oh, you don't have the items required to buy either the Angel's Bracelet or the Devil's Bracelet. In order to obtain one, you must first bring me <font color="LEVEL">25 Big Red Nimble Fish</font>, <font color="LEVEL">50 Great Codrans</font>, and <font color="LEVEL">4 Memento Moris, 5 Earth Eggs, 5 Nonliving Nuclei, 3 Dragon Hearts</font>, and <font color="LEVEL">7,500,000 Adena</font>.
 </body></html>

+ 1 - 1
L2J_DataPack_BETA/dist/game/data/html/merchant/30098.htm → L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Alexandria/30098.html

@@ -4,6 +4,6 @@ Ah! Now, you can use <font color="LEVEL">Adena</font> to pay for your goods.<br>
 If you would like to purchase a weapon, please ask my husband.<br>
 <a action="bypass -h npc_%objectId%_multisell 300984001">Purchase Armor.</a><br>
 <a action="bypass -h npc_%objectId%_multisell 300984002">Purchase Specialty Items.</a><br>
-<a action="bypass -h npc_%objectId%_Quest PurchaseBracelet">Purchase Agathion Bracelet.</a><br>
+<a action="bypass -h Quest Alexandria 30098-02.html">Purchase Agathion Bracelet.</a><br>
 <a action="bypass -h npc_%objectId%_Quest">Quest</a>
 </body></html>

+ 145 - 0
L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/Alexandria/Alexandria.java

@@ -0,0 +1,145 @@
+/*
+ * 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.Alexandria;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import ai.npc.AbstractNpcAI;
+
+import com.l2jserver.gameserver.model.actor.L2Npc;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.holders.ItemHolder;
+
+/**
+ * Alexandria (Armor Merchant) AI.
+ * @author xban1x
+ */
+public final class Alexandria extends AbstractNpcAI
+{
+	// NPC
+	private static final int ALEXANDRIA = 30098;
+	// Items
+	private static final ItemHolder[] REQUIRED_ITEMS = new ItemHolder[]
+	{
+		new ItemHolder(57, 3550000),
+		new ItemHolder(5094, 400),
+		new ItemHolder(6471, 200),
+		new ItemHolder(9814, 40),
+		new ItemHolder(9815, 30),
+		new ItemHolder(9816, 50),
+		new ItemHolder(9817, 50),
+	};
+	// Agathions
+	private static final ItemHolder[] LITTLE_DEVILS = new ItemHolder[]
+	{
+		new ItemHolder(10321, 10408, 600),
+		new ItemHolder(10322, 0, 10),
+		new ItemHolder(10323, 0, 10),
+		new ItemHolder(10324, 0, 5),
+		new ItemHolder(10325, 0, 5),
+		new ItemHolder(10326, 0, 370),
+	};
+	private static final ItemHolder[] LITTLE_ANGELS = new ItemHolder[]
+	{
+		new ItemHolder(10315, 10408, 600),
+		new ItemHolder(10316, 0, 10),
+		new ItemHolder(10317, 0, 10),
+		new ItemHolder(10318, 0, 5),
+		new ItemHolder(10319, 0, 5),
+		new ItemHolder(10320, 0, 370),
+	};
+	private static final Map<String, List<ItemHolder>> AGATHIONS = new HashMap<>();
+	static
+	{
+		AGATHIONS.put("littleAngel", Arrays.asList(LITTLE_ANGELS));
+		AGATHIONS.put("littleDevil", Arrays.asList(LITTLE_DEVILS));
+	}
+	
+	private Alexandria()
+	{
+		super(Alexandria.class.getSimpleName(), "ai/npc");
+		addStartNpc(ALEXANDRIA);
+		addTalkId(ALEXANDRIA);
+		addFirstTalkId(ALEXANDRIA);
+	}
+	
+	@Override
+	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
+	{
+		String htmltext = null;
+		if (event.equals("30098-02.html"))
+		{
+			htmltext = event;
+		}
+		else if (AGATHIONS.containsKey(event))
+		{
+			final int chance = getRandom(1000);
+			int chance2 = 0;
+			int chance3 = 0;
+			for (ItemHolder agathion : AGATHIONS.get(event))
+			{
+				chance3 += agathion.getCount();
+				if ((chance >= chance2) && (chance2 < chance3))
+				{
+					boolean hasAllItems = true;
+					for (ItemHolder item : REQUIRED_ITEMS)
+					{
+						if (getQuestItemsCount(player, item.getId()) < item.getCount())
+						{
+							hasAllItems = false;
+							break;
+						}
+					}
+					if (hasAllItems)
+					{
+						for (ItemHolder item : REQUIRED_ITEMS)
+						{
+							takeItems(player, item);
+						}
+						giveItems(player, agathion.getId(), 1);
+						if (agathion.getObjectId() == 0)
+						{
+							htmltext = "30098-03.html";
+						}
+						else
+						{
+							giveItems(player, agathion.getObjectId(), 1);
+							htmltext = "30098-03a.html";
+						}
+					}
+					else
+					{
+						htmltext = "30098-04.html";
+					}
+					break;
+				}
+				chance2 += agathion.getCount();
+			}
+		}
+		return htmltext;
+	}
+	
+	public static void main(String[] args)
+	{
+		new Alexandria();
+	}
+}

+ 3 - 1
L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/WyvernManager/WyvernManager.java

@@ -27,6 +27,7 @@ import com.l2jserver.Config;
 import com.l2jserver.gameserver.SevenSigns;
 import com.l2jserver.gameserver.model.actor.L2Npc;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.entity.Fort;
 import com.l2jserver.gameserver.model.entity.clanhall.SiegableHall;
 import com.l2jserver.gameserver.util.Util;
 
@@ -143,7 +144,8 @@ public final class WyvernManager extends AbstractNpcAI
 			}
 			case FORT:
 			{
-				if ((player.getClan() != null) && (npc.getFort() != null))
+				final Fort fort = npc.getFort();
+				if ((player.getClan() != null) && (fort != null) && (fort.getOwnerClan() != null))
 				{
 					return (player.isClanLeader() && (player.getClanId() == npc.getFort().getOwnerClan().getClanId()));
 				}

+ 0 - 43
L2J_DataPack_BETA/dist/game/data/scripts/custom/Listeners/NewbieAccountTracker.java

@@ -1,43 +0,0 @@
-package custom.Listeners;
-
-import com.l2jserver.gameserver.model.actor.L2Playable;
-import com.l2jserver.gameserver.model.actor.events.AbstractCharEvents;
-import com.l2jserver.gameserver.model.actor.events.listeners.ILevelChangeEventListener;
-import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
-import com.l2jserver.gameserver.model.variables.AccountVariables;
-
-/**
- * This tracker is attached to every player, until 1 character on account reaches level 6.
- * @author xban1x
- */
-public final class NewbieAccountTracker implements ILevelChangeEventListener
-{
-	private NewbieAccountTracker()
-	{
-		AbstractCharEvents.registerStaticListener(this);
-	}
-	
-	@Override
-	public boolean onLevelChange(L2Playable playable, byte levels)
-	{
-		if (playable.isPlayer())
-		{
-			final L2PcInstance player = playable.getActingPlayer();
-			if ((player != null) && (player.getLevel() < 6) && ((player.getLevel() + levels) >= 6))
-			{
-				final AccountVariables vars = player.getAccountVariables();
-				if (!vars.hasVariable(L2PcInstance.NEWBIE_KEY))
-				{
-					vars.set(L2PcInstance.NEWBIE_KEY, player.getObjectId());
-					player.getEvents().unregisterListener(this);
-				}
-			}
-		}
-		return true;
-	}
-	
-	public static void main(String[] args)
-	{
-		new NewbieAccountTracker();
-	}
-}

+ 0 - 8
L2J_DataPack_BETA/dist/game/data/scripts/custom/PurchaseBracelet/30098.htm

@@ -1,8 +0,0 @@
-<html><body>Trader Alexandria:<br>
-Ah, you have excellent taste! This bracelet is truly unique. In fact, it is said that it contains an <font color="LEVEL">Agathion</font>. Quite a find, eh? Wondering if it for sale? Of course it is -- that's why I'm here!<br>
-Both this <font color="LEVEL">Little Angel Agathion Bracelet</font> and this <font color="LEVEL">Little Devil Agathion Bracelet</font> were discovered by another group of adventurers while exploring some ancient ruins. I am positive that they contain Agathions! Of course, no one knows for sure the power an Agathion possesses or how long it lasts. I have been reluctant to experiment on them because it's clear that some of the bracelets possess only limited magic power.<br>
-Other have more, however. What you get will depend on your luck, I'm afraid.<br>
-If you wish to buy either the Little Angel bracelet or the Little Devil Bracelet, bring me <font color="LEVEL">25 Big Red Nimble Fish, 50 Great Codrans, 4 Messengers' Skeletons in Crystal of Life, 5 Earth Eggs and 5 Nonliving Nuclei, 3 Dragon Hearts</font>, and <font color="LEVEL">7,500,000 Adena</font>. I wish I could part with them in exchange for crystals as normally would, but the adventurers who delivered the bracelets here insisted on these other items for payment. Even so, I still believe this is a reasonable price. After all, an Agathion isn't something you run across every day, eh? So, would you like to buy one?<br>
-<a action="bypass -h Quest PurchaseBracelet Little_Angel">Purchase the Little Angel Agathion Bracelet.</a><br>
-<a action="bypass -h Quest PurchaseBracelet Little_Devil">Purchace the Little Devil Agathion Bracelet.</a>
-</body></html>

+ 0 - 109
L2J_DataPack_BETA/dist/game/data/scripts/custom/PurchaseBracelet/PurchaseBracelet.java

@@ -1,109 +0,0 @@
-/*
- * 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 custom.PurchaseBracelet;
-
-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;
-
-/**
- * Purchase Bracelet AI.
- * @author Nyaran
- */
-public class PurchaseBracelet extends Quest
-{
-	private static final String qn = "PurchaseBracelet";
-	
-	private static final int NPC = 30098;
-	
-	private static final int ANGEL_BRACELET = 10320;
-	private static final int DEVIL_BRACELET = 10326;
-	
-	private static final int ADENA = 57;
-	private static final int BIG_RED_NIBLE_FISH = 6471;
-	private static final int GREAT_CODRAN = 5094;
-	private static final int MEMENTO_MORI = 9814;
-	private static final int EARTH_EGG = 9816;
-	private static final int NONLIVING_NUCLEUS = 9817;
-	private static final int DRAGON_HEART = 9815;
-	
-	@Override
-	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
-	{
-		String htmltext = event;
-		QuestState st = player.getQuestState(qn);
-		if (st == null)
-		{
-			return htmltext;
-		}
-		
-		if ((st.getQuestItemsCount(6471) >= 20) && (st.getQuestItemsCount(GREAT_CODRAN) >= 50) && (st.getQuestItemsCount(MEMENTO_MORI) >= 4) && (st.getQuestItemsCount(EARTH_EGG) >= 5) && (st.getQuestItemsCount(NONLIVING_NUCLEUS) >= 5) && (st.getQuestItemsCount(DRAGON_HEART) >= 3) && (st.getQuestItemsCount(ADENA) >= 7500000))
-		{
-			st.takeItems(BIG_RED_NIBLE_FISH, 25);
-			st.takeItems(GREAT_CODRAN, 50);
-			st.takeItems(MEMENTO_MORI, 4);
-			st.takeItems(EARTH_EGG, 5);
-			st.takeItems(NONLIVING_NUCLEUS, 5);
-			st.takeItems(DRAGON_HEART, 3);
-			st.takeItems(ADENA, 7500000);
-			htmltext = "";
-			if (event.equals("Little_Devil"))
-			{
-				st.giveItems(DEVIL_BRACELET, 1);
-			}
-			else if (event.equals("Little_Angel"))
-			{
-				st.giveItems(ANGEL_BRACELET, 1);
-			}
-		}
-		else
-		{
-			htmltext = "30098-no.htm";
-		}
-		st.exitQuest(true);
-		return htmltext;
-	}
-	
-	@Override
-	public String onTalk(L2Npc npc, L2PcInstance player)
-	{
-		String htmltext = "";
-		QuestState st = player.getQuestState(qn);
-		if (st == null)
-		{
-			st = newQuestState(player);
-		}
-		htmltext = "30098.htm";
-		return htmltext;
-	}
-	
-	public PurchaseBracelet(int id, String name, String descr)
-	{
-		super(id, name, descr);
-		
-		addStartNpc(NPC);
-		addTalkId(NPC);
-	}
-	
-	public static void main(String args[])
-	{
-		new PurchaseBracelet(-1, qn, "custom");
-	}
-}

+ 1 - 1
L2J_DataPack_BETA/dist/sql/game/npc.sql

@@ -6419,7 +6419,7 @@ INSERT INTO `npc` VALUES
 (30094, 30094, "Gentler", 0, "Wizard-use Equipment Merchant", 0, "LineageNPC.a_traderB_MHuman", 8, 25, 70, "male", "L2Merchant", 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),
 (30095, 30095, "Randolf", 0, "Warehouse Keeper", 0, "LineageNPC.a_warehouse_keeper_MDwarf", 8, 17, 70, "male", "L2Warehouse", 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),
 (30097, 30097, "Galladucci", 0, "Weapon Merchant", 0, "LineageNPC.a_traderA_MDwarf", 8, 17, 70, "male", "L2Merchant", 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),
-(30098, 30098, "Alexandria", 0, "Armor Merchant", 0, "LineageNPC.a_traderB_FHuman", 8, 24.5, 70, "female", "L2Merchant", 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),
+(30098, 30098, "Alexandria", 0, "Armor Merchant", 0, "LineageNPC.a_traderB_FHuman", 8, 24.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),
 (30103, 30103, "Valkon", 0, "Warehouse Keeper", 0, "LineageNPC.a_warehouse_keeper_MDwarf", 8, 17, 70, "male", "L2Warehouse", 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),
 (30104, 30104, "Parman", 0, "Warehouse Keeper", 0, "LineageNPC.a_warehouse_keeper_MDwarf", 8, 17, 70, "male", "L2Warehouse", 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),
 (30105, 30105, "Genwitter", 0, "Master", 0, "LineageNPC.a_fighterguild_teacher_MHuman", 8, 23, 70, "male", "L2Trainer", 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),