ZURSULUS L2

Exploration of the Giants Cave, Part 1

ID
376
Название
Exploration of the Giants Cave, Part 1
start_npcs_json
[31147]
npc_ids_json
[30182,31147]
constants_json
{"SOBLING":31147,"CLIFF":30182,"PARCHMENT":5944,"DICTIONARY_BASIC":5891,"MYSTERIOUS_BOOK":5890,"DICTIONARY_INTERMEDIATE":5892}
Статус разбора
metadata_only; dynamic Java conditions/rewards retained in source; unresolved starts: []
Источник
game/data/scripts/quests/Q00376_ExplorationOfTheGiantsCavePart1/Q00376_ExplorationOfTheGiantsCavePart1.java

NPC квеста

IDНазваниеСтарт квестаУровень
30182CliffНет70
31147SoblingДа70

Условия уровней: выражения из Java

htmltext = (player.getLevel() < 51) ? "31147-01.htm" : "31147-02.htm";

Выдача предметов, адены и опыта: выражения из Java

giveItems(player, DICTIONARY_BASIC, 1);
giveItems(player, DICTIONARY_INTERMEDIATE, 1);
giveItems(partyMember, MYSTERIOUS_BOOK, 1);
giveItems(player, RECIPES[type][getRandom(RECIPES[type].length)], 1);

Квесты содержат динамические условия Java. Выражения выдачи включают промежуточные предметы, варианты и случайные награды; это не гарантированная награда. Константы приведены выше. Полные условия — в исходнике.

Тексты квеста

