ZURSULUS L2

Get a Pet

ID
419
Название
Get a Pet
start_npcs_json
[30731]
npc_ids_json
[30072,30091,30256,30731]
constants_json
{"MARTIN":30731,"BELLA":30256,"METTY":30072,"ELLIE":30091,"ANIMAL_LOVER_LIST":3417,"ANIMAL_SLAYER_LIST_1":3418,"ANIMAL_SLAYER_LIST_2":3419,"ANIMAL_SLAYER_LIST_3":3420,"ANIMAL_SLAYER_LIST_4":3421,"ANIMAL_SLAYER_LIST_5":3422,"BLOODY_FANG":3423,"BLOODY_CLAW":3424,"BLOODY_NAIL":3425,"BLOODY_KASHA_FANG":3426,"BLOODY_TARANTULA_NAIL":3427,"WOLF_COLLAR":2375}
Статус разбора
metadata_only; dynamic Java conditions/rewards retained in source; unresolved starts: []
Источник
game/data/scripts/quests/Q00419_GetAPet/Q00419_GetAPet.java

NPC квеста

IDНазваниеСтарт квестаУровень
30072MettyНет80
30091EllieНет70
30256BellaНет70
30731MartinДа70

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

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

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

giveItems(player, ANIMAL_SLAYER_LIST_1 + race, 1);
giveItems(player, ANIMAL_LOVER_LIST, 1);
giveItems(player, drop[0], 1);
giveItems(st.getPlayer(), WOLF_COLLAR, 1);

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

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

