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: k109
   * 
   * Date: 12/5/07
   * Directory: /scripts/quests/albion/
   * 
   * Compiled on SVN 905
   * 
   * Description: The "When Good Brownies Go Bad" quest, mimics live US servers.
   */
  using System;
  using DOL.Database;
  using DOL.Events;
  using DOL.Language;
  
  namespace DOL.GS.Quests.Albion
  {
  	public class WhenGoodBrowniesGoBad : RewardQuest
  	{
  		private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  
  		protected static string questTitle = LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Alb.WhenGoodBrowniesGoBad.QuestTitle");
  		protected const int minimumLevel = 2;
  		protected const int maximumLevel = 5;
  
  		private static GameNPC MasterKless = null;
  		private QuestGoal browniesKilled;
  
  		private static ItemTemplate lightredclothdye = null;
  		private static ItemTemplate lightredleatherdye = null;
  		private static ItemTemplate lightredenamel = null;
  		public WhenGoodBrowniesGoBad()
  			: base()
  		{
  			Init();
  		}
  
  		public WhenGoodBrowniesGoBad(GamePlayer questingPlayer)
  			: this(questingPlayer, 1)
  		{
  		}
  
  		public WhenGoodBrowniesGoBad(GamePlayer questingPlayer, int step)
  			: base(questingPlayer, step)
  		{
  			Init();
  		}
  
  		public WhenGoodBrowniesGoBad(GamePlayer questingPlayer, DBQuest dbQuest)
  			: base(questingPlayer, dbQuest)
  		{
  			Init();
  		}
  
  		private void Init()
  		{
  			#region defineItems
  
  			// item db check
  			lightredclothdye = GameServer.Database.FindObjectByKey<ItemTemplate>("light_red_cloth_dye");
  			if (lightredclothdye == null)
  			{
  				lightredclothdye = new ItemTemplate();
  				lightredclothdye.Name = LanguageMgr.GetTranslation(ServerProperties.Properties.DB_LANGUAGE, "Alb.WhenGoodBrowniesGoBad.Init.Text1");
  				if (log.IsWarnEnabled)
  					log.Warn("Could not find " + lightredclothdye.Name + ", creating it ...");
  
  				lightredclothdye.Level = 1;
  				lightredclothdye.Weight = 0;
  				lightredclothdye.Model = 229;
  				lightredclothdye.Color = 0;
  
  				lightredclothdye.Object_Type = (int)eObjectType.GenericItem;
  				lightredclothdye.Id_nb = "light_red_cloth_dye";
  				lightredclothdye.Price = Money.GetMoney(0,0,0,0,40);
  				lightredclothdye.IsPickable = true;
  				lightredclothdye.IsDropable = true; // can't be sold to merchand
  				lightredclothdye.Quality = 100;
  				lightredclothdye.Condition = 50000;
  				lightredclothdye.MaxCondition = 50000;
  				lightredclothdye.Durability = 50000;
  				lightredclothdye.MaxDurability = 50000;
  
  
  				//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(lightredclothdye);
  			}
  			lightredleatherdye = GameServer.Database.FindObjectByKey<ItemTemplate>("light_red_leather_dye");
  			if (lightredleatherdye == null)
  			{
  				lightredleatherdye = new ItemTemplate();
  				lightredleatherdye.Name = LanguageMgr.GetTranslation(ServerProperties.Properties.DB_LANGUAGE, "Alb.WhenGoodBrowniesGoBad.Init.Text2");
  				if (log.IsWarnEnabled)
  					log.Warn("Could not find " + lightredleatherdye.Name + ", creating it ...");
  
  				lightredleatherdye.Level = 1;
  				lightredleatherdye.Weight = 0;
  				lightredleatherdye.Model = 229;
  				lightredleatherdye.Color = 0;
  
  				lightredleatherdye.Object_Type = (int)eObjectType.GenericItem;
  				lightredleatherdye.Id_nb = "light_red_leather_dye";
  				lightredleatherdye.Price = Money.GetMoney(0,0,0,0,40);
  				lightredleatherdye.IsPickable = true;
  				lightredleatherdye.IsDropable = true; // can't be sold to merchand
  				lightredleatherdye.Quality = 100;
  				lightredleatherdye.Condition = 50000;
  				lightredleatherdye.MaxCondition = 50000;
  				lightredleatherdye.Durability = 50000;
  				lightredleatherdye.MaxDurability = 50000;
  
  
  				//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
  				
  					GameServer.Database.AddObject(lightredleatherdye);
  			}
  			lightredenamel = GameServer.Database.FindObjectByKey<ItemTemplate>("light_red_enamel");
  			if (lightredenamel == null)
  			{
  				lightredenamel = new ItemTemplate();
  				lightredenamel.Name = LanguageMgr.GetTranslation(ServerProperties.Properties.DB_LANGUAGE, "Alb.WhenGoodBrowniesGoBad.Init.Text3");
  				if (log.IsWarnEnabled)
  					log.Warn("Could not find " + lightredenamel.Name + ", creating it ...");
  
  				lightredenamel.Level = 1;
  				lightredenamel.Weight = 0;
  				lightredenamel.Model = 229;
  				lightredenamel.Color = 0;
  
  				lightredenamel.Object_Type = (int)eObjectType.GenericItem;
  				lightredenamel.Id_nb = "light_red_enamel";
  				lightredenamel.Price = Money.GetMoney(0,0,0,0,40);
  				lightredenamel.IsPickable = true;
  				lightredenamel.IsDropable = true; // can't be sold to merchand
  				lightredenamel.Quality = 100;
  				lightredenamel.Condition = 50000;
  				lightredenamel.MaxCondition = 50000;
  				lightredenamel.Durability = 50000;
  				lightredenamel.MaxDurability = 50000;
  
  
  				//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
  				
  					GameServer.Database.AddObject(lightredenamel);
  			}
  			#endregion
  
  			ItemTemplate brownieBlood = new ItemTemplate();
  			brownieBlood.Weight = 0;
  			brownieBlood.Condition = 50000;
  			brownieBlood.MaxCondition = 50000;
  			brownieBlood.Model = 99;
  			brownieBlood.Extension = 1;
  			brownieBlood.Name = LanguageMgr.GetTranslation(ServerProperties.Properties.DB_LANGUAGE, "Alb.WhenGoodBrowniesGoBad.Init.Text4");
  
  			Level = 1;
  			QuestGiver = MasterKless;
  			Rewards.Experience = 90;
  			Rewards.MoneyPercent = 80;
  			Rewards.AddOptionalItem(lightredclothdye);
  			Rewards.AddOptionalItem(lightredleatherdye);
  			Rewards.AddOptionalItem(lightredenamel);
  			Rewards.ChoiceOf = 1;
  			browniesKilled = AddGoal(LanguageMgr.GetTranslation(ServerProperties.Properties.SERV_LANGUAGE, "Alb.WhenGoodBrowniesGoBad.Init.Text5"), QuestGoal.GoalType.KillTask, 3, brownieBlood);
  		}
  
  		[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 ...");
  
  
  			#region defineNPCS
  
  			GameNPC[] npcs = WorldMgr.GetNPCsByName(LanguageMgr.GetTranslation(ServerProperties.Properties.DB_LANGUAGE, "Alb.WhenGoodBrowniesGoBad.ScriptLoaded.Text1"), eRealm.Albion);
  
  
gt: 			if (npcs.Length == 0)