[30182-01.htm] Warehouse Freightman Cliff: It seems that Sobling has found a good partner at last! What a splendid discovery! Using this book, the language of the Titans will finally be completely deciphered! Please wait a moment. "I'll wait." [30182-02.htm] Warehouse Freightman Cliff: I have filled in the missing information. With this, you'll be able to better understand the language of the Titans. As a token of my gratitude, please accept this "Titan Language Dictionary". It will be helpful to you. [30182-03.htm] Warehouse Freightman Cliff: Was the dictionary I gave you helpful? [31147-01.htm] Head Researcher Sobling: To explore the Cave of Giants I must organize a large team. Funding will not be easily secured. I hope I can find experienced adventurers to prove the fact that this project is worthy of support... (This quest may only be undertaken by a character of level 51 and above.) [31147-02.htm] Head Researcher Sobling: To explore the Cave of Giants I must organize a large team. Funding will not be easily secured. The guild looks at this project quite skeptically. If only they understood how important this research is! I believe that if some valuable ancient relics were found there, they would change their mind. Please help me. "I will help." [31147-03.htm] Head Researcher Sobling: Wonderful! Slay the monsters in the Cave of Giants and bring back proof that ancient relics are in the cave. Here is some advice... Although you are clearly an experienced adventurer, it is much too dangerous for you to go alone. You must find fellow adventurers to accompany you. When you bring back proof, I will form an excavation team. I will give you this "Ancient Language Dictionary: Basic Level" in exchange for the relics you collect. Please bring back only valuable items. [31147-04.htm] Head Researcher Sobling: This is indeed a book about ancient technology! This will make the eyes of the elders of the guild pop out. Ha! Thank you! Although it isn't much, please accept this in exchange for your work. By the way, could you bring me more of these books? the more books I have, the easier it will be to convince the guild. "Settle the account on the completed document." "I will continue to look for more books." "I quit." [31147-05.htm] Head Researcher Sobling: Little or no evidence will do nothing to persuade the guild. I must have genuine ancient relics to convince them. [31147-06.htm] Head Researcher Sobling: I was right! I have a good sense about people! Please keep up the good work. [31147-07.htm] Head Researcher Sobling: I've never seen this language before! If we can decipher it, we may open up a new era in the research of Titan technology... Please go to Oren Castle Town and meet with my friend, Warehouse Keeper Cliff. Although relatively unknown, he is the foremost expert on the Titan language. [31147-08.htm] Head Researcher Sobling: Have you met my friend, Warehouse Keeper Cliff? Although he is now working as a warehouse keeper in Oren Castle Town, he happens to be the foremost expert on the ancient Titan language. [31147-09.htm] Head Researcher Sobling: Oh, what a shame! I misjudged you...
Исходник условий и наград (Java)
/*
 * Copyright (c) 2013 L2jMobius
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
 * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package quests.Q00376_ExplorationOfTheGiantsCavePart1;

import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.entity.actor.Npc;
import org.l2jmobius.gameserver.entity.actor.Player;
import org.l2jmobius.gameserver.mechanics.script.Quest;
import org.l2jmobius.gameserver.mechanics.script.QuestSound;
import org.l2jmobius.gameserver.mechanics.script.QuestState;
import org.l2jmobius.gameserver.mechanics.script.State;

public class Q00376_ExplorationOfTheGiantsCavePart1 extends Quest
{
	// NPCs
	private static final int SOBLING = 31147;
	private static final int CLIFF = 30182;
	
	// Items
	private static final int PARCHMENT = 5944;
	private static final int DICTIONARY_BASIC = 5891;
	private static final int MYSTERIOUS_BOOK = 5890;
	private static final int DICTIONARY_INTERMEDIATE = 5892;
	private static final int[][] BOOKS =
	{
		// @formatter:off
		// medical theory -> tallum tunic, tallum stockings
		{5937, 5938, 5939, 5940, 5941},
		// architecture -> dark crystal leather, tallum leather
		{5932, 5933, 5934, 5935, 5936},
		// golem plans -> dark crystal breastplate, tallum plate
		{5922, 5923, 5924, 5925, 5926},
		// basics of magic -> dark crystal gaiters, dark crystal leggings
		{5927, 5928, 5929, 5930, 5931}
		// @formatter:on
	};
	
	// Rewards
	private static final int[][] RECIPES =
	{
		// @formatter:off
		// medical theory -> tallum tunic, tallum stockings
		{5346, 5354},
		// architecture -> dark crystal leather, tallum leather
		{5332, 5334},
		// golem plans -> dark crystal breastplate, tallum plate
		{5416, 5418},
		// basics of magic -> dark crystal gaiters, dark crystal leggings
		{5424, 5340}
		// @formatter:on
	};
	
	public Q00376_ExplorationOfTheGiantsCavePart1()
	{
		super(376, "Exploration of the Giants Cave, Part 1");
		registerQuestItems(DICTIONARY_BASIC, MYSTERIOUS_BOOK);
		addStartNpc(SOBLING);
		addTalkId(SOBLING, CLIFF);
		addKillId(20647, 20648, 20649, 20650);
	}
	
	@Override
	public String onEvent(String event, Npc npc, Player player)
	{
		String htmltext = event;
		final QuestState st = getQuestState(player, false);
		if (st == null)
		{
			return htmltext;
		}
		
		switch (event)
		{
			case "31147-03.htm":
			{
				st.startQuest();
				st.set("condBook", "1");
				giveItems(player, DICTIONARY_BASIC, 1);
				break;
			}
			case "31147-04.htm":
			{
				htmltext = checkItems(player, st);
				break;
			}
			case "31147-09.htm":
			{
				st.exitQuest(true, true);
				break;
			}
			case "30182-02.htm":
			{
				st.setCond(3, true);
				takeItems(player, MYSTERIOUS_BOOK, -1);
				giveItems(player, DICTIONARY_INTERMEDIATE, 1);
				break;
			}
		}
		
		return htmltext;
	}
	
	@Override
	public String onTalk(Npc npc, Player player)
	{
		String htmltext = getNoQuestMsg(player);
		final QuestState st = getQuestState(player, true);
		
		switch (st.getState())
		{
			case State.CREATED:
			{
				htmltext = (player.getLevel() < 51) ? "31147-01.htm" : "31147-02.htm";
				break;
			}
			case State.STARTED:
			{
				final int cond = st.getCond();
				switch (npc.getId())
				{
					case SOBLING:
					{
						htmltext = checkItems(player, st);
						break;
					}
					case CLIFF:
					{
						if ((cond == 2) && hasQuestItems(player, MYSTERIOUS_BOOK))
						{
							htmltext = "30182-01.htm";
						}
						else if (cond == 3)
						{
							htmltext = "30182-03.htm";
						}
						break;
					}
				}
				break;
			}
		}
		
		return htmltext;
	}
	
	@Override
	public void onKill(Npc npc, Player player, boolean isPet)
	{
		// Drop parchment to anyone
		Player partyMember = getRandomPartyMemberState(player, State.STARTED);
		if (partyMember == null)
		{
			return;
		}
		
		QuestState st = partyMember.getQuestState(getName());
		if (st == null)
		{
			return;
		}
		
		giveItemRandomly(partyMember, npc, PARCHMENT, 1, 0, 0.2, true);
		
		// Drop mysterious book to person who still need it
		partyMember = getRandomPartyMember(player, "condBook", "1");
		if (partyMember == null)
		{
			return;
		}
		
		st = partyMember.getQuestState(getName());
		if (st == null)
		{
			return;
		}
		
		if (Rnd.get(100d) < 0.1)
		{
			giveItems(partyMember, MYSTERIOUS_BOOK, 1);
			playSound(partyMember, QuestSound.ITEMSOUND_QUEST_ITEMGET);
			st.unset("condBook");
		}
	}
	
	private static String checkItems(Player player, QuestState st)
	{
		if (hasQuestItems(player, MYSTERIOUS_BOOK))
		{
			final int cond = st.getCond();
			if (cond == 1)
			{
				st.setCond(2, true);
				return "31147-07.htm";
			}
			
			return "31147-08.htm";
		}
		
		for (int type = 0; type < BOOKS.length; type++)
		{
			boolean complete = true;
			for (int book : BOOKS[type])
			{
				if (!hasQuestItems(player, book))
				{
					complete = false;
				}
			}
			
			if (complete)
			{
				for (int book : BOOKS[type])
				{
					takeItems(player, book, 1);
				}
				
				giveItems(player, RECIPES[type][getRandom(RECIPES[type].length)], 1);
				return "31147-04.htm";
			}
		}
		
		return "31147-05.htm";
	}
}