[30072-01.htm] Guard Metty: Yes, I am a member of the animal lover's association. Why did you want to see me? I am very busy. Speak up! "Tell me about the pets." [30072-02.htm] Guard Metty: So, you want to learn about pets? I'll tell you everything I know. First of all, the wolf. This is the first pet that you will breed. A wolf's sense of smell can detect an object as far as 2.4 km away. They hunt in packs of 7-14 with a male leader. Fully grown they are no larger than a man, and can be distinguished from dogs by their drooping tails. There are also many kinds of wild wolves in Aden, and they vary from region to region. Around here you will find Dire Wolves, the oldest and most primitive type. In Elmore, to the far north, there are Kasha Wolves in Orc country and Black Wolves in the Dwarf lands. [30091-01.htm] Jeweler Ellie: How did you know that I am a member of the animal lover's association? Ah, I see - Mr. Martin spoke of me. So, what can I do for you? "I wish to learn about pets." [30091-02.htm] Jeweler Ellie: We should talk about the wolf that you will be raising... I must first explain their reproductive cycle. A wolf's fertility period is normally 1-2 months, and the pregnancy lasts for approximately 60-62 days. Normally, they will give birth to 3-6 cubs, but can produce up to 10 cubs at a time. They create a very safe home for their young ones. Places such as between rocks, under cliffs, and caves. Wolves are more omnivirous than assumed. A full grown wolf can easily devour a calf or goat whole. Wolves also eat the flesh of dead animals, wild pheasants, and even berries. They can go without food for 5-6 days, but cannot live long without water. [30256-01.htm] Gatekeeper Bella: Yes, it is true. I am a Gatekeeper from the Ivory Tower, and also a member of the animal lover's association. Why have you come? Did Martin send you? "I wish to learn about pets." [30256-02.htm] Gatekeeper Bella: Pets can be very useful creatures. If you are unable to carry items due to space or weight restrictions, you can transfer items to your pet and they will carry them for you. Bear in mind that they cannot run errands. If your pet is killed it may be resurrected within 20 minutes. If it is not revived within the time limit, the pet will be gone forever. Next [30256-03.htm] Gatekeeper Bella: Your pet shall be a wolf. You must learn more about them. Wolves are biologically classified as canines. Canines are extremely varied, and include dogs, raccoons, foxes, jackals, and even timberwolves. The lifespan of wolves in the wild is unknown, but wolves in captivity can live from 12 to 15 years. [30731-01.htm] Pet Manager Martin: Ah, so you want a pet! A good idea, but you are not ready to have one. Come back when you have more experience. (This quest may only be undertaken by a character of level 15 and above.) [30731-02.htm] Pet Manager Martin: Ah, so you want a pet! I see you have the experience needed to keep a pet, but even so, we don't distribute pets to just anyone. First, you must demonstrate that you are qualified to raise a pet. Ask detailed questions. [30731-03.htm] Pet Manager Martin: First there is something I'd like you to do for your pet and other pet lovers. Recently, there have been monsters who have been stalking the animals and attacking them as prey. I would like for you to get rid of these monsters. If you wish to have a pet, you must know how to love one. When you complete two or more tasks for me, I shall test you myself on your knowledge of pets. What do you think? Will you give it a try? I will take the task. [30731-04.htm] Pet Manager Martin: Let's see...There are so many! You are from Talking Island, am I correct? In that case, you must go to your hometown and stop the slaughter of innocent animals there. Can you handle that? Talking Island is infested with giant spiders, talon spiders and blade spiders. They are the worst offenders. These monsters are devouring innocent animals every day, so much so that their populations are rapidly dwindling. You must kill these monsters and bring proof of your victory. Now, if everything is clear, be off! [30731-05.htm] Pet Manager Martin: Let's see...There are so many of them... Oh yes, you are an Elf, aren't you? In that case, you must go to your hometown and stop the slaughter of the animals there. Can you handle that? In the Elven Forest you will find the crimson spider, the hook spider and the pincer spider. These are the worst offenders. If they are allowed to continue many species will surely become extinct. You must kill them and stop this slaughter of innocents. When you are done bring proof of you victory. Now, if everything is clear, be off! [30731-06.htm] Pet Manager Martin: Let's see...There are so many of them... Oh, yes, you are a Dark Elf, aren't you? In that case, you must go to your hometown and stop the slaughter of the animals there. Do you think you can handle this task? In the Dark Elven Forest, you will find the lesser dark horror, the dark horror and the prowler. They are the worst offenders in the Dark Elven Forest. They are killing and consuming the animals at an unsustainable rate. You must kill them to stop this injustice! Please bring us proof of your victory. Now, if everything is clear, be off! [30731-07.htm] Pet Manager Martin: Let's see...There are so many of them... Oh yes, you are an Orc, aren't you? In that case, you must go to your hometown and stop the slaughter of innocent animals there. Can you handle that? If you go to the Immortal Plateau you will find the kasha spider, kasha fang spiders and kasha blade spiders. They are the worst offenders in that area. They are killing off the animals at an unsustainable rate. You must go and kill them and bring back proof of your victory! Now, if everything is clear, be off! [30731-08.htm] Pet Manager Martin: Let's see...There are so many of them... Oh, yes, you are a Dwarf, aren't you? In that case, you must go to your hometown and stop the slaughter of innocent animals there. Do you think you can handle this task? In the Spine Mountains Mining Zone you will find the hunter tarantula and plunder tarantula. They are the worst offenders in the that area. They are killing and devouring animals every day. Soon there will be no animals left! You must kill these monsters and bring proof of your victory. Now, if everything is clear, be off! [30731-09.htm] Pet Manager Martin: What, you're still here? Didn't I give you the list of the monsters you must kill? Go now and get rid of those filthy animal killers! Leave now! [30731-10.htm] Pet Manager Martin: Is that the best you can do? That is not nearly enough! Go and slay some more of the evil animal killers. [30731-11.htm] Pet Manager Martin: Ah, yes, I see! You have brought 50 of them! Well done! Soon you will be ready to own your own pet! I hope you didn't think that was the only thing you had to do to prove that you were ready! Oh, no, my friend... You are just ready for the next task... Ask about the next task [30731-12.htm] Pet Manager Martin: Your next task is to learn the basics about the pets. Without basic knowledge, you'll never be able to care for a pet. You may not know it, but I am the branch office manager of the Animal Lovers Association. We take care of everything concerning pets, and screen all candidates to make sure they qualify to raise a pet. Only qualified people will receive pets. The members of the Animal Lovers Association are spread out all over the world. It is, in fact, a large organization. I want you to meet the members of our Animal Lovers Association, and come back after you have gained knowledge about pets from them. Do you understand? I shall give you the list of people that you need to meet. Come back to me once you have met all the members on the list. But be aware, just meeting them is not enough. You must listen to what they say, and learn about pets from them. Once you've done that, I shall test you myself. Our members will give you plenty of helpful information. Just listen carefully to them and you will do fine on my test. [30731-13.htm] Pet Manager Martin: So, have you met the members of the Animal Lovers Association like I asked? Well done! Now I will test the knowledge that you've learned from our members. There are ten questions in all. If you make even one mistake, you'll fail the examination and won't be able to get a pet! As soon as you decide to take the test, you'll have your questions. What do you say, are you ready for the test? I am ready for the test. [30731-14.htm] Pet Manager Martin: No, sorry...You failed the test! You made a worthy effort but it wasn't enough. No pet for you. Oh, I hate to see you look so sad, I suppose I can give you one more chance. You can take the test again, but it won't be the same, of course... First you must meet with the animal lovers association members again and take some lessons from them. Then you can take the test again. [30731-15.htm] Pet Manager Martin: Congratulations! You answered every question correctly! I acknowledge that you are qualified to keep a pet. May you always keep a loving and caring mind for animals and never forget the true value of your pet. If you have any questions at all feel free to come here to consult with me anytime. [30731-16.htm] Pet Manager Martin: Hey, aren't you supposed to be meeting with the animal lovers association members? Did you forget? OK, I'll repeat it one more time. Go and meet the Gatekeeper Bella of Gludio Castle Town, the Guard Metty of Dion Castle Town, and the Jeweler Ellie in Giran Castle Town. Is that clear? [30731-20.htm] Question: Pets are very useful to their owners. Which of the following is not an appropriate use of a pet? Can be traded or sold to a new owner for adena. Can help during hunting by assisting in attacks. Can be used for item transportation. Can be sent to the village to buy items. None of the above. [30731-21.htm] Question: What is the best way to train your pet? Tell your pet to pick up items. When taking down a monster, always have a pet's company. Tell your pet to attack monsters first. Let your pet do what it wants. None of the above. [30731-22.htm] Question: When the pet is killed it may be resurrected within a certain amount of time. What is the maximum delay allowed before resurrection becomes impossible? 10 minutes 20 minutes 15 minutes 25 minutes None of the above. [30731-23.htm] Question: What are the oldest and most primitive type of wolves found in Aden? Dire Wolf Turek Wolf Kasha Wolf Air Wolf None of the above. [30731-24.htm] Question: How is a wolf's tail normally positioned? It's tail is always curled up. What are you talking about?! A wolf doesn't have a tail. It's tail is always pointing straight down. It's tail is always wagging back and forth. None of the above. [30731-25.htm] Question: The wolf is a meat-eating mammal of the canine family. Which animal among the following is not a meat-eating mammal of the canine family? Shepherd Dog Jackal Fox Raccoon None of the above. [30731-26.htm] Question: How far (in kilometers) can a wolf's smell reach? 1.4 km 3.4 km 4.4 km 2.4 km None of the above. [30731-27.htm] Question: What kind of wolf leads the rest when hunting in a pack? Male Female A baby that was born two years ago A baby that was born last year None of the above. [30731-28.htm] Question: Which of the following is not a part of the wolf's diet? Wild Bird Berries Meat of a dead animal Goat None of the above. [30731-29.htm] Question: Which is not a proper description of the breeding of wolves? Babies are born in April-June. Breeding season is January-February. Pregnancy is nine months. Has up to ten offspring at one time. None of the above. [30731-30.htm] Question: What is the normal lifespan of a wolf in captivity? 6-9 years 9-12 years 3-6 years 12-15 years None of the above. [30731-31.htm] Question: Which of the following do not describe the life of a wolf? Wolves gather and move in groups of 7-13 animals. A pregnant wolf makes its home in a wide open place to have its babies. Wolves can eat a whole calf in one sitting. If they have water, wolves can live for 5-6 days without eating anything. None of the above. [30731-32.htm] Question: Which of the following is the correct description of a wolf? A wolf enjoys eating Dwarves. The color of a wolf's fur is the same as the place where it lives. A wolf changes into a werewolf during a full-moon. A grown wolf is still not as heavy as a fully-grown male adult human. None of the above. [30731-33.htm] Question: The following connections are made between the wolves and their habitats. Which is not correct? Talking Island - Wolf Elven Forest - Gray Wolf Orc - Black Wolf Dark Forest -Ashen Wolf None of the above.
Исходник условий и наград (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.Q00419_GetAPet;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

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 Q00419_GetAPet extends Quest
{
	// NPCs
	private static final int MARTIN = 30731;
	private static final int BELLA = 30256;
	private static final int METTY = 30072;
	private static final int ELLIE = 30091;
	
	// Items
	private static final int ANIMAL_LOVER_LIST = 3417;
	private static final int ANIMAL_SLAYER_LIST_1 = 3418;
	private static final int ANIMAL_SLAYER_LIST_2 = 3419;
	private static final int ANIMAL_SLAYER_LIST_3 = 3420;
	private static final int ANIMAL_SLAYER_LIST_4 = 3421;
	private static final int ANIMAL_SLAYER_LIST_5 = 3422;
	private static final int BLOODY_FANG = 3423;
	private static final int BLOODY_CLAW = 3424;
	private static final int BLOODY_NAIL = 3425;
	private static final int BLOODY_KASHA_FANG = 3426;
	private static final int BLOODY_TARANTULA_NAIL = 3427;
	
	// Reward
	private static final int WOLF_COLLAR = 2375;
	
	// Droplist
	private static final Map<Integer, int[]> DROPLIST = new HashMap<>();
	static
	{
		// @formatter:off
		DROPLIST.put(20103, new int[]{BLOODY_FANG, 600000});
		DROPLIST.put(20106, new int[]{BLOODY_FANG, 750000});
		DROPLIST.put(20108, new int[]{BLOODY_FANG, 1000000});
		DROPLIST.put(20460, new int[]{BLOODY_CLAW, 600000});
		DROPLIST.put(20308, new int[]{BLOODY_CLAW, 750000});
		DROPLIST.put(20466, new int[]{BLOODY_CLAW, 1000000});
		DROPLIST.put(20025, new int[]{BLOODY_NAIL, 600000});
		DROPLIST.put(20105, new int[]{BLOODY_NAIL, 750000});
		DROPLIST.put(20034, new int[]{BLOODY_NAIL, 1000000});
		DROPLIST.put(20474, new int[]{BLOODY_KASHA_FANG, 600000});
		DROPLIST.put(20476, new int[]{BLOODY_KASHA_FANG, 750000});
		DROPLIST.put(20478, new int[]{BLOODY_KASHA_FANG, 1000000});
		DROPLIST.put(20403, new int[]{BLOODY_TARANTULA_NAIL, 750000});
		DROPLIST.put(20508, new int[]{BLOODY_TARANTULA_NAIL, 1000000});
		// @formatter:on
	}
	
	public Q00419_GetAPet()
	{
		super(419, "Get a Pet");
		registerQuestItems(ANIMAL_LOVER_LIST, ANIMAL_SLAYER_LIST_1, ANIMAL_SLAYER_LIST_2, ANIMAL_SLAYER_LIST_3, ANIMAL_SLAYER_LIST_4, ANIMAL_SLAYER_LIST_5, BLOODY_FANG, BLOODY_CLAW, BLOODY_NAIL, BLOODY_KASHA_FANG, BLOODY_TARANTULA_NAIL);
		addStartNpc(MARTIN);
		addTalkId(MARTIN, BELLA, ELLIE, METTY);
		addKillId(DROPLIST.keySet());
	}
	
	@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 "task":
			{
				final int race = player.getRace().ordinal();
				htmltext = "30731-0" + (race + 4) + ".htm";
				st.startQuest();
				giveItems(player, ANIMAL_SLAYER_LIST_1 + race, 1);
				break;
			}
			case "30731-12.htm":
			{
				playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
				takeItems(player, ANIMAL_SLAYER_LIST_1, 1);
				takeItems(player, ANIMAL_SLAYER_LIST_2, 1);
				takeItems(player, ANIMAL_SLAYER_LIST_3, 1);
				takeItems(player, ANIMAL_SLAYER_LIST_4, 1);
				takeItems(player, ANIMAL_SLAYER_LIST_5, 1);
				takeItems(player, BLOODY_FANG, -1);
				takeItems(player, BLOODY_CLAW, -1);
				takeItems(player, BLOODY_NAIL, -1);
				takeItems(player, BLOODY_KASHA_FANG, -1);
				takeItems(player, BLOODY_TARANTULA_NAIL, -1);
				giveItems(player, ANIMAL_LOVER_LIST, 1);
				break;
			}
			case "30256-03.htm":
			{
				st.set("progress", String.valueOf(st.getInt("progress") | 1));
				if (st.getInt("progress") == 7)
				{
					playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
				}
				break;
			}
			case "30072-02.htm":
			{
				st.set("progress", String.valueOf(st.getInt("progress") | 2));
				if (st.getInt("progress") == 7)
				{
					playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
				}
				break;
			}
			case "30091-02.htm":
			{
				st.set("progress", String.valueOf(st.getInt("progress") | 4));
				if (st.getInt("progress") == 7)
				{
					playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
				}
				break;
			}
			case "test":
			{
				st.set("answers", "0");
				st.set("quiz", "20 21 22 23 24 25 26 27 28 29 30 31 32 33");
				return checkQuestions(st);
			}
			case "wrong":
			{
				st.set("wrong", String.valueOf(st.getInt("wrong") + 1));
				return checkQuestions(st);
			}
			case "right":
			{
				st.set("correct", String.valueOf(st.getInt("correct") + 1));
				return checkQuestions(st);
			}
		}
		
		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() < 15) ? "30731-01.htm" : "30731-02.htm";
				break;
			}
			case State.STARTED:
			{
				switch (npc.getId())
				{
					case MARTIN:
					{
						if (hasAtLeastOneQuestItem(player, ANIMAL_SLAYER_LIST_1, ANIMAL_SLAYER_LIST_2, ANIMAL_SLAYER_LIST_3, ANIMAL_SLAYER_LIST_4, ANIMAL_SLAYER_LIST_5))
						{
							final int proofs = getQuestItemsCount(player, BLOODY_FANG) + getQuestItemsCount(player, BLOODY_CLAW) + getQuestItemsCount(player, BLOODY_NAIL) + getQuestItemsCount(player, BLOODY_KASHA_FANG) + getQuestItemsCount(player, BLOODY_TARANTULA_NAIL);
							if (proofs == 0)
							{
								htmltext = "30731-09.htm";
							}
							else if (proofs < 50)
							{
								htmltext = "30731-10.htm";
							}
							else
							{
								htmltext = "30731-11.htm";
							}
						}
						else if (st.getInt("progress") == 7)
						{
							htmltext = "30731-13.htm";
						}
						else
						{
							htmltext = "30731-16.htm";
						}
						break;
					}
					case BELLA:
					{
						htmltext = "30256-01.htm";
						break;
					}
					case METTY:
					{
						htmltext = "30072-01.htm";
						break;
					}
					case ELLIE:
					{
						htmltext = "30091-01.htm";
						break;
					}
				}
				break;
			}
		}
		
		return htmltext;
	}
	
	@Override
	public void onKill(Npc npc, Player player, boolean isPet)
	{
		final QuestState st = getQuestState(player, false);
		if ((st == null) || !st.isStarted())
		{
			return;
		}
		
		final int[] drop = DROPLIST.get(npc.getId());
		if (hasQuestItems(player, drop[0] - 5))
		{
			if (getQuestItemsCount(player, drop[0]) < 50)
			{
				giveItems(player, drop[0], 1);
				if (getQuestItemsCount(player, drop[0]) < 50)
				{
					playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
				}
				else
				{
					playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
				}
			}
		}
	}
	
	private static String checkQuestions(QuestState st)
	{
		final int answers = st.getInt("correct") + (st.getInt("wrong"));
		if (answers < 10)
		{
			final String[] questions = st.get("quiz").split(" ");
			final int index = getRandom(questions.length - 1);
			final String question = questions[index];
			if (questions.length > (10 - answers))
			{
				questions[index] = questions[questions.length - 1];
				st.set("quiz", String.join(" ", Arrays.copyOf(questions, questions.length - 1)));
			}
			
			return "30731-" + question + ".htm";
		}
		
		if (st.getInt("wrong") > 0)
		{
			st.unset("progress");
			st.unset("answers");
			st.unset("quiz");
			st.unset("wrong");
			st.unset("correct");
			return "30731-14.htm";
		}
		
		takeItems(st.getPlayer(), ANIMAL_LOVER_LIST, 1);
		giveItems(st.getPlayer(), WOLF_COLLAR, 1);
		st.exitQuest(true, true);
		
		return "30731-15.htm";
	}
}