Просмотр исходного кода

Katenar AI for quests Certified Soul Breaker (65)
Reviewed by: @Zoey76

ivantotov 10 лет назад
Родитель
Сommit
6b8d661030

+ 1 - 0
L2J_DataPack/dist/game/data/scripts.cfg

@@ -36,6 +36,7 @@ ai/npc/FortressArcherCaptain/FortressArcherCaptain.java
 ai/npc/FortressSiegeManager/FortressSiegeManager.java
 ai/npc/FreyasSteward/FreyasSteward.java
 ai/npc/Jinia/Jinia.java
+ai/npc/Katenar/Katenar.java
 ai/npc/KetraOrcSupport/KetraOrcSupport.java
 ai/npc/ManorManager/ManorManager.java
 ai/npc/MercenaryCaptain/MercenaryCaptain.java

+ 3 - 0
L2J_DataPack/dist/game/data/scripts/ai/npc/Katenar/32242-01.html

@@ -0,0 +1,3 @@
+<html><body>Katenar:<br>
+Do not speak to me.
+</body></html>

+ 5 - 0
L2J_DataPack/dist/game/data/scripts/ai/npc/Katenar/32242-02.html

@@ -0,0 +1,5 @@
+<html><body>Katenar:<br>
+Well done! The truth is, my letter was mixed in with the other items in the box.<br>
+Wehn I saw someone pursuing these goods, I decided to follow, but I was a little late getting here. Thankfully, you drove them away and I was able to protect the secret. Thank you for your assistance -- you have done more than you realize. Here, please take this to the Elder.<br>
+<a action="bypass -h Quest Katenar GOOD_LUCK">Wait...</a>
+</body></html>

+ 4 - 0
L2J_DataPack/dist/game/data/scripts/ai/npc/Katenar/32242-03.html

@@ -0,0 +1,4 @@
+<html><body>Katenar:<br>
+Well done! The truth is, my letter was mixed in with the other items in the box.<br>
+Wehn I saw someone pursuing these goods, I decided to follow, but I was a little late getting here. Thankfully, you drove them away and I was able to protect the secret. Thank you for your assistance -- you have done more than you realize. Here, please take this to the Elder.
+</body></html>

+ 3 - 0
L2J_DataPack/dist/game/data/scripts/ai/npc/Katenar/32242-04.html

@@ -0,0 +1,3 @@
+<html><body>Katenar:<br>
+Deliver these documents to the Elder.
+</body></html>

+ 144 - 0
L2J_DataPack/dist/game/data/scripts/ai/npc/Katenar/Katenar.java

@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2004-2015 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.Katenar;
+
+import quests.Q00065_CertifiedSoulBreaker.Q00065_CertifiedSoulBreaker;
+import ai.npc.AbstractNpcAI;
+
+import com.l2jserver.gameserver.model.actor.L2Npc;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.quest.QuestState;
+import com.l2jserver.gameserver.network.NpcStringId;
+import com.l2jserver.gameserver.network.clientpackets.Say2;
+
+/**
+ * Katenar AI for quests Certified Soul Breaker (65)
+ * @author ivantotov
+ */
+public final class Katenar extends AbstractNpcAI
+{
+	// NPC
+	private static final int KATENAR = 32242;
+	// Item
+	private static final int SEALED_DOCUMENT = 9803;
+	
+	private Katenar()
+	{
+		super(Katenar.class.getSimpleName(), "ai/npc");
+		addStartNpc(KATENAR);
+		addTalkId(KATENAR);
+		addFirstTalkId(KATENAR);
+		addSpawnId(KATENAR);
+	}
+	
+	@Override
+	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
+	{
+		final L2Npc npc0 = npc.getVariables().getObject("npc0", L2Npc.class);
+		String htmltext = null;
+		
+		switch (event)
+		{
+			case "CREATED_50":
+			{
+				if (npc0 != null)
+				{
+					if (!npc.getVariables().getBoolean("SPAWNED", false))
+					{
+						npc0.getVariables().set("SPAWNED", false);
+					}
+				}
+				npc.deleteMe();
+				break;
+			}
+			case "GOOD_LUCK":
+			{
+				final QuestState qs = player.getQuestState(Q00065_CertifiedSoulBreaker.class.getSimpleName());
+				if (qs.isMemoState(14))
+				{
+					if (npc0 != null)
+					{
+						if (!npc.getVariables().getBoolean("SPAWNED", false))
+						{
+							npc0.getVariables().set("SPAWNED", false);
+							broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.GOOD_LUCK);
+						}
+					}
+					npc.deleteMe();
+				}
+				break;
+			}
+		}
+		return htmltext;
+	}
+	
+	@Override
+	public String onFirstTalk(L2Npc npc, L2PcInstance talker)
+	{
+		final QuestState qs = talker.getQuestState(Q00065_CertifiedSoulBreaker.class.getSimpleName());
+		String htmltext = getNoQuestMsg(talker);
+		final int memoState = qs.getMemoState();
+		if (memoState == 12)
+		{
+			htmltext = "32242-01.html";
+		}
+		else if (memoState == 13)
+		{
+			final L2PcInstance player = npc.getVariables().getObject("player0", L2PcInstance.class);
+			if (player == talker)
+			{
+				qs.setMemoState(14);
+				qs.setCond(13, true);
+				htmltext = "32242-02.html";
+			}
+			else
+			{
+				qs.setMemoState(14);
+				qs.setCond(13, true);
+				htmltext = "32242-03.html";
+			}
+			if (!hasQuestItems(player, SEALED_DOCUMENT))
+			{
+				giveItems(player, SEALED_DOCUMENT, 1);
+			}
+		}
+		else if (memoState == 14)
+		{
+			htmltext = "32242-04.html";
+		}
+		return htmltext;
+	}
+	
+	@Override
+	public String onSpawn(L2Npc npc)
+	{
+		startQuestTimer("CREATED_50", 50000, npc, null);
+		final L2PcInstance player = npc.getVariables().getObject("player0", L2PcInstance.class);
+		if (player != null)
+		{
+			broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.I_AM_LATE);
+		}
+		return super.onSpawn(npc);
+	}
+	
+	public static void main(String[] args)
+	{
+		new Katenar();
+	}
+}