ZURSULUS L2

Runaway Youth

ID
651
Название
Runaway Youth
start_npcs_json
[32014]
npc_ids_json
[31989,32014]
constants_json
{"IVAN":32014,"BATIDAE":31989,"SCROLL_OF_ESCAPE":736}
Статус разбора
metadata_only; dynamic Java conditions/rewards retained in source; unresolved starts: []
Источник
game/data/scripts/quests/Q00651_RunawayYouth/Q00651_RunawayYouth.java

NPC квеста

IDНазваниеСтарт квестаУровень
31989BatidaeНет70
32014IvanДа70

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

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

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

giveAdena(player, 2883, true);

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

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

[31989-01.htm] Fishing Guild Member Batidae: Oh, thank you so much! My son has returned to me and started learning to fish! Please, accept this token of my gratitude. I wish I could give you more... I'm just a poor fisherman, and I don't catch as many fish as I used to... I don't blame my son for wanting to run away from home, but what can I do... People will always need fish! [32014-01.htm] Ivan: Oh, you're an adventurer, aren't you? Phew... I'm Ivan. I'm a fisherman like my father! But to tell you the truth, I hate the smell of fish! So I left home... I've been wandering around this dangerous place, and now I'm thinking that maybe my father was right after all! I wish I could go back home... Maybe one day you'll be able to help me. (This quest may only be undertaken by a character of level 26 and above.) [32014-02.htm] Ivan: Oh, you're an adventurer, aren't you? Phew... I'm Ivan. I'm a fisherman like my father! But to tell you the truth, I hate the smell of fish! So I left home... I've been wandering around this dangerous place, and now I'm thinking that maybe my father was right after all! I wish I could go back home... Please help me!! "Here's a Scroll of Escape." "Get lost! I've got my own problems." [32014-02a.htm] Ivan: Ok, don't be mad at me! I thought you could help me. [32014-03.htm] Ivan: Thank you so much! Now I can get home safely. Again, thank you. My father is Batidae, a Fishing Guild Member of the Town of Schuttgart. If you go there, please look for my father. He'll reward you. I'm leaving now... Good luck! [32014-04.htm] Ivan: You don't have a Scroll of Escape! Talk to me when you get one. [32014-04a.htm] Ivan: Oh, it's you! Thank again for the last time! I decided to follow my father's way ... I hate fishes, but it is less dangerous than roaming the world!
Исходник условий и наград (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.Q00651_RunawayYouth;

import org.l2jmobius.gameserver.entity.Location;
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.QuestState;
import org.l2jmobius.gameserver.mechanics.script.State;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;

public class Q00651_RunawayYouth extends Quest
{
	// NPCs
	private static final int IVAN = 32014;
	private static final int BATIDAE = 31989;
	
	// Item
	private static final int SCROLL_OF_ESCAPE = 736;
	
	// Table of possible spawns
	private static final Location[] SPAWNS =
	{
		new Location(118600, -161235, -1119, 0),
		new Location(108380, -150268, -2376, 0),
		new Location(123254, -148126, -3425, 0)
	};
	
	// Current position
	private int _currentPosition = 0;
	
	public Q00651_RunawayYouth()
	{
		super(651, "Runaway Youth");
		addStartNpc(IVAN);
		addTalkId(IVAN, BATIDAE);
		addSpawn(IVAN, 118600, -161235, -1119, 0, false, 0);
	}
	
	@Override
	public String onEvent(String event, Npc npc, Player player)
	{
		String htmltext = event;
		final QuestState st = getQuestState(player, false);
		if (st == null)
		{
			return htmltext;
		}
		
		if (event.equals("32014-04.htm"))
		{
			if (hasQuestItems(player, SCROLL_OF_ESCAPE))
			{
				st.startQuest();
				takeItems(player, SCROLL_OF_ESCAPE, 1);
				npc.broadcastPacket(new MagicSkillUse(npc, npc, 2013, 1, 3500, 0));
				startQuestTimer("apparition_npc", 4000, npc, player, false);
				htmltext = "32014-03.htm";
			}
			else
			{
				st.exitQuest(true);
			}
		}
		else if (event.equals("apparition_npc"))
		{
			int chance = getRandom(3);
			
			// Loop to avoid to spawn to the same place.
			while (chance == _currentPosition)
			{
				chance = getRandom(3);
			}
			
			// Register new position.
			_currentPosition = chance;
			
			npc.deleteMe();
			addSpawn(IVAN, SPAWNS[chance], false, 0);
			return null;
		}
		
		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() < 26) ? "32014-01.htm" : "32014-02.htm";
				break;
			}
			case State.STARTED:
			{
				switch (npc.getId())
				{
					case BATIDAE:
					{
						htmltext = "31989-01.htm";
						giveAdena(player, 2883, true);
						st.exitQuest(true, true);
						break;
					}
					case IVAN:
					{
						htmltext = "32014-04a.htm";
						break;
					}
				}
				break;
			}
		}
		
		return htmltext;
	}
}