context: using System;
  using DOL.Events;
  using DOL.AI.Brain;
  using DOL.GS;
  using DOL.GS.PacketHandler;
  using log4net;
  
  namespace DOL.GS.Keeps
  {
  	/// <summary>
  	/// Class for the Lord Guard
  	/// </summary>
  	public class GuardLord : GameKeepGuard
  	{
  		private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  
  		private eRealm m_lastRealm = eRealm.None;
  		private long m_lastKillTime = 0;
  
  		/// <summary>
  		/// Lord needs more health at the moment
  		/// </summary>
  		public override int MaxHealth
  		{
  			get
  			{
  				return base.MaxHealth * 3;
  			}
  		}
  
  		public override int RealmPointsValue
  		{
  			get
  			{
  				// PvE Lords drop stacks of dreaded seals instead of giving RP directly
                  if (Realm == eRealm.None && GameServer.Instance.Configuration.ServerType == eGameServerType.GST_PvE)
                      return 0;
  
                  long duration = (CurrentRegion.Time - m_lastKillTime) / 1000L;
  
  				if (duration < ServerProperties.Properties.LORD_RP_WORTH_SECONDS)
  				{
  					return 0;
  				}
  
  				if (this.Component == null || this.Component.AbstractKeep == null)
  				{
  					return 5000;
  				}
  				else
  				{
  					return this.Component.AbstractKeep.RealmPointsValue();
  				}
  			}
  		}
  
  		public override int BountyPointsValue
  		{
  			get
  			{
  				// PvE Lords drop stacks of dreaded seals instead of giving RP directly
  				if (Realm == eRealm.None && GameServer.Instance.Configuration.ServerType == eGameServerType.GST_PvE)
  					return 0;
  
  				long duration = (CurrentRegion.Time - m_lastKillTime) / 1000L;
  				if (duration < ServerProperties.Properties.LORD_RP_WORTH_SECONDS)
  				{
  					return 0;
  				}
  
  				if (this.Component != null && this.Component.AbstractKeep != null)
  				{
  					return this.Component.AbstractKeep.BountyPointsValue();
  				}
  
  				return base.BountyPointsValue;
  			}
  		}
  
  		public override long ExperienceValue
  		{
  			get
  			{
  				long duration = (CurrentRegion.Time - m_lastKillTime) / 1000L;
  				if (duration < ServerProperties.Properties.LORD_RP_WORTH_SECONDS)
  				{
  					return 0;
  				}
  
  				if (this.Component != null && this.Component.AbstractKeep != null)
  				{
  					return this.Component.AbstractKeep.ExperiencePointsValue();
  				}
  
  				return base.ExperienceValue;
  			}
  		}
  
  		public override double ExceedXPCapAmount
  		{
  			get
  			{
  				if (this.Component != null && this.Component.AbstractKeep != null)
  				{
  					return this.Component.AbstractKeep.ExceedXPCapAmount();
  				}
  
  				return base.ExceedXPCapAmount;
  			}
  		}
  
  		public override long MoneyValue
  		{
  			get
  			{
  				long duration = (CurrentRegion.Time - m_lastKillTime) / 1000L;
  				if (duration < ServerProperties.Properties.LORD_RP_WORTH_SECONDS)
  				{
  					return 0;
  				}
  
  				if (this.Component != null && this.Component.AbstractKeep != null)
  				{
  					return this.Component.AbstractKeep.MoneyValue();
  				}
  
  				return base.MoneyValue;
  			}
  		}
  
  
  		public override int AttackRangeDistance
  		{
  			get
  			{
  				return 1200;
  			}
  		}
  
  		/// <summary>
  		/// Keep lords are narcissitic; they don't assist themselves or anyone else
  		/// </summary>
  		/// <param name="lord"></param>
  		/// <returns>Whether or not we are responding</returns>
  		public override bool AssistLord(GuardLord lord)
  		{
  			return false;
  		}
  
  		/// <summary>
  		/// When Lord dies, we update Area Mgr to call the various functions we need
  		/// And update the player stats
  		/// </summary>
  		/// <param name="killer">The killer object</param>
  		public override void Die(GameObject killer)
  		{
  			m_lastRealm = eRealm.None;
  
  			if (ServerProperties.Properties.LOG_KEEP_CAPTURES)
  			{
  				try
  				{
  					if (this.Component != null)
  					{
  						DOL.Database.KeepCaptureLog keeplog = new DOL.Database.KeepCaptureLog();
  						keeplog.KeepName = Component.AbstractKeep.Name;
  
  						if (Component.AbstractKeep is GameKeep)
  							keeplog.KeepType = "Keep";
  						else
  							keeplog.KeepType = "Tower";
  
  						keeplog.NumEnemies = GetEnemyCountInArea();
  						keeplog.RPReward = RealmPointsValue;
  						keeplog.BPReward = BountyPointsValue;
  						keeplog.XPReward = ExperienceValue;
  						keeplog.MoneyReward = MoneyValue;
  
  						if (Component.AbstractKeep.StartCombatTick > 0)
  						{
  							keeplog.CombatTime = (int)((Component.AbstractKeep.CurrentRegion.Time - Component.AbstractKeep.StartCombatTick) / 1000 / 60);
  						}
  
  						keeplog.CapturedBy = GlobalConstants.RealmToName(killer.Realm);
  
  						string listRPGainers = "";
  
  						foreach (System.Collections.DictionaryEntry de in XPGainers)
  						{
  							GameLiving living = de.Key as GameLiving;
  							if (living != null)
  							{
  								listRPGainers += living.Name + ";";
  							}
  						}
  
  						keeplog.RPGainerList = listRPGainers.TrimEnd(';');
  
  						GameServer.Database.AddObject(keeplog);
  					}
  					else
  					{
  						log.Error("Component null for Guard Lord " + Name);
  					}
  				}
  				catch (System.Exception ex)
  				{
  					log.Error("KeepCaptureLog Exception", ex);
  				}
  			}
  
  			base.Die(killer);
  
  			if (this.Component != null)
  			{
  				GameServer.ServerRules.ResetKeep(this, killer);
  			}
  
  			m_lastKillTime = CurrentRegion.Time;
  		}
  
  		/// <summary>
  		/// When we interact with lord, we display all possible options
  		/// </summary>
  		/// <param name="player">The player object</param>
  		/// <returns></returns>
  		public override bool Interact(GamePlayer player)
  		{
  			if (!base.Interact(player))
  				return false;
  
  			if (this.Component == null)
  				return false;
  
  
gt: 			if (InCombat || Component.AbstractKeep.InCombat)