context: /*
   * DAWN OF LIGHT - The first free open source DAoC server emulator
   * 
   * This program 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 2
   * of the License, or (at your option) any later version.
   * 
   * This program 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, write to the Free Software
   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
   *
   */
  /*
   * Author:		Gandulf Kohlweiss
   * Date:			
   * Directory: /scripts/quests/midgard/
   *
   * Description:
   *  Brief Walkthrough: 
   * 1) Harlfug can be found at loc=52670,16862 East Svealand. 
   * 2) Zone into Jordheim and /USE the Assistant Necklace from Harlfug. 
   * 3) Talk with the Jordheim Assistant that appeared from using the necklace. Click on [vault keeper] option when it is given. 
   * 4) Hand Jarl Yuliwyf the Scroll for Vault Keeper Yuliwyf from Harlfug and then the Small Chest of Coins. 
   * 5) Click on the Jordheim Assistant to teleport back to the west gate. 
   * 6) Go back to Harlfug and hand him the Receipt for Harlfug from Jarl Yuliwyf. 
   * 7) Give Harlfug the Ticket to Mularn. 
   * 8) Give Dalikor the Note to Dalikor from Harlfug, chat with him a bit more for your reward.
   */
  
  using System;
  using System.Reflection;
  using DOL.Database;
  using DOL.Events;
  using DOL.GS.PacketHandler;
  using log4net;
  /* I suggest you declare yourself some namespaces for your quests
   * Like: DOL.GS.Quests.Albion
   *       DOL.GS.Quests.Midgard
   *       DOL.GS.Quests.Hibernia
   * Also this is the name that will show up in the database as QuestName
   * so setting good values here will result in easier to read and cleaner
   * Database Code
   */
  
  namespace DOL.GS.Quests.Midgard
  {
  	/* The first thing we do, is to declare the class we create
  	 * as Quest. To do this, we derive from the abstract class
  	 * AbstractQuest
  	 * 	 
  	 */
  
  	public class CityOfJordheim : BaseDalikorQuest
  	{
  		/// <summary>
  		/// Defines a logger for this class.
  		/// </summary>
  		private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  
  		/* Declare the variables we need inside our quest.
  		 * You can declare static variables here, which will be available in 
  		 * ALL instance of your quest and should be initialized ONLY ONCE inside
  		 * the OnScriptLoaded method.
  		 * 
  		 * Or declare nonstatic variables here which can be unique for each Player
  		 * and change through the quest journey...
  		 * 
  		 */
  
  		protected const string questTitle = "City of Jordheim";
  		protected const int minimumLevel = 1;
  		protected const int maximumLevel = 1;
  
  		protected static GameLocation warriorTrainer = new GameLocation("Warrior Trainer", 101, 29902, 35916, 8005, 2275);
  		protected static GameLocation savageTrainer = new GameLocation("Savage Trainer", 101, 28882, 35823, 8021, 2662);
  		protected static GameLocation skaldTrainer = new GameLocation("Skald Trainer", 101, 30395, 34943, 8005, 4004);
  		protected static GameLocation thaneTrainer = new GameLocation("Thane Trainer", 101, 29811, 34936, 8005, 159);
  
  		protected static GameLocation westGates = new GameLocation("West Gates", 101, 36017, 32659, 8005, 1045);
  
  		protected static GameLocation vaultKeeper = new GameLocation("Vault Keeper", 101, 31929, 28279, 8819, 2013);
  		protected static GameLocation berserkerTrainer = new GameLocation("Berserker Trainer", 101, 30327, 35598, 8002, 1706);
  
  		private static GameNPC dalikor = null;
  		private static GameNPC yuliwyf = null;
  		private static GameNPC harlfug = null;
  
  		private GameNPC assistant = null;
  		private GameTimer assistantTimer = null;
  
  		private static ItemTemplate ticketToMularn = null;
  		private static ItemTemplate scrollYuliwyf = null;
  		private static ItemTemplate receiptHarlfug = null;
  		private static ItemTemplate letterDalikor = null;
  		private static ItemTemplate assistantNecklace = null;
  		private static ItemTemplate chestOfCoins = null;
  		private static ItemTemplate recruitsRoundShield = null;
  		private static ItemTemplate recruitsBracer = null;
  
  
  		/* We need to define the constructors from the base class here, else there might be problems
  		 * when loading this quest...
  		 */
  
  		public CityOfJordheim() : base()
  		{
  		}
  
  		public CityOfJordheim(GamePlayer questingPlayer) : this(questingPlayer, 1)
  		{
  		}
  
  		public CityOfJordheim(GamePlayer questingPlayer, int step) : base(questingPlayer, step)
  		{
  		}
  
  		public CityOfJordheim(GamePlayer questingPlayer, DBQuest dbQuest) : base(questingPlayer, dbQuest)
  		{
  		}
  
  
  		/* The following method is called automatically when this quest class
  		 * is loaded. You might notice that this method is the same as in standard
  		 * game events. And yes, quests basically are game events for single players
  		 * 
  		 * To make this method automatically load, we have to declare it static
  		 * and give it the [ScriptLoadedEvent] attribute. 
  		 *
  		 * Inside this method we initialize the quest. This is neccessary if we 
  		 * want to set the quest hooks to the NPCs.
  		 * 
  		 * If you want, you can however add a quest to the player from ANY place
  		 * inside your code, from events, from custom items, from anywhere you
  		 * want. 
  		 */
  
  		[ScriptLoadedEvent]
  		public static void ScriptLoaded(DOLEvent e, object sender, EventArgs args)
  		{
  			if (!ServerProperties.Properties.LOAD_QUESTS)
  				return;
  			if (log.IsInfoEnabled)
  				log.Info("Quest \"" + questTitle + "\" initializing ...");
  			/* First thing we do in here is to search for the NPCs inside
  				* the world who comes from the Albion realm. If we find a the players,
  				* this means we don't have to create a new one.
  				* 
  				* NOTE: You can do anything you want in this method, you don't have
  				* to search for NPC's ... you could create a custom item, place it
  				* on the ground and if a player picks it up, he will get the quest!
  				* Just examples, do anything you like and feel comfortable with :)
  				*/
  
  			#region defineNPCs
  
  			dalikor = GetDalikor();
  
  			GameNPC[] npcs = WorldMgr.GetNPCsByName("Jarl Yuliwyf", eRealm.Midgard);
  			if (npcs.Length == 0)
  			{
  				yuliwyf = new GameNPC();
  				yuliwyf.Model = 159;
  				yuliwyf.Name = "Jarl Yuliwyf";
  				if (log.IsWarnEnabled)
  					log.Warn("Could not find " + yuliwyf.Name + ", creating ...");
  				yuliwyf.GuildName = "Part of " + questTitle + " Quest";
  				yuliwyf.Realm = eRealm.Midgard;
  				yuliwyf.CurrentRegionID = 101;
  				yuliwyf.Size = 51;
  				yuliwyf.Level = 50;
  				yuliwyf.X = 31929;
  				yuliwyf.Y = 28279;
  				yuliwyf.Z = 8819;
  				yuliwyf.Heading = 2013;
  				yuliwyf.EquipmentTemplateID = "5101262";
  				//You don't have to store the created mob in the db if you don't want,
  				//it will be recreated each time it is not found, just comment the following
  				//line if you rather not modify your database
  				if (SAVE_INTO_DATABASE)
  					yuliwyf.SaveIntoDatabase();
  
  				yuliwyf.AddToWorld();
  			}
  			else
  				yuliwyf = npcs[0];
  
  			npcs = WorldMgr.GetNPCsByName("Harlfug", eRealm.Midgard);
  			if (npcs.Length == 0)
  			{
  				harlfug = new GameStableMaster();
  				harlfug.Model = 215;
  				harlfug.Name = "Harlfug";
  				if (log.IsWarnEnabled)
  					log.Warn("Could not find " + harlfug.Name + ", creating her ...");
  				harlfug.GuildName = "Stable Master";
  				harlfug.Realm = eRealm.Midgard;
  				harlfug.CurrentRegionID = 100;
  				harlfug.Size = 52;
  				harlfug.Level = 41;
  				harlfug.X = 773458;
  				harlfug.Y = 754240;
  				harlfug.Z = 4600;
  				harlfug.Heading = 2707;
  				harlfug.EquipmentTemplateID = "5100798";
  
  				//You don't have to store the created mob in the db if you don't want,
  				//it will be recreated each time it is not found, just comment the following
  				//line if you rather not modify your database
  				if (SAVE_INTO_DATABASE)
  					harlfug.SaveIntoDatabase();
  				harlfug.AddToWorld();
  			}
  			else
  				harlfug = npcs[0];
  
  			#endregion
  
  			#region defineItems
  
  			ticketToMularn = CreateTicketTo("Mularn", "hs_src_mularn");
  
  			scrollYuliwyf = GameServer.Database.FindObjectByKey<ItemTemplate>("scroll_for_yuliwyf");
  			if (scrollYuliwyf == null)
  			{
  				scrollYuliwyf = new ItemTemplate();
  				scrollYuliwyf.Name = "Scroll for Jarl Yuliwyf";
  				if (log.IsWarnEnabled)
  					log.Warn("Could not find " + scrollYuliwyf.Name + " , creating it ...");
  
  				scrollYuliwyf.Weight = 3;
  				scrollYuliwyf.Model = 498;
  
  				scrollYuliwyf.Object_Type = (int) eObjectType.GenericItem;
  
  				scrollYuliwyf.Id_nb = "scroll_for_yuliwyf";
  				scrollYuliwyf.IsPickable = true;
  				scrollYuliwyf.IsDropable = false;
  
  				//You don't have to store the created item in the db if you don't want,
  				//it will be recreated each time it is not found, just comment the following
  				//line if you rather not modify your database
  				if (SAVE_INTO_DATABASE)
  					GameServer.Database.AddObject(scrollYuliwyf);
  			}
  
  
  			receiptHarlfug = GameServer.Database.FindObjectByKey<ItemTemplate>("receipt_for_harlfug");
  			if (receiptHarlfug == null)
  			{
  				receiptHarlfug = new ItemTemplate();
  				receiptHarlfug.Name = "Receipt for Harlfug";
  				if (log.IsWarnEnabled)
  					log.Warn("Could not find " + receiptHarlfug.Name + " , creating it ...");
  
  				receiptHarlfug.Weight = 3;
  				receiptHarlfug.Model = 498;
  
  				receiptHarlfug.Object_Type = (int) eObjectType.GenericItem;
  
  				receiptHarlfug.Id_nb = "receipt_for_harlfug";
  				receiptHarlfug.IsPickable = true;
  				receiptHarlfug.IsDropable = false;
  
  				//You don't have to store the created item in the db if you don't want,
  				//it will be recreated each time it is not found, just comment the following
  				//line if you rather not modify your database
  				if (SAVE_INTO_DATABASE)
  					GameServer.Database.AddObject(receiptHarlfug);
  			}
  
  			chestOfCoins = GameServer.Database.FindObjectByKey<ItemTemplate>("small_chest_of_coins");
  			if (chestOfCoins == null)
  			{
  				chestOfCoins = new ItemTemplate();
  				chestOfCoins.Name = "Small Chest of Coins";
  				if (log.IsWarnEnabled)
  					log.Warn("Could not find " + chestOfCoins.Name + " , creating it ...");
  
  				chestOfCoins.Weight = 15;
  				chestOfCoins.Model = 602;
  
  				chestOfCoins.Object_Type = (int) eObjectType.GenericItem;
  
  				chestOfCoins.Id_nb = "small_chest_of_coins";
  				chestOfCoins.IsPickable = true;
  				chestOfCoins.IsDropable = false;
  
  				//You don't have to store the created item in the db if you don't want,
  				//it will be recreated each time it is not found, just comment the following
  				//line if you rather not modify your database
  				if (SAVE_INTO_DATABASE)
  					GameServer.Database.AddObject(chestOfCoins);
  			}
  
  			letterDalikor = GameServer.Database.FindObjectByKey<ItemTemplate>("letter_for_dalikor");
  			if (letterDalikor == null)
  			{
  
gt: 				letterDalikor = new ItemTemplate();