ZURSULUS L2

An Aged Ex-Adventurer

ID
652
Название
An Aged Ex-Adventurer
start_npcs_json
[32012]
npc_ids_json
[30180,32012]
constants_json
{"TANTAN":32012,"SARA":30180,"SOULSHOT_C":1464,"ENCHANT_ARMOR_D":956}
Статус разбора
metadata_only; dynamic Java conditions/rewards retained in source; unresolved starts: []
Источник
game/data/scripts/quests/Q00652_AnAgedExAdventurer/Q00652_AnAgedExAdventurer.java

NPC квеста

IDНазваниеСтарт квестаУровень
30180SaraНет70
32012TantanДа70

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

htmltext = (player.getLevel() < 46) ? "32012-00.htm" : "32012-01.htm";

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

giveAdena(player, 5026, true);
giveItems(player, ENCHANT_ARMOR_D, 1);
giveAdena(player, 10000, true);

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

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

[30180-01.htm] Sara: Thank you so much! My father-in-law came home safely, thanks to your help. You made him very happy, by the way! He hadn't met any fellow adventurers for quite a while. Please accept this as a token of my appreciation! Thank you again. [30180-02.htm] Sara: I'm so sorry. I thought you were just a customer... You're the one who helped my father-in-law! Unfortunately, he was seriously injured on the way home by monsters! Luckily, he escaped with his life and he is now at home. But still, you helped him make it out alive. Thank you so much! (Because the old man was injured, you don't have the heart to ask for a reward.) [32012-00.htm] Tantan: Ah-ha! You're a novice adventurer... I haven't met anyone like you on the plains for long time. I'm Tantan. I may be old now, but in my day, I was a famous adventurer! You've heard of me, haven't you? Those young fellows in the village say I'm making it all up! Youngsters these days are just plain rude! So, I've come all the way out here to catch some monsters to show them. I'm out of Soulshots, and my strength is not what it used to be... I'm in a bit of a fix... Maybe one day you'll be able to help me. (This quest may only be undertaken by a character of level 46 and above.) [32012-01.htm] Tantan: Ah-ha! You're a novice adventurer... I haven't met anyone like you on the plains for long time. I'm Tantan. I may be old now, but in my day, I was a famous adventurer! You've heard of me, haven't you? Those young fellows in the village say I'm making it all up! Youngsters these days are just plain rude! So, I've come all the way out here to catch some monsters to show them. I'm out of Soulshots, and my strength is not what it used to be... I'm in a bit of a fix... "I'll share 100 C-grade Soulshots with you. Please make your way home safely with these." "I've got problems of my own! Beat it!" [32012-02.htm] Tantan: Thank you so much... There is still chivalry left in this world! You've made me realize that I can still have adventures! I'll show those whippersnappers! It's so nice to meet someone like you who understands me.. If you ever visit the Town of Oren... speak with Grocer Sara, my daughter-in-law. She's a good one who's always worrying about me... She'll reward you for your good heart. I'm going back home then... Good luck. [32012-02a.htm] Tantan: I appreciate your kindness, but I need 100 C-grade Soulshots in order to return safe to Oren. Sara, my daughter-in-law, must be worried at that hour... [32012-03.htm] Tantan: Hump! Very well. Nevermind an old fart like me, just go about your business! Like I said, young ones these days are just plain rude! It's different from my day... I want to go back home to my daughter-in-law... [32012-04.htm] Tantan: Thank you so much... There is still chivalry left in this world! You've made me realize that I can still have adventures! I'll show those whippersnappers! It's so nice to meet someone like you who understands me.. If you ever visit the Town of Oren... speak with Grocer Sara, my daughter-in-law. She's a good one who's always worrying about me... She'll reward you for your good heart. I'm going back home then... Good luck. [32012-04a.htm] Tantan: Hey, youngster! I appreciate your help for the last time! Don't forget to see Sara, my daughter-in-law in Town of Oren. She should have a nice reward for 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.Q00652_AnAgedExAdventurer;

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;

public class Q00652_AnAgedExAdventurer extends Quest
{
	// NPCs
	private static final int TANTAN = 32012;
	private static final int SARA = 30180;
	
	// Item
	private static final int SOULSHOT_C = 1464;
	
	// Reward
	private static final int ENCHANT_ARMOR_D = 956;
	
	// Table of possible spawns
	private static final Location[] SPAWNS =
	{
		new Location(78355, -1325, -3659, 0),
		new Location(79890, -6132, -2922, 0),
		new Location(90012, -7217, -3085, 0),
		new Location(94500, -10129, -3290, 0),
		new Location(96534, -1237, -3677, 0)
	};
	
	// Current position
	private int _currentPosition = 0;
	
	public Q00652_AnAgedExAdventurer()
	{
		super(652, "An Aged Ex-Adventurer");
		addStartNpc(TANTAN);
		addTalkId(TANTAN, SARA);
		addSpawn(TANTAN, 78355, -1325, -3659, 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("32012-02.htm"))
		{
			if (getQuestItemsCount(player, SOULSHOT_C) >= 100)
			{
				st.startQuest();
				takeItems(player, SOULSHOT_C, 100);
				npc.getAI().setIntentionMoveTo(new Location(85326, 7869, -3620));
				startQuestTimer("apparition_npc", 6000, npc, player, false);
			}
			else
			{
				htmltext = "32012-02a.htm";
				st.exitQuest(true);
			}
		}
		else if (event.equals("apparition_npc"))
		{
			int chance = getRandom(5);
			
			// Loop to avoid to spawn to the same place.
			while (chance == _currentPosition)
			{
				chance = getRandom(5);
			}
			
			// Register new position.
			_currentPosition = chance;
			
			npc.deleteMe();
			addSpawn(TANTAN, SPAWNS[chance].getX(), SPAWNS[chance].getY(), SPAWNS[chance].getZ(), SPAWNS[chance].getHeading(), 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() < 46) ? "32012-00.htm" : "32012-01.htm";
				break;
			}
			case State.STARTED:
			{
				switch (npc.getId())
				{
					case SARA:
					{
						if (getRandom(100) < 50)
						{
							htmltext = "30180-01.htm";
							giveAdena(player, 5026, true);
							giveItems(player, ENCHANT_ARMOR_D, 1);
						}
						else
						{
							htmltext = "30180-02.htm";
							giveAdena(player, 10000, true);
						}
						
						st.exitQuest(true, true);
						break;
					}
					case TANTAN:
					{
						htmltext = "32012-04a.htm";
						break;
					}
				}
				break;
			}
		}
		
		return htmltext;
	}
}